本文簡要介紹ES5版本集羣部署時的要點。 更多相關信息請參閱官網。node
部分配置未在生產環境體現。 生產中2個集羣20臺centOS,總數據15TB,90億條。 實時寫入5000條/s, 最大7萬/s。bootstrap
1. vi /etc/sysctl.conf 加入:
vm.max_map_count=262144app
執行 sysctl -p 使配置生效運維
2. vi /etc/security/limits.d/20-nproc.conf #打開進程數
* soft nproc 65536 curl
3. vi /etc/security/limits.conf #打開文件數
* soft nofile 65536
* hard nofile 65536
* - memlock unlimitedasync
對master,因爲bulk請求涉及頻繁gc, 設置爲以下的G1GC。 tcp
-XX:+UseG1GCpost
node.attr.rack: crm-master-01
node.name: golden-master01
network.publish_host: 10.27.1.1優化
cluster.name : goldeneye
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
path:
data:
- /home/data1
- /home/data2ui
bootstrap.memory_lock: true
discovery.zen.minimum_master_nodes: 2
action.destructive_requires_name: true
script.max_compilations_per_minute: 120
indices.query.bool.max_clause_count: 4096
##===================MASTER NODE =========================
node.master: true
node.data: false
node.ingest: true
discovery.zen.ping_timeout: 10s
xpack.monitoring.history.duration: 1d
xpack.graph.enabled: false
xpack.watcher.enabled: false
#xpack.security.enabled: false
xpack.security.dls_fls.enabled: false
xpack.security.transport.filter.enabled: false
##===================DATA NODE =========================
node.master: false
node.data: true
node.ingest: false
http.enabled: false
xpack.security.enabled: true
xpack.monitoring.enabled: true
xpack.graph.enabled: false
xpack.watcher.enabled: false
curl -XPUT localhost:9200/_cluster/settings -d '
{
"transient": {
"cluster": {
"routing": {
"rebalance": {
"enable": "none" #初始導入前,禁用shard移動
},
"allocation": {
"node_concurrent_incoming_recoveries": "6", #初始導入後,將replica設爲1時, 加速replica複製速度。默認爲2
"node_concurrent_outgoing_recoveries": "6"
}
}
},
"indices": {
"recovery": {
"max_bytes_per_sec": "500mb" #初始導入後,將replica設爲1時, 加速replica複製速度,默認爲40m
},
"store": {
"throttle": {
"type": "merge",
"max_bytes_per_sec": "500m" #數據導入時,及_forcemerge?max_num_segments=3時加速
}
}
}
}
}
'
curl -XPUT localhost:9200/_template/crm_v5 -d '
{
"template": "crm*",
"aliases": {
"crm_v5.0": {}
},
"settings": {
"index": {
"number_of_shards": "1",
"number_of_replicas": "1", #初始化導入時設置 0,
"refresh_interval": "10s", #初始化導入時設置 -1
"translog.durability":"async", #大量寫入場景
"translog.flush_threshold_size":"1024m" #默認512m
"max_result_window": "5000000",
"max_rescore_window":"20000",
"unassigned.node_left.delayed_timeout": "10m",
"search.slowlog.threshold.query.warn":"30s",
"indexing.slowlog.threshold.index.warn": "10s"
}
},
"mappings": {
"customer": {
"_all": { "enabled": false }, #內存優化
"properties": {
字段使用盡可能短的類型:能short就不要使用int,能half 就不要使用float。
如long,integer,short, byte
float, half_float
"end_time": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis" #兩種格式2016-0-01T00:00:00 +08:00
}
更新template的 number_of_replicas=0,refresh_interval=-1
1. 確認已導入的庫大小, 對大於30GB的庫,從新設置shard個數number_of_shards,使每一個shard約爲30GB。 使用 _reindex 和_alias 接口配合完成。
2. 合併每一個shard的segment數目 , 加強search速度。
curl -XPOST /crm*/_forcemerge?max_num_segments=3
3. 啓動副本備份。 number_of_replicas=1
curl -XPUT 'localhost:9200/crm*/_settings' -d ' { "index" : { "number_of_replicas" : 1 } }'
A: 移動Index所屬節點
curl -XPUT localhost:9200/_cluster/reroute 遷移節點數據
{
"commands" : [ {
"move" :
{
"index" : "crm-0720", "shard" : 0,
"from_node" : "data02", "to_node" : "data03"
}
}]
}
若是關閉一個節點,則執行reroute前, 還必須禁用系統自動的shard分配
curl -XPUT localhost:9200/_cluster/settings -d '{ "transient" : { "cluster.routing.allocation.enable" : "none" } }' #默認爲all
PUT /_cluster/settings
{
"persistent" : {
"cluster.routing.allocation.enable":"none",
"cluster.routing.rebalance.enable":"replicas",
"action.destructive_requires_name":true
}
}
當前文件夾內查找關鍵字,顯示所在文件,所在行,行內容:grep -nHIrF KeyWord ./