- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

CentOS に 7.2.3 の Splunk Forwarder をインストールし、以下のマニュアルに記載された手順をもとに fowarder を systemd のサービスとして登録しました。
https://docs.splunk.com/Documentation/Splunk/7.2.3/Admin/RunSplunkassystemdservice
但し、"systemctl stop Splunkd.service" で forwarder を停止しようとしたときに、splunkのプロセスが強制終了されているように見えます。
強制終了ではなく、"./splunk stop"のように終了する方法はありますでしょうか。
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

splunkd プロセスが強制終了される理由としては、systemd が SIGTERM シグナルを送っているためです。
SIGTERM を SIGINT に変更することで強制終了の問題を回避することができます。
なお、splunk の unit ファイルに「KillMode=mixed」および「KillSignal=SIGINT」を追加することで、SIGTERM から SIGINT に変更できます。
# cat /etc/systemd/system/Splunkd.service
#This unit file replaces the traditional start-up script for systemd
#configurations, and is used when enabling boot-start for Splunk on
#systemd-based Linux distributions.
[Unit]
Description=Systemd service file for Splunk, generated by 'splunk enable boot-start'
After=network.target
[Service]
Type=simple
Restart=always
ExecStart=/home/splunk/723_so/splunk/bin/splunk _internal_launch_under_systemd
LimitNOFILE=65536
SuccessExitStatus=51 52
RestartPreventExitStatus=51
RestartForceExitStatus=52
User=splunk
Delegate=true
MemoryLimit=100G
CPUShares=1024
PermissionsStartOnly=true
ExecStartPost=/bin/bash -c "chown -R splunk:splunk /sys/fs/cgroup/cpu/system.slice/%n"
ExecStartPost=/bin/bash -c "chown -R splunk:splunk /sys/fs/cgroup/memory/system.slice/%n"
KillMode=mixed
KillSignal=SIGINT
[Install]
WantedBy=multi-user.target
また、splunk がシャットダウンに時間がかかる場合でも、強制終了される可能性がありますので、その際には、unitファイルに「TimeoutStopSec」を追加し、timeoutの時間を増やしてください。
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Summary of the issue:
Splunk 6.0.0 - Splunk 7.2.1 defaults to using init.d when enabling boot start
Splunk 7.2.2 - Splunk 7.2.9 defaults to using systemd when enabling boot start
Splunk 7.3.0 - Splunk 8.x defaults to using init.d when enabling boot start
systemd defaults to prompting for root credentials upon stop/start/restart of Splunk
Here is a simple fix if you have encountered this issue and prefer to use the traditional init.d scripts vs systemd.
Splunk Enterprise/Heavy Forwarder example (note: replace the splunk user below with the account you run splunk as):
sudo /opt/splunk/bin/splunk disable boot-start
sudo /opt/splunk/bin/splunk enable boot-start -user splunk -systemd-managed 0
Splunk Universal Forwarder example (note: replace the splunk user below with the account you run splunk as):
sudo /opt/splunkforwarder/bin/splunk disable boot-start
sudo /opt/splunkforwarder/bin/splunk enable boot-start -user splunk -systemd-managed 0
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

splunkd プロセスが強制終了される理由としては、systemd が SIGTERM シグナルを送っているためです。
SIGTERM を SIGINT に変更することで強制終了の問題を回避することができます。
なお、splunk の unit ファイルに「KillMode=mixed」および「KillSignal=SIGINT」を追加することで、SIGTERM から SIGINT に変更できます。
# cat /etc/systemd/system/Splunkd.service
#This unit file replaces the traditional start-up script for systemd
#configurations, and is used when enabling boot-start for Splunk on
#systemd-based Linux distributions.
[Unit]
Description=Systemd service file for Splunk, generated by 'splunk enable boot-start'
After=network.target
[Service]
Type=simple
Restart=always
ExecStart=/home/splunk/723_so/splunk/bin/splunk _internal_launch_under_systemd
LimitNOFILE=65536
SuccessExitStatus=51 52
RestartPreventExitStatus=51
RestartForceExitStatus=52
User=splunk
Delegate=true
MemoryLimit=100G
CPUShares=1024
PermissionsStartOnly=true
ExecStartPost=/bin/bash -c "chown -R splunk:splunk /sys/fs/cgroup/cpu/system.slice/%n"
ExecStartPost=/bin/bash -c "chown -R splunk:splunk /sys/fs/cgroup/memory/system.slice/%n"
KillMode=mixed
KillSignal=SIGINT
[Install]
WantedBy=multi-user.target
また、splunk がシャットダウンに時間がかかる場合でも、強制終了される可能性がありますので、その際には、unitファイルに「TimeoutStopSec」を追加し、timeoutの時間を増やしてください。
