Changeset 172
- Timestamp:
- Jun 9, 2010, 5:10:28 PM (15 years ago)
- Location:
- nutchez-0.2/src/test
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
nutchez-0.2/src/test/add_hosts
r165 r172 40 40 # 附加 nutch_nodes 到 /etc/hosts 41 41 cp -f /etc/hosts /etc/hosts.bak 42 cat $1 >> $242 cat $1 | grep -v '#' >> $2 -
nutchez-0.2/src/test/duplicate_del
r165 r172 11 11 # Delete duplicating ip addresss in file 12 12 IPs=$(cat $1 | grep -v 'ip6' | grep -v '#' | grep -v '^$' | awk '{print $1}') 13 cp -f $1 ${1}.bak 13 14 # 刪掉空白行 15 sed -i '/^$/d' $1 16 17 cp -f "$1" "${1}.old" 18 #read -p "cp - f $1 ${1}.old ; $?" 14 19 15 20 for ip_add in $(echo $IPs) … … 25 30 done 26 31 27 28 32 # Dlete duplicating hostname in file 29 33 hostnames=$(cat $1 | grep -v ip6 | grep -v '#' | grep -v '^$' |awk '{print $2}') … … 40 44 done 41 45 done 46 47 cp -f "$1" "${1}.bak" 48 #read -p "cp -f $1 ${1}.bak ; $?" -
nutchez-0.2/src/test/nutchez
r171 r172 9 9 # 2010/06/07 Rock First release (1.0) 10 10 11 # Variables Declaration#11 # [Variables Declaration] # 12 12 DIALOG=dialog 13 13 main_choice= 14 #LIST_Option="off" 15 16 # PATH Declaration 14 15 # [PATH Declaration] # 17 16 NutchEZ_Install_PATH=/opt/nutchez 18 17 NutchEZ_HOME=/home/nutchuser/nutchez 19 18 20 # Functions Declaration#21 ## Prepare Check##19 # [Functions Declaration] # 20 ## [Prepare Check] ## 22 21 function prepare_check(){ 23 if [ ! -e $NutchEZ_HOME/system/nutch_nodes ]; then 22 # 若無 nutchez_nodes 則跳出 23 if [ ! -e "${NutchEZ_HOME}/system/nutch_nodes" ]; then 24 24 $DIALOG --clear --backtitle "= [NutchEz Management Interface] ~by NCHC =" --title "[nutch_nodes Files]" \ 25 --msgbox "Fail: Don't find $NutchEZ_Source_HOME/nutch_nodes !!!" 10 40 26 exit 27 fi 28 29 $DIALOG --clear --defaultno --backtitle "= [NutchEz Management Interface] ~by NCHC =" --title "[/etc/host Update]" \ 30 --yesno "Do you want to update \"/etc/hosts\" !!!\n(First time to execute it, please update)" 6 50 31 32 33 if [ "$?" == "0" ]; then 34 ./duplicate_del $NutchEZ_HOME/system/nutch_nodes 35 echo -e "\nPlz input root password to update /etc/hosts !!!" 36 su root -c "./duplicate_del /etc/hosts && ./add_hosts $NutchEZ_HOME/nutch_nodes /etc/hosts" 37 fi 38 } 39 40 ## Main Menu 25 --msgbox "Fail: Don't find $NutchEZ_HOME/system/nutch_nodes !!!" 10 40 26 exit 27 fi 28 29 # 判斷 nutch_nodes 和 nutch_nodes.back 30 # 第一次執行則要求 user 更新 /etc/hosts 31 if [ ! -e "${NutchEZ_HOME}/system/nutch_nodes.bak" ]; then 32 $DIALOG --clear --backtitle "= [NutchEz Management Interface] ~by NCHC =" --title "[/etc/host Update]" \ 33 --yesno "First execut nutchez management interface.\nPlz update /etc/hosts !!!" 10 55 34 35 echo -e "Plz input root password to update /etc/hosts !!!" 36 ./duplicate_del "${NutchEZ_HOME}/system/nutch_nodes" 37 su root -c "./duplicate_del /etc/hosts && ./add_hosts ${NutchEZ_HOME}/system/nutch_nodes /etc/hosts" 38 # 若密碼輸入失敗則跳出 39 if [ $? == "1" ]; then 40 echo "Root password is error ! Plz check root password !!!" 41 exit 42 fi 43 # 若 nutch_nodes 被更新過,則要求更新 /etc/hosts 44 elif [ ${NutchEZ_HOME}/system/nutch_nodes -nt ${NutchEZ_HOME}/system/nutch_nodes.bak ]; then 45 $DIALOG --clear --backtitle "= [NutchEz Management Interface] ~by NCHC =" --title "[/etc/host Update]" \ 46 --yesno "nutch_nodes already be modified.\nPlz update /etc/hosts !!!" 10 55 47 48 echo -e "Plz input root password to update /etc/hosts !!!" 49 ./duplicate_del "${NutchEZ_HOME}/system/nutch_nodes" 50 su root -c "./duplicate_del /etc/hosts && ./add_hosts ${NutchEZ_HOME}/system/nutch_nodes /etc/hosts" 51 # 若密碼輸入失敗則跳出 52 if [ $? == "1" ]; then 53 echo "Root password is error ! Plz check root password !!!" 54 exit 55 fi 56 fi 57 58 } 59 60 ## [Main Menu] ## 41 61 function main_menu(){ 42 62 main_choice="/tmp/main_choice" … … 52 72 } 53 73 54 ## Cluster Setup (datanode & tasktracker)##74 ## [Cluster Setup (datanode & tasktracker)] ## 55 75 function cluster_setup(){ 56 57 node_list=$(cat /home/nutchuser/nutchez/nutch_nodes | awk '{print $1}') 58 #echo -e $node_list 59 #read 60 61 #dataNodes=$($DIALOG --clear --backtitle "= [NutchEz Management Interface] ~by NCHC = " --title "datanode & tasknode setup" \ 62 # --checklist "datanode & tasknode choose: " 15 55 7 $(cat /home/nutchuser/nutch_nodes | awk '{print $1 "\t" $2 "\t" "off" }')) 63 #echo $dataNodes 76 # 從 nutch_nodes 讀出 ip 和 hostname 77 #IP_list=$(cat $NutchEZ_HOME/system/nutch_nodes | grep -v '^$' | grep -v '#' | awk '{print $1}') 78 #HOST_list=$(cat $NutchEZ_HOME/system/nutch_nodes | grep -v '^$' | grep -v '#' | awk '{print $2}') 79 LIST_status="off" 80 allpart="/tmp/allpart" 81 runNodes="/tmp/runNodes" 64 82 clusterSetup="/tmp/clusterSetup" 83 84 $DIALOG --clear --backtitle "= [NutchEz Management Interface] ~by NCHC =" \ 85 --title "[Management Options]" \ 86 --menu "Plz choose: " 15 55 2 \ 87 "All" "All nodes" \ 88 "Part" "choose part nodess" 2>$allpart 89 90 # 判斷是否選 all 和 part,若是 all 直接到服務選單,若是 part 則先到機器選單 91 if [ $(cat $allpart) == "All" ]; then 92 cat $NutchEZ_HOME/system/nutch_nodes | grep -v '^$' | grep -v '#' | awk '{print $1}' >$runNodes 93 else 94 $DIALOG --clear --backtitle "= [NutchEz Management Interface] ~by NCHC = " --title "[Datanode & Tasktracker Nodes Choose]" \ 95 --checklist "datanode & tasktracker choose: " 15 55 7 $(cat $NutchEZ_HOME/system/nutch_nodes | \ 96 grep -v '^$' | grep -v '#' | awk '{print $1 "\t" $2 "\t" "$LIST_status" }') 2>$runNodes 97 fi 98 65 99 $DIALOG --clear --backtitle "= [NutchEz Management Interface] ~by NCHC =" --title "[Datanode & Tasktracker Setup]" \ 66 100 --menu "Plz choose: " 10 65 3 \ 67 "start" "Start all datanodes & tasktrackers in cluster" \ 68 "stop" "Stop all datanodes & tasktrackers in cluster" \ 101 "start" "Start datanodes & tasktrackers" \ 102 "stop" "Stop datanodes & tasktrackers" \ 103 "restart" "restart datanodes & tasktrackers" \ 69 104 "exit" "Exit" 2>$clusterSetup 70 105 71 #echo -e "$clusterSetup"72 73 106 if [ "$(cat $clusterSetup)" == "start" ]; then 74 echo "/opt/nutchez/nutch/bin/hadoop-daemon.sh start datanode" 75 echo "/opt/nutchez/nutch/bin/hadoop-daemon.sh start tasktracker" 76 /opt/nutchez/nutch/bin/hadoop-daemon.sh start datanode 77 /opt/nutchez/nutch/bin/hadoop-daemon.sh start tasktracker 78 for node in $(echo $node_list) 107 for node in $(cat $runNodes) 79 108 do 109 echo -e "start !" 80 110 echo -e "ssh -o StrictHostKeyChecking=no $node /opt/nutchez/nutch/bin/hadoop-daemon.sh start datanode" 81 111 ssh -o StrictHostKeyChecking=no $node "/opt/nutchez/nutch/bin/hadoop-daemon.sh start datanode" 82 112 echo -e "ssh -o StrictHostKeyChecking=no $node /opt/nutchez/nutch/bin/hadoop-daemon.sh start tasktracker" 83 113 ssh -o StrictHostKeyChecking=no $node "/opt/nutchez/nutch/bin/hadoop-daemon.sh start tasktracker" 114 [ $? == "0" ] || echo "Can't ssh to $node !!!" 84 115 done 85 116 elif [ "$(cat $clusterSetup)" == "stop" ]; then 86 echo "/opt/nutchez/nutch/bin/hadoop-daemon.sh stop datanode" 87 echo "/opt/nutchez/nutch/bin/hadoop-daemon.sh stop tasktracker" 88 /opt/nutchez/nutch/bin/hadoop-daemon.sh stop datanode 89 /opt/nutchez/nutch/bin/hadoop-daemon.sh stop tasktracker 90 for node in $(echo $node_list) 117 for node in $(cat $runNodes) 91 118 do 119 echo -e "stop !" 92 120 echo -e "ssh -o StrictHostKeyChecking=no $node /opt/nutchez/nutch/bin/hadoop-daemon.sh stop datanode" 93 121 ssh -o StrictHostKeyChecking=no $node "/opt/nutchez/nutch/bin/hadoop-daemon.sh stop datanode" 94 122 echo -e "ssh -o StrictHostKeyChecking=no $node /opt/nutchez/nutch/bin/hadoop-daemon.sh stop tasktracker" 95 123 ssh -o StrictHostKeyChecking=no $node "/opt/nutchez/nutch/bin/hadoop-daemon.sh stop tasktracker" 124 [ $? == "0" ] || echo "Can't ssh to $node !!!" 96 125 done 97 126 else 98 exit 0 99 fi 100 } 101 102 ## Tomcat Severice start/stop/restart ## 127 for node in $(cat $runNodes) 128 do 129 echo -e "restart !" 130 ssh -o StrictHostKeyChecking=no $node "/opt/nutchez/nutch/bin/hadoop-daemon.sh stop datanode" 131 ssh -o StrictHostKeyChecking=no $node "/opt/nutchez/nutch/bin/hadoop-daemon.sh stop tasktracker" 132 ssh -o StrictHostKeyChecking=no $node "/opt/nutchez/nutch/bin/hadoop-daemon.sh start datanode" 133 ssh -o StrictHostKeyChecking=no $node "/opt/nutchez/nutch/bin/hadoop-daemon.sh start tasktracker" 134 [ $? == "0" ] || echo "Can't ssh to $node !!!" 135 done 136 137 fi 138 } 139 140 ## [Tomcat Severice start/stop/restart] ## 103 141 function tomcat_switch(){ 104 142 pid_tc=$(ps axw -eo pid,command | grep "catalina" | grep "java" | grep "start" | awk '{print $1}') … … 135 173 } 136 174 137 ## Tomcat Port change##175 ## [Tomcat Port Change] ## 138 176 function tomcat_port(){ 139 177 … … 156 194 157 195 158 ## Language Change##196 ## [Language Change] ## 159 197 function lang_switch(){ 160 198 echo -e "lang_switch" … … 169 207 170 208 171 # Main Code209 # [Main Code] # 172 210 if [ $USER != "nutchuser" ]; then 173 211 echo -e "\nYour identify is not nutchuser, plz change to \"nutchuser\" !!!"
Note: See TracChangeset
for help on using the changeset viewer.