本过程针对集群环境中的 ElasticSearch 5.4.1版本,初始安装后是没有任何访问限制的,公司网络安全要求增加安全防护,所以增加安全插件,过程如下:
1.下载 elasticsearch6-http-basic-plugin.jar
[可参考下载地址:https://download.youkuaiyun.com/download/windtears/87764337 ]
在plugins 下建立 http-basic 目录,把文件放入目录。
在plugins目录下新建文件:plugin-descriptor.properties 内容如下:
classname=com.cleafy.elasticsearch6.plugins.http.HttpBasicServerPlugin
name=elasticsearch6-http-basic
description=Plugin to enable HTTP basic authentication and/or Ip based authentication
version=1.0.0
java.version=1.8
elasticsearch.version=5.4.1
(其中 elasticsearch.version 必须对应其使用的版本)
2.针对服务器修改环境要求
使用root用户登录,修改配置文件,命令:
vi /etc/security/limits.conf
添加下面内容
* soft nofile 65536
* hard nofile 131072
* soft nproc 4096
* hard nproc 4096
也可临时手动 ulimit -n 65536
vi /etc/security/limits.d/90-nproc.conf
将以下内容修改:
* soft nproc 4096
vi /etc/sysctl.conf
进入后修改一下内容:
vm.max_map_count=655360
修改后执行命令:
sysctl -p
3.在配制elasticsearch.yml文件中新增
http.basic.enabled: true
http.basic.log: false
http.basic.username: "elasticsearch"
http.basic.password: "!1q2w3e@"
http.basic.ipwhitelist: 132.xxx.43.192,xxx.xxx.xxx.xxx
(此处只支持IP,不要加中括号)
4.重启
service elasticsearch restart
或
su - elasticsearch -c "/usr/lib/elasticsearch/bin/elasticsearch -d" (前提是用户可登陆哈)