实验环境:在SaltStack部署完毕的前提下进行实验:
系统: redhat6
server1 172.25.45.1 salt-master keepalived
server2 172.25.45.2 salt-minion apache
server2 172.25.45.3 salt-minion nginx
server4 172.25.45.4 salt-minion keepalived
server4的yum源配置负载均衡包:
[root@server4 ~]# vim /etc/yum.repos.d/rhel-source.repo [
rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=http://172.25.45.250/rhel6.5
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[saltsack]
name=saltsack
baseurl=http://172.25.45.250/rhel6 enabled=1
gpgcheck=0
[LoadBalancer]
name=LoadBalancer
baseurl=http://172.25.45.250/rhel6.5/LoadBalancer
gpgcheck=0
一、安装keepalived(源码编译)
[root@server1 ~]# cd /srv/salt/
[root@server1 salt]# mkdir keepalived
[root@server1 salt]# cd keepalived/
[root@server1 keepalived]# mkdir files
[root@server1 keepalived]# cd files/
[root@server1 files]# mv /root/keepalived-2.0.6.tar.gz .
[root@server1 files]# ls
keepalived-2.0.6.tar.gz
[root@server1 files]# cd ..
[root@server1 keepalived]# vim install.sls
kp-install:
pkg.installed:
- pkgs:
- gcc:
- pcre-devel:
- openssl-devel
file.managed:
- name: /mnt/keepalived-2.0.6.tar.gz
- source: salt://keepalived/files/keepalived-2.0.6.tar.gz
cmd.run:
- name: cd /mnt && tar zxf keepalived-2.0.6.tar.gz && cd keepalived-2.0.6
&& ./configure --prefix&