centos7虚拟机安装elasticsearch6.4.x-遇到的坑

OS:Centos7x虚拟机 1H2G
jdk:1.8
elasticsearch:5.6.0

1、下载“elasticsearch-5.6.0.tar.gz”解压到/usr/local/elasticsearch目录下。

2、启动elasticSearch

这里需要注意的是es 规定 root 用户不能启动 es,所以需要创建一个用户来启动 es

复制代码
# 创建用户名为 es 的用户
useradd es
# 设置 es 用户的密码
passwd es

# 创建 es 的 data 和 logs 目录
mkdir elasticsearch-6.4.0/data
mkdir elasticsearch-6.4.0/logs 

# 将 /usr/local/elasticsearch/elasticsearch-6.4.0 的拥有者设置为 es
chown -R es:es /usr/local/elasticsearch/elasticsearch-6.4.0
复制代码

编辑配置文件config/elasticsearch.yml

network.host: 你自己的服务器ip
http.port: 9200

切换到 es 用户,启动 es

su es

# -d是后台启动,第一次不建议后台启动,前台启动可以直观的看到日志信息
bin/elasticsearch -d

可能遇到的错误:

问题:

max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

解决方法:

#切换到root用户修改
vim /etc/security/limits.conf

# 在最后面追加下面内容
es hard nofile 65536
es soft nofile 65536

修改后重新登录 es 用户,使用如下命令查看是否修改成功

ulimit -Hn
65536

问题:

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决方法 提高vm.max_map_count 的大小

# 切换到root用户
vim /etc/sysctl.conf
# 在最后面追加下面内容
vm.max_map_count=262144
# 使用 sysctl -p 查看修改后的结果
sysctl -p

问题:

Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)

解决方法:

# 由于elasticsearch5.0默认分配jvm空间大小为2g,修改jvm空间分配
# 如果使用虚拟机安装,内存最好不小于2G
# vim config/jvm.options  
-Xms512m
-Xmx512m

在确定服务器端口(9200)开启,elasticsearch启动的情况下(ps -ef | grep elasticsearch)可以在浏览器中访问

问题:

max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

  每个进程最大同时打开文件数太小,可通过下面2个命令查看当前数量

ulimit -Hn
ulimit -Sn

  修改/etc/security/limits.conf文件,增加配置,用户退出后重新登录生效

*               soft    nofile          65536
*               hard    nofile          65536

问题: 

max number of threads [3818] for user [es] is too low, increase to at least [4096]

 问题同上,最大线程个数太低。修改配置文件/etc/security/limits.conf,增加配置,用户退出后重新登录生效

 
1
2
*               soft    nproc           4096
*               hard    nproc           4096

  可通过命令查看

ulimit -Hu
ulimit -Su

OS:Centos7x虚拟机 1H2G
jdk:1.8
elasticsearch:5.6.0

1、下载“elasticsearch-5.6.0.tar.gz”解压到/usr/local/elasticsearch目录下。

2、启动elasticSearch

这里需要注意的是es 规定 root 用户不能启动 es,所以需要创建一个用户来启动 es

复制代码
# 创建用户名为 es 的用户
useradd es
# 设置 es 用户的密码
passwd es

# 创建 es 的 data 和 logs 目录
mkdir elasticsearch-6.4.0/data
mkdir elasticsearch-6.4.0/logs 

# 将 /usr/local/elasticsearch/elasticsearch-6.4.0 的拥有者设置为 es
chown -R es:es /usr/local/elasticsearch/elasticsearch-6.4.0
复制代码

编辑配置文件config/elasticsearch.yml

network.host: 你自己的服务器ip
http.port: 9200

切换到 es 用户,启动 es

su es

# -d是后台启动,第一次不建议后台启动,前台启动可以直观的看到日志信息
bin/elasticsearch -d

可能遇到的错误:

问题:

max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

解决方法:

#切换到root用户修改
vim /etc/security/limits.conf

# 在最后面追加下面内容
es hard nofile 65536
es soft nofile 65536

修改后重新登录 es 用户,使用如下命令查看是否修改成功

ulimit -Hn
65536

问题:

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决方法 提高vm.max_map_count 的大小

# 切换到root用户
vim /etc/sysctl.conf
# 在最后面追加下面内容
vm.max_map_count=262144
# 使用 sysctl -p 查看修改后的结果
sysctl -p

问题:

Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)

解决方法:

# 由于elasticsearch5.0默认分配jvm空间大小为2g,修改jvm空间分配
# 如果使用虚拟机安装,内存最好不小于2G
# vim config/jvm.options  
-Xms512m
-Xmx512m

在确定服务器端口(9200)开启,elasticsearch启动的情况下(ps -ef | grep elasticsearch)可以在浏览器中访问

问题:

max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

  每个进程最大同时打开文件数太小,可通过下面2个命令查看当前数量

ulimit -Hn
ulimit -Sn

  修改/etc/security/limits.conf文件,增加配置,用户退出后重新登录生效

*               soft    nofile          65536
*               hard    nofile          65536

问题: 

max number of threads [3818] for user [es] is too low, increase to at least [4096]

 问题同上,最大线程个数太低。修改配置文件/etc/security/limits.conf,增加配置,用户退出后重新登录生效

 
1
2
*               soft    nproc           4096
*               hard    nproc           4096

  可通过命令查看

ulimit -Hu
ulimit -Su

猜你喜欢

转载自www.cnblogs.com/shanshanlaichi/p/9581711.html