步骤:
1、更新hosts文件
路径:C:\Windows\System32\drivers\etc
在hosts文件里添加:
xxx.xxx.xxx.xxx mongodb0.example.net
xxx.xxx.xxx.xxx mongodb1.example.net
xxx.xxx.xxx.xxx mongodb2.example.net
2、添加文件夹
路径:D:\MongoDB\data
添加3个文件夹db26001,db26002,db26003
3、生成keyfile文件
linux环境:
openssl rand -base64 756 > aaakeyfile1.dat
chmod 400 aaakeyfile1.dat
//文件需要转换格式,从Unix到Windows格式
4、准备config文件
路径:D:\MongoDB\Server\3.2\bin
文件名:mongodb26001.conf
内容:
port=26001
logpath=D:\MongoDB\data\db26001\mongod26001.log
logappend=true
pidfilepath=D:\MongoDB\data\db26001\26001.pid
dbpath=D:\MongoDB\data\db26001
#bind_ip=mongodb0.example.net
maxConns=500
replSet=rs0
#auth=true
#keyFile=D:\MongoDB\Server\3.2\bin\aaakeyfile1.dat
#fork=true
#cpu=true
#noauth=true
//相应配置mongodb26002.conf,mongodb26003.conf
5、启动mongod