Elasticsearch cluster construction 1 Welcome to my elk world!

Source: Internet
Author: User
System Environment:

Jdk1.8 Environment
Ubuntu16.04 system 172.20.1.10 node-1
Ubuntu16.04 system 172.20.1.20 node-2
Ubuntu16.0.4 system 172.20.1.30 node-3

Install elasticsearch version: elasticsearch-6.2.2.tar.gz
Download path of the installation package (packages 6.2.2, 6.4.2, and jdk1.8 are included ):
Https://pan.baidu.com/s/1bTBb6n27wcunwAFCRB5yNQ password: 8raw
1. Install elasticsearch reference: http://www.cnblogs.com/hanyinglong/p/5409003.html
Let's talk about my own practices.
Check whether your Java environment is replaced with jdk1.8. There are a lot of reference documents on the Internet.

Here we will talk about how to decompress the package and configure the environment variables.

The path is specified based on the extracted location. Finally, source/etc/profile

Mkdir-P/data/software/elasticsearch

Create a user because the root user cannot be used to start es.

Sudo adduser es

Then, let's knock on y to complete the process.
CD/home/to see if there is a home directory.

Then extract the package from the package storage path.

Sudo tar-zxvf elasticsearch-2.3.1.tar.gz
Sudo MV elasticsearch-2.3.1/data/software/elasticsearch
Sudo chown-r es. es/data/software/elasticsearch

Let's take a look at the es file structure:

We create an elasticsearch instance on each machine. This is neither a suggestion nor an experience. Because you are an O & M Engineer (backpot Xia), you must pay attention to creating an elasticsearch instance. In case the machine goes down, all data is lost. The most common practice of Small and white security is to make only one node on each server on three machines (this practice allows and only allows any server to crash ), if you don't know why elasticsearch does this, read my technical point.
Next, modify the elasticsearch configuration file.

After the modification is complete, switch to the ES user to start the ES. Remember: switch to the ES user! Switch to ES user !! Switch to ES user !!!
Otherwise, the following situations may occur:

However, you may encounter the following situations. Haha, don't panic: basic operations.

[1]: Max virtual memory areas VM. max_map_count [65530] is too low, increase to at least [262144]
And so on, modify several configuration files:

Add ulimit-shn 65536 at the end of the/etc/profile file
The/etc/security/limits. conf file is added at the end:

  • Soft nofile 65536
  • Hard nofile 65536
  • Soft nproc 4096
  • Hard nproc 4096

Then we apply these configurations to es users. You can refer to ulimit-hn.
Restart After everything is normal.

The following content is displayed on the webpage access IP Address: 9200, indicating that the request is successful.

The operations on the other two nodes are normal (a problem may occur when data in the/data/software/elasticsearch/data/node directory is deleted before startup ), if yes, congratulations.
The next step is to install the troublesome and low elasticsearch-head. Let's take a look at it. (The head plug-in can be used in the production environment as far as possible, because security is especially poor and exposed to others, others can operate nodes on your elasticsearch instances)
Elasticsearch 5.x does not support direct plug-in installation of head plug-ins. Instead, head is installed as an independent service. First, you need to install the dependent node, NPM, grunt
Apt-Get install NPM
Apt-Get install nodejs-Legacy
NPM install-G GRUNT
NPM install-G grunt-cli
Download elasticsearch-head. I decompress it to the/data/software/elasticsearch-head directory and change the directory user to es.
Then modify the configuration

1. Modify the head connection address elasticsearch-head/_ site/APP. js

This. base_uri = This. config. base_uri | this. prefs. Get ("app-base_uri") | "http: // localhost: 9200 ";

Change localhost to your own IP Address
2. Modify the server listening address elasticsearch-head/gruntfile. js

connect: {             server: {                 options: {                     port: 9100,                     base: ‘.‘,                     keepalive: true                 }             }         }  

Add hostname: '*' to options :'*'
3. Modify the elasticseach configuration file elasticsearch. yml, modify the corresponding IP address and cross-domain settings, and add:

HTTP. CORS. Enabled: True

HTTP. CORS. Allow-origin :"*"
3. Run: grunt server under elasticsearch-head
3.1 but an error message will appear (the NPM start command at that time should be the same ):

[Email protected]:/usr/local/kencery/elasticsearch-head # NPM start

> [Email protected] Start/usr/local/kencery/elasticsearch-head
> Grunt Server

Grunt-CLI: The grunt command line interface (v1.2.0)

Fatal error: unable to find local grunt.

If you're seeing this message, grunt hasn' t been installed locally
Your project. For more information about installing and processing ing grunt,
Please see the Getting Started Guide:

Http://gruntjs.com/getting-started

NPM Err! Linux 4.4.0-62-generic
NPM Err! Argv "/usr/bin/nodejs" "/usr/bin/NPM" "start"
NPM Err! Node v4.2.6
NPM Err! NPM v3.5.2
NPM Err! Code elifecycle
NPM Err! [Email protected] Start:grunt server
NPM Err! Exit status 99
NPM Err!
NPM Err! Failed at the [email protected] Start script 'grunt Server '.
NPM Err! Make sure you have the latest version of node. js and NPM installed.
NPM Err! If you do, this is most likely a problem with the elasticsearch-head package,
NPM Err! Not with NPM itself.
NPM Err! Tell the author that this fails on your system:
NPM Err! Grunt Server
NPM Err! You can get information on how to open an issue for this project:
NPM Err! NPM bugs elasticsearch-head
NPM Err! Or if that isn't available, you can get their info:
NPM Err! NPM owner ls elasticsearch-head
NPM Err! There is likely Additional Logging output above.
NPM Err! Please include the following file with any support request:
NPM Err! /Usr/local/kencery/elasticsearch-head/npm-debug.log

I have noticed that the version is not the latest, so I will try to upgrade NPM and Node

NPM cache clean-F
NPM install-g N
N stable
NPM install [email protected]-G

Check the next version.

[Email protected]: ~ $ Node-V
V10.4.0
[Email protected]: ~ $ NPM-V
6.1.0

3.2 but the grunt server still reports the following error:

Grunt hasn't been installed locally to your project

Refer to the https://segmentfault.com/q/1010000004172559/a-1020000004193932 and execute:

NPM install grunt -- save-Dev

3.3 run again and an error is still reported:
[Email protected]:/usr/local/kencery/elasticsearch-head $ grunt Server

Local NPM module "Grunt-contrib-clean" Not found. Is it installed?
Local NPM module "Grunt-contrib-Concat" Not found. Is it installed?
Local NPM module "Grunt-contrib-watch" Not found. Is it installed?
Local NPM module "Grunt-contrib-Connect" Not found. Is it installed?
Local NPM module "Grunt-contrib-Copy" Not found. Is it installed?
Local NPM module "Grunt-contrib-Jasmine" Not found. Is it installed?
Warning: Task "Connect: Server" Not found. Use -- force to continue.

Then I simply installed grunt with the latest one:

NPM install [email protected]
NPM install [email protected]
NPM install [email protected]
NPM install [email protected]
NPM install [email protected]
NPM install [email protected]
NPM install [email protected]
NPM install [email protected]
NPM install [email protected]

4.4 Finally, grunt server can be started:

[Email protected]:/usr/local/kencery/elasticsearch-head $ grunt Server
(Node: 1527) experimentalwarning: The http2 module is an experimental API.
Running "Connect: Server" (CONNECT) task
Waiting forever...
Started connect web server on http: // localhost: 9100

We can see that the port number of the elasticsearch service is 9200, and the port number of the head plug-in service is 9100. We can access the head and then the head to access elasticsearch.

Reference:
180618073

Elasticsearch cluster construction 1 Welcome to my elk world!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.