Linux用戶登陸(bae),咱們用的是5.3版本的包。從官網下載:java
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.3.0.tar.gz
解壓後,進入到bin目錄下,使用 ./elasticsearch 命令啓動,看到以下的提示,即爲啓動成功。端口號9200.node
1.記住不要在root下啓動,不然會報錯:can not run elasticsearch as rootgit
2.若是是在root下下載的elasticsearch,可能會報下面的錯誤:github
main ERROR Could not register mbeans Java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
【解決】:改變elasticsearch文件夾全部者到當前用戶bootstrap
sudo chown -R bae:bae elasticsearch
3. jdk的版本要在1.8以上api
4.錯誤:cookie
ERROR: bootstrap checks failed max file descriptors [10240] for elasticsearch process is too low, increase to at least [65536] system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk [2017-05-09T21:34:03,914][INFO ][o.e.n.Node ] [m1-hic-ssd-bae03] stopping ... [2017-05-09T21:34:03,946][INFO ][o.e.n.Node ] [m1-hic-ssd-bae03] stopped [2017-05-09T21:34:03,946][INFO ][o.e.n.Node ] [m1-hic-ssd-bae03] closing ... [2017-05-09T21:34:03,960][INFO ][o.e.n.Node ] [m1-hic-ssd-bae03] closed
【解決方法】:負載均衡
切換到root用戶, vi /etc/security/limits.confcurl
添加以下內容:elasticsearch
* soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096
#下面的work是用戶名,用哪一個用戶啓動es,就配置成對應的用戶名
work soft memlock unlimited
work hard memlock unlimited
vi /etc/security/limits.d/90-nproc.conf
修改以下內容: * soft nproc 1024
#修改成 * soft nproc 2048
vi /etc/sysctl.conf
添加下面配置:vm.max_map_count=655360
並執行命令: sysctl -p
執行上述sysctl -p命令可能會遇到以下錯誤:
net.ipv4.ip_forward = 0 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 kernel.sysrq = 0 kernel.core_uses_pid = 1 net.ipv4.tcp_syncookies = 1 error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key error: "net.bridge.bridge-nf-call-iptables" is an unknown key error: "net.bridge.bridge-nf-call-arptables" is an unknown key kernel.msgmnb = 65536 kernel.msgmax = 65536 kernel.shmmax = 68719476736 kernel.shmall = 4294967296
錯誤的緣由是3個bridge模塊未加載。能夠先執行命令,
modprobe bridge
而後再執行sysctl -p命令
重啓elasticsearch。此處備註一下es的啓動,能夠在bin目錄下直接執行./elasticsearch,可是有一個問題,終端關閉以後,elasticsearch這個進程就被殺掉了。此時,可使用以下命令啓動
nohup ./elasticsearch &
5. 報錯:
ERROR: bootstrap checks failed
system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
【解決】:
在elasticsearch.yml中配置bootstrap.system_call_filter爲false,注意要在Memory下面:
bootstrap.memory_lock: false bootstrap.system_call_filter: false
【錯誤緣由】:
這是在由於Centos6不支持SecComp,而ES5.2.0默認bootstrap.system_call_filter爲true進行檢測,因此致使檢測失敗,失敗後直接致使ES不能啓動。
多機集羣中的節點能夠分爲master nodes和data nodes,在配置文件中使用Zen發現(Zen discovery)機制來管理不一樣節點。Zen發現是ES自帶的默認發現機制,使用多播發現其它節點。只要啓動一個新的ES節點並設置和集羣相同的名稱這個節點就會被加入到集羣中。
Elasticsearch集羣中有的節點通常有三種角色:master node、data node和client node。
咱們選m1這臺機器做爲client node,elasticsearch.yml中的配置以下:
cluster.name: mkt-es-cluster node.name: ${HOSTNAME} network.host: 0.0.0.0 discovery.zen.ping.unicast.hosts: ["10.**.**.**"]
在m2上配置elasticsearch.yml:
cluster.name: mkt-es-cluster node.name: ${HOSTNAME} network.host: 0.0.0.0 discovery.zen.ping.unicast.hosts: ["10.**.**.**"]
咱們在任意一臺機器上請求:curl 'localhost:9200/_cat/health?v'
咱們能夠看到,標誌着集羣狀態的status顯示爲green,節點個數爲2個。
1.下載安裝包https://github.com/medcl/elasticsearch-analysis-ik/releases
有針對不一樣es版本的安裝包,須要下載與所安裝的es版本匹配的安裝包。咱們仍是用5.3.0版本.zip格式的好了。
2.在elasticsearch/plugins目錄下新建ik目錄,將zip包拷貝到ik目錄下,解壓。
3.重啓elasticsearch
4.注意事項:若是是搭建的集羣,須要在每一個節點下都安裝ik
5.調用下面的url
GET _analyze { "analyzer":"ik_max_word", "text":"中華人民共和國國歌" }
會獲得下面結果:
{ "tokens": [ { "token": "中華人民共和國", "start_offset": 0, "end_offset": 7, "type": "CN_WORD", "position": 0 }, { "token": "中華人民", "start_offset": 0, "end_offset": 4, "type": "CN_WORD", "position": 1 }, { "token": "中華", "start_offset": 0, "end_offset": 2, "type": "CN_WORD", "position": 2 }, { "token": "華人", "start_offset": 1, "end_offset": 3, "type": "CN_WORD", "position": 3 }, { "token": "人民共和國", "start_offset": 2, "end_offset": 7, "type": "CN_WORD", "position": 4 }, { "token": "人民", "start_offset": 2, "end_offset": 4, "type": "CN_WORD", "position": 5 }, { "token": "共和國", "start_offset": 4, "end_offset": 7, "type": "CN_WORD", "position": 6 }, { "token": "共和", "start_offset": 4, "end_offset": 6, "type": "CN_WORD", "position": 7 }, { "token": "國", "start_offset": 6, "end_offset": 7, "type": "CN_CHAR", "position": 8 }, { "token": "國歌", "start_offset": 7, "end_offset": 9, "type": "CN_WORD", "position": 9 } ] }
或者經過postman採用這種方式:hz01-bae3-rdtest00.hz01.baidu.com:8920/_analyze?analyzer=ik_max_word&text= 我是好人
問題表現:請求es機器集羣信息:http://*******.com:8920/_cluster/health?pretty
可是kibana上面status確實red,重啓都不行。顯示以下:
先恢復一下數據吧,參照下面連接:
https://stackoverflow.com/questions/42376101/getting-plugin-is-red-error-when-launching-kibana
刪掉es的每一個節點下data/es/ 裏面的全部數據,重啓每一個節點。就ok了。
具體緣由參考下面連接:(其實就是我不知道怎麼的吧.kibana這個索引刪掉了)
https://stackoverflow.com/questions/31201051/elasticsearch-is-still-initializing-the-kibana-index