ElasticSearch7.3.2-集群搭建

ElasticSearch7.3.2-集群搭建我们选择基于7.3.2版本安装部署,基于cluster部署,假设我们有三台虚拟机 node1-192.168.1.1、node2-192.168.1.2、node3-192.168.1.3。 基于root用户下,创建用户组elastic,并添加用户elastic及及设置密码el…

1、环境准备

我们选择基于7.3.2版本安装部署,基于cluster部署,假设我们有三台虚拟机 node1-192.168.1.1node2-192.168.1.2node3-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 root@192.168.1.2:/opt/elastic
scp -P 22 ./elastic root@192.168.1.3:/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

下面的是我的公众号二维码图片,欢迎关注。

秋夜无霜

今天的文章ElasticSearch7.3.2-集群搭建分享到此就结束了,感谢您的阅读。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/22980.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注