es插件的安装

Elasticsearch插件必须安装在集群中的每个节点上才能使用,安装完成后必须重启每个节点才能生效,这显然太过繁琐且不利于插件的统一管理。
这里,我们利用网络文件系统(NFS)来统一管理es插件。
注意到es5.5开始就已经移除了自定义插件安装目录path.plugins,https://www.elastic.co/guide/en/elasticsearch/reference/5.5/breaking_50_plugins.html,我们这里选集群中某个节点的plugins目录作为共享目录,其它节点则挂载该文件夹。
安装:CentOS是自带NFS,所以无需安装,要安装的话用yum -y install nfs-utils rpcbind
启动NFS:默认已启动,如果没有启动,输入命令:service rpcbind start,service nfs start
1、这里我们es集群有三个节点,在192.168.14.194节点上设置共享目录/opt/elasticsearch-node3/plugins,把该目录开放给192.168.68.187和192.168.14.197,编辑/etc/exports,增加两行
/opt/elasticsearch-node3/plugins 192.168.68.187(rw,no_root_squash,no_all_squash,sync)
/opt/elasticsearch-node3/plugins 192.168.14.197(rw,no_root_squash,no_all_squash,sync)
2、使配置生效,输入命令:exportfs -r
3、查看已共享的目录,输入命令:showmount -e
4、在192.168.68.187和192.168.14.197挂载共享文件夹,分别输入命令:
mount -t nfs 192.168.14.194:/opt/elasticsearch-node3/plugins /opt/elasticsearch-node1/plugins

mount -t nfs 192.168.14.194:/opt/elasticsearch-node3/plugins /opt/elasticsearch-node2/plugins
5、查看目录信息:df -hv。/opt/elasticsearch-node1/plugins和/opt/elasticsearch-node2/plugins已指向192.168.14.194的/opt/elasticsearch-node3/plugins
如果出现mount.nfs: Connection timed out连接超时,试试关闭服务端防火墙systemctl stop firewalld


analysis-ik插件安装
到192.168.14.194节点的es安装目录下执行命令:
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.1.1/elasticsearch-analysis-ik-7.1.1.zip
注意将7.1.1替换成对应的版本号
安装完成后,我们分别到192.168.68.187和192.168.14.197节点的es安装目录下,执行命令:
./bin/elasticsearch-plugin list
可以发现,这两个节点也已经安装了analysis-ik插件


head插件的安装
es5以上版本安装head需要安装node和grunt
到任一目录下执行:
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
npm run start
open http://localhost:9100/
由于同源策略,elasticsearch会拒绝elasticsearch-head对es的请求,这里需要在elasticsearch.yml配置文件中增加两项配置:
http.cors.enabled: true
http.cors.allow-origin: “*”

分享到