Changeset 159 for nutchez-0.2/src


Ignore:
Timestamp:
Jun 7, 2010, 5:27:48 PM (14 years ago)
Author:
shunfa
Message:
  1. 新增寫入mac address
  2. 新增ssh-add
File:
1 edited

Legend:

Unmodified
Added
Removed
  • nutchez-0.2/src/test/client_install_func.sh

    r157 r159  
    163163# 此步驟若無法連到 master 則跳出
    164164function scp_master_nutchuser_sshkey(){
    165 echo -e "\n\033[31m= scp_master_nutchuser_sshkey (debug) =\033[0m"
    166 echo -e "mkdir -p /home/nutchuser/"
    167 mkdir -p /home/nutchuser/.ssh/
    168 rm -fr /home/nutchuser/.ssh/*
    169 
    170 unset Nutchuser_Passwd2
    171 
    172 echo -e "scp nutchuser@$1:~/.ssh /home/nutchuser/"
     165  echo -e "\n\033[31m= scp_master_nutchuser_sshkey (debug) =\033[0m"
     166  echo -e "mkdir -p /home/nutchuser/"
     167  mkdir -p /home/nutchuser/.ssh/
     168  rm -fr /home/nutchuser/.ssh/*
     169
     170  unset Nutchuser_Passwd2
     171
     172  echo -e "scp nutchuser@$1:~/.ssh /home/nutchuser/"
    173173expect -c "spawn scp -r -o StrictHostKeyChecking=no nutchuser@$1:~/.ssh /home/nutchuser/
    174174expect \"*: \" { send \"$Nutchuser_Passwd\r\" }
     
    176176expect eof"
    177177
    178 if [ -e "/home/nutchuser/.ssh/authorized_keys" ]; then
     178  if [ -e "/home/nutchuser/.ssh/authorized_keys" ]; then
    179179        echo -e "\nscp correct."   
    180180    else
    181         echo -e "\nscp is error,\n(1)plz check nutchuser password in server\n(2)nutchuser's authorized_keys in server\n(3)server's network status"
    182         exit
     181      echo -e "\nscp is error,\n(1)plz check nutchuser password in server\n(2)nutchuser's authorized_keys in server\n(3)server's network status"
     182      exit
    183183    fi
    184 
    185     echo "chown -R nutchuser:nutchuser /home/nutchuser/.ssh"
    186     chown -R nutchuser:nutchuser /home/nutchuser/.ssh
    187 
     184  ssh-add /home/nutchuser/.ssh/id_rsa
     185  echo "chown -R nutchuser:nutchuser /home/nutchuser/.ssh"
     186  chown -R nutchuser:nutchuser /home/nutchuser/.ssh
    188187}
    189188
     
    234233# 目前僅需做到能無礙的複製遠端的/opt/nutchez/到local的/opt/
    235234function scp_packages(){
    236 echo -e "\n\033[31m= scp_packages (debug) =\033[0m"
    237 
    238 mkdir /opt/nutchez
    239 mkdir /var/nutchez
    240 mkdir /home/nutchuser/nutchez
    241 chmod 777 /opt/nutchez
    242 #su nutchuser -c "scp -r -o StrictHostKeyChecking=no nutchuser@$1:/opt/nutchez /opt/"
    243 echo "scp -r nutchuser@$1:/opt/nutchez/NutchezForClientOf_$Master_IP_Address.tar.gz /opt/nutchez/"
    244 su nutchuser -c "scp -r -o StrictHostKeyChecking=no nutchuser@$1:/opt/nutchez/NutchezForClientOf_$Master_IP_Address.tar.gz /opt/nutchez"
    245 
    246 echo -e "\nchown -R nutchuser:nutchuser /opt/nutchez"
    247 chown -R nutchuser:nutchuser /opt/nutchez
    248 chown -R nutchuser:nutchuser /var/nutchez
    249 chown -R nutchuser:nutchuser /home/nutchuser/nutchez
    250 
    251 chmod 755 /opt/nutchez
     235  echo -e "\n\033[31m= scp_packages (debug) =\033[0m"
     236  mkdir /opt/nutchez
     237  mkdir /var/nutchez
     238  mkdir /home/nutchuser/nutchez
     239  mkdir /home/nutchuser/nutchez/source
     240  chmod 777 /opt/nutchez
     241  #su nutchuser -c "scp -r -o StrictHostKeyChecking=no nutchuser@$1:/opt/nutchez /opt/"
     242  echo "scp -r nutchuser@$1:/opt/nutchez/NutchezForClientOf_$Master_IP_Address.tar.gz /opt/nutchez/"
     243  su nutchuser -c "scp -r -o StrictHostKeyChecking=no nutchuser@$1:/home/nutchuser/nutchez/source/NutchezForClientOf_$Master_IP_Address.tar.gz /home/nutchuser/nutchez/source"
     244
     245  echo -e "\nchown -R nutchuser:nutchuser /opt/nutchez"
     246  chown -R nutchuser:nutchuser /opt/nutchez
     247  chown -R nutchuser:nutchuser /var/nutchez
     248  chown -R nutchuser:nutchuser /home/nutchuser/nutchez
     249  chmod 755 /opt/nutchez
    252250}
    253251
     
    255253function install_nutch_package(){
    256254  echo -e "\n\033[31m= install_nutch_package (debug) =\033[0m"
    257   tar -zxvf /opt/nutchez/NutchezForClientOf_$Master_IP_Address.tar.gz -C /
    258   sed -i.bak '1a '$Master_IP_Address' '$Master_Hostname'' /etc/hosts
     255  tar -zxvf /home/nutchuser/nutchez/source/NutchezForClientOf_$Master_IP_Address.tar.gz -C /opt/nutchez
     256  sed -i '1a '$Master_IP_Address' '$Master_Hostname'' /etc/hosts
    259257  #/opt/nutchez/nutch/bin/hadoop-daemon.sh start datanode
    260258  #/opt/nutchez/nutch/bin/hadoop-daemon.sh start tasktracker
     
    270268if [ "$net_nu" == "1" ]; then
    271269
    272 ifconfig $net_interfaces | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1
     270# ifconfig $net_interfaces | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1
    273271net_address=$(ifconfig $net_interfaces | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1)
     272net_MacAddr=$(ifconfig $net_interfaces | grep 'HW' | sed 's/^.*HWaddr //g')
    274273echo "net_address is $net_address"
     274echo "net_MacAddr is $net_MacAddr"
    275275
    276276# 若有多個 eth 時
     
    289289        net_choice=1
    290290    fi   
    291    
     291
    292292    echo "choice is $net_choice"
    293293    net_interface=$(echo $net_interfaces | cut -d " " -f $net_choice)
    294     ifconfig $net_interface | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1
     294    # config $net_interface | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1
    295295    net_address=$(ifconfig $net_interface | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1)
     296    net_MacAddr=$(ifconfig $net_interfaces | grep 'HW' | sed 's/^.*HWaddr //g')
    296297    echo "net_address is $net_address"
    297 fi
    298 
    299 echo "ssh nutchuser@$1 echo $net_address $(hostname) \>\> ~/nutchez/nutch_nodes"
    300 su nutchuser -c "ssh nutchuser@$1 echo $net_address $(hostname) \>\> ~/nutchez/nutch_nodes"
     298    echo "net_MacAddr is $net_MacAddr"
     299fi
     300
     301echo "ssh nutchuser@$1 echo $net_address $(hostname) $net_MacAddr \>\> ~/nutchez/nutch_nodes"
     302su nutchuser -c "ssh nutchuser@$1 echo $net_address $(hostname) $net_MacAddr \>\> ~/nutchez/nutch_nodes"
    301303
    302304#su nutchuser -c expect -c "spawn ssh nutchuser@$1
Note: See TracChangeset for help on using the changeset viewer.