1、环境准备
我们选择基于7.3.2版本安装部署,基于cluster部署,假设我们有三台虚拟机(192.168.1.1、192.168.1.2、192.168.1.3)。
1.1、下载解压
基于root用户下
su root
mkdir /opt/elastic
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.2-linux-x86_64.tar.gz
tar zxvf elasticsearch-7.3.2-linux-x86_64.tar.gz
mv elasticsearch-7.3.2 elastic
复制代码
1.2、创建elastic用户,并授权目录权限
基于root用户下,创建用户组elastic,并添加用户elastic及及设置密码elastic。
groupadd elastic
useradd elastic -g elastic
passwd elastic
chown -R elastic:elastic /opt/elastic
chown -R elastic:elastic /var/elastic
复制代码
2、参数配置
2.1、elasticsearch.yml配置
vim /opt/elastic/config/elasticsearch.yml
复制代码
更多配置:www.elastic.co/guide/en/el…
进入其中一台虚拟机(192.168.1.1),参考配置如下:
cluster.name: my-elasticsearch
node.name: node1
path.data: [/var/elastic/data]
path.logs: [/var/elastic/logs]
bootstrap.system_call_filter: false
bootstrap.memory_lock: false
network.host: 192.168.1.1
http.host: 192.168.1.1
transport.bind_host: 192.168.1.1
discovery.zen.ping.unicast.hosts: ["192.168.1.1:9300","192.168.1.2:9300","192.168.1.3:9300"]
discovery.zen.minimum_master_nodes: 2
cluster.initial_master_nodes: ["node1","node2","node3"]
node.master: true
node.data: true
http.cors.enabled : true
http.cors.allow-origin : "*"
http.max_initial_line_length: 12kb
http.cors.allow-credentials: true
http.cors.allow-headers: WWW-Authenticate,X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
复制代码
然后拷贝到其他虚拟机(192.168.1.2、192.168.1.3)
scp -P 22 ./elastic [email protected]:/opt/elastic
scp -P 22 ./elastic [email protected]:/opt/elastic
复制代码
修改虚拟机(192.168.1.2)elasticsearch.yml配置如下
cluster.name: my-elasticsearch
node.name: node2
path.data: [/var/elastic/data]
path.logs: [/var/elastic/logs]
bootstrap.system_call_filter: false
bootstrap.memory_lock: false
network.host: 192.168.1.2
http.host: 192.168.1.2
transport.bind_host: 192.168.1.2
discovery.zen.ping.unicast.hosts: ["192.168.1.1:9300","192.168.1.2:9300","192.168.1.3:9300"]
discovery.zen.minimum_master_nodes: 2
cluster.initial_master_nodes: ["node1","node2","node3"]
node.master: true
node.data: true
http.cors.enabled : true
http.cors.allow-origin : "*"
http.max_initial_line_length: 12kb
http.cors.allow-credentials: true
http.cors.allow-headers: WWW-Authenticate,X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
复制代码
修改虚拟机(192.168.1.3)elasticsearch.yml配置如下
cluster.name: my-elasticsearch
node.name: node3
path.data: [/var/elastic/data]
path.logs: [/var/elastic/logs]
bootstrap.system_call_filter: false
bootstrap.memory_lock: false
network.host: 192.168.1.3
http.host: 192.168.1.3
transport.bind_host: 192.168.1.3
discovery.zen.ping.unicast.hosts: ["192.168.1.1:9300","192.168.1.2:9300","192.168.1.3:9300"]
discovery.zen.minimum_master_nodes: 2
cluster.initial_master_nodes: ["node1","node2","node3"]
node.master: true
node.data: true
http.cors.enabled : true
http.cors.allow-origin : "*"
http.max_initial_line_length: 12kb
http.cors.allow-credentials: true
http.cors.allow-headers: WWW-Authenticate,X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
复制代码
3、JVM配置
由于ElasticSearch自带虚拟机,需要设置堆大小,只需要
vim /opt/elastic/config/jvm.options
复制代码
修改如下配置
-Xms4g
-Xmx4g
复制代码
4、启动
基于elastic用户,依次启动三个节点
su elastic
nohup /opt/elastic/bin/elasticsearch > /var/elastic/es.log >&1 &
复制代码
可以查看启动日志
tail -200f /var/elastic/es.log
复制代码
5、Kibana安装
kibana相当于mysql的navicat,就是个客户端,我们安装到其中一台虚拟机即可。
5.1、下载解压
下载到
tar zxvf kibana-7.3.2-linux-x86_64.tar.gz
mv kibana-7.3.2 kibana
复制代码
5.2、参数配置
vim /opt/kibana/config/kibana.yml
复制代码
配置如下:
server.port: 5601
server.host: 192.168.1.1
elasticsearch.hosts: ["http://192.168.1.1:9200"]
elasticsearch.username: "elastic"
elasticsearch.password: "elastic"
复制代码
5.3、启动
nohup /opt/kibana/bin/kibana &
复制代码
6、遇到问题
vm.max_map_count
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
复制代码
问题翻译过来就是:elasticsearch用户拥有的内存权限太小,至少需要262144;
解决: 切换到root用户 执行命令: sysctl -w vm.max_map_count=262144 查看结果: sysctl -a|grep vm.max_map_count 显示: vm.max_map_count = 262144
上述方法修改之后,如果重启虚拟机将失效,所以: 解决办法: 在 /etc/sysctl.conf文件最后添加一行 vm.max_map_count=262144