Changeset 172


Ignore:
Timestamp:
Jun 9, 2010, 5:10:28 PM (14 years ago)
Author:
rock
Message:

修改 Bug (Bug ID 1,2,3,4)

Location:
nutchez-0.2/src/test
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • nutchez-0.2/src/test/add_hosts

    r165 r172  
    4040# 附加 nutch_nodes 到 /etc/hosts
    4141cp -f /etc/hosts /etc/hosts.bak
    42 cat $1 >> $2
     42cat $1 | grep -v '#' >> $2
  • nutchez-0.2/src/test/duplicate_del

    r165 r172  
    1111# Delete duplicating ip addresss in file
    1212IPs=$(cat $1 | grep -v 'ip6' | grep -v '#' | grep -v '^$' | awk '{print $1}')
    13 cp -f $1 ${1}.bak
     13
     14# 刪掉空白行
     15sed -i '/^$/d' $1
     16
     17cp -f "$1" "${1}.old"
     18#read -p "cp - f $1 ${1}.old ; $?"
    1419
    1520for ip_add in $(echo $IPs)
     
    2530done
    2631 
    27 
    2832# Dlete duplicating hostname in file
    2933hostnames=$(cat $1 | grep -v ip6 | grep -v '#' | grep -v '^$' |awk '{print $2}')
     
    4044    done                                                                                                                                                             
    4145done
     46
     47cp -f "$1" "${1}.bak"
     48#read -p "cp -f $1 ${1}.bak ; $?"
  • nutchez-0.2/src/test/nutchez

    r171 r172  
    99#   2010/06/07  Rock    First release (1.0)
    1010
    11 # Variables Declaration #
     11# [Variables Declaration] #
    1212DIALOG=dialog
    1313main_choice=
    14 #LIST_Option="off"
    15 
    16 # PATH Declaration
     14
     15# [PATH Declaration] #
    1716NutchEZ_Install_PATH=/opt/nutchez
    1817NutchEZ_HOME=/home/nutchuser/nutchez
    1918
    20 # Functions Declaration #
    21 ## Prepare Check  ##
     19# [Functions Declaration] #
     20## [Prepare Check]  ##
    2221function prepare_check(){
    23 if [ ! -e $NutchEZ_HOME/system/nutch_nodes ]; then
     22# 若無 nutchez_nodes 則跳出
     23if [ ! -e "${NutchEZ_HOME}/system/nutch_nodes" ]; then
    2424    $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
     27fi
     28
     29# 判斷 nutch_nodes 和 nutch_nodes.back
     30# 第一次執行則要求 user 更新 /etc/hosts
     31if [ ! -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
     44elif [ ${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
     56fi
     57
     58}
     59
     60## [Main Menu] ##
    4161function main_menu(){
    4262main_choice="/tmp/main_choice"
     
    5272}
    5373
    54 ## Cluster Setup (datanode & tasktracker) ##
     74## [Cluster Setup (datanode & tasktracker)] ##
    5575function 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}')
     79LIST_status="off"
     80allpart="/tmp/allpart"
     81runNodes="/tmp/runNodes"
    6482clusterSetup="/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 則先到機器選單
     91if [ $(cat $allpart) == "All" ]; then
     92     cat $NutchEZ_HOME/system/nutch_nodes | grep -v '^$' | grep -v '#'  | awk '{print $1}' >$runNodes
     93else
     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
     97fi
     98
    6599$DIALOG --clear --backtitle "= [NutchEz Management Interface] ~by NCHC =" --title "[Datanode & Tasktracker Setup]" \
    66100    --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" \
    69104    "exit" "Exit" 2>$clusterSetup
    70105
    71 #echo -e "$clusterSetup" 
    72 
    73106if [ "$(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)
    79108    do
     109        echo -e "start !"
    80110        echo -e "ssh -o StrictHostKeyChecking=no $node /opt/nutchez/nutch/bin/hadoop-daemon.sh start datanode"
    81111        ssh -o StrictHostKeyChecking=no $node "/opt/nutchez/nutch/bin/hadoop-daemon.sh start datanode"
    82112        echo -e "ssh -o StrictHostKeyChecking=no $node /opt/nutchez/nutch/bin/hadoop-daemon.sh start tasktracker"
    83113        ssh -o StrictHostKeyChecking=no $node "/opt/nutchez/nutch/bin/hadoop-daemon.sh start tasktracker"
     114        [ $? == "0" ] || echo "Can't ssh to $node !!!"
    84115    done
    85116elif [ "$(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)
    91118    do
     119        echo -e "stop !"
    92120        echo -e "ssh -o StrictHostKeyChecking=no $node /opt/nutchez/nutch/bin/hadoop-daemon.sh stop datanode"
    93121        ssh -o StrictHostKeyChecking=no $node "/opt/nutchez/nutch/bin/hadoop-daemon.sh stop datanode"
    94122        echo -e "ssh -o StrictHostKeyChecking=no $node /opt/nutchez/nutch/bin/hadoop-daemon.sh stop tasktracker"
    95123        ssh -o StrictHostKeyChecking=no $node "/opt/nutchez/nutch/bin/hadoop-daemon.sh stop tasktracker"
     124        [ $? == "0" ] || echo "Can't ssh to $node !!!"
    96125    done
    97126else
    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 
     137fi
     138}
     139
     140## [Tomcat Severice start/stop/restart] ##
    103141function tomcat_switch(){
    104142pid_tc=$(ps axw -eo pid,command | grep "catalina" | grep "java" | grep "start" | awk '{print $1}')
     
    135173}
    136174
    137 ##  Tomcat Port change ##
     175## [Tomcat Port Change] ##
    138176function tomcat_port(){
    139177
     
    156194
    157195
    158 ## Language Change ##
     196## [Language Change] ##
    159197function lang_switch(){
    160198echo -e "lang_switch"
     
    169207
    170208
    171 # Main Code
     209# [Main Code] #
    172210if [ $USER != "nutchuser" ]; then
    173211    echo -e "\nYour identify is not nutchuser, plz change to \"nutchuser\" !!!"
Note: See TracChangeset for help on using the changeset viewer.