elasticsearch-6.7.1叢集搭建

z597011036發表於2019-04-10

elasticsearch下載地址:ttps://github.com/elastic/elasticsearch/releases

ik下載地址:


1.下載解壓es和jdk包

[root@node1 ~]# wget

[root@node1 ~]# tar xvf elasticsearch-6.7.1.tar.gz -C /opt/

[root@node1 ~]# wget

[root@node1 ~]# scp jdk-8u202-linux-x64.rpm  node2:/root/    --將jdk傳到各節點上

[root@node1 ~]# scp jdk-8u202-linux-x64.rpm  node3:/root/    --將jdk傳到各節點上

[root@node1 ~]# rpm -ivh jdk-8u202-linux-x64.rpm             --在各節點安裝jdk

[root@node1 ~]# cd /opt/elasticsearch-6.7.1/

[root@node1 elasticsearch-6.7.1]# useradd wuhan     --建立es使用者,es不能用root使用者啟動

[root@node1 elasticsearch-6.7.1]# passwd wuhan

更改使用者 wuhan 的密碼 。

新的 密碼:

無效的密碼: 密碼少於 8 個字元

重新輸入新的 密碼:

passwd:所有的身份驗證令牌已經成功更新。

[root@node1 elasticsearch-6.7.1]# chown -R wuhan:wuhan /opt/elasticsearch-6.7.1/

[root@node1 elasticsearch-6.7.1]# vim /etc/security/limits.conf 

*      soft    nofile    65535

*      hard    nofile    65535

[root@node1 elasticsearch-6.7.1]# vim /etc/sysctl.conf 

vm.max_map_count=262144

[root@node1 elasticsearch-6.7.1]# sysctl -p

[root@node1 elasticsearch-6.7.1]# vim /opt/elasticsearch-6.7.1/config/elasticsearch.yml

cluster.name: wuhan     --設定叢集節點名

node.name: node-1       --為每臺機器設定node名字,各節點名字不能一樣

path.data: /opt/elasticsearch-6.7.1/data    --es資料目錄

path.logs: /opt/elasticsearch-6.7.1/logs    --日誌目錄

discovery.zen.ping.unicast.hosts: ["node1", "node2", "node3", "node4"]

network.host: 172.16.8.23    --繫結本機的IP地址

http.port: 9200              --指定埠

[root@node1 elasticsearch-6.7.1]#


2.將node1的es檔案複製到其它節點(與node1配置一樣)

[root@node1 opt]# scp -r elasticsearch-6.7.1 node2:/opt/

[root@node1 opt]# scp -r elasticsearch-6.7.1 node3:/opt/

[root@node2 ~]# chown -R wuhan:wuhan /opt/elasticsearch-6.7.1/

[root@node2 ~]# vim /etc/security/limits.conf 

*      soft    nofile    65535

*      hard    nofile    65535

[root@node2 ~]# vim /etc/sysctl.conf

vm.max_map_count=262144

[root@node2 ~]# sysctl -p


3.啟動各節點的es服務

[root@node1 ~]# su - wuhan 

[wuhan@node1 ~]$ cd /opt/elasticsearch-6.7.1/bin/

[wuhan@node1 bin]$ ./elasticsearch -d

[wuhan@node1 bin]# curl

{

  "name" : "node-1",

  "cluster_name" : "wuhan",

  "cluster_uuid" : "_na_",

  "version" : {

    "number" : "6.7.1",

    "build_flavor" : "default",

    "build_type" : "tar",

    "build_hash" : "2f32220",

    "build_date" : "2019-04-02T15:59:27.961366Z",

    "build_snapshot" : false,

    "lucene_version" : "7.7.0",

    "minimum_wire_compatibility_version" : "5.6.0",

    "minimum_index_compatibility_version" : "5.0.0"

  },

  "tagline" : "You Know, for Search"

}

[wuhan@node1 bin]# 


4.安裝head外掛

[root@node1 ~]$ wget

[root@node1 ~]$ tar xvf node-v11.13.0-linux-x64.tar.xz 

[root@node1 ~]$ mv node-v11.13.0-linux-x64 /opt/node-v11.13.0

[root@node1 ~]$ vim /etc/profile

export PATH=$PATH:/opt/node-v11.13.0/bin

[root@node1 ~]$ git clone git://github.com/mobz/elasticsearch-head.git

[root@node1 ~]# cd elasticsearch-head/

[root@node1 elasticsearch-head]# npm  install

npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):

npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 9 packages from 13 contributors and audited 1853 packages in 157.775s

found 33 vulnerabilities (19 low, 8 moderate, 6 high)

  run `npm audit fix` to fix them, or `npm audit` for details

[root@node1 elasticsearch-head]# npm run start

> elasticsearch-head@0.0.0 start /root/elasticsearch-head

> grunt server

Running "connect:server" (connect) task

Waiting forever...

Started connect web server on


5.修改es配置檔案,重啟服務

[wuhan@node1 bin]# vim /opt/elasticsearch-6.7.1/config/elasticsearch.yml 

http.cors.enabled: true 

http.cors.allow-origin: "*"

[wuhan@node1 bin]$ jps

17849 Elasticsearch

17935 Jps

[wuhan@node1 bin]$ kill -9 17849

[wuhan@node1 bin]$ cd /opt/elasticsearch-6.7.1/bin

[wuhan@node1 bin]$ ./elasticsearch -d


6.訪問web頁面

[root@node1 elasticsearch-head]# grunt server &

[1] 20212

[root@node1 elasticsearch-head]# 


錯誤提示:

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! phantomjs-prebuilt@2.1.16 install: `node install.js`

npm ERR! Exit status 1

npm ERR! 

npm ERR! Failed at the phantomjs-prebuilt@2.1.16 install script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR!     /root/.npm/_logs/2019-04-09T11_24_27_132Z-debug.log


解決方法:

[root@node1 elasticsearch-head]# npm install phantomjs-prebuilt@2.1.16 --ignore-scripts

npm notice created a lockfile as package-lock.json. You should commit this file.

npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):

npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ phantomjs-prebuilt@2.1.16

added 62 packages from 64 contributors, removed 4 packages and audited 1717 packages in 20.487s

found 31 vulnerabilities (18 low, 7 moderate, 6 high)

  run `npm audit fix` to fix them, or `npm audit` for details

[root@node1 elasticsearch-head]#


錯誤提示:

[2019-04-10T14:42:30,931][ERROR][o.e.b.Bootstrap          ] [node-1] Exception

java.lang.IllegalArgumentException: Plugin [analysis-ik] was built for Elasticsearch version 6.7.0 but version 6.7.1 is running

        at org.elasticsearch.plugins.PluginsService.verifyCompatibility(PluginsService.java:346) ~[elasticsearch-6.7.1.jar:6.7.1]

        at org.elasticsearch.plugins.PluginsService.loadBundle(PluginsService.java:531) ~[elasticsearch-6.7.1.jar:6.7.1]

        at org.elasticsearch.plugins.PluginsService.loadBundles(PluginsService.java:471) ~[elasticsearch-6.7.1.jar:6.7.1]

        at org.elasticsearch.plugins.PluginsService.<init>(PluginsService.java:163) ~[elasticsearch-6.7.1.jar:6.7.1]

        at org.elasticsearch.node.Node.<init>(Node.java:339) ~[elasticsearch-6.7.1.jar:6.7.1]

        at org.elasticsearch.node.Node.<init>(Node.java:266) ~[elasticsearch-6.7.1.jar:6.7.1]


解決方法:

ES和ik版本必須一至,否則會出錯


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25854343/viewspace-2640895/,如需轉載,請註明出處,否則將追究法律責任。

相關文章