1. 配置域名
Server1:
OS version: CentOS Linux release 8.5.2111
hostnamectl --static set-hostname mongo01
vi /etc/sysconfig/network
# Created by anaconda
hostname=mong01
echo "192.168.88.20 mong1 mongo01.com mongo02.com" >> /etc/hosts
echo "192.168.88.24 mong2 mongo03.com mongo04.com" >> /etc/hosts
echo "192.168.88.26 mong3 mongo05.com mongo06.com" >> /etc/hosts
Server2:
OS version: CentOS Linux release 8.5.2111
hostnamectl --static set-hostname mongo2
vi /etc/sysconfig/network
# Created by anaconda
hostname=mong2
echo "192.168.88.20 mong1 mongo01.com mongo02.com" >> /etc/hosts
echo "192.168.88.24 mong2 mongo03.com mongo04.com" >> /etc/hosts
echo "192.168.88.26 mong3 mongo05.com mongo06.com" >> /etc/hosts
Server3:
OS version: CentOS Linux release 8.5.2111
hostnamectl --static set-hostname mongo3
vi /etc/sysconfig/network
# Created by anaconda
hostname=mong3
echo "192.168.88.20 mong1 mongo01.com mongo02.com" >> /etc/hosts
echo "192.168.88.24 mong2 mongo03.com mongo04.com" >> /etc/hosts
echo "192.168.88.26 mong3 mongo05.com mongo06.com" >> /etc/hosts
2. 准备分片目录
在各服务器上创建数据目录,使用/data,也可以按特定需求指定目录
在mongo01.com,mongo03.com,mongo05.com上执行:
mkdir -p /data/shard1/db /data/shard1/log /data/config/db /data/config/log
在mongo02.com,mongo04.com,mongo06.com上执行:
mkdir -p /data/shard2/db /data/shard2/log /data/mongos
3. download mongo image
Download MongoDB Community Server | MongoDB