Get the App
SLTechnology News&Howtos  ›  Servers  › 

Centos7.3 deployment Elasticsearch5.4.0 cluster

Shulou Source: shulou.com Published: 2022-06-02 02:45:50 11月14日 Update

First, install JDK

1.1 download and install

cd /usr/local/src

tar -zxvf jdk-8u131-linux-x64.tar.gz

mv jdk1.8.0_131 /usr/local/java

1.2 modify the configuration file

vim /etc/profile //last added

export JAVA_HOME=/usr/local/javaCLASSPATH=/usr/local/java/lib/dt.jar/usr/local/java/lib/tools.jarPATH=/usr/local/java/bin:$PATHexport PATH JAVA_HOMECLASSPATH

source /etc/profile //import configuration file

java -version //View java version

Second, install Elasticsearch

Official website: www.elastic.co/downloads

Reference: blog.csdn.net/u013365215/article/details/70159159

2.1 download and install

cd /usr/local/src/

curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.0.tar.gz

tar -xvf elasticsearch-5.4.0.tar.gz

mv elasticsearch-5.4.0 /usr/local/

cd /usr/local/elasticsearch-5.4.0/

2.2 system tuning

1) Configure the maximum number of open file descriptors in the system

vim /etc/sysctl.conf

vm.max_map_count = 262144

Execute the following order effective

sysctl -p

2) Configure process maximum open file descriptor

vim /etc/security/limits.conf //file last

* soft nofile 65536* hard nofile 65536

2.3 Writing ES Master Node Profile

vim config/elasticsearch.yml

cluster.name my-esnode.name: 192.168.19.141http.port: 9200transport.tcp.port: 9300discovery.zen.ping.unicast.hosts: ["192.168.19.141","192.168.19.143"]discovery.zen.minimum_master_nodes: 2#Avoid cross-domain issues http.cors.enabled: truehttp. cors.allow-origin: "*" 192.168.19.142 node-1network.host

The configuration of the second and third nodes only needs to be modified to the corresponding ones.

2.4 Start ES

java.lang.RuntimeException: can not runelasticsearch as root

Since Elasticsearch 6.0 cannot be started with root account, we first create an elasticsearch group and account:

groupadd elsearch

useradd elsearch -g elsearch -p elasticsearch

chown -R elsearch.elsearch /usr/local/elasticsearch-5.4.0/

Background Start:

su - elsearch -c "/usr/local/elasticsearch-5.4.0/bin/elasticsearch -d"

2.5 Install the head open source plugin

Reference: blog.csdn.net/ronmy/article/details/63685254

Just install the plugin on the master. elasticsearch6 cannot be installed directly via plugin -install mobz/elasticsearch-head, and head needs to run in node environment. The specific steps are as follows:

Step 1: Install Node

curl -sL -o /etc/yum.repos.d/khara-nodejs.repohttps://copr.fedoraproject.org/coprs/khara/nodejs/repo/epel-7/khara-nodejs-epel-7.repo

yum install -y nodejs nodejs-npm

View installed version

Step 2: Install grunt

cd /usr/lib/node_modules/npm/

npm install grunt-cli

npm install grunt

View Version:

/usr/lib/node_modules/npm/node_modules/.bin/grunt -version

Step 3: Install the head

yum install -y git

cd /usr/local/

git clone git://github.com/mobz/elasticsearch-head.git

cd elasticsearch-head/

npm install

Note: There may be some error messages in this step, which can be ignored.

vim _site/app.js

#Modify http://localhost:9200 field to local ES port and IP

Step 4: Start head and run in background

./ node_modules/grunt/bin/gruntserver &

Browser access:

Note: If clusters cannot be formed, it may be iptables or selinux.

2.6 boot-up

vim /etc/rc.local

su - elsearch -c "/usr/local/elasticsearch-5.3.1/bin/elasticsearch -d"/usr/local/elasticsearch-head/node_modules/grunt/bin/grunt server &

After saving and exiting, grant execution permission to the bootloader file (if not added, Centos7 will not boot and execute)

chmod +x /etc/rc.d/rc.local

Tags: File configuration version Max background plug-in system Node account reference run Cluster three Information reason simply Command Field permission step Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info vpn macOS MySQL Redmi