1. 程式人生 > >es6.3叢集安裝方法(elasticsearch)

es6.3叢集安裝方法(elasticsearch)

es6.3叢集安裝方法(elasticsearch)
(一)下載安裝包
elasticsearch-6.3.0.tar.gz
elasticsearch-analysis-ik-6.3.0.zip
下載地址:
https://www.elastic.co/cn/downloads/past-releases

https://github.com/medcl/elasticsearch-analysis-ik/tags?after=v6.3.0

(二)建立非root使用者es
es 不能在root使用者下啟動,所有需要新建立一個使用者es
useradd es
passwd es
1
如果是已經建好的目錄許可權是root
需要改目錄及子目錄的許可權
chown

es.es -R /usr/cwgis/app/es
chown es.es -R /usr/cwgis/data/es
(三)安裝es
安裝到目錄/usr/cwgis/app/es
資料和日誌目錄
/usr/cwgis/data/es/esdata
/usr/cwgis/data/es/eslog
解壓檔案
tar -zxvf elasticsearch-6.3.0.tar.gz
mv elasticsearch-6.3.0 es
配置引數檔案/es/config/elasticsearch.yml
主要新增如下內容:

cluster.name: es_sapsoft
node.name: node111     
#不同機子改為不同機器名或IP,如node112,node123,
#注意:冒號後面有一個空格
path.data: /usr/cwgis/data/es/esdata
path.logs: /usr/cwgis/data/es/eslog
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: node111     #不同機子改為不同機器名或IP
http.port: 9200
#9300為叢集服務的埠
discovery.zen.ping.unicast.hosts: ["node111", "node112", "node113", "node115", "node116", "node117", "node118", "node119", "node120", "node121", "node122", "node123"]
#為了避免stop,叢集節點數最少為 半數+1
discovery.zen.minimum_master_nodes: 7
http.cors.enabled: true  
http.cors.allow-origin: "*"

分發安裝目錄
cc.sh /usr/cwgis/app/es /usr/cwgis/app/ es
cc.sh /usr/cwgis/data/es /usr/cwgis/data/ es

(四)安裝ik分詞器(提供分詞查詢,所有機器必須安裝)
1.ik分詞器
安裝到es/plugins/ik 目錄下,需要新建一個ik目錄
解壓檔案elasticsearch-analysis-ik-6.3.0.zip到目錄/usr/cwgis/app/es/plugins/ik
分發外掛安裝目錄
cc.sh /usr/cwgis/app/es/plugins/ik /usr/cwgis/app/es/plugins/ es

2.拼音分詞器
安裝到es/plugins/pinyin 目錄下,需要新建一個pinyin目錄
elasticsearch-analysis-pinyin-6.3.0.zip
下載地址:

https://github.com/medcl/elasticsearch-analysis-pinyin
選擇releases版本項下載6.3.0版本
解壓檔案elasticsearch-analysis-pinyin-6.3.0.zip到目錄/usr/cwgis/app/es/plugins/pinyin
分發外掛安裝目錄
cc.sh /usr/cwgis/app/es/plugins/pinyin /usr/cwgis/app/es/plugins/ es

(五)修改centos中的系統檔案內容:
vi /etc/security/limits.conf 修改內容如下:

* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

分發配置檔案cc.sh /etc/security/limits.conf /etc/security/limits.conf es
vi /etc/security/limits.d/20-nproc.conf 修改內容如下:

* soft nproc 2048

分發配置檔案cc.sh /etc/security/limits.d/20-nproc.conf /etc/security/limits.d/20-nproc.conf es
vi /etc/sysctl.conf 修改內容如下:

vm.max_map_count=655360

分發配置檔案cc.sh /etc/sysctl.conf /etc/sysctl.conf es
並執行命令sysctl -p
runCmd.sh “sysctl -p” es

(六)啟動es叢集
後臺啟動命令:/es/bin/elasticsearch -d
需要以es使用者啟動es叢集,不能用root有戶啟動

su es
1
runCmd.sh "/usr/cwgis/app/es/bin/elasticsearch -d" es

(七)顯示檢視web頁面
http://node111:9200/_cat/

=^.^=
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_cat/tasks
/_cat/indices
/_cat/indices/{index}
/_cat/segments
/_cat/segments/{index}
/_cat/count
/_cat/count/{index}
/_cat/recovery
/_cat/recovery/{index}
/_cat/health
/_cat/pending_tasks
/_cat/aliases
/_cat/aliases/{alias}
/_cat/thread_pool
/_cat/thread_pool/{thread_pools}
/_cat/plugins
/_cat/fielddata
/_cat/fielddata/{fields}
/_cat/nodeattrs
/_cat/repositories
/_cat/snapshots/{repository}
/_cat/templates

檢視所有節點地址:http://node111:9200/_cat/nodes

192.168.30.112 38 43 0 0.00 0.01 0.05 mdi - node112
192.168.30.116 34 26 0 0.00 0.01 0.05 mdi - node116
192.168.30.117 22 34 0 0.00 0.01 0.05 mdi * node117
192.168.30.120 35 27 0 0.00 0.01 0.05 mdi - node120
192.168.30.118 34 29 0 0.00 0.01 0.05 mdi - node118
192.168.30.111 22 54 0 0.00 0.02 0.05 mdi - node111
192.168.30.119 35 28 0 0.04 0.09 0.07 mdi - node119
192.168.30.123 31 30 0 0.01 0.04 0.05 mdi - node123
192.168.30.113 29 40 0 0.00 0.01 0.05 mdi - node113
192.168.30.121 31 30 0 0.00 0.01 0.05 mdi - node121
192.168.30.115 37 28 0 0.00 0.01 0.05 mdi - node115
192.168.30.122 31 27 0 0.05 0.10 0.08 mdi - node122
  • node117表示當前活動主master節點

(八)es測試
建立index

[[email protected] root]$ curl -XPUT "http://node111:9200/index"
{"acknowledged":true,"shards_acknowledged":true,"index":"index"}

分詞測試
分析型別:ik_smart

[[email protected] root]$ curl -XPOST http://node111:9200/_analyze?pretty -H 'Content-Type:application/json' -d '{ "analyzer": "ik_smart", "text": "手機充值" }'
{
  "tokens" : [
    {
      "token" : "手機",
      "start_offset" : 0,
      "end_offset" : 2,
      "type" : "CN_WORD",
      "position" : 0
    },
    {
      "token" : "充值",
      "start_offset" : 2,
      "end_offset" : 4,
      "type" : "CN_WORD",
      "position" : 1
    }
  ]
}

分析型別ik_max_word

[[email protected] root]$ curl -XPOST http://node111:9200/_analyze?pretty -H 'Content-Type:application/json' -d '{ "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
    }
  ]
}

拼音分詞測試

[[email protected] root]$ curl -XPOST http://node111:9200/_analyze?pretty -H 'Content-Type:application/json' -d '{ "analyzer": "pinyin", "text": "張學友" }'
{
  "tokens" : [
    {
      "token" : "zhang",
      "start_offset" : 0,
      "end_offset" : 0,
      "type" : "word",
      "position" : 0
    },
    {
      "token" : "zxy",
      "start_offset" : 0,
      "end_offset" : 0,
      "type" : "word",
      "position" : 0
    },
    {
      "token" : "xue",
      "start_offset" : 0,
      "end_offset" : 0,
      "type" : "word",
      "position" : 1
    },
    {
      "token" : "you",
      "start_offset" : 0,
      "end_offset" : 0,
      "type" : "word",
      "position" : 2
    }
  ]
}

—the—end—
參考地址:
https://blog.csdn.net/u012666361/article/details/80111696
https://blog.csdn.net/liangzhao_jay/article/details/56840941
http://blog.sina.com.cn/s/blog_6592485b0102z4w5.html

es head外掛安裝方法參考地址:
https://blog.csdn.net/qq_24570443/article/details/82151056

下載es head google擴充套件外掛(最簡單的方式)
https://download.csdn.net/download/z670707170/10647995

google遊覽器安裝離線擴充套件程式方法
eshead.crx 改副檔名為rar,然後解壓到目錄
拷貝目錄到google遊覽器/更多工具/擴充套件程式/開發者模式/載入已解壓的擴充套件程式
中,就可以在google遊覽器位址列後面新增一個es head 外掛小圖示,點選就進入es head外掛介面中錄入es服務地址:
http://localhost:9200
http://node111:9200 就可以檢視web客戶端管理介面。