问题
启动失败,日志:
[3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max number of threads [3795] for user [es] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
分析+解决
- [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
系统为elasticsearch进程分配的最大可用文件描述符4096不够用,至少分配65535个。
增加配置命令:ulimit -n 65535
- [2]: max number of threads [3795] for user [es] is too low, increase to at least [4096]
系统为es用户分配的最大可用线程数3795太少,至少分配4096个。
增加线程数: ulimit -u 4096
- [3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
内核参数:最大虚拟内存65530太少,至少分配262144
执行命令:sysctl -w vm.max_map_count=262144
以上方式只是暂时解决,每次登录都要设置。
永久修改
- 修改文件限制
vi /etc/security/limits.conf
追加
#当前系统最大可打开的fd 65535
* soft nofile 65535
#系统最大可打开的fd 65535
* hard nofile 65535
#当前系统最大允许进程数
* soft nproc 4096
#系统最大允许进程数
* hard nproc 4096
#当前系统最大可锁内存
* soft memlock unlimited
#系统最大可锁内存
* hard memlock unlimited
-
vi /etc/systemd/system.conf
DefaultLimitNOFILE=65536
DefaultLimitNPROC=32000
DefaultLimitMEMLOCK=infinity
- 修改内核参数
vi /etc/sysctl.conf
追加
vm.max_map_count=262144
重新加载 sysctl -p