1.安装salt-minion
sed -i 's/^#//g' /etc/yum.repos.d/centos7.4.repo
sed -i 's/enabled=0/enabled=1/g' /etc/yum.repos.d/centos7.4.repo
rm -rf /etc/salt/pki/minion/minion_master.pub
systemctl stop firewalld.service
systemctl disable firewalld
mshn=cnsz17pl2287
msip=10.116.100.149
hn="hadoop_datanode_"$(hostname)
yum install salt-minion -y
sed -i "s/^#master:.*/master: $mshn/g" /etc/salt/minion
sed -i "s/^master:.*/master: $mshn/g" /etc/salt/minion
sed -i "s/^#id:.*/id: $hn/g" /etc/salt/minion
sed -i "s/^id:.*/id: $hn/g" /etc/salt/minion
echo "$msip $mshn" >> /etc/hosts
systemctl restart salt-minion.service
systemctl enable salt-minion
echo "TERM=linux" >> /etc/profile
source /etc/profile
2.salt-master操作
a.接受key
salt-key -L
salt-key -A => Y
b.建分组
vim /etc/salt/master
加入
dn: 'hadoop_datanode_*'
hms: 'L@hadoop_history_webproxy_metastore_cnsz17pl1793,hive_metastore_cnsz17pl1786,
hive_metastore_cnsz17pl1787,hive_metastore_cnsz17pl1789,hive_metastore_cnsz17pl2465'
c.测试
salt -N hms test.ping
salt -N hms cmd.run 'ls -ll /app'
d.更新salt版本
salt -N hms cp.get_file salt://salt/minionsetup.py /tmp/minionsetup.py
salt -N hms cmd.run "python /tmp/minionsetup.py upgrade"
e.重启salt-minion
salt -N hms cmd.run 'systemctl restart salt-minion.service'
f.同步jdk
salt -N newdn state.apply jdk
3.安装py2、py3
salt -N newdn state.apply py2
salt -N newdn state.apply py3
4.同步hosts文件
salt '*hadoop' state.apply hosts
5.同步rack机架信息
salt '*hadoop' state.apply rack
--目标机器检查rack是否更新
6.同步hdfs-site配置
salt -N newdn state.apply hadoop.hdfs-site
7.同步yarn-site配置
salt -N newdn state.apply hadoop.yarn-site
8.同步mapred-site配置
salt -N newdn state.apply hadoop.mapred-site
9.同步yarn jar包
salt -N newdn state.apply hadoop.lib
10.同步system服务
salt -N newdn state.apply hadoop.systemd
11.同步HDATA目录
salt -N newdn state.apply hadoop.dir
12.同步log目录
salt -N newdn state.apply hadoop.logdir