Changeset 158
- Timestamp:
- Jun 7, 2010, 5:02:45 PM (15 years ago)
- Location:
- nutchez-0.2/src/test
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
nutchez-0.2/src/test/install
r150 r158 10 10 # *.sh及nutchez-0.2-0531.tar.gz均在同一目錄下 11 11 12 # 執行環境檢查13 check_info () {14 check_root15 check_systemInfo16 check_nez_installed17 check_sunJava18 check_ssh19 check_dialog20 install_packages21 }22 12 23 13 main () { 14 #check_info 24 15 echo "歡迎使用NutchEZ, 此安裝程序會為您新建一個nutchuser帳號" 25 16 set_install_information … … 40 31 su nutchuser -c "touch /home/nutchuser/nutchez/urls/urls.txt" 41 32 su nutchuser -c "mkdir /home/nutchuser/nutchez/search" 33 su nutchuser -c "mkdir /home/nutchuser/nutchez/source" 42 34 make_client_install 43 35 … … 55 47 } 56 48 57 check_info58 49 main -
nutchez-0.2/src/test/install_func.sh
r152 r158 13 13 14 14 ####### fafa code here ########### 15 16 17 # shell檔及壓縮檔在同一目錄中 18 19 20 ####### 環境變數section########### 15 21 User_HOME=/home/nutchuser/nutchez 16 22 NutchEZ_HOME=/opt/nutchez … … 18 24 Tomcat_HOME=$NutchEZ_HOME/tomcat 19 25 Index_DB=$User_HOME/search 20 MasterIP_Address=`/sbin/ifconfig eth0 | grep 'inet addr' | sed 's/^.*addr://g' | sed 's/Bcast.*$//g' | sed 's/ .*// '` 21 22 # DNS暫時以IP取代 23 MasterDNS=$MasterIP_Address 26 Admin_email=nutchuser@nutch 27 28 # $MasterIP_Address 29 # $net_MacAddr 30 31 ######function section section####### 32 33 34 function debug_echo () { 35 if [ $? -eq 0 ]; then 36 echo -e "\033[1;32;40m $1 \033[0m" 37 fi 38 } 39 40 41 check_info () { 42 check_root 43 check_systemInfo 44 check_nez_installed 45 check_sunJava 46 check_ssh 47 check_dialog 48 install_packages 49 } 24 50 25 51 function set_install_information () { 26 52 set_nutchuser_passwd 27 read -p "Please enter Administrator's e-mail address: " Admin_email28 53 select_eth 29 54 MasterIP_Address=$net_address 30 # read -p "Please enter the Master DNS: " MasterDNS31 55 } 32 56 33 57 function set_nutchuser_passwd () { 34 read - p "Please enter nutchuser's password : " nutchuser_passwd35 read - p "Please enter nutchuser's password again: " nutchuser_passwd_confirm58 read -sp "Please enter nutchuser's password : " nutchuser_passwd 59 read -sp "Please enter nutchuser's password again: " nutchuser_passwd_confirm 36 60 if [ $nutchuser_passwd != $nutchuser_passwd_confirm ]; then 37 61 set_nutchuser_passwd … … 46 70 # 若只有一個 eth 時 47 71 if [ "$net_nu" == "1" ]; then 48 ifconfig $net_interfaces | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f172 #ifconfig $net_interfaces | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1 49 73 net_address=$(ifconfig $net_interfaces | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1) 50 # echo "net_address is $net_address" 74 net_MacAddr=$(ifconfig $net_interfaces | grep 'HW' | sed 's/^.*HWaddr //g') 75 echo "net_address is $net_address" 76 echo "net_MacAddr is $net_MacAddr" 51 77 52 78 # 若有多個 eth 時 … … 70 96 ifconfig $net_interface | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1 71 97 net_address=$(ifconfig $net_interface | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1) 98 net_MacAddr=$(ifconfig $net_interfaces | grep 'HW' | sed 's/^.*HWaddr //g') 72 99 echo "net_address is $net_address" 100 echo "net_MacAddr is $net_MacAddr" 73 101 fi 74 102 } … … 76 104 77 105 function show_info () { 78 echo "Administrator's e-mail address is $Admin_email." 79 echo "The Master IP Address is: $MasterDNS" 106 echo "The Master IP Address is $MasterIP_Address" 80 107 } 81 108 … … 85 112 86 113 function make_ssh_key () { 114 debug_echo "Make ssh key(begin...)" 87 115 su nutchuser -c 'ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ""' 88 116 su nutchuser -c "cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys" 117 su nutchuser -c "ssh-add /home/nutchuser/.ssh/id_rsa" 118 debug_echo "Make ssh key(done!)" 89 119 } 90 120 91 121 92 122 function set_haoop-site () { 93 echo "set $Nutch_HOME/conf/hadoop-site.xml"123 debug_echo "set hadoop-site.xml(begin...)" 94 124 cd $Nutch_HOME/conf/ 95 125 cat > hadoop-site.xml << EOF … … 109 139 </configuration> 110 140 EOF 141 debug_echo "set hadoop-site.xml(done!)" 111 142 } 112 143 113 144 # 修改nutch-site.xml中-http.agent.url, http.agent.email 114 145 function set_nutch-site () { 115 echo "set $Nutch_HOME/conf/nutch-site.xml"146 debug_echo "set nutch-site.xml(begin...)" 116 147 Line_NO=`cat $Nutch_HOME'/conf/nutch-site.xml' | grep -n 'http.agent.url' | sed 's/:.*//g'` 117 echo "debug...http.agent.url line number = $Line_NO..."148 debug_echo "debug...http.agent.url line number = $Line_NO..." 118 149 sed -i ''$((Line_NO+1))'d' $Nutch_HOME/conf/nutch-site.xml 119 echo "debug...edit http.agent.url delete line $((Line_NO+1))..."150 debug_echo "debug...edit http.agent.url delete line $((Line_NO+1))..." 120 151 sed -i ''$Line_NO'a <value>'$MasterIP_Address'</value>' $Nutch_HOME/conf/nutch-site.xml 121 echo "debug...edit http.agent.url done..."152 debug_echo "debug...edit http.agent.url done..." 122 153 123 154 Line_NO=`cat $Nutch_HOME'/conf/nutch-site.xml' | grep -n 'http.agent.email' | sed 's/:.*//g'` 124 echo "debug...http.agent.email line number = $Line_NO..."155 debug_echo "debug...http.agent.email line number = $Line_NO..." 125 156 126 157 sed -i ''$((Line_NO+1))'d' $Nutch_HOME/conf/nutch-site.xml 127 echo "debug...edit http.agent.email delete line $((Line_NO+1))..."158 debug_echo "debug...edit http.agent.email delete line $((Line_NO+1))..." 128 159 sed -i ''$Line_NO'a <value>'$Admin_email'</value>' $Nutch_HOME/conf/nutch-site.xml 129 echo "debug...edit http.agent.email done..." 160 debug_echo "debug...edit http.agent.email done..." 161 debug_echo "set nutch-site.xml(done!)" 130 162 } 131 163 132 164 function format_HDFS () { 133 echo "format HDFS..."165 debug_echo "format HDFS..." 134 166 su nutchuser -c "$Nutch_HOME/bin/hadoop namenode -format" 135 167 } 136 168 137 169 function start_up_NutchEZ (){ 138 echo "start up NutchEZ..."170 debug_echo "start up NutchEZ..." 139 171 su nutchuser -c "$Nutch_HOME/bin/start-all.sh" 140 172 } … … 148 180 function client_PassMasterIPAddr () { 149 181 Line_NO=`cat client_install | grep -n '# Master IP here' | sed 's/:.*//g'` 150 echo "debug...Master IP here line number = $Line_NO..."182 debug_echo "debug...Master IP here line number = $Line_NO..." 151 183 sed -i ''$((Line_NO+1))'d' client_install 152 echo "debug...edit Master IP at line $((Line_NO+1))..."184 debug_echo "debug...edit Master IP at line $((Line_NO+1))..." 153 185 sed -i ''$Line_NO'a Master_IP_Address='$MasterIP_Address'' client_install 154 echo "edit client_install done..."186 debug_echo "edit client_install done..." 155 187 } 156 188 157 189 function client_PassMaster_Hostname () { 158 190 Line_NO=`cat client_install | grep -n '# Master Hostname here' | sed 's/:.*//g'` 159 echo "debug...Master hostname here line number = $Line_NO..."191 debug_echo "debug...Master hostname here line number = $Line_NO..." 160 192 sed -i ''$((Line_NO+1))'d' client_install 161 echo "debug...edit Master Hostname at line $((Line_NO+1))..."193 debug_echo "debug...edit Master Hostname at line $((Line_NO+1))..." 162 194 sed -i ''$Line_NO'a Master_Hostname='$(hostname)'' client_install 163 echo "edit client_install done..."195 debug_echo "edit client_install done..." 164 196 } 165 197 166 198 function make_client_install () { 199 # 建立資料夾(用來存放client的安奘檔) 200 su nutchuser -c "mkdir $User_HOME/source" 201 167 202 # 將Master_IP_Address給client 168 203 # 打包安裝目錄(不含tomcat) … … 170 205 client_PassMasterIPAddr 171 206 client_PassMaster_Hostname 172 su nutchuser -c "tar -cvzf /opt/nutchez/NutchezForClientOf_$Master_IP_Address.tar.gz /home/nutchuser/nutchez/" 207 cd /opt/nutchez/ 208 su nutchuser -c "tar -cvzf NutchezForClientOf_$Master_IP_Address.tar.gz nutch" 209 210 # 複製檔案至$User_HOME/source目錄下 211 mv NutchezForClientOf_$Master_IP_Address.tar.gz /home/nutchuser/nutchez/source 212 cp client_install client_install_func.sh /home/nutchuser/nutchez/source 173 213 } 174 214 175 215 function start_up_tomcat () { 176 echo "start up tomcat..."216 debug_echo "start up tomcat..." 177 217 sleep 10s 178 echo "su nutchuser -c "$Tomcat_HOME/bin/startup.sh""179 218 su nutchuser -c "$Tomcat_HOME/bin/startup.sh" 180 } 181 219 debug_echo "tomcat has been started..." 220 } 221 222 ###最後再整理### 182 223 # client簡易步驟 183 224 function client_install_command () {
Note: See TracChangeset
for help on using the changeset viewer.