Changeset 164
- Timestamp:
- Jun 8, 2010, 3:22:23 PM (15 years ago)
- Location:
- nutchez-0.2/src/test
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
nutchez-0.2/src/test/install
r163 r164 10 10 # *.sh及nutchez-0.2-0531.tar.gz均在同一目錄下 11 11 12 function show_info () { 13 if [ $? -eq 0 ]; then 14 echo -e "\033[1;32;40m $1 \033[0m" 15 fi 16 } 12 17 13 18 main () { 14 19 check_info 15 echo "歡迎使用NutchEZ, 此安裝程序會為您新建一個nutchuser帳號"20 show_info "歡迎使用NutchEZ, 此安裝程序會為您新建一個nutchuser帳號並協助您設定密碼" 16 21 set_install_information 17 show_info18 22 read -p "Please confirm your install infomation: 1.Yes 2.No " confirm 19 23 if [ $confirm -eq 1 ]; then … … 39 43 start_up_tomcat 40 44 # 安裝流程結束,並進入網頁管理頁面設定爬網網址...等 41 echo "Install Successfully!!"42 echo "Visit http://$MasterIP_Address:8080"45 show_info "Install Successfully!!" 46 show_info "Visit http://$MasterIP_Address:8080" 43 47 client_install_command 44 48 elif [ $confirm -eq 2 ]; then … … 47 51 } 48 52 49 # todo: 處理/etc/hosts50 # 多張網卡時的bug51 53 main -
nutchez-0.2/src/test/install_func.sh
r163 r164 32 32 33 33 34 function debug_echo () { 34 function debug_info () { 35 if [ $? -eq 0 ]; then 36 echo -e "\033[1;35;40m info - $1 \033[0m" 37 fi 38 } 39 40 41 function show_info () { 35 42 if [ $? -eq 0 ]; then 36 43 echo -e "\033[1;32;40m $1 \033[0m" … … 79 86 else 80 87 declare -i i=1 81 echo -e"\nSystem have multiple network device, which network use for this machine: "88 show_info "\nSystem have multiple network device, which network use for this machine: " 82 89 83 90 for net in $net_interfaces 84 91 do 85 echo "($i) $net $(ifconfig $net | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1)"92 show_info "($i) $net $(ifconfig $net | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1)" 86 93 i=i+1 87 94 done 88 95 89 read -p "Pl zchoice(1/2/3...): " net_choice96 read -p "Please choice(1/2/3...): " net_choice 90 97 if [ -z $net_choice ]; then 91 98 net_choice=1 92 99 fi 93 100 94 echo "Your choice is $net_choice"101 show_info "Your choice is $net_choice" 95 102 net_interface=$(echo $net_interfaces | cut -d " " -f $net_choice) 96 103 #ifconfig $net_interface | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1 97 104 net_address=$(ifconfig $net_interface | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1) 98 net_MacAddr=$(ifconfig $net_interface s| grep 'HW' | sed 's/^.*HWaddr //g')99 echo "net_address is $net_address"100 echo "net_MacAddr is $net_MacAddr"105 net_MacAddr=$(ifconfig $net_interface | grep 'HW' | sed 's/^.*HWaddr //g') 106 show_info "net_address is $net_address" 107 show_info "net_MacAddr is $net_MacAddr" 101 108 fi 102 109 } … … 104 111 105 112 function show_info () { 106 echo "The Master IP Address is $MasterIP_Address"107 echo "The Master MacAddr is $net_MacAddr"113 show_info "The Master IP Address is $MasterIP_Address" 114 show_info "The Master MacAddr is $net_MacAddr" 108 115 } 109 116 … … 113 120 114 121 function make_ssh_key () { 115 debug_ echo "Make ssh key(begin...)"122 debug_info "Make ssh key(begin...)" 116 123 su nutchuser -c 'ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ""' 117 124 su nutchuser -c "cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys" 118 125 su nutchuser -c "ssh-add /home/nutchuser/.ssh/id_rsa" 119 debug_ echo "Make ssh key(done!)"126 debug_info "Make ssh key(done!)" 120 127 } 121 128 122 129 123 130 function set_haoop-site () { 124 debug_ echo "set hadoop-site.xml(begin...)"131 debug_info "set hadoop-site.xml(begin...)" 125 132 cd $Nutch_HOME/conf/ 126 133 cat > hadoop-site.xml << EOF … … 140 147 </configuration> 141 148 EOF 142 debug_ echo "set hadoop-site.xml(done!)"149 debug_info "set hadoop-site.xml(done!)" 143 150 } 144 151 145 152 # 修改nutch-site.xml中-http.agent.url, http.agent.email 146 153 function set_nutch-site () { 147 debug_ echo "set nutch-site.xml(begin...)"154 debug_info "set nutch-site.xml(begin...)" 148 155 Line_NO=`cat $Nutch_HOME'/conf/nutch-site.xml' | grep -n 'http.agent.url' | sed 's/:.*//g'` 149 debug_ echo "debug...http.agent.url line number = $Line_NO..."156 debug_info "debug...http.agent.url line number = $Line_NO..." 150 157 sed -i ''$((Line_NO+1))'d' $Nutch_HOME/conf/nutch-site.xml 151 debug_ echo "debug...edit http.agent.url delete line $((Line_NO+1))..."158 debug_info "debug...edit http.agent.url delete line $((Line_NO+1))..." 152 159 sed -i ''$Line_NO'a <value>'$MasterIP_Address'</value>' $Nutch_HOME/conf/nutch-site.xml 153 debug_ echo "debug...edit http.agent.url done..."160 debug_info "debug...edit http.agent.url done..." 154 161 155 162 Line_NO=`cat $Nutch_HOME'/conf/nutch-site.xml' | grep -n 'http.agent.email' | sed 's/:.*//g'` 156 debug_ echo "debug...http.agent.email line number = $Line_NO..."163 debug_info "debug...http.agent.email line number = $Line_NO..." 157 164 158 165 sed -i ''$((Line_NO+1))'d' $Nutch_HOME/conf/nutch-site.xml 159 debug_ echo "debug...edit http.agent.email delete line $((Line_NO+1))..."166 debug_info "debug...edit http.agent.email delete line $((Line_NO+1))..." 160 167 sed -i ''$Line_NO'a <value>'$Admin_email'</value>' $Nutch_HOME/conf/nutch-site.xml 161 debug_ echo "debug...edit http.agent.email done..."162 debug_ echo "set nutch-site.xml(done!)"168 debug_info "debug...edit http.agent.email done..." 169 debug_info "set nutch-site.xml(done!)" 163 170 } 164 171 165 172 function format_HDFS () { 166 debug_ echo "format HDFS..."173 debug_info "format HDFS..." 167 174 su nutchuser -c "$Nutch_HOME/bin/hadoop namenode -format" 168 175 } 169 176 170 177 function start_up_NutchEZ (){ 171 debug_ echo "start up NutchEZ..."178 debug_info "start up NutchEZ..." 172 179 su nutchuser -c "$Nutch_HOME/bin/start-all.sh" 173 180 } 174 181 182 183 function set_hosts () { 184 Line_NO=`cat /etc/hosts | grep -n $(hostname) | sed 's/:.*//g'` 185 content=$(cat /etc/hosts | awk 'NR=='$Line_NO'{printf "# " ; print}' ) 186 sed -i ""$Line_NO"c $content" /etc/hosts 187 sed -i '1i '$MasterIP_Address' '$(hostname)'' /etc/hosts 188 } 189 175 190 function Install_Nutch () { 191 debug_info "MasterIP_Address=$MasterIP_Address" 192 debug_info "Master_Hostname=$(hostname)" 193 set_hosts 176 194 set_haoop-site 177 195 set_nutch-site … … 182 200 cd $Start_PATH 183 201 Line_NO=`cat client_install | grep -n '# Master IP here' | sed 's/:.*//g'` 184 debug_ echo "debug...Master IP here line number = $Line_NO..."202 debug_info "debug...Master IP here line number = $Line_NO..." 185 203 sed -i ''$((Line_NO+1))'d' client_install 186 debug_ echo "debug...edit Master IP at line $((Line_NO+1))..."204 debug_info "debug...edit Master IP at line $((Line_NO+1))..." 187 205 sed -i ''$Line_NO'a Master_IP_Address='$MasterIP_Address'' client_install 188 debug_ echo "edit client_install done..."206 debug_info "edit client_install done..." 189 207 } 190 208 … … 193 211 cd $Start_PATH 194 212 Line_NO=`cat client_install | grep -n '# Master Hostname here' | sed 's/:.*//g'` 195 debug_ echo "debug...Master hostname here line number = $Line_NO..."213 debug_info "debug...Master hostname here line number = $Line_NO..." 196 214 sed -i ''$((Line_NO+1))'d' client_install 197 debug_ echo "debug...edit Master Hostname at line $((Line_NO+1))..."215 debug_info "debug...edit Master Hostname at line $((Line_NO+1))..." 198 216 sed -i ''$Line_NO'a Master_Hostname='$(hostname)'' client_install 199 debug_ echo "edit client_install done..."217 debug_info "edit client_install done..." 200 218 } 201 219 … … 207 225 # 將Master_IP_Address給client 208 226 # 打包安裝目錄(不含tomcat) 209 echo "function make_client_install..."227 debug_info "function make_client_install..." 210 228 client_PassMasterIPAddr 211 229 client_PassMaster_Hostname 212 230 cd /opt/nutchez/ 213 su nutchuser -c "tar -cvzf NutchezForClientOf_ $Master_IP_Address.tar.gz nutch"231 su nutchuser -c "tar -cvzf NutchezForClientOf_"$MasterIP_Address".tar.gz nutch" 214 232 215 233 # 複製檔案至$User_HOME/source目錄下 … … 219 237 220 238 function start_up_tomcat () { 221 debug_echo "start up tomcat..." 222 sleep 10s 239 debug_info "start up tomcat..." 240 i=10 241 until [ $i -lt 1 ] 242 do 243 sleep 1s 244 debug_info "wait $i sec..." 245 i=`expr $i - 1` 246 done 223 247 su nutchuser -c "$Tomcat_HOME/bin/startup.sh" 224 debug_ echo "tomcat has been started..."248 debug_info "tomcat has been started..." 225 249 } 226 250 … … 228 252 # client簡易步驟 229 253 function client_install_command () { 230 echo "Client Install Command as Follows:"231 echo "cd ~"232 echo "mkdir nutchez_client_install"233 echo "cd nutchez_client_install"234 echo "scp nutchuser@masterIP:/home/nutchuser/nutchez/source/* ."235 echo "./client_install"236 } 254 show_info "Client Install Command as Follows:" 255 show_info "cd ~" 256 show_info "mkdir nutchez_client_install" 257 show_info "cd nutchez_client_install" 258 show_info "scp nutchuser@$Master_IP_Address:/home/nutchuser/nutchez/source/* ." 259 show_info "./client_install" 260 }
Note: See TracChangeset
for help on using the changeset viewer.