http://blog.csdn.net/tanga842428/article/details/76161461 (Elasticsearch cluster management tool head installation)
http://blog.csdn.net/q15150676766/article/details/76039270 (ElasticSearch learns the installation of Head)
1. Environmental preparation
download nodejs
Nodejs official website download address https://nodejs.org/dist/
[root@localhost data]# wget https://nodejs.org/dist/v6.11.2/node-v6.11.2-linux-x64.tar.xz
2. Configure node environment variables
[root@node1 data]# xz -d node-v6.11.2-linux-x64.tar.xz
[root@node1 data]# tar -xvf node-v6.11.2-linux-x64.tar -C /usr/local/
[root@node1 data]# cd ~
[root@node1 ~]# ln -s /usr/local/node-v6.11.2-linux-x64/bin/node /usr/bin/node
[root@node1 ~]# ln -s /usr/local/node-v6.11.2-linux-x64/bin/npm /usr/bin/npm
[root@node1 ~]# node -v
v6.11.2
[root@node1 ~]# npm -v
3.10.10
[root@node1 ~]#
or:
root@node1 data]# vim /etc/profile Add the following 2 lines
export NODE_HOME=/usr/local/node-v6.11.2-linux-x64
export PATH=$PATH:$NODE_HOME/bin
root@node1 data]# source /etc/profile
[root@node1 data]# node -v
v6.11.2
[root@node1 data]# npm -v
3.10.10
4. Install grunt
If the production environment cannot be connected to the Internet to install grunt online, you can find a host that can connect to the Internet to configure node, and after installing grunt, package and upload the node_models in the elasticsearch-head directory.
[root@node1 ~]# npm install -g grunt-cli #After executing the command, the display is as follows:
/usr/local/node-v6.11.2-linux-x64/bin/grunt -> /usr/local/node-v6.11.2-linux-x64/lib/node_modules/grunt-cli/bin/grunt
/usr/local/node-v6.11.2-linux-x64/lib
│ └─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ └── [email protected]
│ └── [email protected]
Re-associate grunt
[root@node1 ~]# ln -s /usr/local/node-v6.9.5-linux-x64/lib/node_modules/grunt-cli/bin/grunt /usr/bin/grunt
Grunt is a convenient build tool that can perform packaging, compression, testing, execution, etc. The head plugin in 5.x is started through grunt;
The #"-g" parameter represents global installation, which is generally installed in the "lib/node_modules" directory of nodejs; without the parameter "-g", it is a local installation, generally installed in the directory where the npm command is run, which is required here. Install to the head plugin directory;
#Build a soft link for the grunt command to facilitate global execution, or add environment variables;;
#If the image speed is not ideal, you can switch to the domestic image in advance and execute before installing grunt-cli: npm config set registry https://registry.npm.taobao.org.
5. Download elasticsearch-head
[root@node1 ~]# cd /usr/local
[root@node1 local]# git clone git://github.com/mobz/elasticsearch-head.git
[root@node1 local]# cd elasticsearch-head/
[root@node1 elasticsearch-head]# npm install
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
3 warning messages are found, just ignore them. The "npm WARN [email protected] license should be a valid SPDX license expression" warning message can be handled as follows: http://www.itdadao.com/articles/ c15a1031952p0.html
That is, modify "Apache2" in line 19 of the "package.json" file in the "./elasticsearch-head" directory to "Apache-2.0", which involves the use of open source software and other cooperative software.
#If the grunt binary is not installed globally, execute "npm install grunt --save" or "npm install grunt-cli" in the "elasticsearch-head" directory.
6. Configure the head file
[root@node1 elasticsearch-head]# cd _site/
[root@node1 _site]# cp app.js app.js.bak
[root@node1 _site]# vim app.js
#In line 4330, modify the original "http://localhost:9200" to "http://10.129.11.86:9200", otherwise the head plugin cannot obtain node status information.
[root@node1 elasticsearch-head]# cp Gruntfile.js Gruntfile.js.bak
[root@node1 elasticsearch-head]# vim Gruntfile.js
connect: {
server: {
options: {
hostname: '0.0.0.0',
port: 9100,
base: '.',
keepalive: true
}
}
}
# Add "hostname: '0.0.0.0', " to line 93 to ensure that it can be accessed.
7. Restart elasticsearch, and start node and verify,
[root@node1 elasticsearch-head]# nohup node_modules/grunt/bin/grunt server &exit
#Start the head plugin, you need to go to the elasticsearch-head directory
If you want to turn off the head plugin, use the Linux find process command:
ps aux|grep head
end process:
kill 进程号