Fork me on GitHub

SaltStack+Docker构建高可用与自动发现服务

SaltStack+Docker构建高可用与自动发现服务

环境说明

主机名称IP服务备注
linux-node3.example.com192.168.200.107salt-master redis
linux-node4.example.com192.168.200.106sakt-minion haproxy
linux-node5.example.com192.168.200.115sakt-minion docker
linux-node7.example.com192.168.200.117sakt-minion docker

#

1
2
3
4
5
6
7
8
[root@linux-node3 ~]# yum install -y redis
[root@linux-node3 ~]# vim /etc/redis.conf
bind 192.168.200.107
[root@linux-node3 ~]# systemctl enable redis
[root@linux-node3 ~]# systemctl start redis
[root@linux-node3 ~]# yum install -y salt-master
[root@linux-node3 ~]# systemctl start salt-master
[root@linux-node3 ~]# systemctl enable salt-master
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
[root@linux-node5 ~]# grep -vE "^$|^#" /etc/salt/minion
master: 192.168.200.107
id: 192.168.200.115
[root@linux-node5 ~]# systemctl enable salt-minion
[root@linux-node5 ~]# systemctl start salt-minion


[root@linux-node3 ~]# salt-key -L
Accepted Keys:
Denied Keys:
Unaccepted Keys:
192.168.200.106
192.168.200.115
192.168.200.117
Rejected Keys:
[root@linux-node3 ~]# salt-key -A -y
The following keys are going to be accepted:
Unaccepted Keys:
192.168.200.106
192.168.200.115
192.168.200.117
Key for minion 192.168.200.106 accepted.
Key for minion 192.168.200.115 accepted.
Key for minion 192.168.200.117 accepted.
[root@linux-node3 ~]# salt-key -L
Accepted Keys:
192.168.200.106
192.168.200.115
192.168.200.117
Denied Keys:
Unaccepted Keys:
Rejected Keys:

[root@linux-node3 haproxy]# salt -L '192.168.200.115,192.168.200.117' cp.get_file salt://haproxy/docker_nginx_manage.py /usr/local/bin/docker_nginx_manage.py
192.168.200.117:
/usr/local/bin/docker_nginx_manage.py
192.168.200.115:
/usr/local/bin/docker_nginx_manage.py
[root@linux-node3 haproxy]# salt '*' saltutil.refresh_pillar
192.168.200.117:
True
192.168.200.115:
True
192.168.200.106:
True

115
117
yum remove -y docker docker-common docker-selinux docker-engine
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum-config-manager --enable docker-ce-edge
yum-config-manager --enable docker-ce-test
yum list docker-ce --showduplicates | sort -r |grep stable
yum install -y docker-ce-17.06.2.ce
systemctl start docker
systemctl enable docker

mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://k9lgui7f.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker


# yum install -y haproxy
# systemctl enable haproxy
# systemctl start haproxy
[root@linux-node3 ~]# salt '*' cmd.run 'yum install -y python-pip && pip install redis docker'

docker_nginx_manage.py

======================================================
希望各位朋友支持一下

本文作者:dongsheng
本文地址https://mds1455975151.github.io/archives/f3d3f3f5.html
版权声明:转载请注明出处!

坚持技术分享,您的支持将鼓励我继续创作!