Linux安装ElasticSearch7.5.1,开启xpack

385 阅读1分钟

1.安装

1.1 上传安装文件到服务器上并解压安装包

1.2 创建es用户(es不能以root用户启动)

adduser esuser

# 更新密码
passwd esuser

1.3 授权

chown -R esuser:esuser elasticsearch-7.5.1

image.png

1.4 编辑conf文件

vim elasticsearch.yml

image.png

  • 在最后面写入以下信息
#配置es的集群名称,默认是elasticsearch,es会自动发现在同一网段下的es,如果在同一网段下有多个集群,就可以用这个属性来区分不同的集群。
cluster.name: cluster
#节点名称
node.name: node-1
#设置索引数据的存储路径
path.data: /home/soft/elasticsearch/data
#设置日志的存储路径
path.logs: /home/soft/elasticsearch/logs
#设置当前的ip地址,通过指定相同网段的其他节点会加入该集群中
network.host: 0.0.0.0
#设置对外服务的http端口
http.port: 9200
#设置节点之间交互的端口号
#transport.tcp.port: 9300
#设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点
#discovery.seed_hosts: ["http://127.0.0.1:9300"]
cluster.initial_master_nodes: ["node-1"]


# 开启xpack
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.license.self_generated.type: basic
http.cors.enabled: true
http.cors.allow-origin: "*"

1.5 # 修改/etc/security/limits.conf

vim /etc/security/limits.conf 
  • 最后面写入以下内容
* soft nofile 65536
* hard nofile 65536

1.6 修改/etc/sysctl.conf

vim /etc/sysctl.conf
  • 最后面写入以下内容
vm.max_map_count=655360
  • 执行sysctl -p
sysctl -p

1.6 启动

  • 切换到esuser用户
su esuser
  • 执行运行命令
./bin/elasticsearch -d

1.7 开启xpack

./bin/elasticsearch-setup-passwords interactive
  • 按照提示输入密码

1.7 验证

curl --basic -u elastic:上一步输入的密码 localhost:9200

image.png