How does Elasticsearch install the Head plug-in?
1. Introduction and download of Head plug-in
Head plug-in is a graphical interface tool of Elasticsearch. Through this plug-in, it is very convenient to add, delete, modify, query and other data interactive operations. After the Elasticsearch6.x version, the head plug-in is already a separate Web App, so there is no need to integrate with Elasticsearch. The Head plug-in can be installed on any machine, and here the Head plug-in is installed on the 172.16.0.57 (server1) machine, which readers can download from https://github.com/mobz/elasticsearch-head.
Since the Head plug-in is essentially a Node.js project, you need to install Node.js and use the npm tool to install the dependent packages. Here we briefly talk about Node.js and NPM as the groundwork for knowledge.
Node.js is a Javascript running environment and a new front-end framework, which is used to build network applications with fast response and easy to expand conveniently.
NPM, whose full name is Node Package Manager, is a Node.js package management and distribution tool that defines package dependency standards and provides downloads of common third-party frameworks needed for JavaScript development.
2. On Centos7 series systems, Node.js and NPM tools can be installed online directly through yum.
[root\ @ localhost\ ~]\ # yum install-y nodejs npm
Download the Head plug-in. Here we download the Head plug-in through git, so we need to install the git tool first
[root\ @ localhost\ ~]\ # yum install-y git
Next, start installing the head plug-in, where you install the head plug-in to the / usr/local directory, as follows:
[root\ @ localhost local]\ # git clone git://github.com/mobz/elasticsearch-head.git
The first step is to clone the head plug-in from github through the git command
The cloned head plug-in is named elasticsearch-head. Go to this directory to modify the configuration file: / usr/local/elasticsearch-head/_site/app.js, and modify the contents shown below:
It means that the head plug-in will access the elasticsearch cluster through 172.16.0.51.
Note: you can get all the information about the cluster by visiting any node in the elasticsearch cluster.
Start the configuration and then install
[root\ @ localhost local]\ # npm config set registry= http://registry.npm.taobao.org/[root\@localhost local]\ # cd elasticsearch-head [root\ @ localhost elasticsearch-head]\ # npm install
The first step is to change the source address to Taobao NPM image, because the official source of default NPM is https://registry.npmjs.org/. The download speed abroad will be very slow, so it is recommended to switch to Taobao's NPM mirror site. The fourth step is to install the libraries and third-party frameworks required for the head plug-in.
Note: if you report an error, please check out: npm install Times phantomjs-prebuilt@2.1.16 installation failed, solution: npm install phantomjs-prebuilt@2.1.16-- ignore-scripts, and then execute npm install again
3. Modify elasticsearch configuration.
In the above configuration, the address of the head plug-in to access the cluster is configured as 172.16.0.51 (this is a host in my es cluster). Next, you need to modify the configuration of elasticsearch on this host to add cross-domain access support.
Modify the leasticsearch configuration file of this host to allow the head plug-in to access elasticsearch across domains, and add the following at the end of the elasticsearch.yml file:
Http.cors.enabled indicates that slug access support is enabled. This value defaults to false. Http.cors.allow-origin indicates the addresses of domain names allowed for cross-domain access. Regular expressions can be used, where "*" means that all domain names are allowed to access.
4. Start head plug-in service.
Then we can start the service with the head plug-in installed.
[root\ @ localhost\ ~]\ # cd / usr/local/elasticsearch-head [root\ @ localhost elasticsearch-head]\ # npm run start
After the head plug-in service is started, the default access port is 9100. Just open http://172.16.0.57:9100 in the browser.