注意问题:
一旦有冲突,客户端会重启。
客户端上minion一旦发生变化,服务会自动停掉
保证minion正常运行,又要迁移过去。
1、 新准备一台主机
2、 安装master
yum install -y epel-release
yum install -y salt-master salt-minion
3、 打包老master目录下的pki目录,传到新master目录
[root@saltsalt]# tar -cvf pkitar.gzpki
pki/
pki/master/
pki/master/minions_rejected/
pki/master/minions_rejected/salt.wolf.com
pki/master/minions_pre/
pki/master/minions_pre/salt.wolf.com
pki/master/master.pub
pki/master/master.pem
pki/master/minions_autosign/
pki/master/minions_autosign/salt.wolf.com
pki/master/minions/
pki/master/minions/slave01.wolf.com
pki/master/minions/salt.wolf.com
pki/master/minions/slave02.wolf.com
pki/master/minions_denied/
pki/master/minions_denied/salt.wolf.com
pki/minion/
pki/minion/minion.pem
pki/minion/minion_master.pub
pki/minion/minion.pub
[root@salt salt]#ls
master minion minion.d minion_id pki pkitar.gz
[root@salt salt]# salt '*' cmd.run 'cat/etc/issue'
slave01.wolf.com:
CentOS release 6.8 (Final)
Kernel \r on an \m
slave02.wolf.com:
CentOS release 6.8 (Final)
Kernel \r on an \m
salt.wolf.com:
CentOS release 6.5 (Final)
Kernel \r on an \m
[root@salt salt]# salt '*' cmd.run 'cat/etc/hosts'
slave01.wolf.com:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.3.49 www.wolf.com wolf.com
192.168.3.49 bbs.wolf.com
192.168.3.49 blog.wolf.com
192.168.3.201 salt.wolf.com salt nginx
192.168.3.49 slave01.wolf.com slave01
192.168.3.52 slave02.wolf.com slave02
salt.wolf.com:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.3.201 salt.wolf.com salt node1
192.168.3.49 slave01.wolf.com slave01
192.168.3.52 slave02.wolf.com slave02
slave02.wolf.com:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.3.52 bbs.wolf.com
192.168.3.201 salt.wolf.com salt
192.168.3.49 slave01.wolf.com slave01
192.168.3.52 slave02.wolf.com slave02
[root@salt salt]# salt '*' cmd.run 'grep salt/etc/hosts'
slave01.wolf.com:
192.168.3.201 salt.wolf.com salt nginx
salt.wolf.com:
192.168.3.201 salt.wolf.com salt node1
slave02.wolf.com:
192.168.3.201 salt.wolf.com salt
[root@salt salt]# scp pki.tar.gz192.168.3.107:/etc/salt/
The authenticityof host '192.168.3.107 (192.168.3.107)' can't be established.
RSA keyfingerprint is 50:d1:85:98:0c:9f:b8:04:9e:01:c9:94:79:9e:a6:f1.
Are you sure youwant to continue connecting (yes/no)? yes
Warning: Permanentlyadded '192.168.3.107' (RSA) to the list of known hosts.
root@192.168.3.107'spassword:
pki.tar.gz 100% 20KB 20.0KB/s 00:00
4、新master上操作
[root@mysql salt]#tar -xvf pki.tar.gz
pki/
pki/master/
pki/master/minions_rejected/
pki/master/minions_rejected/salt.wolf.com
pki/master/minions_pre/
pki/master/minions_pre/salt.wolf.com
pki/master/master.pub
pki/master/master.pem
pki/master/minions_autosign/
pki/master/minions_autosign/salt.wolf.com
pki/master/minions/
pki/master/minions/slave01.wolf.com
pki/master/minions/salt.wolf.com
pki/master/minions/slave02.wolf.com
pki/master/minions_denied/
pki/master/minions_denied/salt.wolf.com
pki/minion/
pki/minion/minion.pem
pki/minion/minion_master.pub
pki/minion/minion.pub
[root@mysql salt]#ls
master minion pki pki.tar.gz
[root@mysql salt]#cd pki
[root@mysql pki]#ls
master minion
[root@mysql pki]# /etc/init.d/salt-master start
Startingsalt-master daemon: [ OK ]
5、Old master上操作
修改old master地址
[root@salt salt]# salt '*' cmd.run "sed -i's/201/107/' /etc/hosts"
slave01.wolf.com:
slave02.wolf.com:
salt.wolf.com:
再查看
[root@salt salt]# salt '*' cmd.run 'grep salt/etc/hosts'
slave02.wolf.com:
192.168.3.107 salt.wolf.com salt
salt.wolf.com:
192.168.3.107 salt.wolf.com salt node1
slave01.wolf.com:
192.168.3.107 salt.wolf.com salt nginx
重启服务
salt '*' service.restartsalt-minion
[root@salt salt]# salt '*' service.restartsalt-minion
slave01.wolf.com:
True
slave02.wolf.com:
True
salt.wolf.com:
True
重启服务,他只判断,是否有key,如果有就启动,没有就生成
6、 老master上修改配置文件和hosts文件的ip
7、、 重启服务
8、新master’上查看
. [root@mysql salt]# salt '*' test.ping
slave02.wolf.com:
True
slave01.wolf.com:
True
salt.wolf.com