Elasticsearch is a distributed search service that provides Restful API. The bottom layer is based on Lucene. It uses multiple shards to ensure [Data Security] (https://cloud.tencent.com/solution/data_protection?from=10680) and provides automatic resharding. Large sites such as github also use Elasticsearch as their search service. . I won’t repeat the nonsense here. The following records the deployment process of the Elasticsearch cluster under CentOS7:
Before deploying an Elasticsearch cluster on three servers:
qd-vpc-op-es01 101.119.92.247
qd-vpc-op-es02 101.119.92.249
qd-vpc-op-es03 101.119.92.254
Next, add another es04 machine to the cluster, the operation is as follows:
qd-vpc-op-es04 101.119.92.161) Install jdk and elasticsearch
jdk-8u5-linux-x64.rpm download address:
https://pan.baidu.com/s/1bpxtX5X(Extract password: df6s)
elasticsearch-5.5.0.rpm download address:
https://pan.baidu.com/s/1mibwWeG (Extract password: vtm2)
[ root@qd-vpc-op-es04 ~]# cd tools/[root@qd-vpc-op-es04 tools]# ls
elasticsearch-5.5.0.rpm jdk-8u5-linux-x64.rpm
[ root@qd-vpc-op-es04 tools]# rpm -ivh elasticsearch-5.5.0.rpm
[ root@qd-vpc-op-es04 tools]# rpm -ivh jdk-8u5-linux-x64.rpm
[ root@qd-vpc-op-es04 tools]# java -version
java version "1.8.0_05"Java(TM) SE Runtime Environment(build 1.8.0_05-b13)
Java HotSpot(TM)64-Bit Server VM(build 25.5-b02, mixed mode)2) Configure elasticsearch
[ root@qd-vpc-op-es04 ~]# cd /etc/elasticsearch/[root@qd-vpc-op-es04 elasticsearch]# ls
elasticsearch.yml elasticsearch.yml.bak jvm.options log4j2.properties nohup.out scripts
[ root@qd-vpc-op-es04 elasticsearch]# cat elasticsearch.yml|grep -v "#"//The configuration content of each node in the cluster is basically the same
cluster.name: image_search //Cluster name
node.name: image_search_node_4 //The node name of this node in the cluster, just define it here
path.data:/data/es/data //Service directory path
path.logs:/data/es/logs //Service log path
discovery.zen.ping.unicast.hosts:["101.119.92.247","101.119.92.249","101.119.92.254","10.111.233.16"]//Here is the ip address of each node
network.host:0.0.0.0//Network address bound to the service
The default elasticsearch service port is 9200[root@qd-vpc-op-es04 elasticsearch]# cat elasticsearch.yml|grep 9200
# http.port:9200[root@qd-vpc-op-es04 elasticsearch]# systemctl start elasticsearch.service
[ root@qd-vpc-op-es04 elasticsearch]# systemctl restart elasticsearch.service
[ root@qd-vpc-op-es04 elasticsearch]# systemctl status elasticsearch.service
[ root@qd-vpc-op-es04 elasticsearch]# ps -ef|grep elasticsearch
[ root@qd-vpc-op-es04 elasticsearch]# lsof -i:9200
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 10998 elasticsearch 320u IPv4 39255 0t0 TCP *:wap-wsp(LISTEN)
Check the health status of elasticsearch
[ root@qd-vpc-op-es04 elasticsearch]# curl 'localhost:9200/_cat/indices?v'
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open video_filter Bx7He6ZtTEWuRBqXYC6gRw 5145801304.1gb 2gb
green open recommend_history_image svYo_Do4SM6wUiv6taUWug 512865902024.9gb 12.4gb
green open recommend_history_gif rhN3MDN2TbuYILqEDksQSg 5126573102.4gb 1.2gb
green open post_images TMsMsMEoR5Sdb7UEQJsR5Q 51487249320407.3gb 203.9gb
green open review_images_v2 qzqnknpgTniU4rCsvXzs0w 5150375955061.6gb 30.9gb
green open review_images rWC4WlfMS8aGe-GOkTauZg 51518108770439.3gb 219.7gb
green open sensitive_images KxSrjvXdSz-y8YcqwBMsZA 51133930128.1mb 64mb
green open post_images_v2 FDphBV4-QuKVoD4_G3vRtA 5149340491055.8gb 27.8gb
As can be seen from the above command results, this node has been successfully added to the name image_Search is in the elasticsearch cluster. Green indicates that the node status is healthy and the data is already in synchronization.
3 ) Update the configuration of elasticsearch in the code
Notify the development colleagues to add the configuration of the new elasticsearch node to the code. After the online update, check the elasticsearch log on the new node to see if there is any information written:
[ root@qd-vpc-op-es04 ~]# cd /data/es/logs/[root@qd-vpc-op-es04 ~]# chown -R elasticsearch.elasticsearch /data/es
[ root@qd-vpc-op-es04 logs]# ls
image_search_deprecation.log image_search_index_indexing_slowlog.log image_search_index_search_slowlog.log image_search.log
----------------------------------------------------------------------------------------------------------------
note:
If you add a node to the elasticsearch cluster, do as follows:
1 ) Install jdk and elasticsearch service on the new node, configure elasticsearch.yml file, start elasticsearch service
2 ) Configure elasticsearch on other nodes in the cluster.yml file, no need to start elasticsearch service
3 ) Execute curl on the new node'localhost:9200/_cat/indices?v'Command to view health status and data synchronization
4 ) Add the configuration of the new elasticsearch node to the code. After the online update, check whether the elasticsearch log of the new node has information written
----------------------------------------------------------------------------------------------------------------
Finally, by the way, post the elasticsearch of the other three nodes.yml file configuration:
[ root@qd-vpc-op-es01 ~]# cat /etc/elasticsearch/elasticsearch.yml |grep -v "#"
cluster.name: image_search
node.name: image_search_node_1
path.data:/data/es/data
path.logs:/data/es/logs
discovery.zen.ping.unicast.hosts:["10.111.233.16","101.119.92.247","101.119.92.249","101.119.92.254"]
network.host:0.0.0.0[root@qd-vpc-op-es02 ~]# cat /etc/elasticsearch/elasticsearch.yml |grep -v "#"
cluster.name: image_search
node.name: image_search_node_2
path.data:/data/es/data
path.logs:/data/es/logs
discovery.zen.ping.unicast.hosts:["10.111.233.16","101.119.92.247","101.119.92.249","101.119.92.254"]
network.host:0.0.0.0[root@qd-vpc-op-es03 ~]# cat /etc/elasticsearch/elasticsearch.yml|grep -v "#"
cluster.name: image_search
node.name: image_search_node_3
path.data:/data/es/data
path.logs:/data/es/logs
discovery.zen.ping.unicast.hosts:["101.119.92.247","101.119.92.249","101.119.92.254","10.111.233.16"]
network.host:0.0.0.0----------------------------------------------------------------------------------------------------------------
If you shut down a node or bring it out of the cluster, you need to notify the node in advance to stop synchronizing data (it will be used during migration):
# curl -XPUT 'localhost:9200/_cluster/settings'-d '{"transient":{"cluster.routing.allocation.enable": "none”}}’
Recommended Posts