安裝keepalived:
wget http://www.keepalived.org/software/keepalived-1.3.5.tar.gz tar zxf keepalived-1.3.5.tar.gz cd keepalived-1.3.5
然后怎么裝任洞,看一下./configure --help
./configure -- prefix=/usr/local/keepalived --disable-fwmark make make install
源碼包提供的啟動(dòng)腳本在/usr/local/src/keepalived-1.3.5/keepalived/etc/init.d
這個(gè)目錄下有個(gè)keepalived.init的文件蓄喇,要修改這個(gè)啟動(dòng)腳本。
還有一個(gè)模板配置文件交掏,/usr/local/src/keepalived-1.3.5/keepalived/etc/keepalived/keepalived.conf
這兩個(gè)文件我們都需要公罕,拷貝過(guò)去。
mkdir -p /srv/salt/prod/keepalived/files
cp /usr/local/src/keepalived-1.3.5/keepalived/etc/init.d/keepalived.init /srv/salt/prod/keepalived/files
cp /usr/local/src/keepalived-1.3.5/keepalived/etc/keepalived/keepalived.conf /srv/salt/prod/keepalived/files
cp /usr/local/keeplived/etc/sysconfig/keepalived /srv/salt/prod/keepalived/files/keepalived.sysconfig
修改啟動(dòng)腳本啦:
start(){
deamon /usr/local/keealived/sbin/keepalived $ {KEEPALIVED_OPTIONS}
}
配置文件改好以后就要寫安裝的腳本了耀销。
cd /srv/salt/prod/keepalived
vim install.sls
include:
- pkg.pkg-init
keepalived-install:
file.managed:
- name: /usr/local/src/keepalived-1.3.5
- sourcde: salt://keepalived/files/keepalived-1.3.5.tar.gz
- user: root
- gourp: root
- mode: 755
cmd.run:
- name: cd /usr/local/src/ && tar zxf keepalived-1.3.5.tar.gz && cd keepalived-1.3.5 && ./configure -- prefix=/usr/local/keepalived --disable-fwmark && make && make install
- unless: test -d /usr/local/keepalived
- require:
- pkg: pkg-init
- file: keepalived-install
keepalived-init:
file.managed:
- dource: salt:///keepalived/files/keeplived.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
執(zhí)行salt '*' state.sls keepalived.install env= prod