阅读更多
参考
http://blog.csdn.net/zwgdft/article/details/54585644
https://www.cnblogs.com/wgp13x/p/4859680.html
安装elasticsearch
在es集群的各个机器上安装 es实例,centOS 推荐 rpm包安装。版本号与阿里云es一致 选择 5.5.3版本
下载地址:https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.3.rpm
通过rpm命令进行安装
~]# rpm -ivh elasticsearch-5.5.3.rpm
查看安装目录
~]# whereis elasticsearch
elasticsearch: /etc/elasticsearch /usr/share/elasticsearch
其中/etc/elasticsearch 存放es配置文件, /usr/share/elasticsearch 是es根目录
系统配置
修改进程数
修改 /etc/security/limits.d/90-nproc.conf
* soft nproc 1024
* soft nproc 2048
修改/etc/security/limits.conf
root soft nofile 65536
root hard nofile 65536
* soft nofile 65536
* hard nofile 65536
按机器性能修改JVM空间
ES默认分配jvm空间大小为2g,可以编辑/etc/elasticsearch/jvm.options进行修改
例如:-Xms4g -Xmx4g
修改VMA(虚拟内存区域)的数量
在/etc/sysctl.conf 中添加
vm.max_map_count=655360
并执行命令:
sysctl -p
由于CentOS6 不支持沙箱所以需要把ES相关check去掉
修改 /etc/elasticsearch/elasticsearch.yml文件,添加:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
ES集群配置
修改/etc/elasticsearch/elasticsearch.yml文件
修改集群名称,进群内机器必须保持一致
cluster.name: datacenter
**注意** 数据中心配置的集群名称要与此集群名一致
修改节点名称,每个es实例一个节点名集群内唯一
node.name: node-1
放开访问控制
network.host: 0.0.0.0
http端口,跨域配置
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
节点发现host
discovery.zen.ping.unicast.hosts: ["host1:port","host2:port"]
集群master数量,应设置为节点数N/2 + 1
discovery.zen.minimum_master_nodes: 2
启动、 停止、重启
~]# /etc/init.d/elasticsearch start
~]# /etc/init.d/elasticsearch stop
~]# /etc/init.d/elasticsearch restart
查看集群运行状态
~]# curl -XGET http://127.0.0.1:9200/_cluster/health?pretty
{
"cluster_name" : "elasticsearch",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 2,
"number_of_data_nodes" : 2,
"active_primary_shards" : 5,
"active_shards" : 5,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 5,
"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" : 50.0
}