$ cd mongodb-4.2.1 $ bin/mongod -f ../MongoData/db1/mongod.conf about to fork child process, waiting until server is ready for connections. forked process: 3714 child process started successfully, parent exiting $ bin/mongod -f ../MongoData/db2/mongod.conf about to fork child process, waiting until server is ready for connections. forked process: 3752 child process started successfully, parent exiting $ bin/mongod -f ../MongoData/db3/mongod.conf about to fork child process, waiting until server is ready for connections. forked process: 3790 child process started successfully, parent exiting
通过ps和netstat分别查看一下:
1 2 3 4 5 6 7 8 9 10 11 12
$ ps -ef | grep mongod top 3714 1 3 22:09 ? 00:00:00 bin/mongod -f ../MongoData/db1/mongod.conf top 3752 1 6 22:09 ? 00:00:01 bin/mongod -f ../MongoData/db2/mongod.conf top 3790 1 16 22:09 ? 00:00:01 bin/mongod -f ../MongoData/db3/mongod.conf top 3827 3111 0 22:09 pts/0 00:00:00 grep --color=auto mongod $ netstat -antp | grep mongod (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0 0 0.0.0.0:28018 0.0.0.0:* LISTEN 3714/bin/mongod tcp 0 0 0.0.0.0:28019 0.0.0.0:* LISTEN 3752/bin/mongod tcp 0 0 0.0.0.0:28020 0.0.0.0:* LISTEN 3790/bin/mongod
配置节点
进入第一个节点:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
$ bin/mongo top:28018 > rs.initiate() { "info2" : "no configuration specified. Using a default configuration for the set", "me" : "top:28018", "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1575211318, 1), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } }, "operationTime" : Timestamp(1575211318, 1) } rs0:SECONDARY> rs0:PRIMARY>