I installed td-agent on amazon linux2 and tried to collect apache log files, but I couldn't because of a permission problem.
I can find a solution if I run the td-agent daemon with init.d, but which configuration file do I need to change if I run it with systemd?
Environment
1 Install apache and td-agent as an answer
#ansable/playbook.yml
# install apache
- name —install httpd(apache)
become:yes
yum:
name —httpd
state —present
# install td-agent
- name —install td-agent
raw: "curl-L https://toolbelt.treasuredata.com/sh/install-amazon2- td-agent3.sh | sh"
- name —Upload etc/td-agent/td-agent.conf
become:yes
copy: src=../etc/td-agent/td-agent.conf
dest=/etc/td-agent/td-agent.conf
directory_mode=yes
--
#/etc/td-agent/td-agent.conf
<source>
type tail
format apache
path/var/log/httpd/access_log
tag apache.access_log
pos_file/var/log/td-agent/access_log.pos
</source>
<source>
type tail
format apache
path/var/log/httpd/error_log
tag apache.error_log
pos_file/var/log/td-agent/error_log.pos
</source>
<match apache.**>
type forward
<server>
name jobq01
host52.68.22.100
port24224
</server>
</match>
Launch Apache
$sudo systemctl start httpd
Verify apache is started by accessing vagrant ip in chrome
Verify that td-agent is started
--
$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 (/usr/lib/systemd/system/td-agent.service; disabled; vendor preset: disabled)
Active: active(running) since month 2018-08-0605:24:22 UTC; 1min1sago
Docs: https://docs.treasuredata.com/articles/td-agent
Process: 5532 ExecStart=/opt/td-agent/embedded/bin/fluentd --log/var/log/td-agent/td-agent.log -- daemon/var/run/td-agent/td-agent.pid$TD_AGENT_OPTIONS (code=exited, status=0/SUCC)
Main PID: 5537 (fluentd)
CGgroup: /system.slice/td-agent.service
--5537/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
August 06 05:24:21 localhost systemd[1]: Starting td-agent: Fluentd based data collector for Treasure Data...
August 06 05:24:22 localhost systemd[1]: Started td-agent: Fluentd based data collector for Treasure Data.
/lib/systemd/system/td-agent.service
The user and group in the above file were set to root and resolved.
Reference
https://qiita.com/comefigo/items/faf6983dbc405791c070
© 2024 OneMinuteCode. All rights reserved.