1. 创建普通用户
-- adduser方式为脚本方式,一行搞定
$ adduser chenbing
$ passwd chenbing
$ su chenbing
$ cd ~
$ cd ..
$ su root
$ chmod 777 -R chenbing
$ su chenbing
-- useradd方式有点繁琐
2. 下载解压
$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.16.1-linux-x86_64.tar.gz
$ wget https://artifacts.elastic.co/downloads/logstash/logstash-7.16.1-linux-x86_64.tar.gz
$ tar -zxvf elasticsearch-7.16.1-linux-x86_64.tar.gz
$ tar -zxvf logstash-7.16.1-linux-x86_64.tar.gz
3. logstash-cbb.conf配置
input {
stdin { }
jdbc {
jdbc_connection_string => "jdbc:mysql://localhost:3306/elk_test?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&useSSL=false"
jdbc_driver_library => "/home/chenbing/cbbUtil/mysql-connector-java-8.0.22.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_paging_enabled => "true"
jdbc_page_size => "50000"
jdbc_user => "root"
jdbc_password => "root"
statement => "select * from user"
schedule => "* * * * *"
tracking_column => "createdate"
tracking_column_type => "timestamp"
record_last_run => true
last_run_metadata_path => "/home/chenbing/cbbSoft/logstash-7.16.1/jdbc-result.txt"
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "user"
document_id => "%{userid}"
document_type => "_doc"
}
stdout {
codec => json_lines
}
}
4. 启动
$ /bin/elasticsearch
./bin/elasticsearch -d -p pid
$ bin/logstash -f config/logstash-cbb.conf
5. 关闭
$ jps
$ kill -9 进程号
$ ps -ef | grep elastic
$ kill -9 进程号
附录
config/elasticsearch.yml配置
cluster.name: my-application
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["0.0.0.0", "[::1]"]
cluster.initial_master_nodes: ["node-1"]
action.destructive_requires_name: true
运行报错vm.max_map_count [65530] is too low
$ vim /etc/sysctl.conf
$ /sbin/sysctl -p
办法千万种,解决最重要。
|