ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
1)软件下载 [admin@master files]$ pwd /srv/salt/prod/keepalived/files [admin@master files]$ sudo wget http://www.keepalived.org/software/keepalived-1.4.0.tar.gz --2018-01-29 18:00:05-- http://www.keepalived.org/software/keepalived-1.4.0.tar.gz Resolving www.keepalived.org (www.keepalived.org)... 37.59.63.157, 2001:41d0:8:7a9d::1 Connecting to www.keepalived.org (www.keepalived.org)|37.59.63.157|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 731936 (715K) [application/x-gzip] Saving to: ‘keepalived-1.4.0.tar.gz’ 100%[==============================================>] 731,936 735KB/s in 1.0s 2018-01-29 18:00:07 (735 KB/s) - ‘keepalived-1.4.0.tar.gz’ saved [731936/731936] 一般情况找一台机器手工安装一下keepalived,然后把配置文件和启动脚本拷贝到/srv/salt/prod/keepalived/files 配置文件和启动脚本,默认在这个目录里: [admin@proxy02 etc]$ pwd /usr/local/src/keepalived-1.4.0/keepalived/etc [admin@proxy02 etc]$ ll total 64 drwxrwxr-x. 2 1000 1000 4096 Feb 3 16:56 init drwxrwxr-x. 2 1000 1000 4096 Feb 3 16:55 init.d drwxrwxr-x. 2 1000 1000 4096 Dec 11 19:16 keepalived -rw-r--r--. 1 root root 18459 Feb 3 16:55 Makefile -rw-rw-r--. 1 1000 1000 181 Dec 11 19:16 Makefile.am -rw-rw-r--. 1 1000 1000 18206 Dec 30 02:00 Makefile.in drwxrwxr-x. 2 1000 1000 4096 Dec 11 19:16 openrc drwxrwxr-x. 2 1000 1000 4096 Dec 11 19:16 sysconfig [admin@proxy02 src]$ cd /usr/local/keepalived/etc/sysconfig/ [admin@proxy02 sysconfig]$ ll total 4 -rw-r--r--. 1 root root 667 Feb 3 16:56 keepalived 2)创建目录 [admin@master ~]$ sudo mkdir /srv/salt/prod/keepalived [admin@master ~]$ sudo mkdir /srv/salt/prod/keepalived/files 总之要有下面几个文件 [admin@master files]$ ll total 728 -rw-r--r--. 1 root root 731936 Dec 30 02:02 keepalived-1.4.0.tar.gz -rw-r--r--. 1 root root 3550 Jan 29 18:22 keepalived.conf -rwxr-xr-x. 1 root root 1335 Jan 29 18:26 keepalived.init -rwxr-xr-x. 1 root root 667 Jan 29 18:36 keepalived.sysconfig 更改一下脚本: ~~~ start() { echo -n $"Starting $prog: " daemon /usr/local/keepalived/sbin/keepalived ${KEEPALIVED_OPTIONS} RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog } ~~~ 3)编写keepalived的sls文件 ~~~ include: - pkg.pkg-init Dependency_package_installation: pkg.installed: - names: - libnl-devel - libnfnetlink-devel keepalived-install: file.managed: - name: /usr/local/src/keepalived-1.4.0.tar.gz - source: salt://keepalived/files/keepalived-1.4.0.tar.gz - user: root - group: root - mode: 755 cmd.run: - name: cd /usr/local/src && sudo tar xf keepalived-1.4.0.tar.gz && cd keepalived-1.4.0 && sudo ./configure --prefix=/usr/local/keepalived && sudo make && sudo make install - unless: test -d /usr/local/keepalived - require: - pkg: pkg-init - pkg: Dependency_package_installation - file: keepalived-install keepalived-init: file.managed: - name: /etc/init.d/keepalived - source: salt://keepalived/files/keepalived.init - user: root - group: root - mode: 755 cmd.run: - name: chkconfig --add keepalived - unless: chkconfig --list|grep keepalived - require: - file: keepalived-init /etc/sysconfig/keepalived: file.managed: - source: salt://keepalived/files/keepalived.sysconfig - user: root - group: root - mode: 644 /etc/keepalived: file.directory: - user: root - group: root - mode: 755 ~~~