主頁 > 知識(shí)庫 > 詳解centos7中配置keepalived日志為別的路徑

詳解centos7中配置keepalived日志為別的路徑

熱門標(biāo)簽:哈爾濱400電話去哪辦理 廣東如何申請(qǐng)400電話 寧波400電話辦理對(duì)企業(yè)的意義 西柏坡地圖標(biāo)注 燃?xì)夤芫€地圖標(biāo)注顏色 北京人工外呼系統(tǒng)廠家 話術(shù)外呼系統(tǒng) i智能電話機(jī)器人yeta 400電話申請(qǐ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

由于在默認(rèn)狀態(tài)下keepalived的日志會(huì)寫入到/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使用。因?yàn)閏entos 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去啟動(dòng);

2. 啟動(dòng)keepalived的時(shí)候,會(huì)去讀service的配置文件:/lib/systemd/system/keepalived.service;

3. 在service的配置文件時(shí):

3.1 啟動(dòng)文件路徑ExecStart=/sbin/keepalived $KEEPALIVED_OPTIONS,即啟動(dòng)方式是帶環(huán)境變量文件中參數(shù)來啟動(dòng);

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了。

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

標(biāo)簽:湘潭 阜陽 張家口 珠海 襄陽 巴中 開封 西藏

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《詳解centos7中配置keepalived日志為別的路徑》,本文關(guān)鍵詞  詳解,centos7,中,配置,keepalived,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《詳解centos7中配置keepalived日志為別的路徑》相關(guān)的同類信息!
  • 本頁收集關(guān)于詳解centos7中配置keepalived日志為別的路徑的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章