跳转至

Elasticsearch配置

JDK与ES安装后,启动命令

Bash
1
2
3
systemctl daemon-reload
systemctl enable elasticsearch.service
systemctl start elasticsearch.service

由于目前单节点部署,简单配置即可

配置ES内存大小

Bash
1
2
3
4
root@pts/0 # vim /etc/elasticsearch/jvm.options
# 堆内存大小,Xms与 Xmx的大小相同,建议系统内存50%,但是不要超过32G
-Xms4g
-Xmx4g

修改配置文件

Bash
root@pts/0 # vim /etc/elasticsearch/elasticsearch.yml
# 集群名称
cluster.name: es-log
# 节点名称
node.name: node-57
# 数据存放路径,建议分开,rpm默认就好
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
# 设置绑定主机IP
network.host: 0.0.0.0
# http访问端口
http.port: 9200
# 集群节点发现
discovery.seed_hosts: ["172.26.32.57"]
# 提供群集中符合主节点条件的节点的列表
cluster.initial_master_nodes: ["172.26.32.57"]
# 启用基本 X-Pack 功能:basic
xpack.license.self_generated.type: basic
# 启用安全功能
xpack.security.enabled: True
# 用于启用或禁用TLS/SSL协议,启用安全功能就必须启TLS/SSL
xpack.security.transport.ssl.enabled: true

重启服务才可以设置密码

systemctl restart elasticsearch

初始化密码

Bash
root@pts/0 # /usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive
Enter password: xxxxxxxx

内置默认用户

Bash
1
2
3
4
5
6
elastic:内置超级用户
kibana:仅可用于kibana用来连接elasticsearch并与之通信, 不能用于kibana登录
logstash_system:用于Logstash在Elasticsearch中存储监控信息时使用
apm_system:
beats_system:
remote_monitoring_user:

验证服务启动

Bash
root@pts/0 # curl -s "http://elastic:xxxxxxxx@127.0.0.1:9200"
{
  "name" : "node-57",
  "cluster_name" : "es-log",
  "cluster_uuid" : "GaPrqyCxSjilYLXLiEVv6A",
  "version" : {
    "number" : "7.6.1",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "aa751e09be0a5072e8570670309b1f12348f023b",
    "build_date" : "2020-02-29T00:15:25.529771Z",
    "build_snapshot" : false,
    "lucene_version" : "8.4.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}