Changeset 158 for nutchez-0.2


Ignore:
Timestamp:
Jun 7, 2010, 5:02:45 PM (14 years ago)
Author:
shunfa
Message:
  1. 修正clinet tar.gz包及路徑
  2. 修正ip及hostname
  3. 新增function: debug_echo
  4. 新增ssh-add
  5. 新增紀錄mac address

註:所有功能目前僅分別測試單一function

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

Legend:

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

    r150 r158  
    1010# *.sh及nutchez-0.2-0531.tar.gz均在同一目錄下
    1111
    12 # 執行環境檢查
    13 check_info () {
    14   check_root
    15   check_systemInfo
    16   check_nez_installed
    17   check_sunJava
    18   check_ssh
    19   check_dialog
    20   install_packages
    21 }
    2212
    2313main () {
     14  #check_info
    2415  echo "歡迎使用NutchEZ, 此安裝程序會為您新建一個nutchuser帳號"
    2516  set_install_information
     
    4031    su nutchuser -c "touch /home/nutchuser/nutchez/urls/urls.txt"
    4132    su nutchuser -c "mkdir /home/nutchuser/nutchez/search"
     33    su nutchuser -c "mkdir /home/nutchuser/nutchez/source"
    4234    make_client_install
    4335
     
    5547}
    5648
    57 check_info
    5849main
  • nutchez-0.2/src/test/install_func.sh

    r152 r158  
    1313
    1414####### fafa code here ###########
     15
     16
     17# shell檔及壓縮檔在同一目錄中
     18
     19
     20####### 環境變數section###########
    1521User_HOME=/home/nutchuser/nutchez
    1622NutchEZ_HOME=/opt/nutchez
     
    1824Tomcat_HOME=$NutchEZ_HOME/tomcat
    1925Index_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
     26Admin_email=nutchuser@nutch
     27
     28# $MasterIP_Address
     29# $net_MacAddr
     30
     31######function section section#######
     32
     33
     34function debug_echo () {
     35  if [ $? -eq 0 ]; then
     36    echo -e "\033[1;32;40m $1 \033[0m"
     37  fi
     38}
     39
     40
     41check_info () {
     42  check_root
     43  check_systemInfo
     44  check_nez_installed
     45  check_sunJava
     46  check_ssh
     47  check_dialog
     48  install_packages
     49}
    2450
    2551function set_install_information () {
    2652  set_nutchuser_passwd
    27   read -p "Please enter Administrator's e-mail address: " Admin_email
    2853  select_eth
    2954  MasterIP_Address=$net_address
    30   # read -p "Please enter the Master DNS:  " MasterDNS
    3155}
    3256
    3357function set_nutchuser_passwd () {
    34   read -p "Please enter nutchuser's password :  " nutchuser_passwd
    35   read -p "Please enter nutchuser's password again:  " nutchuser_passwd_confirm
     58  read -sp "Please enter nutchuser's password :  " nutchuser_passwd
     59  read -sp "Please enter nutchuser's password again:  " nutchuser_passwd_confirm
    3660  if [ $nutchuser_passwd != $nutchuser_passwd_confirm ]; then
    3761    set_nutchuser_passwd
     
    4670  # 若只有一個 eth 時
    4771  if [ "$net_nu" == "1" ]; then
    48     ifconfig $net_interfaces | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1
     72    #ifconfig $net_interfaces | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1
    4973    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"
    5177
    5278  # 若有多個 eth 時
     
    7096    ifconfig $net_interface | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1
    7197    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')
    7299    echo "net_address is $net_address"
     100    echo "net_MacAddr is $net_MacAddr"
    73101  fi
    74102}
     
    76104
    77105function 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"
    80107}
    81108
     
    85112
    86113function make_ssh_key () {
     114  debug_echo "Make ssh key(begin...)"
    87115  su nutchuser -c 'ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ""'
    88116  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!)"
    89119}
    90120
    91121
    92122function set_haoop-site () {
    93   echo "set $Nutch_HOME/conf/hadoop-site.xml"
     123  debug_echo "set hadoop-site.xml(begin...)"
    94124  cd $Nutch_HOME/conf/
    95125  cat > hadoop-site.xml << EOF
     
    109139</configuration>
    110140EOF
     141  debug_echo "set hadoop-site.xml(done!)"
    111142}
    112143
    113144# 修改nutch-site.xml中-http.agent.url, http.agent.email
    114145function set_nutch-site () {
    115   echo "set $Nutch_HOME/conf/nutch-site.xml"
     146  debug_echo "set nutch-site.xml(begin...)"
    116147  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..."
    118149  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))..."
    120151  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..."
    122153
    123154  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..."
    125156
    126157  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))..."
    128159  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!)"
    130162}
    131163
    132164function format_HDFS () {
    133   echo "format HDFS..."
     165  debug_echo "format HDFS..."
    134166  su nutchuser -c "$Nutch_HOME/bin/hadoop namenode -format"
    135167}
    136168
    137169function start_up_NutchEZ (){
    138   echo "start up NutchEZ..."
     170  debug_echo "start up NutchEZ..."
    139171  su nutchuser -c "$Nutch_HOME/bin/start-all.sh"
    140172}
     
    148180function client_PassMasterIPAddr () {
    149181  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..."
    151183  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))..."
    153185  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..."
    155187}
    156188
    157189function client_PassMaster_Hostname () {
    158190  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..."
    160192  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))..."
    162194  sed -i ''$Line_NO'a Master_Hostname='$(hostname)'' client_install
    163   echo "edit client_install done..."
     195  debug_echo "edit client_install done..."
    164196}
    165197
    166198function make_client_install () {
     199  # 建立資料夾(用來存放client的安奘檔)
     200  su nutchuser -c "mkdir $User_HOME/source"
     201
    167202  # 將Master_IP_Address給client
    168203  # 打包安裝目錄(不含tomcat)
     
    170205  client_PassMasterIPAddr
    171206  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
    173213}
    174214
    175215function start_up_tomcat () {
    176   echo "start up tomcat..."
     216  debug_echo "start up tomcat..."
    177217  sleep 10s
    178   echo "su nutchuser -c "$Tomcat_HOME/bin/startup.sh""
    179218  su nutchuser -c "$Tomcat_HOME/bin/startup.sh"
    180 }
    181 
     219  debug_echo "tomcat has been started..."
     220}
     221
     222###最後再整理###
    182223# client簡易步驟
    183224function client_install_command () {
Note: See TracChangeset for help on using the changeset viewer.