美文网首页
【ES-01】CentOS7.6安装Elasticsearch

【ES-01】CentOS7.6安装Elasticsearch

作者: 境与界 | 来源:发表于2019-05-11 17:09 被阅读0次

1、环境

  • centos7.6
[root@localhost soft]# lsb_release -a
LSB Version:    :core-4.1-amd64...
Distributor ID: CentOS
Description:    CentOS Linux release 7.6.1810 (Core) 
Release:        7.6.1810
Codename:       Core
  • jdk1.8
[root@localhost soft]# java -version
java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)

2、下载 elasticsearch-6.2.2.tar.gz

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

3、解压到你喜欢的目录

 tar zxvf elasticsearch-6.2.2.tar.gz -C /usr/local/develop/elasticsearch/

4、修改config/elasticsearch.yml配置

#数据目录
path.data: /usr/local/develop/elasticsearch/elasticsearch-6.2.2/data
#日志目录
path.logs: /usr/local/develop/elasticsearch/elasticsearch-6.2.2/logs
#支持外网访问
network.host: 0.0.0.0

4.进入目录elasticsearch-6.2.2,并启动elasticsearch

cd elasticsearch-6.2.2/bin

./elasticsearch

# 报错:
java.lang.RuntimeException: can not runelasticsearch as root

5、解决不可以用root用户启动es

#增加用户组
sudo groupadd es

#增加用户,并规定所属用户组和密码
sudo useradd es -g es -p es -M

# 递归更改文件的拥有者
sudo chown -R es:es /usr/local/elasticsearch6.2.2

6、修改max_map_count太小

错误信息:max virtual memory areas vm.max_map_count [65530] is too low
max_map_count:允许一个进程在VMAs(虚拟内存区域)拥有最大数量。

解决:
sudo vim /etc/sysctl.conf

#增加以下内容:
vm.max_map_count=262144

#保存退出vim后使sysctl.conf生效:
sysctl -p

7、最大文件数、最大进程数、 最大锁定内存地址空间。

错误信息:Unable to lock JVM Memory: error=12, reason=Cannot allocate memory
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
memory locking requested for elasticsearch process but memory is not locked12345

解决:修改limits.conf配置
sudo vim /etc/security/limits.conf

# 添加如下内容:
es soft nofile 65536
es hard nofile 65536
es soft nproc 65536
es hard nproc 65536 
es soft memlock unlimited
es hard memlock unlimited 

8、启动elasticsearch

# 切换到es用户,在bin下执行./elasticsearch
su es
./elasticsearch

10、成功后退出再后台启动。

./elasticsearch -d

11、查看状态

linux命令行:
#查看可以监测的参数
curl localhost:9200/_cat

#查看健康信息
curl localhost:9200/_cat/health

浏览器:
#查看elasticsearch是否启动成功
http://ip:9200/

#查看elasticsearch健康状态
http://ip:9200/_cat/health?v
image.png

相关文章

网友评论

      本文标题:【ES-01】CentOS7.6安装Elasticsearch

      本文链接:https://www.haomeiwen.com/subject/mloxaqtx.html