elasticsearch 安装
环境
操作系统:centos6.5 64位
版本:elasticsearch-6.1.1
jdk版本:1.8
安装用户:etl
节点安排
10.20.23.29 master
10.20.23.38 负载均衡
10.20.23.41 data
10.20.23.42 data
10.20.23.82 data
解压elasticsearch
unzip elasticsearch-6.1.1.zip
修改elasticsearch 的配置文件
修改conf目录下面的 elasticsearch.yml文件
cluster.name: es_dev
node.name: node-5
#如果是master节点设置成true 如果是
node.master: false
#如果是data节点设置成true
node.data: true
path.data: /data/elasticsearch-6.1.1/data
path.logs: /data/elasticsearch-6.1.1/logs
network.host: 10.20.23.82
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["10.20.23.29", "10.20.23.38","10.20.23.41","10.20.23.42","10.20.23.82"]
discovery.zen.minimum_master_nodes: 1
bootstrap.memory_lock: true
bootstrap.system_call_filter: false
http.cors.enabled: true
http.cors.allow-origin: "*"
启动elasticsearch 服务
./elasticsearch -d
验证
在浏览器上输入 http://10.20.23.29:9200/_cluster/health?pretty
{
"cluster_name" : "es_dev",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 5,
"number_of_data_nodes" : 3,
"active_primary_shards" : 0,
"active_shards" : 0,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}
异常解决
[etl@node1 logs]$ tail -f es_dev.log
[2018-01-29T10:25:19,090][INFO ][o.e.b.BootstrapChecks ] [node-1] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
[2018-01-29T10:25:19,093][ERROR][o.e.b.Bootstrap ] [node-1] node validation exception
[3] bootstrap checks failed
[1]: memory locking requested for elasticsearch process but memory is not locked
[2]: max number of threads [1024] for user [etl] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方案
修改 /etc/security/limits.conf
增加
* soft nofile 65536
* hard nofile 131072
etl soft memlock unlimited
etl hard memlock unlimited
etl hard nproc 4096
etl soft nproc 4096
修改 /etc/sysctl.conf
增加
vm.max_map_count=262144
vm.swappiness=1
用命令sysctl -p 生效
sysctl vm.max_map_count 查看值是否修改, 也可以通过sysctl -w vm.max_map_count=262144 临时设置值