ES 7.4.1 和logstash7.4.1 组合搭建mysql数据同步

mac2024-06-26  48

1.服务器环境介质

服务器java系统Linuxjava version "1.8.0_201"  Centos 6.5

2.下载 ES 7.4.1 logstash 7.4.1

//通过tar 或者 unzip 解压安装 tar -axvf unzip

3.启动报错解决记录

ES启动报错

1.用root 用户启动会报错

创建非root用户用于启动ES

//创建用户 adduse esStart //设置密码 passwd esStart

 

2.用esStart用户启动仍然会报错

2.3配置其运行环境

1、切换到root用户,编辑limits.conf 添加类似如下内容

vi /etc/security/limits.conf 

添加如下内容:

* soft nofile 65536

* hard nofile 131072

* soft nproc 2048

* hard nproc 4096

2、切换到root用户,进入limits.d目录下修改配置文件。

vi /etc/security/limits.d/90-nproc.conf 

修改如下内容:

* soft nproc 1024

#修改为

* soft nproc 2048

3、切换到root用户修改配置sysctl.conf

vi /etc/sysctl.conf 

添加下面配置:

vm.max_map_count=655360

并执行命令:

sysctl -p

 

3.启动异常:

ERROR: bootstrap checks failed system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk

 

问题原因:因为Centos6不支持SecComp,而ES5.2.1默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。详见 :https://github.com/elastic/elasticsearch/issues/22899

 

解决方法:在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面: bootstrap.memory_lock: false bootstrap.system_call_filter: false

3.ES中的请自行创建和数据库对应的index和type

 

4.将mysql中的数据同步到ES中

logstash 同步数据命令

cd /home/logstash/logstash-7.4.1/bin ./logstash -f logstash-mysql.conf

配置文件logstash-mysql.conf

input { jdbc { jdbc_driver_library => "/home/logstash/logstash-7.4.1/logstash-core/lib/jars/mysql-connector-java-5.1.44-bin.jar" jdbc_driver_class => "com.mysql.jdbc.Driver" jdbc_connection_string => "jdbc:mysql://127.0.0.1:3306/trsgank?characterEncoding=UTF-8&useSSL=false&autoReconnect=true" jdbc_user => "nihao" jdbc_password => "nihao123" statement => "SELECT * FROM TRSGANK_BOOKMARK" jdbc_paging_enabled => "true" jdbc_page_size => "1000" schedule => "* * * * *" } } output { elasticsearch { hosts => ["127.0.0.1"] index => "gank" document_type => "bookmark" document_id => "%{id}" user => "gank" password => "gank2018" } stdout { codec => rubydebug } }

Logstash 利用mysql同步数据是会报错

错误信息:jdbc_driver_library 不存在

解决办法

需要将驱动移动到/logstash-7.4.1/logstash-core/lib/jars/ 目录下

 

最新回复(0)