vagrant + docker-compose部署实验的elasticsearch cluster

当我们在docker container里面设置 vm.max_map_count值的时候并不起作用,需要在vagrant vm里面也要进行相应的设置,因为docker的文件其实在vm里面也是以文件的形式存在。

这里我们可以直接修改docker本身的参数,当然也可以直接修改宿主机本身的配置文件,需要注意的是在docker 容器中执行

sysctl -w vm.max_map_count=655360

会提示错误:

sysctl: setting key “vm.max_map_count”: Read-only file system

在vm里和物理机里面设置vm.max_map_count的方法是:

sysctl -w vm.max_map_count=655360

sysctl -a | grep vm.max_map_count
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
 es-node1:
       image:  elasticsearch:6.8.9
       container_name: es-node1
       restart: always
       volumes:
         - ./node1/data:/usr/share/elasticsearch/data:rw
         - ./node1/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
         - ./node1/logs:/user/share/elasticsearch/logs:rw
         - ./limits.conf:/etc/security/limits.conf:rw
         - ./sysctl.conf:/etc/sysctl.conf:rw
       networks:
         elasnet:
           ipv4_address: 172.23.2.3
     es-node2:
       image:  elasticsearch:6.8.9
       container_name: es-node2
       restart: always
       volumes:
         - ./node2/data:/usr/share/elasticsearch/data:rw
         - ./node2/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
         - ./node2/logs:/user/share/elasticsearch/logs:rw
         - ./limits.conf:/etc/security/limits.conf:rw
         - ./sysctl.conf:/etc/sysctl.conf:rw
       networks:
         elasnet:
           ipv4_address: 172.23.2.4

[vagrant@node1 ~]$ cat sysctl.conf 
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
#
vm.max_map_count=262144

[vagrant@node1 ~]$ cat limits.conf 
#*               soft    core            0
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#@student        -       maxlogins       4
*               soft    nofile            65535
*               hard    nofile             65535
*               soft    nproc           4096
*               hard    nproc           4096

# End of file

你可能感兴趣的:(vagrant + docker-compose部署实验的elasticsearch cluster)