ElasticSearch插件es-head安装及使用

ElasticSearch插件es-head安装及使用

es-head需要nodejs环境编译,先看看机器中是否已经有nodejs环境,如果没有的话我们先要安装nodejs环境:

一、先下载安装nodejs

nodjs官网:https://nodejs.org/en/download/
这里下载的新版本 v12.18.1

wget https://nodejs.org/dist/v12.18.1/node-v12.18.1-linux-x64.tar.xz
tar xf node-v12.18.1-linux-x64.tar.xz
mv node-v12.18.1-linux-x64 /usr/local/node
# 设置环境变量
echo "export PATH=$PATH:/usr/local/node/bin" >> ~/.bashrc
# 刷新
source ~/.bashrc

1.1 测试安装是否成功

node -v

自此,需要的环境已准备完毕,下面开始安装es-head插件。

二、下载elasticsearch head

可使用git命令在线下载,或者下载zip包之后,离线安装都可以

git下载

下载zip包

2.1 编译安装

进入head目录执行npm命令或cnpm命令安装:

cd elasticsearch-head
npm install

安装cnpm

npm install -g cnpm --registry=https://registry.npm.taobao.org

2.2 修改镜像源

如果npm install一直卡在Receiving...不动的话,是因为访问的npm registry网络不行,我们可以修改为淘宝的仓库:

#查看npm仓库
npm config get registry
#或
npm info express
 
#修改为淘宝的源
npm config set registry http://registry.npm.taobao.org

这时候再执行npm install速度就快许多!

2.3启动验证

配置es:

# vim $ES_HOME/config/elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "*"

修改完ES配置重启ES后,在es-head安装目录下使用下面的命令启动es-head插件:

npm run start & # 后台运行

如下图:启动成功
在这里插入图片描述
根据提示,我们访问http://xxx:9100 看看效果,已成功启动并访问我们的ES集群:
在这里插入图片描述

2.4 es-head使用密码访问ES

ES开启安全认证,把集群修改其中一项配置然后重启ES集群

http.cors.enabled: true
http.cors.allow-origin: "*"
#http.cors.allow-headers: Authorization  #这个配置改为下面的
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true

使用xpack安全认证的ES集群,密码改为自己的即可

Linux使用命令检测集群是否健康

curl -XGET -u elastic:JCK3BPr2g25G http://xxx:9200/_cluster/health?pretty

web页面登录

http://xxx:9100/?auth_user=elastic&auth_password=JCK3BPr2g25G

参考:文章

猜你喜欢

转载自blog.csdn.net/chj_1224365967/article/details/120237793