制作KVM ES镜像文件
大约 3 分钟
安装KVM,创建centos虚拟机的步骤,参考:https://note.youdao.com/ynoteshare1/index.html?id=d641f8e6125142a0c2f19a9b416534ac&type=note?auto
- 进入centos服务器,上传es的安装文件到服务器并解压到/usr/share/elasticsearch目录,然后已root用户执行下面步骤:
adduser elastic
echo "* soft nofile 125536" >> /etc/security/limits.conf
echo "* hard nofile 125536" >> /etc/security/limits.conf
echo "* soft nproc 8096" >> /etc/security/limits.conf
echo "* hard nproc 8096" >> /etc/security/limits.conf
echo "vm.max_map_count=522144" >> /etc/sysctl.conf
sysctl -p
chown -R elastic:elastic /usr/share/elasticsearch
如果需要开启 bootstrap.memory_lock: true,则还需要执行:
echo "* hard memlock unlimited" >> /etc/security/limits.conf
echo "* soft memlock unlimited" >> /etc/security/limits.conf
修改jvm.options文件
已elastic用户修改es的配置文件,然后执行 bin/elasticsearch -d
编写自启动脚本
- vi /usr/lib/systemd/system/elasticsearch.service
[Unit]
Description=elasticsearch service
[Service]
User=elastic
ExecStart=/usr/share/elasticsearch/bin/elasticsearch
[Install]
WantedBy=multi-user.target
systemctl enable elasticsearch
systemctl start elasticsearch
Docker部署
由于需要sshd服务,所以我们没有直接使用es7.4.1的docker镜像,而是使用的一个centos的docker镜像
然后同样执行上面的步骤,然后启动docker
docker network create -d macvlan --subnet=172.26.43.0/24 --gateway=172.26.43.129 -o parent=bond0 mynet
docker run -itd -e TZ="Asia/Shanghai" --name es172_26_43_136 -h es172_26_43_136 --restart=always --network=mynet --ip 172.26.43.136 --cpus=15 --memory=27g --memory-swap=27g --ulimit memlock=-1:-1 --privileged -e ES_JAVA_OPTS="-Xms13g -Xmx13g" -v /opt/es/es-172.26.43.136/elasticsearch-7.4.1:/usr/share/elasticsearch -v /opt/es/es-172.26.43.136/backups:/opt/csbit/backups csbit-elasticsearch /usr/sbin/init
注意:这里虽然限制了cpus为15,但是进入到容器内部执行lscpu仍然会显示40个(和宿主机一样的)
系统推荐
- Notion笔记定时备份
- MySQL常用命令
- JVM参数设置
- MySQL高可用
- MongoDB高可用
- InnoDB存储引擎
- 多台centos服务器,文件互相备份
- 批量替换文件名中的指定字符串
- 免费 API 每日提供摸鱼日报,自动返回无水印图片,适用于公众号和小程序
- Docker跨主机通信方案
- PostgreSQL高可用
- Linux dev shm目录
- 随机毒鸡汤:最痛苦的事,不是失败,是我本可以。