感觉可能只是适合我自己的部署习惯吧,且只针对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) ;then new_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_file sed -i "s/eth1/eth0/g" $net_rule_file else new_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" ] ;then echo "you have not input a hostname!" echo "usage:./init_sys_nic.sh cm222.wdzjcdh.com 192.168.14.222" else sed -i "s/localhost.localdomain/$1/g" $net_hostname_file fi #=================================== #resetup NIC config file if (cat $net_conf_file|grep $netmask_conf) ;then echo "done /etc/sysconfig/network-scripts/ifcfg-eth0" elif [ ! -n "$2" ] ;then echo "you have not input a ip address!" else sed -i "/$old_mac/Id" $net_conf_file sed -i "s/dhcp/static/g" $net_conf_file echo "HWADDR=$new_mac" >> $net_conf_file echo "IPADDR=$2" >> $net_conf_file echo "NETMASK=$netmask_conf" >> $net_conf_file echo "GATEWAY=$gateway_conf" >> $net_conf_file echo "DNS1=$dns1_conf" >> $net_conf_file service network restart reboot fi
2,SSH-KEYGEN -T RSA这个命令暂时没有想到好的操作方面(ANSIBLE来部署?)最近动了这个心了,SALTSTACK作应用部署,快,但运维自己的操作,ANSIBLE也是一个选择哟,毕竟纯SSH。。
3,在弄好首台HADOOP之后,如何愉快的COPY到其它结点?这个脚本不太方便,可能相关目录要自定义。。。如果能所有的东东统一到一个目录的话。。。:),还有scp -r $var_folder [email protected]$1:/usr/local/,这个写得奇丑,当时只求快。。
#!/bin/bash echo "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[@]}; do scp $var_file [email protected]$1:$var_file done for var_folder in ${cp_folder[@]}; do scp -r $var_folder [email protected]$1:/usr/local/ done } while getopts :f:h file_name do case $file_name in f) cat $OPTARG | while read line do arr_var=(${line}) cp_file_folder ${arr_var[0]} #run_docker ${arr_var[0]} ${arr_var[1]} ${arr_var[2]} done sleep 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
时间: 2024-10-14 14:02:35