CentOS7添加logstash5啓動腳本

默認狀況使用rpm包安裝完logstash以後沒有啓動腳本,這一點我以爲算是開發不夠完全。官網給了一個腳本,須要根據不一樣的系統版本生成對應的啓動腳本,並且官網沒有給明使用方法,對於新用戶來講算是個坑,不過在終端能夠查看到腳本的使用幫助。java

個人系統是CentOS7,這裏說一下7的使用方法,6相似,具體方法以下:node

[root@elk-node1 ~]# cd /usr/share/logstash/bin/
[root@elk-node1 bin]# ./system-install --help
Usage: system-install [OPTIONSFILE] [STARTUPTYPE] [VERSION]

NOTE: These arguments are ordered, and co-dependent

OPTIONSFILE: Full path to a startup.options file
OPTIONSFILE is required if STARTUPTYPE is specified, but otherwise looks first
in /usr/share/logstash/config/startup.options and then /etc/logstash/startup.options
Last match wins

STARTUPTYPE: e.g. sysv, upstart, systemd, etc.
OPTIONSFILE is required to specify a STARTUPTYPE.

VERSION: The specified version of STARTUPTYPE to use.  The default is usually
preferred here, so it can safely be omitted.
Both OPTIONSFILE & STARTUPTYPE are required to specify a VERSION.

For more information, see https://github.com/jordansissel/pleaserun

a、要跟startup.options文件的絕對路徑,若是是rpm安裝的在/etc/logstash/startup.options,若是是二進制包解壓安裝的則在解壓目錄下的config目錄下面。
b、必需要跟啓動類型,好比CentOS7是systemd,CentOS7是sysv。python

二、執行腳本生成啓動文件git

[root@elk-node1 bin]# /usr/share/logstash/bin/system-install /etc/logstash/startup.options systemd
Using provided startup.options file: /etc/logstash/startup.options
Manually creating startup for specified platform: systemd
Successfully created system startup script for Logstash

三、執行完就可使用systemctl啓動logstash了  github

[root@elk-node1 bin]# systemctl enable logstash.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/logstash.service to /etc/systemd/system/logstash.service.
[root@elk-node1 bin]# systemctl start logstash.service
[root@elk-node1 bin]# systemctl status logstash.service 
● logstash.service - logstash
   Loaded: loaded (/etc/systemd/system/logstash.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2017-12-19 14:27:21 CST; 9s ago
 Main PID: 10125 (java)
   CGroup: /system.slice/logstash.service
           └─10125 /usr/bin/java -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMS...

Dec 19 14:27:21 elk-node1.example.com systemd[1]: Started logstash.
Dec 19 14:27:21 elk-node1.example.com systemd[1]: Starting logstash...
相關文章
相關標籤/搜索