操作系统:RedHat6.4 64位
Config
Route
分片1
分片2
分片3
使用端口
28000
27017
27018
27019
27020
IP地址
192.168.1.30
/etc/config.conf
/etc/route.conf
/etc/sd1.conf(主)
/etc/sd2.conf(仲裁)
/etc/sd3.conf(备)
192.168.1.52
/etc/config.conf
/etc/route.conf
/etc/sd1.conf(备)
/etc/sd2.conf(主)
/etc/sd3.conf(仲裁)
192.168.1.108
/etc/config.conf
/etc/route.conf
/etc/sd1.conf(仲裁)
/etc/sd2.conf(备)
/etc/sd3.conf(主)
一、在三个节点上创建如下目录,做测试的话建议确保在/目录有15G左右的剩余空间
[root@orcl ~]# mkdir -p /var/config
[root@orcl ~]# mkdir -p /var/sd1
[root@orcl ~]# mkdir -p /var/sd2
[root@orcl ~]# mkdir -p /var/sd3
二、查看配置文件
[root@orcl ~]# cat /etc/config.conf
port=28000
dbpath=/var/config
logpath=/var/config/config.log
logappend=true
fork=true
configsvr=true
[root@orcl ~]# cat /etc/route.conf
port=27017
configdb=192.168.1.30:28000,192.168.1.52:28000,192.168.1.108:28000
logpath=/var/log/mongos.log
logappend=true
fork=true
[root@orcl ~]# cat /etc/sd1.conf
port = 27018
dbpath=/var/sd1
logpath =/var/sd1/shard1.log
logappend =true
shardsvr =true
replSet =set1
fork =true
[root@orcl ~]# cat /etc/sd2.conf
port = 27019
dbpath=/var/sd2
logpath =/var/sd2/shard2.log
logappend =true
shardsvr =true
replSet =set2
fork =true
[root@orcl ~]# cat /etc/sd3.conf
port = 27020
dbpath=/var/sd3
logpath =/var/sd3/shard1.log
logappend =true
shardsvr =true
replSet =set3
fork =true
三、在三个节点上同步时间
略
四、在三个节点上启动用config服务器
节点1
[root@orcl ~]# mongod -f /etc/config.conf
about to fork child process, waiting until server is ready for connections.
forked process: 3472
child process started successfully, parent exiting
[root@orcl ~]# ps -ef |grep mongo
root 3472 1 1 19:15 ? 00:00:01 mongod -f /etc/config.conf
root 3499 2858 0 19:17 pts/0 00:00:00 grep mongo
[root@orcl ~]# netstat -anltp|grep 28000
tcp 0 0 0.0.0.0:28000 0.0.0.0:* LISTEN 3472/mongod
节点2
[root@localhost ~]# mongod -f /etc/config.conf
about to fork child process, waiting until server is ready for connections.
forked process: 2998
child process started successfully, parent exiting
[root@localhost ~]# ps -ef |grep mongo
root 2998 1 8 19:15 ? 00:00:08 mongod -f /etc/config.conf
root 3014 2546 0 19:17 pts/0 00:00:00 grep mongo
[root@localhost ~]# netstat -anltp|grep 28000
tcp 0 0 0.0.0.0:28000 0.0.0.0:* LISTEN 2998/mongod
节点3
[root@db10g ~]# mongod -f /etc/config.conf
about to fork child process, waiting until server is ready for connections.
forked process: 4086
child process started successfully, parent exiting
[root@db10g ~]# ps -ef |grep mongo
root 4086 1 2 19:25 ? 00:00:00 mongod -f /etc/config.conf
root 4100 3786 0 19:25 pts/0 00:00:00 grep mongo
[root@db10g ~]# netstat -anltp|grep 28000