码迷,mamicode.com
首页 > 其他好文 > 详细

实战安装ELK6.6.1之ES篇

时间:2019-07-21 10:41:29      阅读:284      评论:0      收藏:0      [点我收藏+]

标签:runtime   cse   proc   安装   locate   javah   需要   虚拟内存   解决   

一、环境以及注意事项

jdk: (build 1.8.0_151-b12)

elasticsearch:6.6.1

centos 7

注意的问题:jdk 版本 版本不能过低必须是1.8

root 用户不能启动es ,必须新建一个用户

下载解压

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.1.zip
unzip elasticsearch-6.6.1.zip

 

1.1 创建新用户

如果你用root启动,会出现“java.lang.RuntimeException: can not runelasticsearch as root”错误,具体如下所示:

需要创建新用户来运行es

1.1.1. 创建新用户
adduser [用户名]
1.1.2. 修改新用户的密码
passwd [用户名]
1.1.3. 授权sudo

新创建的用户并不能使用sudo命令,需要给他添加授权。

  1. 添加sudoers文件可写权限
chmod -v u+w /etc/sudoers
  1. 修改sudoers文件
vim /etc/sudoers
  1. 在sudoers文件中找到如下位置并添加如下内容
    [用户名]    ALL=(ALL)    ALL(如需新用户使用sudo时不用输密码,把最后一个ALL改为NOPASSWD:ALL即可)

技术图片

  1. 收回sudoers文件可写权限
chmod -v u-w /etc/sudoers
复制
1.1.4. 赋值elasticsearch文件夹的权限给新用户

改变文件夹及所有子文件(夹)所属用户和用户组

chown -R kebi:kebi elasticsearch-6.6.1
技术图片

 

二、常见问题

2.1JVM虚拟机内存不足

错误:“JavaHotSpot(TM) 64-Bit Server VM warning: INFO: error=‘Cannotallocate memory‘ (errno=12)”表示内存不足,其配置文件为config目录下的jvm.options,默认为2g,可以修改为1g。

2.2 max_map_count过小

错误“max virtual memory areas vm.max_map_count [65530]is too low, increase to at least [262144]”,max_map_count文件包含限制一个进程可以拥有的VMA(虚拟内存区域)的数量,系统默认是65530,修改成655360。

#在/etc/sysctl.conf文件最后添加一行
vm.max_map_count=655360
#并执行命令
sysctl -p

 

2.3 max file descriptors过小

错误“max file descriptors [65535] for elasticsearchprocess is too low, increase to at least [65536]”,maxfile descriptors为最大文件描述符,设置其大于65536即可。

  • 解决方法是修改/etc/security/limits.conf文件
技术图片

修改完以后,要执行下 source /etc/profile

ulimit -Hn
ulimit -Sn

技术图片

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

  问题同上,最大线程个数太低。修改配置文件/etc/security/limits.conf,增加配置

*               soft    nproc           4096
*               hard    nproc           4096

查看命令

ulimit -Hu
ulimit -Su

 

然后退出用户再登录,否则无效

 

 

2.4 启动报错

OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N

修改config目录下的jvm.options里面的参数,某些软件包启动的时候默认启用 -XX:+AssumeMP导致
技术图片

 

2.5 外网访问设置

修改config目录下elasticsearch.yml文件

技术图片

技术图片

  1. 修改network.host为0.0.0.0
  2. 修改discovery.zen.ping.unicast.hosts为["0.0.0.0"]

 

2.6 elasticsearch-head插件连不上

修改config目录下elasticsearch.yml文件,在最后新增以下两个参数

http.cors.enabled: true
http.cors.allow-origin: "*"

 

2.7 elasticsearch线程队列不够

修改config目录下elasticsearch.yml文件,在最后新增以下参数

thread_pool.bulk.queue_size: 1000

 

三、启动

3.1 切换新用户

su kebi

3.2 后台运行

进入目录下

bin/elasticsearch -d

 

实战安装ELK6.6.1之ES篇

标签:runtime   cse   proc   安装   locate   javah   需要   虚拟内存   解决   

原文地址:https://www.cnblogs.com/lyon91/p/11220312.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!