感觉可能只是适合我自己的部署习惯吧,且只针对CENTOS6及以下版本,以后有时间,可能还是要改进。。
1,从VM的模块产生的虚拟机,如何快速搞定网络配置?
#!/bin/bash#usage:./init_cdh_sys.sh hostname hostip #generate the host from esxi template.must change NIC mac address and change hostname net_rule_file="/etc/udev/rules.d/70-persistent-net.rules" net_conf_file="/etc/sysconfig/network-scripts/ifcfg-eth0" net_hostname_file="/etc/sysconfig/network" netmask_conf="255.255.255.0" gateway_conf="192.168.xx.1" dns1_conf="a.b.c.d" old_mac="00:50:56:BD:92:DA"#此处要替换为模板的MAC地址#============================================ #resetup 70-persistent-net.rules file if (cat $net_rule_file|grep -i $old_mac) ;thennew_mac_str=$(sed -n -e '/eth1/ p' $net_rule_file)#new_mac_1=${new_mac_str:64:17}new_mac=$(echo $new_mac_str| awk -F ',' {'print $4'}|awk -F '==' {'print $2'}|sed 's/\"//g')sed -i "/$old_mac/Id" $net_rule_filesed -i "s/eth1/eth0/g" $net_rule_file elsenew_mac_str=$(sed -n -e '/eth0/ p' $net_rule_file)#new_mac_1=${new_mac_str:64:17}new_mac=$(echo $new_mac_str| awk -F ',' {'print $4'}|awk -F '==' {'print $2'}|sed 's/\"//g')echo "done 70-persistent-net.rules file!" fi#==================================== #change hostname if [ ! -n "$1" ] ;thenecho "you have not input a hostname!"echo "usage:./init_sys_nic.sh cm222.wdzjcdh.com 192.168.14.222" elsesed -i "s/localhost.localdomain/$1/g" $net_hostname_file fi #=================================== #resetup NIC config file if (cat $net_conf_file|grep $netmask_conf) ;thenecho "done /etc/sysconfig/network-scripts/ifcfg-eth0" elif [ ! -n "$2" ] ;thenecho "you have not input a ip address!" elsesed -i "/$old_mac/Id" $net_conf_filesed -i "s/dhcp/static/g" $net_conf_fileecho "HWADDR=$new_mac" >> $net_conf_fileecho "IPADDR=$2" >> $net_conf_fileecho "NETMASK=$netmask_conf" >> $net_conf_fileecho "GATEWAY=$gateway_conf" >> $net_conf_fileecho "DNS1=$dns1_conf" >> $net_conf_fileservice network restartreboot fi
2,SSH-KEYGEN -T RSA这个命令暂时没有想到好的操作方面(ANSIBLE来部署?)最近动了这个心了,SALTSTACK作应用部署,快,但运维自己的操作,ANSIBLE也是一个选择哟,毕竟纯SSH。。
3,在弄好首台HADOOP之后,如何愉快的COPY到其它结点?这个脚本不太方便,可能相关目录要自定义。。。如果能所有的东东统一到一个目录的话。。。:),还有scp -r $var_folder root@$1:/usr/local/,这个写得奇丑,当时只求快。。
#!/bin/bashecho "Usage: ./init_hadoop_spark -f demo-data" cp_file=("/etc/hosts" "/etc/profile.d/env.sh") cp_folder=("/root/.ssh/" "/usr/local/scala-2.11.4" "/usr/local/hadoop-2.6.0" "/usr/local/spark-1.2.2-bin-hadoop2.4" "/usr/local/jdk1.7.0_71")function cp_file_folder() {for var_file in ${cp_file[@]};doscp $var_file root@$1:$var_filedone for var_folder in ${cp_folder[@]};doscp -r $var_folder root@$1:/usr/local/done }while getopts :f:h file_name docase $file_name inf) cat $OPTARG | while read linedoarr_var=(${line})cp_file_folder ${arr_var[0]}#run_docker ${arr_var[0]} ${arr_var[1]} ${arr_var[2]}donesleep 2;;h) echo "Usage: ./init_hadoop_spark -f demo-data" exit 1;;\?) echo "Usage: ./init_hadoop_spark -f demo-data" exit 1 ;; :) echo "Usage: ./init_hadoop_spark -f demo-data" exit 1;;esac done