啓動haproxythis
/usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfgspa
啓動keepalivedrest
配置文件必須是絕對路徑日誌
/usr/local/keepalived/sbin/keepalived -D -f /usr/local/keepalived/etc/keepalived/keepalived.conf orm
/usr/local/keepalived/sbin/keepalived -d -D -S 0 -f /usr/local/keepalived/etc/keepalived/keepalived.confip
首先查看keepalived命令的參數,-S指定syslog的facility。ci
1. /usr/local/keepalived/sbin/keepalived --vrrp -P Only run with VRRP subsystem. rem
2. /usr/local/keepalived/sbin/keepalived --check -C Only run with Health-checker subsystem. get
3. /usr/local/keepalived/sbin/keepalived --dont-release-vrrp -V Dont remove VRRP VIPs & VROUTEs on daemon stop. it
4. /usr/local/keepalived/sbin/keepalived --dont-release-ipvs -I Dont remove IPVS topology on daemon stop.
5. /usr/local/keepalived/sbin/keepalived --dont-fork -n Dont fork the daemon process.
6. /usr/local/keepalived/sbin/keepalived --use-file -f Use the specified configuration file.
7. Default is /etc/keepalived/keepalived.conf.
8. /usr/local/keepalived/sbin/keepalived --dump-conf -d Dump the configuration data.
9. /usr/local/keepalived/sbin/keepalived --log-console -l Log message to local console.
10. /usr/local/keepalived/sbin/keepalived --log-detail -D Detailed log messages.
11. /usr/local/keepalived/sbin/keepalived --log-facility -S 0-7 Set syslog facility to LOG_LOCAL[0-7]. (default=LOG_DAEMON)
12. /usr/local/keepalived/sbin/keepalived --help -h Display this short inlined help screen.
13. /usr/local/keepalived/sbin/keepalived --version -v Display the version number
14. /usr/local/keepalived/sbin/keepalived --pid -p pidfile
15. /usr/local/keepalived/sbin/keepalived --checkers_pid -c checkers pidfile
16. /usr/local/keepalived/sbin/keepalived --vrrp_pid -r vrrp pidfile
而後經過以下命令啓動keepalived,
1. [root@LVS02 ~]# /usr/local/keepalived/sbin/keepalived -d -D -S 0
或者修改/etc/sysconfig/keepalived,而後用service來啓動。
1. [root@LVS02 ~]# cat /etc/sysconfig/keepalived
2. # Options for keepalived. See `keepalived --help' output and keepalived(8) and
3. # keepalived.conf(5) man pages for a list of all options. Here are the most
4. # common ones :
5. #
6. # --vrrp -P Only run with VRRP subsystem.
7. # --check -C Only run with Health-checker subsystem.
8. # --dont-release-vrrp -V Dont remove VRRP VIPs & VROUTEs on daemon stop.
9. # --dont-release-ipvs -I Dont remove IPVS topology on daemon stop.
10. # --dump-conf -d Dump the configuration data.
11. # --log-detail -D Detailed log messages.
12. # --log-facility -S 0-7 Set local syslog facility (default=LOG_DAEMON)
13. #
14.
15. KEEPALIVED_OPTIONS="-D -d -S 0"
16.
17. [root@LVS02 ~]# service keepalived start
指定日誌輸出
最後設置syslog,修改/etc/syslog.conf.
1. root@LVS02 ~]# cat /etc/syslog.conf
2. # Log all kernel messages to the console.
3. # Logging much else clutters up the screen.
4. #kern.* /dev/console
5.
6. # Log anything (except mail) of level info or higher.
7. # Don't log private authentication messages!
8. *.info;mail.none;authpriv.none;cron.none /var/log/messages
9.
10. # The authpriv file has restricted access.
11. authpriv.* /var/log/secure
12.
13. # Log all the mail messages in one place.
14. mail.* -/var/log/maillog
15.
16.
17. # Log cron stuff
18. cron.* /var/log/cron
19.
20. # Everybody gets emergency messages
21. *.emerg *
22.
23. # Save news errors of level crit and higher in a special file.
24. uucp,news.crit /var/log/spooler
25.
26. # Save boot messages also to boot.log
27. local7.* /var/log/boot.log
28.
29. # keepalived -S 0
30. local0.* /var/log/keepalived.log