The feeling may just be suitable for my own deployment habit, and only for CENTOS6 and the following version, there is time later, may want to improve.
1. How do I quickly get the network configuration from a VM-generated virtual machine?
#!/bin/bash#usage:./init_cdh_sys.SH hostnamehostip#generate the host from ESXi template.must change NIC mac address and changehostnameNet_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 --persistent-net.rulesfileif(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: -: -} New_mac=$(Echo$new _mac_str|awk-F','{'Print $4'}|awk-F'=='{'Print $'}|sed 's/\ "//g') sed-I."/$old _mac/id"$net _rule_filesed-I."s/eth1/eth0/g"$net _rule_fileElseNew_mac_str=$(sed-n-e'/eth0/p'$net _rule_file) #new_mac_1=${NEW_MAC_STR: -: -} New_mac=$(Echo$new _mac_str|awk-F','{'Print $4'}|awk-F'=='{'Print $'}|sed 's/\ "//g') Echo "Done 70-persistent-net.rules file!"fi#====================================#changehostnameif[!-N" $"] ; Then Echo "You had 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_filefi#===================================#resetup NIC configfileif(Cat$net _conf_file|grep$netmask _conf); Then Echo "Done/etc/sysconfig/network-scripts/ifcfg-eth0"elif[!-N" $"] ; Then Echo "You had not input a IP address!"Else sed-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= $dns 1_conf">>$net _conf_file Service network restart rebootfi
2,ssh-keygen-t RSA This command temporarily did not think of good operational aspects (Ansible to deploy?). Recently moved this heart, Saltstack for application deployment, fast, but operation of their own operations, Ansible is also a choice yo, after all, pure ssh.
3, after the first Hadoop, how to happily copy to other nodes? This script is not very convenient, may be related to the directory to customize ... If all the things can be unified into a directory ... :), and Scp-r $var _folder [e-mail protected]$1:/usr/local/, this write ugly, then only fast.
#!/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")functionCp_file_folder () { forVar_fileinch${cp_file[@]}; Do SCP$var _file [Email protected]$1: $var _file Done forVar_folderinch${cp_folder[@]}; Do SCP-R $var _folder [email protected]$1:/usr/local/ Done} whilegetopts:f:h file_name Do Case$file _nameinchf)Cat$OPTARG | whileRead Line DoArr_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"Exit1 ;; \?)Echo "Usage:./init_hadoop_spark-f demo-data"Exit1 ;; :) Echo "Usage:./init_hadoop_spark-f demo-data"Exit1 ;; Esac Done
Script two--for rapid deployment of Hadoop,spark these (especially VM virtual machine templates deployed):