在chroot環境下將MySQL日誌輸出到syslog

來源:互聯網
上載者:User

標籤:mysql   syslog   chroot   

好久沒寫部落格了,這幾個月一直在學習nodejs,angularjs,做一些前端開發,目前還是學習階段,等有一些體會再來分享。

這兩天碰到的一個問題是,我們的產品給客戶後,客戶要統一管理日誌,MySQL要將日誌輸出到syslog,就需要在my.cnf的[mysqld_safe]段配置syslog。但是修改了以後探索服務啟動失敗,而且沒有日誌,經過幾番調查,還需要做如下的事情:

1. chroot MySQL的時候需要將/bin/logger拷貝到chroot jail中,因為logger是syslog的shell介面,沒有logger可執行檔,就調用不了syslog

2. 通常情況下,logger做的事情是將日誌發送到/dev/log這個socket上,但是在chroot環境下,jail裡面是訪問不到外面的檔案的,所以要在chroot jail中配置log socket檔案,方法是修改/etc/sysconfig/syslog,將SYSLOGD_OPTIONS改為

SYSLOGD_OPTIONS="-m 0 -a /var/chroot/mysql/dev/log"

男人(man)是這樣說的:

 -a socket
              Using  this argument you can specify additional sockets from that syslogd has to listen to.  This is needed if you’re going to let some
              daemon run within a chroot() environment.  You can use up to 19 additional sockets.  


好了,重啟syslog,MySQL的日誌預設就輸出到/var/log/daemon.log檔案中了,同時可以看到在/var/chroot/mysql/dev目錄下有了log socket檔案。

以上,在CentOS 5.9中測試通過

在chroot環境下將MySQL日誌輸出到syslog

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.