要确保已经安装了OpenJDK,如果没有执行下面命令
yum install java-1.7.0-openjdk
1、安装
cd /home
wget -O /home/logstash-7.10.1.tar.gz https://artifacts.elastic.co/downloads/logstash/logstash-7.10.1-linux-x86_64.tar.gz
tar zxvf logstash-7.10.1.tar.gz
rm -rf logstash-7.10.1.tar.gz
mv logstash-7.10.1 logstash
mkdir /etc/logstash
mkdir /var/log/logstash
这是官网地址,可以根据自己Elaticsearch版本去找地址。
官网地址:https://www.elastic.co/cn/downloads/logstash
这是下载命令
wget https://artifacts.elastic.co/downloads/logstash/logstash-7.10.1-linux-x86_64.tar.gz
2、创建配置文件:(这个路径与下面步骤的启动脚本里是对应的)
vim /etc/logstash/index.conf
添加如下内容:
input {
file {
path => "/var/log/messages"
start_position => "beginning"
codec => plain {
charset => "GBK" }
type => "file"
}
}
output {
elasticsearch {
host => "127.0.0.1"
}
}
3、插件
cd /home/logstash
bin/plugin install contrib
4、启动文件
wget -O /etc/init.d/logstash http://update.biglog.org/logstash
chmod +x /etc/init.d/logstash
chkconfig --add logstash
chkconfig logstash on
service logstash start
5、安装logstash-input-jdbc插件
yum install gem -y
5.1 替换ruby库
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
gem sources -l
5.2 修改配置文件
cd /opt/inst/logstash622/
vi Gemfile
#修改Gemfile文件
#source "https://rubygems.org/"
source "https://gems.ruby-china.com/"
vi Gemfile.lock
#remote: https://rubygems.org/
remote: https://gems.ruby-china.com/
5.3 安装logstash-input-jdbc
到logstash的bin目录下运行下面的命令,查看可用的插件
cd bin
./logstash-plugin list --verbose
下载插件
./logstash-plugin install logstash-integration-jdbc