使用Docker搭建Elasticsearch6.8.6集群及设置集群用户密码

本文基于Docker镜像搭建Elasticsearch集群,集群搭建完成后设置集群用户密码,主要包含以下内容:

  • 修改系统参数
  • 安装docker和docker-compose
  • 编写yml配置文件
  • 获取集群证书
  • 修改yml配置文件
  • 启动ES集群并修改密码
  • 配置kibana

(一)修改系统参数

    (1)    virtual memory

默认情况下,Elasticsearch使用mmapfs目录存储其索引,mmap计数的默认操作系统限制可能太低,这可能会导致内存不足,需要将其调至262144。在 /etc/sysctl.conf 添加一行 :

vm.max_map_count=262144

运行 sysctl -p 使其生效。

(2)disable swap file

通常,Elasticsearch的内存使用由JVM选项控制。不需要启用交换。Linux系统可执行 swapoff -a 不启用。为了避免每次开机都需要手动执行,可将其写入开机执行文件 /etc/rc.local,开机自动执行。

(3)ulimit -n

      系统默认设置1024。Elasticsearch使用了很多文件描述符,文件描述符用完可能是灾难性的,并且很可能导致数据丢失。因此运行Elasticsearch之前需要将文件描述符的数量限制增加到65536或更高。在 /etc/security/limits.conf 末尾追加以下内容:

root soft nofile 65536
root hard nofile 65536
* soft nofile 65536
* hard nofile 65536
* soft memlock  unlimited
* hard memlock  unlimited

如果是Ubuntu系统,追加上述内容后,ulimit -n可能并没有从1024变为65536,还需要在 /etc/systemd/user.conf /etc/systemd/system.conf 中追加 

DefaultLimitNOFILE=65535

注意:修改后重启机器

(二)安装docker和docker-compose

(1)安装docker

Ubuntu和Debian可新建docker.sh,添加以下内容:

#!/bin/bash
OS_NAME=`cat /etc/os-release | grep NAME`

sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common iptables
sudo apt-get remove docker docker-engine docker.io containerd runc

if [[ $OS_NAME =~ "Ubuntu" ]];then
	sudo curl -fsSL 
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值