ElasticSearch三节点集群搭建笔记(中心化版本)

---------------------------------- Cluster -----------------------------------

#设定集群名称

cluster.name: elk4devops

------------------------------------ Node ------------------------------------

#设定节点名称,此处使用的是 hostname

node.name: es1

----------------------------------- Paths ------------------------------------

#设定 es 服务器数据目录

path.data: /var/lib/elasticsearch

#设定 es 服务器日志目录

path.logs: /var/log/elasticsearch

---------------------------------- Network -----------------------------------

#设定此节点加入网络的名称,这里使用的是 FQDN

network.host: 192.168.122.128

--------------------------------- Discovery ----------------------------------

#设定初始的 master 节点为 es1

cluster.initial_master_nodes: [“es1”]

discovery.seed_hosts: [“192.168.122.128”]

------------------------------- App Search ---------------------------------

#提前为 App Search 做好准备

action.auto_create_index: “.app-search--logs-,-.app-search-,+

#http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type

http.cors.enabled: true

http.cors.allow-origin: “*”

http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE

http.cors.allow-headers: “X-Requested-With, Content-Type, Content-Length, X-User”

es2

---------------------------------- Cluster -----------------------------------

cluster.name: elk4devops

------------------------------------ Node ------------------------------------

node.name: es2

----------------------------------- Paths ------------------------------------

path.data: /var/lib/elasticsearch

path.logs: /var/log/elasticsearch

---------------------------------- Network -----------------------------------

network.host: 192.168.122.130

--------------------------------- Discovery ----------------------------------

cluster.initial_master_nodes: [“es1”]

discovery.seed_hosts: [“192.168.122.128”]

------------------------------- App Search ---------------------------------

#提前为 App Search 做好准备

action.auto_create_index: “.app-search--logs-,-.app-search-,+

#http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type

http.cors.enabled: true

http.cors.allow-origin: “*”

http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE

http.cors.allow-headers: “X-Requested-With, Content-Type, Content-Length, X-User”

es3

---------------------------------- Cluster -----------------------------------

#设定集群名称

cluster.name: elk4devops

------------------------------------ Node ------------------------------------

#设定节点名称,此处使用的是 hostname

node.name: es3

----------------------------------- Paths ------------------------------------

#设定 es 服务器数据目录

path.data: /var/lib/elasticsearch

#设定 es 服务器日志目录

path.logs: /var/log/elasticsearch

---------------------------------- Network -----------------------------------

#设定此节点加入网络的名称,这里使用的是 FQDN

network.host: 192.168.122.131

--------------------------------- Discovery ----------------------------------

#设定初始的 master 节点为 es1

cluster.initial_master_nodes: [“es1”]

discovery.seed_hosts: [“192.168.122.128”]

------------------------------- App Search ---------------------------------

#提前为 App Search 做好准备

action.auto_create_index: “.app-search--logs-,-.app-search-,+

#http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type

http.cors.enabled: true

http.cors.allow-origin: “*”

http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE

http.cors.allow-headers: “X-Requested-With, Content-Type, Content-Length, X-User”

三、其他细节

=====================================================================

创建数据及日志目录

mkdir -p /var/lib/elasticsearch

mkdir -p /var/log/elasticsearch

chmod 777 -R /var/lib/elasticsearch

chmod 777 -R /var/log/elasticsearch

关闭防火墙

执行命令

systemctl disable firewalld

systemctl stop firewalld

修改系统最大文件打开数

编辑/etc/security/limits.conf文件

  • hard nofile 65536

  • soft nofile 65536

修改用户最大进程数

编辑/etc/security/limits.conf文件

  • hard nproc 4096

  • soft nproc 4096

修改最大文件句柄数

执行命令

sysctl -w vm.max_map_count=262144

以普通用户身份启动节点

四、验证

===================================================================

分别访问三个节点的HTTP服务地址,出现后续json格式信息代表集群搭建成功

192.168.122.128:9200

{

“name” : “es1”,

“cluster_name” : “elk4devops”,

“cluster_uuid” : “CAeXdMahQ5qz6Xf8BuzxXw”,

“version” : {

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用docker-compose部署8.1.3版本elasticsearch节点集群和kibana的示例docker-compose.yml文件,其中关闭了https: ``` version: '3' services: elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:8.1.3 container_name: elasticsearch environment: - node.name=node1 - cluster.name=my-cluster - discovery.seed_hosts=elasticsearch2,elasticsearch3 - cluster.initial_master_nodes=node1,node2,node3 - ES_JAVA_OPTS=-Xms512m -Xmx512m ulimits: memlock: soft: -1 hard: -1 volumes: - esdata1:/usr/share/elasticsearch/data ports: - 9200:9200 - 9300:9300 networks: - elastic elasticsearch2: image: docker.elastic.co/elasticsearch/elasticsearch:8.1.3 container_name: elasticsearch2 environment: - node.name=node2 - cluster.name=my-cluster - discovery.seed_hosts=elasticsearch,elasticsearch3 - cluster.initial_master_nodes=node1,node2,node3 - ES_JAVA_OPTS=-Xms512m -Xmx512m ulimits: memlock: soft: -1 hard: -1 volumes: - esdata2:/usr/share/elasticsearch/data networks: - elastic elasticsearch3: image: docker.elastic.co/elasticsearch/elasticsearch:8.1.3 container_name: elasticsearch3 environment: - node.name=node3 - cluster.name=my-cluster - discovery.seed_hosts=elasticsearch,elasticsearch2 - cluster.initial_master_nodes=node1,node2,node3 - ES_JAVA_OPTS=-Xms512m -Xmx512m ulimits: memlock: soft: -1 hard: -1 volumes: - esdata3:/usr/share/elasticsearch/data networks: - elastic kibana: image: docker.elastic.co/kibana/kibana:8.1.3 container_name: kibana environment: - ELASTICSEARCH_HOSTS=http://elasticsearch:9200 ports: - 5601:5601 networks: - elastic volumes: esdata1: esdata2: esdata3: networks: elastic: ``` 在终端中使用以下命令启动docker-compose: ``` docker-compose up -d ``` 这会启动一个节点elasticsearch集群和一个单独的kibana节点,可以使用http://localhost:5601访问kibana。如果需要关闭https,只需在kibana的环境变量中指定ELASTICSEARCH_HOSTS为http://elasticsearch:9200即可。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值