Linux安装elasticsearch6.2.2教程(亲测有效)

环境: jdk1.8

一、安装

1.下载elasticsearch 安装包

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.2.tar.gz

2.创建目录用来存放es

mkdir /usr/local/es 

3.进入存放目录

cd  /usr/local/es

4.然后解压到es目录

tar -xvf elasticsearch-6.2.2.tar.gz -C /usr/local/es/

5.修改解压后的目录名称 

mv elasticsearch-6.2.2/ node-1

6.创建用户组和用户(elasticsearch不能用root用户启动)

#创建组es

groupadd es
#创建用户es 指定到elasticsearch用户组 并设置用户es的密码为es
useradd es -g es -p es
##给用户es授权可操作的目录
chown -R es:es /usr/local/es

7.创建elasticsearch 的数据存放目录data

切换用户为es

su es

创建数据存储data


mkdir /usr/local/es/node-1/data

8.编辑elasticsearch.yml文件

进入config目录

cd /usr/local/es/node-1/config/

编辑elasticsearch.yml

vim elasticsearch.yml

编辑的内容如下:

##集群名称
cluster.name: es-cluster
##节点名称
node.name: node-1
##网络监听地址
network.host: 121.36.67.130
http.port: 9200
##使用head等插件监控集群信息,需要打开以下配置项
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-credentials: true

10.修改用户可用的最大线程数配置

切换到root用户

su root

##编辑文件

vim /etc/security/limits.conf

编辑为如下内容

es       soft    nofile           65536
es       hard    nofile          65536

默认不需要添加下面配置
*        soft    nproc            2048
*        hard    nproc            4096

11.编辑 vi /etc/sysctl.conf 

 vim /etc/sysctl.conf

 编辑为如下内容

vm.max_map_count=655360

12.编辑完成后执行命令

sysctl -p

10.切换回es用户启动elasticsearch

su es

启动

cd /usr/local/es/node-1/bin
./elasticsearch

二、设置开机自启


1.创建一个新的elasticsearch服务文件。例如,创建一个名为elasticsearch.service的文件在/etc/systemd/system/目录下:

sudo vim /etc/systemd/system/elasticsearch.service

2.在elasticsearch.service文件中,添加以下内容: 

[Unit]
Description=Elasticsearch
Documentation=http://www.elastic.co
Wants=network-online.target
After=network-online.target

[Service]
User=es
Group=es
WorkingDirectory=/usr/local/es/node-1
Environment=JAVA_HOME=/usr/local/java/jdk1.8.0_191
ExecStart=/usr/local/es/node-1/bin/elasticsearch
Restart=on-failure

[Install]
WantedBy=multi-user.target

 3.重新加载Systemd以识别新的服务文件:

sudo systemctl daemon-reload

4.启动Elasticsearch服务:

 sudo systemctl start elasticsearch.service

5.检查Elasticsearch服务的状态:

sudo systemctl status elasticsearch.service

 6.设置开机自启

sudo systemctl enable elasticsearch.service

 

  • 7
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值