centos7环境安装elasticsearch7.3.2

本文记录1核2G centos7.6下安装elasticsearch7.3.2

快速开始

下载elasticsearch

wget方式下载

1
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.2-linux-x86_64.tar.gz

有时候下的比较慢,可以自己下载后然后手动上传到服务器

解压文件包

1
tar -zxvf elasticsearch-7.3.2-linux-x86_64.tar.gz

移动位置

1
mv elasticsearch-7.3.2 /usr/local/

修改配置elasticsearch.yml

1
vim /usr/local/elasticsearch-7.3.2/config/elasticsearch.yml

主要找到以下几个地方放开注释按需修改:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#集群名字
cluster.name: my-application
#节点名字
node.name: node-1
#data存放地址
path.data: /usr/local/elasticsearch-7.3.2/data
#日志存放地址
path.logs: /usr/local/elasticsearch-7.3.2/logs
#所有网络可访问
network.host: 0.0.0.0
#端口
http.port: 9200
#集群节点 我们就单机写上面node-1就可以了
cluster.inital_master_nodes: ["node-1"]

修改内存jvm.options

配置修改好了,还可以修改内存,我这里是1核2G,elasticsearch7.3.2默认是1G配置,如果发现内存不足启动不了,就调小内存

1
vim /usr/local/elasticsearch-7.3.2/config/jvm.options

1
2
-Xms512m
-Xmx512m

其他配置

修改sysctl.conf

1
vim /etc/sysctl.conf

在末尾添加

1
vm.max_map_count = 655360

使其立即生效

1
sysctl -p

修改limits.conf

1
vim /etc/security/limits.conf

在末尾添加

1
2
3
4
*               soft    nofile          65536
* hard nofile 65536
* soft nproc 4096
* hard nproc 4096

添加elasticsearch专有用户
因为root无法启动elasticsearch,我们必须添加一个专门的用户来管理elasticsearch

1
useradd es

设置密码

1
passwd es

配置拥有权限

1
chown -R es /usr/local/elasticsearch-7.3.2/

启动

先切换成es用户

1
su es

启动 -d表示后台启动

1
./usr/local/elasticsearch-7.3.2/bin/elasticsearch -d

最后访问ip:9200你就可以看到返回的json信息,说明安装成功

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×