三、ElasticSearch6 集羣安裝

經過前兩篇博客、今天將之前的改爲集羣模式 如果從0搭建請先移步第一篇、真實環境中每個節點都需要像文章一一樣配置環境。

一、停止ElasticSearch

[payment@gameServer elasticsearch-6.2.4]$ jps
29963 Jps
29196 Elasticsearch
[payment@gameServer elasticsearch-6.2.4]$ kill -9 29196
[payment@gameServer elasticsearch-6.2.4]$ 
[payment@gameServer elasticsearch-6.2.4]$ jps
29978 Jps

二、清除數據

注:如果不清楚、集羣搭建好之後會報錯的

[payment@gameServer elasticsearch-6.2.4]$ pwd
/home/payment/elasticSearch/elasticsearch-6.2.4
[payment@gameServer elasticsearch-6.2.4]$ ll
總用量 240
drwxr-xr-x.  2 payment payment   4096 6月   5 21:16 bin
drwxr-xr-x.  3 payment payment   4096 6月   6 13:08 config
drwxrwxr-x.  2 payment payment   4096 6月   6 14:12 data
drwxr-xr-x.  2 payment payment   4096 4月  13 04:39 lib
-rw-r--r--.  1 payment payment  11358 4月  13 04:33 LICENSE.txt
drwxr-xr-x.  2 payment payment   4096 6月   6 10:21 logs
drwxr-xr-x. 16 payment payment   4096 4月  13 04:39 modules
-rw-r--r--.  1 payment payment 191887 4月  13 04:38 NOTICE.txt
drwxr-xr-x.  3 payment payment   4096 6月   6 13:08 plugins
-rw-r--r--.  1 payment payment   9268 4月  13 04:33 README.textile
[payment@gameServer elasticsearch-6.2.4]$ rm -rf data/* logs/*

三、拷貝ElasticSearch

[payment@gameServer elasticsearch-6.2.4]$ cd ..
[payment@gameServer elasticSearch]$ ll
總用量 28380
drwxr-xr-x. 9 payment payment     4096 6月   6 10:21 elasticsearch-6.2.4
-rw-rw-r--. 1 payment payment 29056810 5月  15 12:56 elasticsearch-6.2.4.tar.gz
[payment@gameServer elasticSearch]$ 
[payment@gameServer elasticSearch]$ cp -r elasticsearch-6.2.4 elasticsearch-6.2.4-2
[payment@gameServer elasticSearch]$ cp -r elasticsearch-6.2.4 elasticsearch-6.2.4-3
[payment@gameServer elasticSearch]$ mv elasticsearch-6.2.4 elasticsearch-6.2.4-1
[payment@gameServer elasticSearch]$ ll
總用量 28388
drwxr-xr-x. 9 payment payment     4096 6月   6 10:21 elasticsearch-6.2.4-1
drwxr-xr-x. 9 payment payment     4096 6月   6 14:13 elasticsearch-6.2.4-2
drwxr-xr-x. 9 payment payment     4096 6月   6 14:13 elasticsearch-6.2.4-3

四、修改配置文件

分別修改3個節點的配置文件

[payment@gameServer ~]$ grep '^[a-z]'  elasticSearch/elasticsearch-6.2.4-1/config/elasticsearch.yml
cluster.name: dev_elastic_cluster
node.name: node-1
node.master: true
node.data: true
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 172.17.63.15
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.zen.ping.unicast.hosts: ["172.17.63.15:9300", "172.17.63.15:9301", "172.17.63.15:9302"]
[payment@gameServer ~]$ grep '^[a-z]'  elasticSearch/elasticsearch-6.2.4-2/config/elasticsearch.yml
cluster.name: dev_elastic_cluster
node.name: node-2
node.master: true
node.data: true
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 172.17.63.15
http.port: 9201
transport.tcp.port: 9301
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.zen.ping.unicast.hosts: ["172.17.63.15:9300", "172.17.63.15:9301", "172.17.63.15:9302"]
[payment@gameServer ~]$ grep '^[a-z]'  elasticSearch/elasticsearch-6.2.4-3/config/elasticsearch.yml
cluster.name: dev_elastic_cluster
node.name: node-3
node.master: true
node.data: true
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 172.17.63.15
http.port: 9202
transport.tcp.port: 9302
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.zen.ping.unicast.hosts: ["172.17.63.15:9300", "172.17.63.15:9301", "172.17.63.15:9302"]

五、啓動集羣

1、啓動三個節點

  /home/payment/elasticSearch/elasticsearch-6.2.4-1/bin/elasticsearch -d
  /home/payment/elasticSearch/elasticsearch-6.2.4-2/bin/elasticsearch -d
  /home/payment/elasticSearch/elasticsearch-6.2.4-3/bin/elasticsearch -d

2、監聽日誌:

監聽elasticSearch安裝目錄下logs文件夾下的日誌文件(集羣名.log)

[payment@gameServer logs]$ tail -f ~/elasticSearch/elasticsearch-6.2.4-1/logs/dev_elastic_cluster.log 
[2018-06-06T14:23:58,818][INFO ][o.e.n.Node               ] [node-1] initializing ...
[2018-06-06T14:23:58,986][INFO ][o.e.e.NodeEnvironment    ] [node-1] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [402.7gb], net total_space [442.7gb], types [rootfs]
[2018-06-06T14:23:58,986][INFO ][o.e.e.NodeEnvironment    ] [node-1] heap size [990.7mb], compressed ordinary object pointers [true]
[2018-06-06T14:23:58,987][INFO ][o.e.n.Node               ] [node-1] node name [node-1], node ID [QCOxIqY7Tua3gFpNeUiupA]
[2018-06-06T14:23:58,988][INFO ][o.e.n.Node               ] [node-1] version[6.2.4], pid[30202], build[ccec39f/2018-04-12T20:37:28.497551Z], OS[Linux/2.6.32-696.28.1.el6.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_161/25.161-b12]
[2018-06-06T14:23:58,988][INFO ][o.e.n.Node               ] [node-1] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/tmp/elasticsearch.RExwmCgI, -XX:+HeapDumpOnOutOfMemoryError, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Des.path.home=/home/payment/elasticSearch/elasticsearch-6.2.4-1, -Des.path.conf=/home/payment/elasticSearch/elasticsearch-6.2.4-1/config]
[2018-06-06T14:23:59,596][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [aggs-matrix-stats]
[2018-06-06T14:23:59,596][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [analysis-common]
[2018-06-06T14:23:59,596][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [ingest-common]
[2018-06-06T14:23:59,596][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-expression]
[2018-06-06T14:23:59,596][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-mustache]
[2018-06-06T14:23:59,596][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-painless]
[2018-06-06T14:23:59,596][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [mapper-extras]
[2018-06-06T14:23:59,596][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [parent-join]
[2018-06-06T14:23:59,596][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [percolator]
[2018-06-06T14:23:59,596][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [rank-eval]
[2018-06-06T14:23:59,596][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [reindex]
[2018-06-06T14:23:59,596][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [repository-url]
[2018-06-06T14:23:59,597][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [transport-netty4]
[2018-06-06T14:23:59,597][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [tribe]
[2018-06-06T14:23:59,597][INFO ][o.e.p.PluginsService     ] [node-1] loaded plugin [analysis-ik]
[2018-06-06T14:24:02,376][INFO ][o.e.d.DiscoveryModule    ] [node-1] using discovery type [zen]
[2018-06-06T14:24:02,907][INFO ][o.e.n.Node               ] [node-1] initialized
[2018-06-06T14:24:02,907][INFO ][o.e.n.Node               ] [node-1] starting ...
[2018-06-06T14:24:03,150][INFO ][o.e.t.TransportService   ] [node-1] publish_address {172.17.63.15:9300}, bound_addresses {172.17.63.15:9300}
[2018-06-06T14:24:03,158][INFO ][o.e.b.BootstrapChecks    ] [node-1] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2018-06-06T14:24:06,235][INFO ][o.e.c.s.MasterService    ] [node-1] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {node-1}{QCOxIqY7Tua3gFpNeUiupA}{XNjZ-E_tQ--mPyFZi9E2eA}{172.17.63.15}{172.17.63.15:9300}
[2018-06-06T14:24:06,240][INFO ][o.e.c.s.ClusterApplierService] [node-1] new_master {node-1}{QCOxIqY7Tua3gFpNeUiupA}{XNjZ-E_tQ--mPyFZi9E2eA}{172.17.63.15}{172.17.63.15:9300}, reason: apply cluster state (from master [master {node-1}{QCOxIqY7Tua3gFpNeUiupA}{XNjZ-E_tQ--mPyFZi9E2eA}{172.17.63.15}{172.17.63.15:9300} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]])
[2018-06-06T14:24:06,273][INFO ][o.e.h.n.Netty4HttpServerTransport] [node-1] publish_address {172.17.63.15:9200}, bound_addresses {172.17.63.15:9200}
[2018-06-06T14:24:06,273][INFO ][o.e.n.Node               ] [node-1] started
[2018-06-06T14:24:06,395][INFO ][o.e.g.GatewayService     ] [node-1] recovered [0] indices into cluster_state
[2018-06-06T14:24:11,182][INFO ][o.e.c.s.MasterService    ] [node-1] zen-disco-node-join[{node-2}{Q3m2buqsQ7O3RDOabPng6g}{v8PAwZFjT-OGbCbdsazLpA}{172.17.63.15}{172.17.63.15:9301}], reason: added {{node-2}{Q3m2buqsQ7O3RDOabPng6g}{v8PAwZFjT-OGbCbdsazLpA}{172.17.63.15}{172.17.63.15:9301},}
[2018-06-06T14:24:11,381][INFO ][o.e.c.s.ClusterApplierService] [node-1] added {{node-2}{Q3m2buqsQ7O3RDOabPng6g}{v8PAwZFjT-OGbCbdsazLpA}{172.17.63.15}{172.17.63.15:9301},}, reason: apply cluster state (from master [master {node-1}{QCOxIqY7Tua3gFpNeUiupA}{XNjZ-E_tQ--mPyFZi9E2eA}{172.17.63.15}{172.17.63.15:9300} committed version [3] source [zen-disco-node-join[{node-2}{Q3m2buqsQ7O3RDOabPng6g}{v8PAwZFjT-OGbCbdsazLpA}{172.17.63.15}{172.17.63.15:9301}]]])
[2018-06-06T14:24:11,385][WARN ][o.e.d.z.ElectMasterService] [node-1] value for setting "discovery.zen.minimum_master_nodes" is too low. This can result in data loss! Please set it to at least a quorum of master-eligible nodes (current value: [-1], total number of master-eligible nodes used for publishing in this round: [2])
[2018-06-06T14:24:14,698][INFO ][o.e.c.s.MasterService    ] [node-1] zen-disco-node-join[{node-3}{WdB0vdTWTK2Xb_-Ixl6R0Q}{JXU3ZRdWTdSaVN_LDgmj_w}{172.17.63.15}{172.17.63.15:9302}], reason: added {{node-3}{WdB0vdTWTK2Xb_-Ixl6R0Q}{JXU3ZRdWTdSaVN_LDgmj_w}{172.17.63.15}{172.17.63.15:9302},}
[2018-06-06T14:24:14,904][INFO ][o.e.c.s.ClusterApplierService] [node-1] added {{node-3}{WdB0vdTWTK2Xb_-Ixl6R0Q}{JXU3ZRdWTdSaVN_LDgmj_w}{172.17.63.15}{172.17.63.15:9302},}, reason: apply cluster state (from master [master {node-1}{QCOxIqY7Tua3gFpNeUiupA}{XNjZ-E_tQ--mPyFZi9E2eA}{172.17.63.15}{172.17.63.15:9300} committed version [4] source [zen-disco-node-join[{node-3}{WdB0vdTWTK2Xb_-Ixl6R0Q}{JXU3ZRdWTdSaVN_LDgmj_w}{172.17.63.15}{172.17.63.15:9302}]]])

上面日誌中 看到 

zen-disco-node-join[{node-2}{Q3m2buqsQ7O3RDOabPng6g}{v8PAwZFjT-OGbCbdsazLpA}{172.17.63.15}{172.17.63.15:9301}], reason: added {{node-2}{Q3m2buqsQ7O3RDOabPng6g}{v8PAwZFjT-OGbCbdsazLpA}{172.17.63.15}{172.17.63.15:9301},}
表示集羣中加入了節點、如果沒有自動加入節點、請檢查es目錄下data中是否清空 不清空會無法加入

3、檢測每個節點的啓動狀態
[payment@gameServer logs]$ curl "172.17.63.15:9200"
{
  "name" : "node-1",
  "cluster_name" : "dev_elastic_cluster",
  "cluster_uuid" : "_iUYTJZpQUGDadjbiDtzaw",
  "version" : {
    "number" : "6.2.4",
    "build_hash" : "ccec39f",
    "build_date" : "2018-04-12T20:37:28.497551Z",
    "build_snapshot" : false,
    "lucene_version" : "7.2.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}
[payment@gameServer logs]$ curl "172.17.63.15:9201"
{
  "name" : "node-2",
  "cluster_name" : "dev_elastic_cluster",
  "cluster_uuid" : "_iUYTJZpQUGDadjbiDtzaw",
  "version" : {
    "number" : "6.2.4",
    "build_hash" : "ccec39f",
    "build_date" : "2018-04-12T20:37:28.497551Z",
    "build_snapshot" : false,
    "lucene_version" : "7.2.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}
[payment@gameServer logs]$ curl "172.17.63.15:9202"
{
  "name" : "node-3",
  "cluster_name" : "dev_elastic_cluster",
  "cluster_uuid" : "_iUYTJZpQUGDadjbiDtzaw",
  "version" : {
    "number" : "6.2.4",
    "build_hash" : "ccec39f",
    "build_date" : "2018-04-12T20:37:28.497551Z",
    "build_snapshot" : false,
    "lucene_version" : "7.2.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}
[payment@gameServer logs]$ 

4、查看集羣狀態

[payment@gameServer logs]$ curl "172.17.63.15:9200/_cat/health?v"
epoch      timestamp cluster             status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1528502937 08:08:57  dev_elastic_cluster green           3         3     0   0    0    0        0             0                  -                100.0%
能看到 node.total 和 node.data 的數量OK即集羣配置OK




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章