一、安装、配置
win11、JDK8、三个节点,启动有点费内存
ELK安装上篇文章已经介绍过,这篇主要是配置;
1、将ES复制三个,分别命名如图:
比如,node-1里是这样的, node-2、node-3都一样
2、elasticsearch配置
config文件下elasticsearch.yml文件
node-1的配置:
# 换个集群的名字,免得跟别人的集群混在一起
cluster.name: el-my
# 换个节点名字
node.name: node-1001
# 修改一下ES的监听地址,这样别的机器也可以访问
network.host: 0.0.0.0
http.host: 0.0.0.0
#设置对外服务的http端口,默认为9200
http.port: 9201
transport.port: 9301
discovery.seed_hosts: ["127.0.0.1:9301", "127.0.0.1:9302", "127.0.0.1:9303"]
cluster.initial_master_nodes: ["node-1001","node-1002","node-1003"]
# 允许通配符删除索引
action.destructive_requires_name: true
#设置索引数据的存储路径(每个节点都要有自己的data,logs,不然报错)
path.data: M:/elasticsearch-8.5.3.0/node-1001/data/data #换成自己的路径
#设置日志文件的存储路径
path.logs: M:/elasticsearch-8.5.3.0/node-1001/data/logs #换成自己的路径
# 增加新的参数,head插件可以访问es
http.cors.enabled: true
http.cors.allow-origin: "*"
# 关闭http访问限制
xpack.security.enabled: false
xpack.security.enrollment.enabled: true
node-2的配置:
# 换个集群的名字,免得跟别人的集群混在一起
cluster.name: el-my
# 换个节点名字
node.name: node-1002
# 修改一下ES的监听地址,这样别的机器也可以访问
network.host: 0.0.0.0
http.host: 0.0.0.0
#设置对外服务的http端口,默认为9200
http.port: 9202
transport.port: 9302
discovery.seed_hosts: ["127.0.0.1:9301", "127.0.0.1:9302", "127.0.0.1:9303"]
cluster.initial_master_nodes: ["node-1001","node-1002","node-1003"]
# 允许通配符删除索引
action.destructive_requires_name: true
#设置索引数据的存储路径
path.data: M:/elasticsearch-8.5.3.0/node-1002/data/data #换成自己的路径
#设置日志文件的存储路径
path.logs: M:/elasticsearch-8.5.3.0/node-1002/data/logs #换成自己的路径
# 增加新的参数,head插件可以访问es
http.cors.enabled: true
http.cors.allow-origin: "*"
# 关闭http访问限制
xpack.security.enabled: false
xpack.security.enrollment.enabled: true
node-3的配置:
# 换个集群的名字,免得跟别人的集群混在一起
cluster.name: el-my
# 换个节点名字
node.name: node-1003
# 修改一下ES的监听地址,这样别的机器也可以访问
network.host: 0.0.0.0
http.host: 0.0.0.0
#设置对外服务的http端口,默认为9200
http.port: 9203
transport.port: 9303
discovery.seed_hosts: ["127.0.0.1:9301", "127.0.0.1:9302", "127.0.0.1:9303"]
cluster.initial_master_nodes: ["node-1001","node-1002","node-1003"]
# 允许通配符删除索引
action.destructive_requires_name: true
#设置索引数据的存储路径
path.data: M:/elasticsearch-8.5.3.0/node-1003/data/data #换成自己的路径
#设置日志文件的存储路径
path.logs: M:/elasticsearch-8.5.3.0/node-1003/data/logs #换成自己的路径
# 增加新的参数,head插件可以访问es
http.cors.enabled: true
http.cors.allow-origin: "*"
# 关闭http访问限制
xpack.security.enabled: false
xpack.security.enrollment.enabled: true
3、kibana的配置
config下kibana.yml
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://127.0.0.1:9201", "http://127.0.0.1:9202", "http://127.0.0.1:9203"]
i18n.locale: "zh-CN"
4、logstach的配置
input {
stdin {
}
jdbc {
#数据库四大金刚配置
jdbc_connection_string => "jdbc:mysql://127.0.0.0:3306/test?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true"
jdbc_user => "root"
jdbc_password => "123456"
#数据库驱动路径
jdbc_driver_library => "M:/mysql/mysql-connector-java/8.0.30/mysql-connector-java-8.0.30.jar"
jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
jdbc_paging_enabled => "true"
jdbc_page_size => "50000"
#这里可以指定sql文件或直接写SQL语句
statement => "SELECT * FROM user"
#定义每分钟去刷新数据库数据
schedule => "* * * * *"
type => "context"
}
}
filter {
}
output {
elasticsearch {
#输出至ES的端口
hosts => ["http://127.0.0.1:9201", "http://127.0.0.1:9202", "http://127.0.0.1:9203"]
#输出至ES的索引
index => "aaa-*"
#设置_id自增
document_id => "%{id}"
}
stdout {
codec => json_lines
}
}