安装 elasticsearch-head
elasticsearch 7.x 已经无法直接调用 plugin 进行 elasticsearch-head 安装, 参考下面安装步骤
# git clone https://github.com/mobz/elasticsearch-head
/etc/yum.repso.d/yarn.repo
[yarn]
name=Yarn Repository
baseurl=https://dl.yarnpkg.com/rpm/
enabled=1
gpgcheck=0
gpgkey=https://dl.yarnpkg.com/rpm/pubkey.gpg
# curl --silent --location https://rpm.nodesource.com/setup_10.x | bash -
## Installing the NodeSource Node.js 10.x repo...
## Inspecting system...
+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m
## Confirming "el7-x86_64" is supported...
+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_10.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
## Downloading release setup RPM...
+ mktemp
+ curl -sL -o '/tmp/tmp.sy79c77aLt' 'https://rpm.nodesource.com/pub_10.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
## Installing release setup RPM...
+ rpm -i --nosignature --force '/tmp/tmp.sy79c77aLt'
## Cleaning up...
+ rm -f '/tmp/tmp.sy79c77aLt'
## Checking for existing installations...
+ rpm -qa 'node|npm' | grep -v nodesource
## Run `sudo yum install -y nodejs` to install Node.js 10.x and npm.
## You may also need development tools to build native addons:
sudo yum install gcc-c++ make
## To install the Yarn package manager, run:
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install yarn
先安装 gcc-c++ 与 make
[root@ns-yun-020064 git]# yum install gcc-c++ make
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
epel/x86_64/metalink | 2.2 kB 00:00:00
base | 3.6 kB 00:00:00
epel | 4.3 kB 00:00:00
extras | 3.4 kB 00:00:00
nodesource | 2.5 kB 00:00:00
updates | 3.4 kB 00:00:00
nodesource/x86_64/primary_db | 49 kB 00:00:01
软件包 gcc-c++-4.8.5-28.el7_5.1.x86_64 已安装并且是最新版本
软件包 1:make-3.82-23.el7.x86_64 已安装并且是最新版本
无须任何处理
# yum install yarn -y
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
epel/x86_64/metalink | 2.2 kB 00:00:00
base | 3.6 kB 00:00:00
epel | 4.3 kB 00:00:00
extras | 3.4 kB 00:00:00
nodesource | 2.5 kB 00:00:00
updates | 3.4 kB 00:00:00
yarn | 2.9 kB 00:00:00
(1/2): yarn/primary_db | 22 kB 00:00:00
(2/2): nodesource/x86_64/primary_db | 49 kB 00:00:02
正在解决依赖关系
--> 正在检查事务
---> 软件包 yarn.noarch.0.1.22.5-1 将被 安装
--> 正在处理依赖关系 nodejs,它被软件包 yarn-1.22.5-1.noarch 需要
--> 正在检查事务
---> 软件包 nodejs.x86_64.2.10.23.0-1nodesource 将被 安装
--> 解决依赖关系完成
依赖关系解决
==============================================================================================================================
Package 架构 版本 源 大小
==============================================================================================================================
正在安装:
yarn noarch 1.22.5-1 yarn 1.2 M
为依赖而安装:
nodejs x86_64 2:10.23.0-1nodesource nodesource 20 M
事务概要
==============================================================================================================================
安装 1 软件包 (+1 依赖软件包)
总下载量:21 M
安装大小:66 M
Downloading packages:
(1/2): yarn-1.22.5-1.noarch.rpm | 1.2 MB 00:00:02
警告:/var/cache/yum/x86_64/7/nodesource/packages/nodejs-10.23.0-1nodesource.x86_64.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID 34fa74dd: NOKEY
nodejs-10.23.0-1nodesource.x86_64.rpm 的公钥尚未安装
(2/2): nodejs-10.23.0-1nodesource.x86_64.rpm | 20 MB 00:00:12
------------------------------------------------------------------------------------------------------------------------------
总计 1.7 MB/s | 21 MB 00:00:12
从 file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL 检索密钥
导入 GPG key 0x34FA74DD:
用户ID : "NodeSource "
指纹 : 2e55 207a 95d9 944b 0cc9 3261 5ddb e8d4 34fa 74dd
软件包 : nodesource-release-el7-1.noarch (installed)
来自 : /etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
正在安装 : 2:nodejs-10.23.0-1nodesource.x86_64 1/2
正在安装 : yarn-1.22.5-1.noarch 2/2
验证中 : yarn-1.22.5-1.noarch 1/2
验证中 : 2:nodejs-10.23.0-1nodesource.x86_64 2/2
已安装:
yarn.noarch 0:1.22.5-1
作为依赖被安装:
nodejs.x86_64 2:10.23.0-1nodesource
完毕!
# node -v
v10.23.0
# npm -v
6.14.8
# npm install -g grunt-cli
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
/usr/bin/grunt -> /usr/lib/node_modules/grunt-cli/bin/grunt
+ [email protected]
added 153 packages from 126 contributors in 64.745s
# cd /usr/src/git/elasticsearch-head
# npm install
npm WARN deprecated [email protected]: Use the built-in module in node 9.0.0 or newer, instead
npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated [email protected]: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm WARN deprecated [email protected]: this package is now deprecated
npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: Please use the native JSON object instead of JSON 3
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Please use the native JSON object instead of JSON 3
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
> [email protected] install /usr/src/git/elasticsearch-head/node_modules/phantomjs-prebuilt
> node install.js
PhantomJS not found on PATH
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2
Saving to /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
Receiving...
[========================================] 100%
Received 22866K total.
Extracting tar contents (via spawned process)
Removing /usr/src/git/elasticsearch-head/node_modules/phantomjs-prebuilt/lib/phantom
Copying extracted folder /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1606793124348/phantomjs-2.1.1-linux-x86_64 -> /usr/src/git/elasticsearch-head/node_modules/phantomjs-prebuilt/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /usr/src/git/elasticsearch-head/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs
> [email protected] postinstall /usr/src/git/elasticsearch-head/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":"0.10 || 0.12 || 4 || 5 || 6"} (current: {"node":"10.23.0","npm":"6.14.8"})
npm WARN notsup Not compatible with your version of node/npm: [email protected]
npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":">=0.12.0 <9.0.0"} (current: {"node":"10.23.0","npm":"6.14.8"})
npm WARN notsup Not compatible with your version of node/npm: [email protected]
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN [email protected] license should be a valid SPDX license expression
added 519 packages from 631 contributors and audited 521 packages in 1182.206s
5 packages are looking for funding
run `npm fund` for details
found 52 vulnerabilities (26 low, 2 moderate, 24 high)
run `npm audit fix` to fix them, or `npm audit` for details
http.cors.enabled: true
http.cors.allow-origin: "*"
每次重启一台服务器
# systemctl stop elasticsearch.service
# systemctl start elasticsearch.service
重启后, 监控状态是否会变回去 green , 然后再重启另外一台服务器
监控集群状态方法
while [ 1 ]; do curl 'http://localhost:9200/_cat/health?format=json&pretty' ; sleep 3; done
./node_modules/grunt/bin/grunt server
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100
启动后可以连连接对应机器 9100 端口进行访问
默认 localhost:9200 需要修改为 IP 地址连接
[Unit]
Description=elasticsearch head web app
After=network-online.target
Wants=network-online.target
[Service]
Type=forking
WorkingDirectory=/usr/src/git/elasticsearch-head/
ExecStart=/bin/sh -c "/usr/src/git/elasticsearch-head/node_modules/grunt/bin/grunt server &"
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=60
RestartSec=30
KillMode=process
Restart=on-failure
CPUShares=2
MemoryLimit=2G
BlockIOWeight=100
CPUQuota=100%
[Install]
WantedBy=multi-user.target