Elasticsearch安装及配置

1、 Elasticsearch安装及配置
1.1 解压elasticsearch-7.17.9-linux-x86_64.tar.gz

 tar -xvf elasticsearch-7.17.9-linux-x86_64.tar.gz
 mv elasticsearch-7.17.9 /opt/

1.2 创建es用户
创建es用户并设置密码

 groupadd es
 useradd -g es -G es-m es
 passwd es

1.3 给安装目录赋权

 chown -R es:es /opt/elasticsearch-7.17.9/

1.4 修改ES配置文件
1.4.1 备份并修改ES的核心配置文件

 cp /opt/elasticsearch-7.17.9/config/elasticsearch.yml  /opt/elasticsearch-7.17.9/config/elasticsearch.yml.bak
 vim /opt/elasticsearch-7.17.9/config/elasticsearch.yml

文件末尾添加以下几行

cluster.name: elasticsearch
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
cluster.initial_master_nodes: ["node-1"]

1.4.2 备份并修改内存参数配置(根据服务器实际配置调试)

 cp /opt/elasticsearch-7.17.9/config/jvm.options /opt/elasticsearch-7.17.9/config/jvm.options.bak
 vim /opt/elasticsearch-7.17.9/config/jvm.options

在这里插入图片描述

1.5 修改系统配置文件
1.5.1 修改/etc/security/limits.conf

 vim /etc/security/limits.conf

每个进程可以打开的文件数限制

es soft nofile 65536
es hard nofile 65536

1.5.2 修改/etc/security/limits.d/20-nproc.conf

 vim /etc/security/limits.d/20-nproc.conf

每个进程可以打开的文件数限制

es soft nofile 65536
es hard nofile 65536

操作系统级别对每个用户创建的进程数的限制

* hard nproc 4096

1.5.3 修改/etc/sysctl.conf

 vim /etc/sysctl.conf

一个进程可以拥有的虚拟内存区域的数量

vm.max_map_count=655360
sysctl -p

1.5.4 使用下面命令使/etc/sytsctl.conf生效

sysctl -p

1.6 添加环境变量
1.6.1 添加jdk环境变量
添加环境变量

vim /etc/profile
 JDK1.8
export JAVA_HOME=/usr/java/jdk1.8
export JRE_HOME=/usr/java/jdk1.8/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export ES_JAVA_HOME=/opt/elasticsearch-7.17.9/bin/jdk
source /etc/profile

1.7 启动es
1.7.1 切换es用户启动es
切换用户

su es

切换到bin目录

cd /opt/elasticsearch-7.17.9/bin

启动命令,加上-d为后台启动

./elasticsearch -d

1.7.2 启动成功后通过浏览器访问http://192.168.3.230:9200查看,出现以下内容为启动成功
在这里插入图片描述

1.8 配置Elasticsearch的用户名密码
1.8.1 编辑配置文件

 vim /opt/elasticsearch7.17.9/config/elasticsearch.yml

添加以下信息

http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true

1.8.2 关闭es
查看进程

ps -ef|grep elastic

杀死进程

kill -9 id

重新启动

 cd /opt/elasticsearch-7.17.9/bin
 ./elasticsearch -d

2、 运行命令修改密码

 /opt/elasticsearch-7.17.9/bin/elasticsearch-setup-passwords interactive

3、重新用浏览器访问es,弹出以下窗口即为成功,默认用户是elastic
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

即将拥有人鱼线~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值