1、ElasticSearch配置
版本: elasticsearch-7.4.1(6.2或更早版本需要安装X-PACK, 新版本已包含在发行版中)
配置:elasticsearch.yml
新增以下配置:

xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true

保存后重启ES:

systemctl restart elasticsearch

查询初始密码的脚本路径:

find / -name elasticsearch-setup-passwords
/usr/share/elasticsearch/bin/elasticsearch-setup-passwords

执行初始化密码脚本:

/usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive

执行完成会提示设置密码:

Enter password for [elastic]:         #设置elastic密码
Reenter password for [elastic]:       #确认elastic密码
Enter password for [apm_system]:      #设置apm_system密码
Reenter password for [apm_system]:    #确认apm_system密码
Enter password for [kibana]:          #设置kibana密码
Reenter password for [kibana]:        #确认kibana密码
Enter password for [logstash_system]: #设置logstash_system密码
Reenter password for [logstash_system]: #确认logstash_system密码
Enter password for [beats_system]:    #设置beats_system密码
Reenter password for [beats_system]:  #确认beats_system密码
Enter password for [remote_monitoring_user]: #设置remote_monitoring_user密码
Reenter password for [remote_monitoring_user]: #确认remote_monitoring_user密码

以上内置多个用户:
elastic:内置超级用户
kibana_system:仅可用于kibana用来连接elasticsearch并与之通信, 不能用于kibana登录
logstash_system:用于Logstash在Elasticsearch中存储监控信息时使用

2、Kibana配置
在kibana.yml中配置用户名和密码

vim /etc/kibana/kibana.yml
elasticsearch.username: "kibana"
elasticsearch.password: "PASSWORD"

elasticsearch.username和elasticsearch.password默认是被注释掉的,需要取消注释填入对应的密码即可
修改完成后重启kibana:

systemctl restart kibana.service

访问kibana地址http://ip:5601打开登录页面,使用elastic账号登录,并在角色和用户管理中添加用户指定 索引用于访问ES
3、Logstash配置

3.1、在logstash.yml中配置用户名和密码:

vim /etc/logstash/logstash.yml
xpack.monitoring.enabled: true
xpack.monitoring.elasticsearch.username: logstash_system    #访问es的用户名
xpack.monitoring.elasticsearch.password: PASSWORD           #访问es的密码
xpack.monitoring.elasticsearch.hosts: ["IP:9200"]           #es的访问地址:端口

xpack.monitoring.enabled、xpack.monitoring.elasticsearch.username、xpack.monitoring.elasticsearch.password和xpack.monitoring.elasticsearch.hosts默认也是注释掉的,需要取消注释并修改访问es的password以及es的访问地址信息,其中第一个默认是false需要更改为true。

3.2、修改/etc/logstash/conf.d/下的conf文件在该文件的output中加入user => "USERNAME"和password => "PASSWORD":
cat /etc/logstash/conf.d/NEW.conf

input {
    kafka {
      bootstrap_servers => "10.0.4.15:9092"
      group_id => "logstash"
      topics => ["httpd_access"]
          codec => "json"
      add_field => {
            "logstash_type" => "httpd_access"
          }
    }
}

output {
      if [logstash_type] == "httpd_access" {
    elasticsearch {
      hosts => ["ESIP:9200"]
      index => "httpd_access"
      user => "elastic"
      password => "PASSWORD"
    }
     }
}
最后修改:2023 年 06 月 09 日
如果觉得我的文章对你有用,请随意赞赏