7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

fluentd(td-agent)をrootで起動させる方法

Last updated at Posted at 2019-01-30

はじめに

td-agentでnginxのログを収集しようと思って設定したけど、うまく動いてくれない。
/var/log/td-agent/td-agent.log に Permission denied のエラーを吐く。
td-agentの実行ユーザーは初期設定でtd-agentのため、rootしかアクセスできないnginxなどのログを収集するにはrootで起動させなければならないことに気がつく。
その時の手順をメモ。

環境

Ubuntu 18.04.1 LTS (Bionic Beaver)

手順

設定ファイルの確認

sudo systemctl status td-agent.service

Loadedのところ

● td-agent.service - td-agent: Fluentd based data collector for Treasure Data
   Loaded: loaded (/lib/systemd/system/td-agent.service; enabled; vendor preset:
   Active: active (running) since Wed 2019-01-30 23:05:17 JST; 7min ago
     Docs: https://docs.treasuredata.com/articles/td-agent
 Main PID: 950 (fluentd)
    Tasks: 12 (limit: 4662)
   CGroup: /system.slice/td-agent.service
           ├─950 /opt/td-agent/embedded/bin/ruby /opt/td-agent/embedded/bin/flue
           └─969 /opt/td-agent/embedded/bin/ruby -Eascii-8bit:ascii-8bit /opt/td

/usr/lib/systemd/system/td-agent.service が読み込まれているっぽい。
早速開いて編集。


変更前
[Service]
User=td-agent
Group=td-agent


変更後
[Service]
User=root
Group=root

サービスを再起動

sudo systemctl restart td-agent.service

rootで起動した

root       950     1  0 23:05 ?        00:00:00 /opt/td-agent/embedded/bin/ruby /opt/td-agent/embedded/bin/fluentd --log /var/log/td-agent/td-agent.log --daemon /var/run/td-agent/td-agent.pid
root       969   950  0 23:05 ?        00:00:01 /opt/td-agent/embedded/bin/ruby -Eascii-8bit:ascii-8bit /opt/td-agent/embedded/bin/fluentd --log /var/log/td-agent/td-agent.log --daemon /var/run/td-agent/td-agent.pid --under-supervisor
7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?