這篇文章主要介紹了centos7中如何配置keepalived日志為別的路徑,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
創(chuàng)新互聯(lián)建站堅持“要么做到,要么別承諾”的工作理念,服務領(lǐng)域包括:做網(wǎng)站、網(wǎng)站建設、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣等服務,滿足客戶于互聯(lián)網(wǎng)時代的華坪網(wǎng)站設計、移動媒體設計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡建設合作伙伴!
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
由于在默認狀態(tài)下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調(diào)用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,即啟動方式是帶環(huán)境變量文件中參數(shù)來啟動;
3.2 讀取環(huán)境變量參數(shù)EnvironmentFile=/etc/sysconfig/keepalived。
4. $KEEPALIVED_OPTIONS參數(shù)是在/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日志為別的路徑”這篇文章對大家有幫助,同時也希望大家多多支持創(chuàng)新互聯(lián),關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關(guān)知識等著你來學習!
分享題目:centos7中如何配置keepalived日志為別的路徑
URL分享:http://jinyejixie.com/article22/pdcgcc.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導航、服務器托管、電子商務、、Google、手機網(wǎng)站建設
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)