Elasticsearch 下載
https://www.elastic.co/downloads/elasticsearch
ik分詞器下載
https://github.com/medcl/elasticsearch-analysis-ik/releases
1. tar zxvf elasticsearch-6.5.0.tar.gz //解壓
2. rm elasticsearch-6.5.0.tar.gz //刪除
3. mv elasticsearch-6.5.0 elasticsearch //重命名
4. groupadd elsearch //組的添加
5. useradd elsearch -g elsearch //用戶
6. chown -R elsearch:elsearch elasticsearch //更改該elasticsearch文件夾下所屬的用戶 和 用戶組
7. mkdir /data/es
8. chown -R elsearch:elsearch /data/es
9. su elsearch
10. mkdir es/data
11. mkdir es/logs
12. 修改elasticsearch.yml 文件如下
cat /usr/local/elasticsearch/config/elasticsearch.yml |grep ^[^#]
cluster.name: my-es //集羣名字
node.name: node-1
path.data: /data/es/data
path.logs: /data/es/logs
bootstrap.memory_lock: false
bootstrap.system_call_filter: false //新增配置
network.host: 192.168.0.33
http.port: 9200
====集羣配置==== vim config/elasticsearch.yml
<code>cluster.name: lcc-application # 必須一樣
node.name: node-191-168-10-175 # 必須不一樣
path.data: /home/es/elasticsearch/elasticsearch-6.2.0_data/data/
path.logs: /home/es/elasticsearch/elasticsearch-6.2.0_data/logs/
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 0.0.0.0 //0爲允許遠程訪問
http.port: 9200
# 集羣發現
#集羣節點ip或者主機
discovery.zen.ping.unicast.hosts: ["192.168.10.173", "192.168.10.174","192.168.10.175"]
#設置這個參數來保證集羣中的節點可以知道其它N個有master資格的節點。默認爲1,對於大的集羣來說,可以設置大一點的值(2-4)
discovery.zen.minimum_master_nodes: 3
# 下面兩行配置爲haad插件配置,三臺服務器一致。
http.cors.enabled: true
http.cors.allow-origin: "*"
==== ====
12.1 報錯:ERROR: [1] bootstrap checks failed
[1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
修復: elasticsearch.yml中增加配置 cluster.initial_master_nodes: ["node-1"]
13. ./elasticsearch/bin/elasticsearch -d //啓動 -d後臺啓動
啓動後會報:
ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [3802] for user [elsearch] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
14. 問題[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
vi /etc/security/limits.conf //修改此文件後是立即生效的,或者重新登錄elsearch用戶
添加如下內容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
說明:* 代表針對所有用戶
noproc 是代表最大進程數
nofile 是代表最大文件打開數
有soft,hard以及-,
soft指的是當前系統生效的設置值。
hard 表明系統中所能設定的最大值。soft的限制不能比hard限制高。
用-就表明同時設置了soft和hard的值。
問題[2]: max number of threads [3802] for user [elsearch] is too low, increase to at least [4096]
修改文件
vim /etc/security/limits.d/20-nproc.conf
* soft nproc 4096 //改爲4096
15. 問題[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
並執行命令:使用下面的命令確認
sysctl -p
16.臨時關閉Selinux
setenforce 0 //關閉Selinux
#停止firewalld服務
systemctl stop firewalld
17.ie訪問
http://192.168.0.34:9200/
18.關閉es :
1種:ps -ef | grep elastic
kill -9 2382
2種:CTRL+C組合鍵 //不能用ctrl+z
3種:通過發送TERM信號終止服務器進程.
4種:使用REST APIcurl -XPOST 'http://localhost:9200/_shutdown'.
安裝ik分詞器
1. 下載ik 的zip包,zip包不用編譯,tar.gz包需要編譯
https://github.com/medcl/elasticsearch-analysis-ik/releases/
2. 下載elasticsearch-analysis-ik-6.5.0.zip到elasticsearch/plugins/ik目錄下 目錄ik要自己新建
3. 解壓zip到ik目錄下: unzip elasticsearch-analysis-ik-6.5.0.zip
4. 正常啓動es
配置默認分詞器爲 ik,並指定分詞器爲 ik_max_word。
index.analysis.analyzer.default.tokenizer : "ik_max_word"
index.analysis.analyzer.default.type: "ik"
然後重啓 ES 即可。驗證 IK 是否成功安裝,訪問下
localhost:9200/_analyze?analyzer=ik&pretty=true&text=中華人民共和國
安裝kibana
1. 下載https://www.elastic.co/cn/downloads/kibana 版本要和es版本相同
2. 直接解壓到 /usr/local/elasticsearch/kibana-6.2.2-linux-x86_64
3. 配置
# vim /usr/local/elasticsearch/kibana/config/kibana.yml
server.port: 5601 # kibana運行的端口號
server.host: "192.168.0.34" # kibana運行在哪臺機器,如:0.0.0.0允許遠程訪問
elasticsearch.url: "https://192.168.0.34:9200" # kibana監控哪臺es機器
4.啓動# /usr/local/elasticsearch/kibana/bin/kibana
5.查看界面https://192.168.0.34:5601 可以直接訪問