您好,登錄后才能下訂單哦!
這篇文章主要介紹了centos7中如何配置keepalived日志為別的路徑,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
keepalived 安裝:
cd <keepalived_sourcecode_path> ./configure --prefix=/usr/local/keepalived make && make install mkdir /etc/keepalived mkdir /etc/keepalived/scripts cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/ cp /root/keepalived-2.0.6/keepalived/etc/init.d/keepalived /etc/init.d/ cp /usr/local/keepalived/sbin/keepalived /sbin/keepalived cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/ chmod +x /etc/init.d/keepalived
由于在默認狀態下keepalived的日志會寫入到/var/log/message中,我們需要將此剝離出來。
在centos 6下可以:
(1)首先修改/etc/sysconfig/keepalived文件,注釋掉如下,添加如下:
#KEEPALIVED_OPTIONS="-D" KEEPALIVED_OPTIONS="-D -d -S 0"
(2)其次修改 /etc/rsyslog.conf 文件,添加如下:
local0.* /var/log/keepalived.log
在centos 7 下,還需要修改/lib/systemd/system/keepalived.service 文件:
centos 7使用。因為centos 7使用systemctl,通過systemctl調用service,所以需要修改/lib/systemd/system/keepalived.service文件。
將里面的:
EnvironmentFile=-/usr/local/keepalived/etc/sysconfig/keepalived ExecStart=/usr/local/keepalived/sbin/keepalived $KEEPALIVED_OPTIONS
修改成:
EnvironmentFile=/etc/sysconfig/keepalived ExecStart=/sbin/keepalived $KEEPALIVED_OPTIONS
然后重新加載service:
systemctl daemon-reload
整體的思路就是,
1. 通過systemctl start keepalived去啟動;
2. 啟動keepalived的時候,會去讀service的配置文件:/lib/systemd/system/keepalived.service;
3. 在service的配置文件時:
3.1 啟動文件路徑ExecStart=/sbin/keepalived $KEEPALIVED_OPTIONS,即啟動方式是帶環境變量文件中參數來啟動;
3.2 讀取環境變量參數EnvironmentFile=/etc/sysconfig/keepalived。
4. $KEEPALIVED_OPTIONS參數是在/etc/sysconfig/keepalived的配置;我們配置的是KEEPALIVED_OPTIONS="-D -d -S 0";而-S是syslog的facility,0表示放在local0,在/etc/rsyslog.conf 中配置local0.* /var/log/keepalived.log
5. 所以,寫日志就去/var/log/keepalived.log了。
感謝你能夠認真閱讀完這篇文章,希望小編分享的“centos7中如何配置keepalived日志為別的路徑”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。