2021-01-19 elasticsearch7.9.3 集群安装部署

elasticsearch7.9.3安装

es下载

选择华为云下载elasticsearch7.9.3 下载es点击我

es安装

打开防火墙端口

firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --zone=public --add-port=9200/udp --permanent
firewall-cmd --zone=public --add-port=9300/tcp --permanent
firewall-cmd --zone=public --add-port=9300/udp --permanent
firewall-cmd --reload

解压到安装目录

tar -xvf elasticsearch-7.9.3-linux-x86_64.tar.gz

添加用户并授权

useradd es
chown -R es:es elasticsearch-7.9.3

修改配置文件

vim elasticsearch-7.9.3/config/elasticsearch.yml

设置如下内容

#集群名
cluster.name: es
#节点名
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
cluster.initial_master_nodes: ["node-1", "node-2"]

设置 vm

vi /etc/sysctl.conf

添加如下内容

vm.max_map_count=262144

刷新

sysctl -p

设置线程数

vi /etc/security/limits.conf

添加如下内容

es hard nofile 65536 
es soft nofile 65536

设置虚拟机内存,这是针对小内存服务器

vi elasticsearch-7.9.3/config/jvm.options

修改内存如下

-Xms128m
-Xmx128m

启动

./elasticsearch-7.9.3/bin/elasticsearch

访问 IP:9200 查看结果

elasticsearch7.9.3集群部署

master文件配置

# 集群名称
cluster.name: es
# # # 节点名称
node.name: node-1
# # # 是否可以成为master节点
node.master: true
# # # 是否允许该节点存储数据,默认开启
node.data: true
# # # 网络绑定,写自己的主机
network.host: xxx
# # # 设置对外服务的http端口,默认为9200,为和单机分开,我设置9201 
http.port: 9200
# # # 设置节点间交互的tcp端口,默认是9300,为和单机分开,我设置9301
transport.tcp.port: 9300
# # # 手动指定可以成为 mater 的所有节点的 name 或者 ip,这些配置将会在第一次选举中进行计算
#cluster.initial_master_nodes: ["node-1","node-2"]
# # ##设置集群自动发现机器ip的集合
discovery.seed_hosts: ["xxx:9300","xxx:9300"]
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
#  #    
#  #    #允许跨域访问
http.cors.enabled: true
http.cors.allow-origin: "*"


search.max_buckets: 200000
path.repo: /xxx/elasticsearch-7.9.3/data/backup

node文件配置

# 集群名称
cluster.name: es
# # 节点名称
node.name: node-2
# # 是否可以成为master节点
node.master: false
# # 是否允许该节点存储数据,默认开启
node.data: true
# # 网络绑定,写自己的主机
network.host: xxx
# # 设置对外服务的http端口,默认为9200,为和单机分开,我设置9201 
http.port: 9200
# # 设置节点间交互的tcp端口,默认是9300,为和单机分开,我设置9301
transport.tcp.port: 9300
# # 手动指定可以成为 mater 的所有节点的 name 或者 ip,这些配置将会在第一次选举中进行计算
#cluster.initial_master_nodes: ["node-1","node-2"]
# ##设置集群自动发现机器ip的集合
discovery.seed_hosts: ["xxx:9300","xxx:9300"]
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
#    
#    #允许跨域访问
http.cors.enabled: true
http.cors.allow-origin: "*"


search.max_buckets: 200000
path.repo: /xxx/elasticsearch-7.9.3/data/backup

出现错误记着删除data下文件

问题

  1. max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    参考文章:https://www.jianshu.com/p/90ec54cd4b10

  2. the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
    参考文章:https://blog.csdn.net/qq_43655835/article/details/104637625

  3. org.elasticsearch.transport.ConnectTransportException: [node-1][192.168.0.186:9300] connect_timeout[30s]
    这个问题可是太致命了,两台服务使用的是不同厂商服务器,不在内网。猝!

参考文章

https://www.cnblogs.com/leeSmall/p/9220535.html
https://www.cnblogs.com/chenyanbin/p/13493920.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值