Elasticsearch-head插件安装
head插件可以方便看到es集群节点、索引和分片信息,安装head插件依赖Nodejs、grunt
Elasticsearch-head插件有两种安装方式:
方式1:通过chrome应用商店安装Elasticsearch-head插件(最简单,直接可以使用)
方式2:安装elasticsearch-head , 下面教程是通过该方式安装
安装包下载
Nodejs官网:http://nodejs/
Nodejs安装包:https://cdn.npmmirror/binaries/node/v14.15.0/node-v14.15.0-linux-x64.tar.xz
安装Nodejs
进入/opt/app目录,并上传node-v14.15.0-linux-x64.tar.xz压缩包
# 进入/opt/app目录
cd /opt/app
# 解压缩
tar -xvf node-v14.15.0-linux-x64.tar.xz
建立软连接,变为全局
# 变更目录
mv /opt/app/node-v14.15.0-linux-x64 /opt/app/nodejs
# 建立软连接
ln -s /opt/app/nodejs/bin/npm /usr/local/bin/
ln -s /opt/app/nodejs/bin/node /usr/local/bin/
node -v 检查是否安装成功,打印版本号就是成功
[root@node1 app]# node -v
v14.15.0
安装grunt
使用命令 npm install -g grunt-cli 安装grunt
npm install -g grunt-cli
如果安装慢的话或者报错的话可以安装淘宝镜像,使用cnpm命令安装
# 切换淘宝镜像源
npm install -g cnpm --registry=https://registry.npm.taobao
# 建立cnpm软链
ln -s /opt/app/nodejs/bin/cnpm /usr/local/bin/
# 安装grunt-cli
cnpm install -g grunt-cli
[root@node1 app]# cnpm install -g grunt-cli
Downloading grunt-cli to /opt/app/nodejs/lib/node_modules/grunt-cli_tmp
Copying /opt/app/nodejs/lib/node_modules/grunt-cli_tmp/_grunt-cli@1.4.3@grunt-cli to /opt/app/nodejs/lib/node_modules/grunt-cli
Installing grunt-cli's dependencies to /opt/app/nodejs/lib/node_modules/grunt-cli/node_modules
[1/5] grunt-known-options@~2.0.0 installed at node_modules/_grunt-known-options@2.0.0@grunt-known-options
[2/5] interpret@~1.1.0 installed at node_modules/_interpret@1.1.0@interpret
[3/5] v8flags@~3.2.0 installed at node_modules/_v8flags@3.2.0@v8flags
[4/5] nopt@~4.0.1 installed at node_modules/_nopt@4.0.3@nopt
[5/5] liftup@~3.0.1 installed at node_modules/_liftup@3.0.1@liftup
All packages installed (58 packages installed from npm registry, used 1s(network 1s), speed 324.24KB/s, json 58(129.21KB), tarball 274.14KB, manifests cache hit 0, etag hit 0 / miss 0)
[grunt-cli@1.4.3] link /opt/app/nodejs/bin/grunt@ -> /opt/app/nodejs/lib/node_modules/grunt-cli/bin/grunt
[root@node1 app]#
查看是否安装成功,打印版本号代表成功
# 建立grunt软链
ln -s /opt/app/nodejs/bin/grunt /usr/local/bin/
[root@node1 app]# ln -s /opt/app/nodejs/bin/grunt /usr/local/bin/
[root@node1 app]# grunt -version
grunt-cli v1.4.3
安装head插件
下载elasticsearch-head
# 切换目录
cd /opt/app
# github打不开,使用gitee代替
# git clone git://github/mobz/elasticsearch-head.git
git clone https://gitee/cyberton/elasticsearch-head.git
修改所有域名访问,添加 hostname:“*”
# 进入elasticsearch-head目录
cd elasticsearch-head
# 修改Gruntfile.js
vi Gruntfile.js
connect: {
server: {
options: {
hostmame:'*',
port: 9100,
base: '.',
keepalive: true
}
}
}
开始安装并启动 elasticsearch-head
# 安装 (npm命令安装失败,使用cnpm安装)
cnpm install
# 启动
cnpm run start
#后台启动es-head命令 nohup ./grunt server >/dev/null 2>&1 &
#执行命令后,不使用ctrl+c退出,使用exit退出shell即可
[root@node1 elasticsearch-head]# cnpm run start
> elasticsearch-head@0.0.0 start /opt/app/elasticsearch-head
> grunt server
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100
浏览器打开 http://node1:9100/ (node1是配置的hosts)
无法连接es节点,需要配置ES跨域
修改es配置文件,添加如下配置,然后重启Elasticsearch
http.cors.enabled: true
http.cors.allow-origin: “*”
vi /opt/app/elasticsearch-7.10.0//config/elasticsearch.yml
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
network.host: 0.0.0.0
# 允许跨域
http.cors.enabled: true
http.cors.allow-origin: "*"
# Set a custom port for HTTP:
#
#http.port: 9200
更多推荐
Elasticsearch-head插件安装
发布评论