CentOS7添加logstash5启动脚本
默认情况使用rpm包安装完logstash之后没有启动脚本,这一点我觉得算是开发不够彻底。官网给了一个脚本,需要根据不同的系统版本生成对应的启动脚本,而且官网没有给明使用方法,对于新用户来说算是个坑,不过在终端可以查看到脚本的使用帮助。
我的系统是CentOS7,这里说一下7的使用方法,6类似,具体方法如下:
[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。
2、执行脚本生成启动文件
[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
3、执行完就可以使用systemctl启动logstash了
[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...