elasticsearch5.6.8安裝和配置


index(索引庫) type(類型) _id(文檔) 基於RESTful風格的索引庫

put localhost:9200/tensquare_elasticsearch 增加index庫
post localhost:9200/tensquare_elasticsearch/article 增加type類型json數據
get localhost:9200/tensquare_elasticsearch/article/_search 查詢所有type類型數據
put localhost:9200/tensquare_elasticsearch/article/AWpnv2jwq3Et8kEDbn2C 按_id修改文檔
put localhost:9200/tensquare_elasticsearch/article/222 如果沒有該_id則增加此_Id文檔
get localhost:9200/tensquare_elasticsearch/article/222 按_id查找文檔
get localhost:9200/tensquare_elasticsearch/article/_search?q=title:*s* 按_id模糊詞條查找文檔(英文按詞模糊,中文按單個漢字模糊,所以需要分詞)
delete localhost:9200/tensquare_elasticsearch/article/222 按_id刪除文檔

安裝elasticsearch-head-master插件圖形化
安裝node.js環境
安裝cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
將grunt命令設為全局命令
npm install -g grunt-cli
為elasticsearch-head-master插件安裝package.json依賴(需要在pacjage.json目錄下)
cnpm install
啟動插件訪問localhost:9100即可(需要在pacjage.json目錄下)
grunt server

安裝ik分詞器 解壓后直接放到elasticsearch的plugins插件文件夾中即可
測試 最細粒度
http://localhost:9200/_analyze?analyzer=ik_max_word&pretty=true&text=我是程序員
測試 最少分
http://localhost:9200/_analyze?analyzer=ik_smart&pretty=true&text=我是程序員
增加詞條 在ik config下增加文件custom.dic第一行空 第二行加空格 添加詞條保存為UTF-8編碼重啟elasticsearch即可

logstash -f ../mysqletc/mysql.conf 同步數據庫 默認每分鍾更新一次
------------------------------------------------------------------------------------
linux版
cd /home/wuyou/elasticsearch-5.6.8/config
vi jvm.options
-Xms256m
-Xmx256m
vi elasticsearch.yml
path.data: /home/wuyou/elasticsearch-5.6.8/data
path.logs: /home/wuyou/elasticsearch-5.6.8/log

#允許任何主機訪問
network.host: 0.0.0.0
如果centos版本過低 在最后加上
bootstrap.system_call_filter: false
如果進程描述符過低
vi /etc/security/limits.conf
添加內容
* soft nofile 65536
* hard nofile 131072
* soft nproc 4096
* hard nproc 4096
如果還報錯
vi /etc/sysctl.conf
添加
vm.max_map_count=655360
然后執行
sysctl -p
最后重啟配置才能生效
elasticsearch默認不允許root用戶啟動 需要更改文件夾所屬用戶和所屬組
要安裝使用head插件還需要修改配置文件
vi elasticsearch.yml
在文件最末尾添加允許跨域
http.cors.enabled: true
http.cors.allow-origin: "*"


免責聲明!

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



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