1.1下載最新的 elasticsearch-6.5.4.tar.gznode
1.2解壓git
tar -zxvf elasticsearch-6.5.4.tar.gzgithub
1.3 建立用戶bootstrap
elastic默認不能在root用戶下運行,因此須要專門的用戶運行。api
groupadd elsearch
useradd elsearch -g elsearch -p elasticsearch
chown -R elsearch:elsearch elasticsearch-6.5.4.app
1.4 運行jvm
su elsearchelasticsearch
./bin/elasticsearchtcp
1.編輯配置文件 /etc/security/limits.conf 測試
在最後增長
elsearch - nofile 65536
elsearch soft nproc 32768
elsearch hard nproc 65536
elsearch 爲啓動elasticsearch 的用戶
能夠使用 elsearch 用戶登陸 使用 ulimit -a 命令查看是否生效。
2.編輯/etc/sysctl.conf 文件
增長配置
vm.max_map_count=262144
並執行命令 sysctl -p
減小內存交換,緊急狀況仍然容許交換。
vm.swappiness=1
3.在 elasticsearcm.yml 中配置
bootstrap.memory_lock: true
防止elastic的內存被交換出去。
配置完後能夠經過
GET _nodes?filter_path=**.mlockall 檢查是否成功。
將 es 拷貝3份 ,分別爲 es1,es2,es3
修改 conf 下的 elasticsearch.yml
es1
cluster.name: elastic
node.name: node-1
node.master:true
path.data: /redxun/elastic/es1/data
path.logs: /redxun/elastic/es1/logs
bootstrap.memory_lock: false
network.host: 202.10.79.170
network.publish_host: 202.10.79.170
http.port: 9201
transport.tcp.port: 9301
discovery.zen.ping.unicast.hosts: ["202.10.79.170:9201","202.10.79.170:9202","202.10.79.170:9203"]
discovery.zen.minimum_master_nodes: 2
es2
cluster.name: elastic
node.name: node-2
node.master:true
path.data: /redxun/elastic/es2/data
path.logs: /redxun/elastic/es2/logs
bootstrap.memory_lock: false
network.publish_host: 202.10.79.170
network.host: 202.10.79.170
http.port: 9202
transport.tcp.port: 9302
discovery.zen.ping.unicast.hosts: ["202.10.79.170:9201","202.10.79.170:9202","202.10.79.170:9203"]
discovery.zen.minimum_master_nodes: 2
es3
cluster.name: elastic
node.name: node-3
node.master:true
path.data: /redxun/elastic/es3/data
path.logs: /redxun/elastic/es3/logs
bootstrap.memory_lock: false
network.publish_host: 202.10.79.170
network.host: 202.10.79.170
http.port: 9203
transport.tcp.port: 9303
discovery.zen.ping.unicast.hosts: ["202.10.79.170:9201","202.10.79.170:9202","202.10.79.170:9203"]
discovery.zen.minimum_master_nodes: 2
須要注意的是 network.publish_host 必填。
編輯 es1/config/jvm.options
編輯
-Xms1g
-Xmx1g
內存的設置通常爲系統內存的一半。
下載 cerebro-0.8.1
https://github.com/lmenezes/cerebro
下載後配置:
編輯配置文件
application.conf
es = { gzip = true } # Authentication auth = { type: basic settings: { username = "admin" password = "1234" } } hosts = [ { host = "http://202.10.79.170:9201" name = "my-application" } ] http.port=8001 http.address=202.10.79.170
編輯完成後啓動 cerebro
./bin/cerebro
建立索引
建立三個分配,一個副本。
索引分佈
這裏能夠看到索引分佈到了3個實例上,若是一臺機器宕機,那麼數據能夠進行恢復。
下載
https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.5.4/elasticsearch-analysis-ik-6.5.4.zip
在es 的plugins目錄建立一個ik目錄
將文件解壓到這個目錄。
啓動es
啓動時能夠看到日誌
[2019-01-05T17:13:08,535][INFO ][o.e.p.PluginsService ] [node-1] loaded plugin [analysis-ik]
表示 ik 安裝成功。
測試中文分詞,使用cerebro測試
通常的作法在一個集羣中設置3個MASTER節點,將discovery.zen.minimum_master_nodes 設置爲2 就能夠了。
集羣配置參數
通常node.master 設置爲3個
discovery.zen.ping.unicast.hosts 設置node.master的節點地址。
discovery.zen.minimum_master_nodes 設置爲2
建議使用api進行設置。
內存數量量比:
搜索類每一個節點存儲數據最多496g
日誌數據能夠爲31*48 1500g左右。