centos 6.5安裝Elasticsearch 5.6.3集羣和Head插件

LInux:
查看centos版本:lsb_release -a
CentOS release 6.5 (Final)

準備:
java安裝
yum list installed | grep java
yum -y list java*
yum install java-1.8.0-openjdk.x86_64

安裝:
cd /data
mkdir eshome
cd eshome
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.3.tar.gz
tar -xzvf elasticsearch-5.6.3.tar.gz
mv elasticsearch-5.6.3 elasticsearch
es 規定 root 用戶不能啓動 es,所以需要創建一個用戶來啓動 es
# 創建用戶名爲 es 的用戶
useradd es
# 設置 es 用戶的密碼
passwd es  
# 將 /data/eshome/elasticsearch 的擁有者設置爲 es
chown -R es:es /data/eshome/elasticsearch

編輯配置文件vi config/elasticsearch.yml
network.host: 你自己的服務器iphttp.port: 9200
切換到 es 用戶,啓動 es
su es
前臺啓動:./bin/elasticsearch
後臺啓動:./bin/elasticsearch -d
關閉後臺啓動:
ps -ef | grep elasticsearch kill -9
jps | grep Elasticsearch kill -9
如果啓動報錯請跳到後面看:啓動Elasticsearch常見問題

Head插件安裝
安裝nodejs
sudo yum install nodejs
npm安裝:
sudo yum install npm

安裝head插件:
cd elasticsearch
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
grunt安裝:
sudo npm install -g grunt-cli --registry=https://registry.npm.taobao.org (如果慢可用淘寶鏡像資源)
sudo npm install grunt --registry=https://registry.npm.taobao.org
grunt -version

npm install grunt-contrib-clean
npm install grunt-contrib-concat
npm install grunt-contrib-watch
npm install grunt-contrib-connect
npm install grunt-contrib-copy
npm install grunt-contrib-jasmine --registry=https://registry.npm.taobao.org (有個下載比較慢,失敗可以重試)

以下來源網上未驗證
npm install -g cnpm --registry=https://registry.npm.taobao.org (-g全局安裝,安裝淘寶鏡像)
在elasticsearch-head目錄下node_modules/grunt下如果沒有grunt二進制程序,需要執行:
cd elasticsearch-head
npm install grunt --save     

修改配置文件elasticsearch.yml:
vim config/elasticsearch.yml,修改爲以下內容:
cluster.name: xuedasearch
node.name: node-1
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["ip2", "ip3"]
bootstrap.system_call_filter: false
http.cors.enabled: true
http.cors.allow-origin: "*"
修改Gruntfile.js
打開vim elasticsearch-head/Gruntfile.js,找到下面connect屬性,新增hostname: '0.0.0.0',
connect: {
        server: {
            options: {
                hostname: '0.0.0.0',
                port: 9100,
                base: '.',
                keepalive: true
            }
        }
    }   
啓動elasticsearch-head
在elasticsearch-head目錄下,運行啓動命令:
cd elasticsearch-head
前臺啓動:grunt server
後臺啓動:nohup grunt server &
訪問:http://127.0.0.1:9100
關閉head插件:
ps aux|grep head
kill -9

啓動Elasticsearch常見問題:
問題:
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
解決方法:
#切換到root用戶修改vim /etc/security/limits.conf# 在最後面追加下面內容es hard nofile 65536es soft nofile 65536
修改後重新登錄 es 用戶,使用如下命令查看是否修改成功
ulimit -Hn65536

問題:
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解決方法: 提高vm.max_map_count 的大小
# 切換到root用戶vim /etc/sysctl.conf# 在最後面追加下面內容vm.max_map_count=262144# 使用 sysctl -p 查看修改後的結果sysctl -p

在阿里雲上可能出現的問題:
system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
解決方法:在es配置中加入下面命令即可vim config/elasticsearch.yml
bootstrap.system_call_filter: false

問題:max number of threads [1024] for user [es] is too low, increase to at least [2048]
解決方法:vi /etc/security/limits.d/90-nproc.conf ,修改配置如下:
*          soft    nproc     1024  
修改爲:  
*          soft    nproc     2048  

問題:
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
解決方法:
# 由於elasticsearch5.0默認分配jvm空間大小爲2g,修改jvm空間分配# 如果使用虛擬機安裝,內存最好不小於2G# vim config/jvm.options -Xms512m-Xmx512m


運維API:
1. 集羣狀態:http://host:9200/_cluster/health?pretty
2. 節點狀態:http://host:9200/_nodes/process?pretty
3. 分片狀態:http://host:9200/_cat/shards
4. 索引分片存儲信息:http://host:9200/index/_shard_stores?pretty
5. 索引狀態:http://host:9200/index/_stats?pretty
6. 索引元數據:http://host:9200/index?pretty




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