Elasticsearch 5 集群
1 准备工作/etc/profile添加vim高亮显示
export PS1="\[\e]0;\a\]\n\[\e\[\e\H\[\e<\$(date +\"%Y-%m-%d %T\")> \[\e\w\[\e\n\u>\\$ "
服务器信息:
192.168.91.220(elasticsearch-node1)
192.168.91.221(elasticsearch-node2)
192.168.91.222(elasticsearch-node3)
1.1 安装 Java 环境
yum install vim openssh-clients lrzsz -y
yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel -y
这里 java-1.8.0-openjdk-devel 非必须安装,但以后安装插件时可能会需要 Java 的编译器(javac),因此建议提前安装好。
验证版本:
220.elk.node0.com<2016-12-13 12:02:42> ~
root># java -version
openjdk version "1.8.0_111"
OpenJDK Runtime Environment (build 1.8.0_111-b15)
OpenJDK 64-Bit Server VM (build 25.111-b15, mixed mode)
1.2 配置 ES 的 yum 源
导入签名:
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
设置 yum 源
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
Elastic Stack 相关产品均需要使用这个源。
1.3 操作系统配置
官方提供了生产环境下 Elasticsearch 所在操作系统的相关建议,详见这里
1. 跨域支持
根据官网建议添加了如下配置到elasticsearc.yml主配置文件
http.cors.enabled: true
http.cors.allow-origin: "*"
问题二:
max number of threads for user is too low, increase to at least
解决方法:进入limits.d下的配置文件:vim /etc/security/limits.d/90-nproc.conf ,修改配置如下:
vim /etc/security/limits.d/90-nproc.conf
* soft nproc 1024
修改为:
* soft nproc 2048
问题三:
max file descriptors for elasticsearch process is too low, increase to at least
解决办法:
1、虚拟内存设置,编辑 /etc/sysctl.conf ,追加:
vm.max_map_count=262144
2、修改文件句柄限制,编辑 /etc/security/limits.conf ,追加:
root># vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
问题四:
elasticsearch5.0启动失败,出现如下提示:
1、Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
由于elasticsearch5.0默认分配jvm空间大小为2g,修改jvm空间分配
# vim config/jvm.options
-Xms2g
-Xmx2g
修改为
-Xms512m
-Xmx512m
2、Elasticsearch安装
node0 部署
220.elk.inzwc.com<2016-12-13 12:21:06> ~
root># useradd elasticsearch
220.elk.inzwc.com<2016-12-13 12:22:40> ~
root># chown -R elasticsearch:elasticsearch /opt/elasticsearch-node0/
root># tar -zxvf elasticsearch-5.0.2.tar.gz -C /opt/
root># cd /opt
root># mv elasticsearch-5.0.2 elasticsearch-node0
修改配置
root># cat /opt/elasticsearch-node0/config/elasticsearch.yml
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
#cluster
cluster.name: "es-cluster"
node.name: "es-node0"
node.master: true
node.data: true
http.enabled: true
node1 部署
221.elk.inzwc.com<2016-12-13 12:21:10> ~
root># useradd elasticsearch
221.elk.inzwc.com<2016-12-13 12:21:24> ~
root># chown -R elasticsearch:elasticsearch /opt/elasticsearch-node1/
220.elk.node0.com<2016-12-13 12:04:43> /opt
root># scp -rp elasticsearch-node0/ root@192.168.91.222:/opt/elasticsearch-node1
221.elk.node1.com<2016-12-13 12:07:32> /opt/elasticsearch-node1/config
root># cat /opt/elasticsearch-node1/config/elasticsearch.yml
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
#cluster
cluster.name: "es-cluster"
node.name: "es-node1"
node.master: true
node.data: true
http.enabled: true
PS:node.name
node2 部署
222.elk.inzwc.com<2016-12-13 12:21:15> ~
root># useradd elasticsearch
222.elk.inzwc.com<2016-12-13 12:23:20> ~
root># chown -R elasticsearch:elasticsearch /opt/elasticsearch-node2/
220.elk.node0.com<2016-12-13 12:04:43> /opt
root># scp -rp elasticsearch-node0/ root@192.168.91.222:/opt/elasticsearch-node2
222.elk.node2.com<2016-12-13 12:07:32> /opt/elasticsearch-node3/config
root># cat /opt/elasticsearch-node2/config/elasticsearch.yml
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
#cluster
cluster.name: "es-cluster"
node.name: "es-node2"
node.master: true
node.data: true
http.enabled: true
PS:node.name
页:
[1]