安裝elasticsearch5.4.1集群和head插件


這里用的系統版本是CentOS6.6。

192.168.3.56    ES01
192.168.3.49    ES02
192.168.3.57    ES03

1、為三個節點安裝java環境

# yum install -y java java-1.8.0-openjdk-devel
# vim /etc/profile.d/java.sh
export JAVA_HOME=/usr
# source /etc/profile.d/java.sh

2、同步時間

# ntpdate pool.ntp.org

3、上官網下載rpm包,或者按照guide設置官方repo,分別為三個節點安裝ES

# yum install -y elasticsearch-5.4.1.rpm

https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html

4、修改配置文件

節點1,ES01:

# vim /etc/elasticsearch/elasticsearch.yml
cluster.name: oupenges
node.name: es01
bootstrap.system_call_filter: false
http.cors.enabled: true
http.cors.allow-origin: "*"
bootstrap.memory_lock: true
network.host: 192.168.3.56
discovery.zen.ping.unicast.hosts: ["192.168.3.56", "192.168.3.49", "192.168.3.57"]

節點2,ES02:

# vim /etc/elasticsearch/elasticsearch.yml
cluster.name: oupenges
node.name: es02
bootstrap.system_call_filter: false
http.cors.enabled: true
http.cors.allow-origin: "*"
bootstrap.memory_lock: true
network.host: 192.168.3.49
discovery.zen.ping.unicast.hosts: ["192.168.3.56", "192.168.3.49", "192.168.3.57"]

節點3,ES03:

# vim /etc/elasticsearch/elasticsearch.yml
cluster.name: oupenges
node.name: es03
bootstrap.system_call_filter: false
http.cors.enabled: true
http.cors.allow-origin: "*"
bootstrap.memory_lock: true
network.host: 192.168.3.57
discovery.zen.ping.unicast.hosts: ["192.168.3.56", "192.168.3.49", "192.168.3.57"]

兩個http參數的含義可以參考這里:
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-http.html

5、修改limits.conf,系統默認的1024太小,這里需要至少2048才能啟動服務

# vim /etc/security/limits.conf
*               hard    nofile  65536
*               soft    nofile  65536
*               hard    memlock unlimited
*               soft    memlock unlimited
elasticsearch   hard    nproc   514834
elasticsearch   soft    nproc   514834

https://www.elastic.co/guide/en/elasticsearch/reference/current/setting-system-settings.html#limits.conf
https://www.elastic.co/guide/en/elasticsearch/reference/current/_memory_lock_check.html

6、啟動服務

# service elasticsearch start
# chkconfig elasticsearch on

7、通過cluster API查看集群狀態:

# curl -XGET 'http://192.168.3.56:9200/_cluster/health?pretty=true'
{
  "cluster_name" : "oupenges",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 3,
  "number_of_data_nodes" : 3,
  "active_primary_shards" : 71,
  "active_shards" : 142,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}

8、安裝head插件(需要事先安裝nodejs和phantomjs,這里只說一下phantomjs)

安裝phantomjs:

# wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
# tar xvf phantomjs-2.1.1-linux-x86_64.tar.bz2
# cd phantomjs-2.1.1-linux-x86_64/
# ln -sv /root/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/bin/

運行head:

# git clone https://github.com/mobz/elasticsearch-head.git
# cd elasticsearch-head/

# npm install
# nohup npm run start &

默認監聽9100端口,用瀏覽器訪問:http://192.168.3.56:9100/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM