搭建ELASTICSEARCH實現中文分詞搜索功能
安裝ELASTICSERARCH
yum install bzip2 automake libtool gcc-c++ java-1.8.0-openjdk -y
mkdir -p /home/ELK/e
mkdir /home/ELK/e/{data,logs}
useradd elk
tar zxvf elasticsearch-5.5.0.tar.gz
mv elasticsearch-5.5.0 /home/ELK/e/
cd /home/ELK/e/elasticsearch-5.5.0/
vim config/elasticsearch.yml
#修改配置文件以下內容
cluster.name: es_cluster #ES集群名稱
node.name: node-1 #這臺站點名稱
path.data: /home/ELK/e/data #數據存放路徑
path.logs: /home/ELK/e/logs #日誌存放路徑
network.host: 127.0.0.1 #綁定IP,也就是別人訪問ES的IP
http.port: 9200 #啟動的端口
#以ELK用戶啟動elasticsearch,如果以root帳號啟動會報錯
chown -R elk.elk /home/ELK/
nohup su elk -l -c /home/ELK/e/elasticsearch-5.5.0/bin/elasticsearch &
以上為elasticsearch安裝步驟。參考文章 http://mengphilip.blog.51cto.com/2243393/1690455
註意: es 必須用普通用戶啟動,不能用root 啟動,否則會報錯。
ERROR: bootstrap checks failed max file descriptors [10240] for elasticsearch process likely too low, increase to at least [65536] max number of threads [1024] for user [elsearch] likely too low, increase to at least [2048] max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144] [2016-11-14T10:22:17,569][INFO ][o.e.n.Node ] [mysteel-node1] stopping ... [2016-11-14T10:22:17,615][INFO ][o.e.n.Node ] [mysteel-node1] stopped [2016-11-14T10:22:17,615][INFO ][o.e.n.Node ] [mysteel-node1] closing ... [2016-11-14T10:22:17,638][INFO ][o.e.n.Node ] [mysteel-node1] closed
出現上面這個錯誤的時候,修改
解決:切換到root用戶,編輯limits.conf 添加類似如下內容
vi /etc/security/limits.conf
添加如下內容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
問題三:max number of threads [1024] for user [lish] likely too low, increase to at least [2048]
解決:切換到root用戶,進入limits.d目錄下修改配置文件。
vi /etc/security/limits.d/90-nproc.conf
修改如下內容:
* soft nproc 1024
#修改為
* soft nproc 2048
問題四:max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
解決:切換到root用戶修改配置sysctl.conf
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
並執行命令:
sysctl -p
然後,重新啟動elasticsearch,即可啟動成功。
參考文章 http://www.cnblogs.com/sloveling/p/elasticsearch.html
下面先安裝 分詞器,下載地址 https://github.com/medcl/elasticsearch-analysis-ik/releases 我們選擇5.50版本的,和ELASTICSEARCH對應的版本
建立ik目錄 /home/ELK/e/elasticsearch-5.5.0/plugins/ik 將elasticsearch-analysis-ik上傳到這個目錄解壓
重啟elasticsearch即可
驗證
curl -XGET ‘http://192.168.153.128:9200/_analyze?pretty&analyzer=ik_max_word‘ -d ‘我是中國人‘
這樣分詞搜索功能就實現了。參考文章 http://blog.csdn.net/haoxiaoyan/article/details/54668924
搭建ELASTICSEARCH實現中文分詞搜索功能