2
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.

Ubuntu 16.04.3 LTSにtd-agent3(Fluentd v1.0)をインストールする。2018-03-01

Posted at

内容

Installing Fluentd Using deb Packageに従い、td-agent3Fluentd v1.0)を Ubuntu 16.04 にインストールします。

td-agentFluentd)の詳細については割愛します。

Step. 1 aptリポジトリからインストール

下記コマンドを実行するのみです。

$ curl -L https://toolbelt.treasuredata.com/sh/install-ubuntu-xenial-td-agent3.sh | sh

Step. 2 デーモンの起動と確認

起動

$ sudo systemctl start td-agent.service

確認

$ sudo systemctl status td-agent.service
● td-agent.service - td-agent: Fluentd based data collector for Treasure Data
   Loaded: loaded (/lib/systemd/system/td-agent.service; disabled; vendor preset: enabled)
   Active: active (running) since Thu 2018-03-01 07:58:20 UTC; 16s ago
     Docs: https://docs.treasuredata.com/articles/td-agent
  Process: 3068 ExecStart=/opt/td-agent/embedded/bin/fluentd --log /var/log/td-agent/td-agent.log --daemon /var/run/td
 Main PID: 3074 (fluentd)
    Tasks: 11
   Memory: 81.7M
      CPU: 746ms
   CGroup: /system.slice/td-agent.service
           ├─3074 /opt/td-agent/embedded/bin/ruby /opt/td-agent/embedded/bin/fluentd --log /var/log/td-agent/td-agent.
           └─3079 /opt/td-agent/embedded/bin/ruby -Eascii-8bit:ascii-8bit /opt/td-agent/embedded/bin/fluentd --log /va

Mar 01 07:58:20 ubuntu-xenial systemd[1]: Starting td-agent: Fluentd based data collector for Treasure Data...
Mar 01 07:58:20 ubuntu-xenial systemd[1]: Started td-agent: Fluentd based data collector for Treasure Data.

停止

$ sudo systemctl stop td-agent.service

### 確認
$ sudo systemctl status td-agent.service
● td-agent.service - td-agent: Fluentd based data collector for Treasure Data
   Loaded: loaded (/lib/systemd/system/td-agent.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: https://docs.treasuredata.com/articles/td-agent

Mar 01 07:58:20 ubuntu-xenial systemd[1]: Starting td-agent: Fluentd based data collector for Treasure Data...
Mar 01 07:58:20 ubuntu-xenial systemd[1]: Started td-agent: Fluentd based data collector for Treasure Data.
Mar 01 07:59:33 ubuntu-xenial systemd[1]: Stopping td-agent: Fluentd based data collector for Treasure Data...
Mar 01 07:59:35 ubuntu-xenial systemd[1]: Stopped td-agent: Fluentd based data collector for Treasure Data.

Step. 3 試しにログを送ってみる

$ sudo systemctl start td-agent.service
$ sudo lsof -i:8888
COMMAND  PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
fluentd 3172 td-agent   15u  IPv4  57494      0t0  TCP *:8888 (LISTEN)
ruby    3177 td-agent   15u  IPv4  57494      0t0  TCP *:8888 (LISTEN)

8888 で待っているのでそこに送ってみます。
送ったログは /var/log/td-agent/td-agent.log に書き出されます。

# 送る前のログを確認
$ tail -3 /var/log/td-agent/td-agent.log
2018-03-01 08:04:49 +0000 [info]: #0 [input_debug_agent] listening dRuby uri="druby://127.0.0.1:24230" object="Fluent::Engine"
2018-03-01 08:04:49 +0000 [info]: #0 [input_forward] listening port port=24224 bind="0.0.0.0"
2018-03-01 08:04:49 +0000 [info]: #0 fluentd worker is now running worker=0

# 送る
$ curl -X POST -d 'json={"json":"message"}' http://localhost:8888/debug.test

# ログ確認
$ tail -3 /var/log/td-agent/td-agent.log
2018-03-01 08:04:49 +0000 [info]: #0 [input_forward] listening port port=24224 bind="0.0.0.0"
2018-03-01 08:04:49 +0000 [info]: #0 fluentd worker is now running worker=0
2018-03-01 08:05:18.574655177 +0000 debug.test: {"json":"message"}

# もう一回送る
$ curl -X POST -d 'json={"json":"message2"}' http://localhost:8888/debug.test

# ログ確認
$ tail -3 /var/log/td-agent/td-agent.log
2018-03-01 08:04:49 +0000 [info]: #0 fluentd worker is now running worker=0
2018-03-01 08:05:18.574655177 +0000 debug.test: {"json":"message"}
2018-03-01 08:05:25.402478042 +0000 debug.test: {"json":"message2"}

curl で送った内容が /var/log/td-agent/td-agent.lo に出力されているのが確認できました。

まとめ

Installing Fluentd Using deb Packageに従い、td-agent3Fluentd v1.0)を Ubuntu 16.04 にインストールしました。

2
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
2
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?