返回顶部
首页 > 资讯 > 数据库 >MongoDB3.2如何升级至3.4.6
  • 819
分享到

MongoDB3.2如何升级至3.4.6

2024-04-02 19:04:59 819人浏览 薄情痞子
摘要

mongoDB3.2如何升级至3.4.6,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。MonGoDB 升级测试步骤:1、MongoDB版本升级

mongoDB3.2如何升级至3.4.6,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

MonGoDB 升级测试步骤:

1、MongoDB版本升级顺序3.2->3.4->3.6->4.0 不能跨版本升级

2、升级到3.4后,您不能降级到3.2.7或更早版本。您只能降级到3.2.8或更高版本

3、先升级所有副本集中的Secondary

4、将Primary节点降级为Secondary节点

5、升级Primary

6、MongoDB3.2升级到3.4,登录后查看版本信息若还是3.2,执行db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )

7、MongoDB3.4升级到3.6,登录后查看版本信息若还是3.4,执行db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )

8、MongoDB3.6升级到4.0,登录后查看版本信息若还是3.6,执行db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } )

###只在升级到4.0执行###

  cfg = rs.conf();

  cfg.protocolVersion=1;

  rs.reconfig(cfg);

查看MongoDB进程:

[root@127.0.0.1 bin]# ps -ef | grep mongo

root      17908   9428  0 20:43 pts/1    00:00:00 grep mongo

root      47265      1  0 Oct09 ?        00:09:38 /u02/mongodb/mongodb/bin/mongod -f /u02/mongodb/mongodb/2777/conf/mongodb_2777.conf

root     179052      1  0 Oct09 ?        00:05:27 /u02/mongodb/mongodb/bin/mongod -f /u02/mongodb/mongodb/5777/conf/mongodb_5777.conf

root     180521      1  2 Oct08 ?        00:59:01 /u02/mongodb/mongodb/bin/mongod -f /u02/mongodb/mongodb/3777/conf/mongodb_3777.conf

root     185602      1  0 Oct08 ?        00:08:30 /u02/mongodb/mongodb/bin/mongod -f /u02/mongodb/mongodb/4777/conf/mongodb_4777.conf

端口5777为Primary,2777,3777,4777为Secondary

登录副本集查看副本集信息:

[root@127.0.0.1 bin]# /u02/mongodb/mongodb/bin/mongo --port 5777

MongoDB shell version: 3.2.6

connecting to: 127.0.0.1:5777/test

Server has startup warnings: 

2019-10-09T15:08:26.464+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.

2019-10-09T15:08:26.464+0800 I CONTROL  [initandlisten] 

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] 

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] ** WARNING: You are running on a NUMA Machine.

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] **          We suggest launching mongod like this to avoid perfORMance problems:

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] **              numactl --interleave=all mongod [other options]

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] 

shard1:PRIMARY> rs.status()

{

        "set" : "shard1",

        "date" : ISODate("2019-10-10T12:42:36.196Z"),

        "myState" : 1,

        "term" : NumberLong(4),

        "heartbeatIntervalMillis" : NumberLong(2000),

        "members" : [

                {

                        "_id" : 1,

                        "name" : "127.0.0.1:3777",

                        "health" : 1,

                        "state" : 2,

                        "stateStr" : "SECONDARY",

                        "uptime" : 106410,

                        "optime" : {

                                "ts" : Timestamp(1570711316, 2),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T12:41:56Z"),

                        "lastHeartbeat" : ISODate("2019-10-10T12:42:34.326Z"),

                        "lastHeartbeatRecv" : ISODate("2019-10-10T12:42:35.321Z"),

                        "pingMs" : NumberLong(0),

                        "syncingTo" : "127.0.0.1:5777",

                        "configVersion" : 21

                },

                {

                        "_id" : 2,

                        "name" : "127.0.0.1:4777",

                        "health" : 1,

                        "state" : 2,

                        "stateStr" : "SECONDARY",

                        "uptime" : 106410,

                        "optime" : {

                                "ts" : Timestamp(1570711316, 2),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T12:41:56Z"),

                        "lastHeartbeat" : ISODate("2019-10-10T12:42:34.324Z"),

                        "lastHeartbeatRecv" : ISODate("2019-10-10T12:42:35.321Z"),

                        "pingMs" : NumberLong(0),

                        "syncingTo" : "127.0.0.1:5777",

                        "configVersion" : 21

                },

                {

                        "_id" : 3,

                        "name" : "127.0.0.1:5777",

                        "health" : 1,

                        "state" : 1,

                        "stateStr" : "PRIMARY",

                        "uptime" : 106450,

                        "optime" : {

                                "ts" : Timestamp(1570711316, 2),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T12:41:56Z"),

                        "electionTime" : Timestamp(1570711316, 1),

                        "electionDate" : ISODate("2019-10-10T12:41:56Z"),

                        "configVersion" : 21,

                        "self" : true

                },

                {

                        "_id" : 4,

                        "name" : "127.0.0.1:2777",

                        "health" : 1,

                        "state" : 2,

                        "stateStr" : "SECONDARY",

                        "uptime" : 100601,

                        "optime" : {

                                "ts" : Timestamp(1570711316, 2),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T12:41:56Z"),

                        "lastHeartbeat" : ISODate("2019-10-10T12:42:34.324Z"),

                        "lastHeartbeatRecv" : ISODate("2019-10-10T12:42:35.319Z"),

                        "pingMs" : NumberLong(0),

                        "syncingTo" : "127.0.0.1:5777",

                        "configVersion" : 21

                }

        ],

        "ok" : 1

}

将mongodb-linux-x86_64-rhel62-3.4.6.tgz放在/opt下解压后改名

[root@127.0.0.1 bin]# ls

bsondump  mongo  mongod  mongodump  mongoexport  mongofiles  mongoimport  mongooplog  mongoperf  mongoreplay  mongorestore  mongos  mongostat  mongotop

[root@127.0.0.1 bin]# pwd

/opt/mongodb_3_4/bin

删除副本:

shard1:PRIMARY> rs.remove("127.0.0.1:2777")

关闭2777端口mongo

[root@127.0.0.1 bin]# /mongodb/mongodb/bin/mongod -f /u02/mongodb/mongodb/2777/conf/mongodb_2777.conf --shutdown

通过mongodb3.4启动端口2777mongo,升级至3.4

/opt/mongodb_3_4/bin/mongod -f /u02/mongodb/mongodb/2777/conf/mongodb_2777.conf

登录mongo查看版本信息

[root@127.0.0.1 bin]# /opt/mongodb_3_4/bin/mongo --port 2777

MongoDB shell version v3.4.6

connecting to: mongodb://127.0.0.1:2777/

MongoDB server version: 3.4.6

Server has startup warnings: 

2019-10-09T16:41:23.659+0800 I CONTROL  [initandlisten] 

2019-10-09T16:41:23.659+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.

2019-10-09T16:41:23.659+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.

2019-10-09T16:41:23.659+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.

2019-10-09T16:41:23.659+0800 I CONTROL  [initandlisten] 

2019-10-09T16:41:23.660+0800 I CONTROL  [initandlisten] 

2019-10-09T16:41:23.660+0800 I CONTROL  [initandlisten] ** WARNING: You are running on a NUMA machine.

2019-10-09T16:41:23.660+0800 I CONTROL  [initandlisten] **          We suggest launching mongod like this to avoid performance problems:

2019-10-09T16:41:23.660+0800 I CONTROL  [initandlisten] **              numactl --interleave=all mongod [other options]

2019-10-09T16:41:23.660+0800 I CONTROL  [initandlisten] 

将端口2777mongo添加到副本集

shard1:PRIMARY> rs.add("127.0.0.1:2777")

查看2777端口副本集信息

shard1:PRIMARY> rs.status()

{

        "set" : "shard1",

        "date" : ISODate("2019-10-10T12:49:24.623Z"),

        "myState" : 1,

        "term" : NumberLong(4),

        "heartbeatIntervalMillis" : NumberLong(2000),

        "members" : [

                {

                        "_id" : 1,

                        "name" : "127.0.0.1:3777",

                        "health" : 1,

                        "state" : 2,

                        "stateStr" : "SECONDARY",

                        "uptime" : 106819,

                        "optime" : {

                                "ts" : Timestamp(1570711316, 2),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T12:41:56Z"),

                        "lastHeartbeat" : ISODate("2019-10-10T12:49:24.438Z"),

                        "lastHeartbeatRecv" : ISODate("2019-10-10T12:49:23.376Z"),

                        "pingMs" : NumberLong(0),

                        "syncingTo" : "127.0.0.1:5777",

                        "configVersion" : 21

                },

                {

                        "_id" : 2,

                        "name" : "127.0.0.1:4777",

                        "health" : 1,

                        "state" : 2,

                        "stateStr" : "SECONDARY",

                        "uptime" : 106819,

                        "optime" : {

                                "ts" : Timestamp(1570711316, 2),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T12:41:56Z"),

                        "lastHeartbeat" : ISODate("2019-10-10T12:49:24.438Z"),

                        "lastHeartbeatRecv" : ISODate("2019-10-10T12:49:23.374Z"),

                        "pingMs" : NumberLong(0),

                        "syncingTo" : "127.0.0.1:5777",

                        "configVersion" : 21

                },

                {

                        "_id" : 3,

                        "name" : "127.0.0.1:5777",

                        "health" : 1,

                        "state" : 1,

                        "stateStr" : "PRIMARY",

                        "uptime" : 106858,

                        "optime" : {

                                "ts" : Timestamp(1570711316, 2),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T12:41:56Z"),

                        "electionTime" : Timestamp(1570711316, 1),

                        "electionDate" : ISODate("2019-10-10T12:41:56Z"),

                        "configVersion" : 21,

                        "self" : true

                },

                {

                        "_id" : 4,

                        "name" : "127.0.0.1:2777",                       

                        "health" : 1,

                        "state" : 2,

                        "stateStr" : "SECONDARY",                                      

                        "uptime" : 101009,

                        "optime" : {

                                "ts" : Timestamp(1570711316, 2),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T12:41:56Z"),

                        "lastHeartbeat" : ISODate("2019-10-10T12:49:24.405Z"),

                        "lastHeartbeatRecv" : ISODate("2019-10-10T12:49:23.375Z"),

                        "pingMs" : NumberLong(0),

                        "syncingTo" : "127.0.0.1:5777",

                        "configVersion" : 21

                }

        ],

        "ok" : 1

}

登录mongo3.4版本2777端口查询数据测试

[root@127.0.0.1 bin]# /opt/mongodb_3_4/bin/mongo --port 2777    

MongoDB shell version v3.4.6

connecting to: mongodb://127.0.0.1:2777/

MongoDB server version: 3.4.6

Server has startup warnings: 

2019-10-09T16:41:23.659+0800 I CONTROL  [initandlisten] 

2019-10-09T16:41:23.659+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.

2019-10-09T16:41:23.659+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.

2019-10-09T16:41:23.659+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.

2019-10-09T16:41:23.659+0800 I CONTROL  [initandlisten] 

2019-10-09T16:41:23.660+0800 I CONTROL  [initandlisten] 

2019-10-09T16:41:23.660+0800 I CONTROL  [initandlisten] ** WARNING: You are running on a NUMA machine.

2019-10-09T16:41:23.660+0800 I CONTROL  [initandlisten] **          We suggest launching mongod like this to avoid performance problems:

2019-10-09T16:41:23.660+0800 I CONTROL  [initandlisten] **              numactl --interleave=all mongod [other options]

2019-10-09T16:41:23.660+0800 I CONTROL  [initandlisten] 

shard1:SECONDARY> rs.slaveOk()

shard1:SECONDARY> show dbs

local  0.001GB

test   0.000GB

yoon   0.000GB

shard1:SECONDARY> use yoon

switched to db yoon

shard1:SECONDARY> show collections

movie

shard1:SECONDARY> db.movie.find()

{ "_id" : ObjectId("5d9c7ee9d7a8df8fd023D6ed"), "name" : "hank" }

{ "_id" : ObjectId("5d9d9d5d159fa59c5d01985a"), "hname" : "yoon" }

{ "_id" : ObjectId("5d9d9e33159fa59c5d01985b"), "yname" : "hankyoon" }

通过mongodb3.4启动端口3777mongo,升级至3.4

[root@127.0.0.1 bin]# /u02/mongodb/mongodb/bin/mongo --port 5777

MongoDB shell version: 3.2.6

connecting to: 127.0.0.1:5777/test

Server has startup warnings: 

2019-10-09T15:08:26.464+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.

2019-10-09T15:08:26.464+0800 I CONTROL  [initandlisten] 

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] 

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] ** WARNING: You are running on a NUMA machine.

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] **          We suggest launching mongod like this to avoid performance problems:

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] **              numactl --interleave=all mongod [other options]

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] 

shard1:PRIMARY> rs.remove("127.0.0.1:3777")

{ "ok" : 1 }

shard1:PRIMARY> rs.status()

{

        "set" : "shard1",

        "date" : ISODate("2019-10-10T12:52:37.517Z"),

        "myState" : 1,

        "term" : NumberLong(4),

        "heartbeatIntervalMillis" : NumberLong(2000),

        "members" : [

                {

                        "_id" : 2,

                        "name" : "127.0.0.1:4777",

                        "health" : 1,

                        "state" : 2,

                        "stateStr" : "SECONDARY",

                        "uptime" : 107011,

                        "optime" : {

                                "ts" : Timestamp(1570711953, 1),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T12:52:33Z"),

                        "lastHeartbeat" : ISODate("2019-10-10T12:52:37.379Z"),

                        "lastHeartbeatRecv" : ISODate("2019-10-10T12:52:37.379Z"),

                        "pingMs" : NumberLong(0),

                        "syncingTo" : "127.0.0.1:5777",

                        "configVersion" : 22

                },

                {

                        "_id" : 3,

                        "name" : "127.0.0.1:5777",

                        "health" : 1,

                        "state" : 1,

                        "stateStr" : "PRIMARY",

                        "uptime" : 107051,

                        "optime" : {

                                "ts" : Timestamp(1570711953, 1),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T12:52:33Z"),

                        "electionTime" : Timestamp(1570711316, 1),

                        "electionDate" : ISODate("2019-10-10T12:41:56Z"),

                        "configVersion" : 22,

                        "self" : true

                },

                {

                        "_id" : 4,

                        "name" : "127.0.0.1:2777",

                        "health" : 1,

                        "state" : 2,

                        "stateStr" : "SECONDARY",

                        "uptime" : 101202,

                        "optime" : {

                                "ts" : Timestamp(1570711953, 1),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T12:52:33Z"),

                        "lastHeartbeat" : ISODate("2019-10-10T12:52:37.379Z"),

                        "lastHeartbeatRecv" : ISODate("2019-10-10T12:52:37.379Z"),

                        "pingMs" : NumberLong(0),

                        "syncingTo" : "127.0.0.1:5777",

                        "configVersion" : 22

                }

        ],

        "ok" : 1

}

[root@127.0.0.1 bin]# /u02/mongodb/mongodb/bin/mongod -f /u02/mongodb/mongodb/3777/conf/mongodb_3777.conf --shutdown

killing process with pid: 180521

[root@127.0.0.1 bin]# /opt/mongodb_3_4/bin/mongod -f /u02/mongodb/mongodb/3777/conf/mongodb_3777.conf

about to fork child process, waiting until server is ready for connections.

forked process: 25117

child process started successfully, parent exiting

[root@127.0.0.1 bin]# /opt/mongodb_3_4/bin/mongo --port 3777

MongoDB shell version v3.4.6

connecting to: mongodb://127.0.0.1:3777/

MongoDB server version: 3.4.6

Server has startup warnings: 

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] 

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] 

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] 

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] ** WARNING: You are running on a NUMA machine.

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] **          We suggest launching mongod like this to avoid performance problems:

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] **              numactl --interleave=all mongod [other options]

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] 

shard1:OTHER>    

3777端口升级至3.4.6版本,将3777端口加入副本集

[root@127.0.0.1 bin]# /u02/mongodb/mongodb/bin/mongo --port 5777

MongoDB shell version: 3.2.6

connecting to: 127.0.0.1:5777/test

Server has startup warnings: 

2019-10-09T15:08:26.464+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.

2019-10-09T15:08:26.464+0800 I CONTROL  [initandlisten] 

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] 

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] ** WARNING: You are running on a NUMA machine.

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] **          We suggest launching mongod like this to avoid performance problems:

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] **              numactl --interleave=all mongod [other options]

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] 

shard1:PRIMARY> rs.add("127.0.0.1:3777")

{ "ok" : 1 }

shard1:PRIMARY> rs.status()

{

        "set" : "shard1",

        "date" : ISODate("2019-10-10T12:55:20.927Z"),

        "myState" : 1,

        "term" : NumberLong(4),

        "heartbeatIntervalMillis" : NumberLong(2000),

        "members" : [

                {

                        "_id" : 2,

                        "name" : "127.0.0.1:4777",

                        "health" : 1,

                        "state" : 2,

                        "stateStr" : "SECONDARY",

                        "uptime" : 107175,

                        "optime" : {

                                "ts" : Timestamp(1570712117, 1),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T12:55:17Z"),

                        "lastHeartbeat" : ISODate("2019-10-10T12:55:19.964Z"),

                        "lastHeartbeatRecv" : ISODate("2019-10-10T12:55:19.964Z"),

                        "pingMs" : NumberLong(0),

                        "syncingTo" : "127.0.0.1:5777",

                        "configVersion" : 23

                },

                {

                        "_id" : 3,

                        "name" : "127.0.0.1:5777",

                        "health" : 1,

                        "state" : 1,

                        "stateStr" : "PRIMARY",

                        "uptime" : 107214,

                        "optime" : {

                                "ts" : Timestamp(1570712117, 1),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T12:55:17Z"),

                        "electionTime" : Timestamp(1570711316, 1),

                        "electionDate" : ISODate("2019-10-10T12:41:56Z"),

                        "configVersion" : 23,

                        "self" : true

                },

                {

                        "_id" : 4,

                        "name" : "127.0.0.1:2777",

                        "health" : 1,

                        "state" : 2,

                        "stateStr" : "SECONDARY",

                        "uptime" : 101365,

                        "optime" : {

                                "ts" : Timestamp(1570712117, 1),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T12:55:17Z"),

                        "lastHeartbeat" : ISODate("2019-10-10T12:55:19.964Z"),

                        "lastHeartbeatRecv" : ISODate("2019-10-10T12:55:19.965Z"),

                        "pingMs" : NumberLong(0),

                        "syncingTo" : "127.0.0.1:5777",

                        "configVersion" : 23

                },

                {

                        "_id" : 5,

                        "name" : "127.0.0.1:3777",

                        "health" : 1,

                        "state" : 5,

                        "stateStr" : "STARTUP2",

                        "uptime" : 0,

                        "optime" : {

                                "ts" : Timestamp(1570711953, 1),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T12:52:33Z"),

                        "lastHeartbeat" : ISODate("2019-10-10T12:55:19.964Z"),

                        "lastHeartbeatRecv" : ISODate("2019-10-10T12:55:17.966Z"),

                        "pingMs" : NumberLong(0),

                        "configVersion" : 23

                }

        ],

        "ok" : 1

}

在Primary插入一条新数据在3777端口查询测试

查看DB

shard1:PRIMARY> show dbs

local  0.001GB

test   0.000GB

yoon   0.000GB

连接DB

shard1:PRIMARY> use yoon

switched to db yoon

查看DB下表

shard1:PRIMARY> show collections;

movie

查询数据

shard1:PRIMARY> db.movie.find()

{ "_id" : ObjectId("5d9c7ee9d7a8df8fd023d6ed"), "name" : "hank" }

{ "_id" : ObjectId("5d9d9d5d159fa59c5d01985a"), "hname" : "yoon" }

{ "_id" : ObjectId("5d9d9e33159fa59c5d01985b"), "yname" : "hankyoon" }

当前连接DB

shard1:PRIMARY> db

yoon

插入一条新数据

shard1:PRIMARY> db.movie.insert({"kname":"shouqi"})

WriteResult({ "nInserted" : 1 })

查询数据

shard1:PRIMARY> db.movie.find()

{ "_id" : ObjectId("5d9c7ee9d7a8df8fd023d6ed"), "name" : "hank" }

{ "_id" : ObjectId("5d9d9d5d159fa59c5d01985a"), "hname" : "yoon" }

{ "_id" : ObjectId("5d9d9e33159fa59c5d01985b"), "yname" : "hankyoon" }

{ "_id" : ObjectId("5d9f2aacdaabe0e11aebef86"), "kname" : "shouqi" }

登录2777和3777端口分别查看{ "_id" : ObjectId("5d9f2aacdaabe0e11aebef86"), "kname" : "shouqi" }

[root@127.0.0.1 bin]# /opt/mongodb_3_4/bin/mongo --port 2777

MongoDB shell version v3.4.6

connecting to: mongodb://127.0.0.1:2777/

MongoDB server version: 3.4.6

Server has startup warnings: 

2019-10-09T16:41:23.659+0800 I CONTROL  [initandlisten] 

2019-10-09T16:41:23.659+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.

2019-10-09T16:41:23.659+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.

2019-10-09T16:41:23.659+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.

2019-10-09T16:41:23.659+0800 I CONTROL  [initandlisten] 

2019-10-09T16:41:23.660+0800 I CONTROL  [initandlisten] 

2019-10-09T16:41:23.660+0800 I CONTROL  [initandlisten] ** WARNING: You are running on a NUMA machine.

2019-10-09T16:41:23.660+0800 I CONTROL  [initandlisten] **          We suggest launching mongod like this to avoid performance problems:

2019-10-09T16:41:23.660+0800 I CONTROL  [initandlisten] **              numactl --interleave=all mongod [other options]

2019-10-09T16:41:23.660+0800 I CONTROL  [initandlisten] 

shard1:SECONDARY> rs.slaveOk()

shard1:SECONDARY> use yoon

switched to db yoon

shard1:SECONDARY> db.movie.find()

{ "_id" : ObjectId("5d9c7ee9d7a8df8fd023d6ed"), "name" : "hank" }

{ "_id" : ObjectId("5d9d9d5d159fa59c5d01985a"), "hname" : "yoon" }

{ "_id" : ObjectId("5d9d9e33159fa59c5d01985b"), "yname" : "hankyoon" }

{ "_id" : ObjectId("5d9f2aacdaabe0e11aebef86"), "kname" : "shouqi" }

shard1:SECONDARY> 

[root@127.0.0.1 bin]# /opt/mongodb_3_4/bin/mongo --port 3777

MongoDB shell version v3.4.6

connecting to: mongodb://127.0.0.1:3777/

MongoDB server version: 3.4.6

Server has startup warnings: 

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] 

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] 

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] 

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] ** WARNING: You are running on a NUMA machine.

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] **          We suggest launching mongod like this to avoid performance problems:

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] **              numactl --interleave=all mongod [other options]

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] 

shard1:SECONDARY> rs.slaveOk()

shard1:SECONDARY> use yoon

switched to db yoon

shard1:SECONDARY> db.movie.find()

{ "_id" : ObjectId("5d9c7ee9d7a8df8fd023d6ed"), "name" : "hank" }

{ "_id" : ObjectId("5d9d9d5d159fa59c5d01985a"), "hname" : "yoon" }

{ "_id" : ObjectId("5d9d9e33159fa59c5d01985b"), "yname" : "hankyoon" }

{ "_id" : ObjectId("5d9f2aacdaabe0e11aebef86"), "kname" : "shouqi" }

以此类推升级端口4777,至3.4.6

shard1:PRIMARY> rs.remove("127.0.0.1:4777")

{ "ok" : 1 }

[root@127.0.0.1 bin]# /u02/mongodb/mongodb/bin/mongod -f /u02/mongodb/mongodb/4777/conf/mongodb_4777.conf --shutdown

killing process with pid: 185602

[root@127.0.0.1 bin]# /opt/mongodb_3_4/bin/mongod -f /u02/mongodb/mongodb/4777/conf/mongodb_4777.conf

about to fork child process, waiting until server is ready for connections.

forked process: 34453

child process started successfully, parent exiting

[root@127.0.0.1 bin]# /opt/mongodb_3_4/bin/mongo --port 4777    

MongoDB shell version v3.4.6

connecting to: mongodb://127.0.0.1:4777/

MongoDB server version: 3.4.6

将4777端口添加到副本集

[root@127.0.0.1 bin]# /u02/mongodb/mongodb/bin/mongo --port 5777

MongoDB shell version: 3.2.6

connecting to: 127.0.0.1:5777/test

Server has startup warnings: 

2019-10-09T15:08:26.464+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.

2019-10-09T15:08:26.464+0800 I CONTROL  [initandlisten] 

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] 

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] ** WARNING: You are running on a NUMA machine.

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] **          We suggest launching mongod like this to avoid performance problems:

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] **              numactl --interleave=all mongod [other options]

2019-10-09T15:08:26.465+0800 I CONTROL  [initandlisten] 

shard1:PRIMARY> rs.add("127.0.0.1:4777")

{ "ok" : 1 }

shard1:PRIMARY> rs.status()

{

        "set" : "shard1",

        "date" : ISODate("2019-10-10T13:07:58.679Z"),

        "myState" : 1,

        "term" : NumberLong(4),

        "heartbeatIntervalMillis" : NumberLong(2000),

        "members" : [

                {

                        "_id" : 3,

                        "name" : "127.0.0.1:5777",

                        "health" : 1,

                        "state" : 1,

                        "stateStr" : "PRIMARY",

                        "uptime" : 107972,

                        "optime" : {

                                "ts" : Timestamp(1570712875, 1),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T13:07:55Z"),

                        "electionTime" : Timestamp(1570711316, 1),

                        "electionDate" : ISODate("2019-10-10T12:41:56Z"),

                        "configVersion" : 25,

                        "self" : true

                },

                {

                        "_id" : 4,

                        "name" : "127.0.0.1:2777",

                        "health" : 1,

                        "state" : 2,

                        "stateStr" : "SECONDARY",

                        "uptime" : 102123,

                        "optime" : {

                                "ts" : Timestamp(1570712875, 1),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T13:07:55Z"),

                        "lastHeartbeat" : ISODate("2019-10-10T13:07:57.987Z"),

                        "lastHeartbeatRecv" : ISODate("2019-10-10T13:07:55.990Z"),

                        "pingMs" : NumberLong(0),

                        "syncingTo" : "127.0.0.1:5777",

                        "configVersion" : 25

                },

                {

                        "_id" : 5,

                        "name" : "127.0.0.1:3777",

                        "health" : 1,

                        "state" : 2,

                        "stateStr" : "SECONDARY",

                        "uptime" : 758,

                        "optime" : {

                                "ts" : Timestamp(1570712875, 1),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T13:07:55Z"),

                        "lastHeartbeat" : ISODate("2019-10-10T13:07:57.987Z"),

                        "lastHeartbeatRecv" : ISODate("2019-10-10T13:07:55.990Z"),

                        "pingMs" : NumberLong(0),

                        "syncingTo" : "127.0.0.1:5777",

                        "configVersion" : 25

                },

                {

                        "_id" : 6,

                        "name" : "127.0.0.1:4777",

                        "health" : 1,

                        "state" : 5,

                        "stateStr" : "STARTUP2",

                        "uptime" : 0,

                        "optime" : {

                                "ts" : Timestamp(1570712743, 1),

                                "t" : NumberLong(4)

                        },

                        "optimeDate" : ISODate("2019-10-10T13:05:43Z"),

                        "lastHeartbeat" : ISODate("2019-10-10T13:07:57.987Z"),

                        "lastHeartbeatRecv" : ISODate("2019-10-10T13:07:55.990Z"),

                        "pingMs" : NumberLong(0),

                        "configVersion" : 25

                }

        ],

        "ok" : 1

}

将Primary升级至3.4.6

将Primary节点降级为Secondary节点,有两种方式,一种是rs.stepDown() , 另一种是通过修改优先级来修改Primary

shard1:PRIMARY> rs.stepDown()

通过优先级来修改PRIMARY

shard1:PRIMARY> config=rs.conf()      //查看当前配置,存入config变量中

shard1:PRIMARY> config.members[0].priority = 50         //修改config变量,第1组成员的优先级为50

shard1:PRIMARY> rs.reconfig(config)             //配置生效

shard1:PRIMARY> rs.config()                   //查看当前配置

{

"_id" : "shard1",

"version" : 18,

"protocolVersion" : NumberLong(1),

"members" : [

{

"_id" : 1,

"host" : "127.0.0.1:3777",

"arbiterOnly" : false,

"buildIndexes" : true,

"hidden" : false,

"priority" : 50,

"tags" : {

},

"slaveDelay" : NumberLong(0),

"votes" : 1

},

{

"_id" : 2,

"host" : "127.0.0.1:4777",

"arbiterOnly" : false,

"buildIndexes" : true,

"hidden" : false,

"priority" : 1,

"tags" : {

},

"slaveDelay" : NumberLong(0),

"votes" : 1

},

{

"_id" : 3,

"host" : "127.0.0.1:5777",

"arbiterOnly" : false,

"buildIndexes" : true,

"hidden" : false,

"priority" : 1,

"tags" : {

},

"slaveDelay" : NumberLong(0),

"votes" : 1

},

{

"_id" : 4,

"host" : "127.0.0.1:2777",

"arbiterOnly" : false,

"buildIndexes" : true,

"hidden" : false,

"priority" : 1,                                    

"tags" : {

},

"slaveDelay" : NumberLong(0),

"votes" : 1

}

],

"settings" : {

"chainingAllowed" : true,

"heartbeatIntervalMillis" : 2000,

"heartbeatTimeoutSecs" : 10,

"electionTimeoutMillis" : 10000,

"getLastErrorModes" : {

},

"getLastErrorDefaults" : {

"w" : 1,

"wtimeout" : 0

},

"replicaSetId" : ObjectId("5d9c7a7e76695600e03e231f")

}

}

登录3777端口变为Primary

[root@127.0.0.1 bin]# /opt/mongodb_3_4/bin/mongo --port 3777

MongoDB shell version v3.4.6

connecting to: mongodb://127.0.0.1:3777/

MongoDB server version: 3.4.6

Server has startup warnings: 

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] 

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] 

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] 

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] ** WARNING: You are running on a NUMA machine.

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] **          We suggest launching mongod like this to avoid performance problems:

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] **              numactl --interleave=all mongod [other options]

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] 

shard1:PRIMARY> 

升级5777端口

shard1:PRIMARY> rs.remove("127.0.0.1:5777")

{ "ok" : 1 }

[root@127.0.0.1 bin]# /u02/mongodb/mongodb/bin/mongod -f /u02/mongodb/mongodb/5777/conf/mongodb_5777.conf --shutdown

killing process with pid: 179052

[root@127.0.0.1 bin]# /opt/mongodb_3_4/bin/mongod -f /u02/mongodb/mongodb/5777/conf/mongodb_5777.conf

about to fork child process, waiting until server is ready for connections.

forked process: 40446

child process started successfully, parent exiting

[root@127.0.0.1 bin]# /opt/mongodb_3_4/bin/mongo --port 5777

MongoDB shell version v3.4.6

connecting to: mongodb://127.0.0.1:5777/

MongoDB server version: 3.4.6

将5777端口添加至副本集

[root@127.0.0.1 bin]# /opt/mongodb_3_4/bin/mongo --port 3777

MongoDB shell version v3.4.6

connecting to: mongodb://127.0.0.1:3777/

MongoDB server version: 3.4.6

Server has startup warnings: 

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] 

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.

2019-10-10T20:53:40.536+0800 I CONTROL  [initandlisten] 

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] 

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] ** WARNING: You are running on a NUMA machine.

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] **          We suggest launching mongod like this to avoid performance problems:

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] **              numactl --interleave=all mongod [other options]

2019-10-10T20:53:40.537+0800 I CONTROL  [initandlisten] 

shard1:PRIMARY> rs.add("127.0.0.1:5777")

{ "ok" : 1 }

shard1:PRIMARY> rs.status()

{

        "set" : "shard1",

        "date" : ISODate("2019-10-10T13:16:30.878Z"),

        "myState" : 1,

        "term" : NumberLong(5),

        "heartbeatIntervalMillis" : NumberLong(2000),

        "optimes" : {

                "lastCommittedOpTime" : {

                        "ts" : Timestamp(1570713376, 1),

                        "t" : NumberLong(5)

                },

                "appliedOpTime" : {

                        "ts" : Timestamp(1570713376, 1),

                        "t" : NumberLong(5)

                },

                "durableOpTime" : {

                        "ts" : Timestamp(1570713376, 1),

                        "t" : NumberLong(5)

                }

        },

        "members" : [

                {

                        "_id" : 4,

                        "name" : "127.0.0.1:2777",

                        "health" : 1,

                        "state" : 2,

                        "stateStr" : "SECONDARY",

                        "uptime" : 1272,

                        "optime" : {

                                "ts" : Timestamp(1570713376, 1),

                                "t" : NumberLong(5)

                        },

                        "optimeDurable" : {

                                "ts" : Timestamp(1570713376, 1),

                                "t" : NumberLong(5)

                        },

                        "optimeDate" : ISODate("2019-10-10T13:16:16Z"),

                        "optimeDurableDate" : ISODate("2019-10-10T13:16:16Z"),

                        "lastHeartbeat" : ISODate("2019-10-10T13:16:28.911Z"),

                        "lastHeartbeatRecv" : ISODate("2019-10-10T13:16:26.912Z"),

                        "pingMs" : NumberLong(0),

                        "configVersion" : 28

                },

                {

                        "_id" : 5,

                        "name" : "127.0.0.1:3777",

                        "health" : 1,

                        "state" : 1,

                        "stateStr" : "PRIMARY",

                        "uptime" : 1370,

                        "optime" : {

                                "ts" : Timestamp(1570713376, 1),

                                "t" : NumberLong(5)

                        },

                        "optimeDate" : ISODate("2019-10-10T13:16:16Z"),

                        "electionTime" : Timestamp(1570713059, 1),

                        "electionDate" : ISODate("2019-10-10T13:10:59Z"),

                        "configVersion" : 28,

                        "self" : true

                },

                {

                        "_id" : 6,

                        "name" : "127.0.0.1:4777",

                        "health" : 1,

                        "state" : 2,

                        "stateStr" : "SECONDARY",

                        "uptime" : 514,

                        "optime" : {

                                "ts" : Timestamp(1570713376, 1),

                                "t" : NumberLong(5)

                        },

                        "optimeDurable" : {

                                "ts" : Timestamp(1570713376, 1),

                                "t" : NumberLong(5)

                        },

                        "optimeDate" : ISODate("2019-10-10T13:16:16Z"),

                        "optimeDurableDate" : ISODate("2019-10-10T13:16:16Z"),

                        "lastHeartbeat" : ISODate("2019-10-10T13:16:28.911Z"),

                        "lastHeartbeatRecv" : ISODate("2019-10-10T13:16:26.912Z"),

                        "pingMs" : NumberLong(0),

                        "configVersion" : 28

                },

                {

                        "_id" : 7,

                        "name" : "127.0.0.1:5777",

                        "health" : 1,

                        "state" : 2,

                        "stateStr" : "SECONDARY",

                        "uptime" : 11,

                        "optime" : {

                                "ts" : Timestamp(1570713376, 1),

                                "t" : NumberLong(5)

                        },

                        "optimeDurable" : {

                                "ts" : Timestamp(1570713376, 1),

                                "t" : NumberLong(5)

                        },

                        "optimeDate" : ISODate("2019-10-10T13:16:16Z"),

                        "optimeDurableDate" : ISODate("2019-10-10T13:16:16Z"),

                        "lastHeartbeat" : ISODate("2019-10-10T13:16:28.911Z"),

                        "lastHeartbeatRecv" : ISODate("2019-10-10T13:16:27.075Z"),

                        "pingMs" : NumberLong(0),

                        "configVersion" : 28

                }

        ],

        "ok" : 1

}

在Primary插入数据,在所有端口Secondary测试数据是否正常

shard1:PRIMARY> db.movie.insert({"shouyue":"yunweibu"})

WriteResult({ "nInserted" : 1 })

shard1:PRIMARY> db.movie.find()

{ "_id" : ObjectId("5d9c7ee9d7a8df8fd023d6ed"), "name" : "hank" }

{ "_id" : ObjectId("5d9d9d5d159fa59c5d01985a"), "hname" : "yoon" }

{ "_id" : ObjectId("5d9d9e33159fa59c5d01985b"), "yname" : "hankyoon" }

{ "_id" : ObjectId("5d9f2aacdaabe0e11aebef86"), "kname" : "shouqi" }

{ "_id" : ObjectId("5d9f2fa0b384f3ba8df3a0ce"), "shouyue" : "yunweibu" }   #查看各端口是否有此条数据

2777端口:

[root@127.0.0.1 bin]# /opt/mongodb_3_4/bin/mongo --port 2777

MongoDB shell version v3.4.6

connecting to: mongodb://127.0.0.1:2777/

MongoDB server version: 3.4.6

shard1:SECONDARY> show dbs

2019-10-10T21:19:51.176+0800 E QUERY    [thread1] Error: listDatabases failed:{

        "ok" : 0,

        "errmsg" : "not master and slaveOk=false",

        "code" : 13435,

        "codeName" : "NotMasterNoSlaveOk"

} :

_getErrorWithCode@src/mongo/shell/utils.js:25:13

Mongo.prototype.getDBs@src/mongo/shell/mongo.js:62:1

shellHelper.show@src/mongo/shell/utils.js:769:19

shellHelper@src/mongo/shell/utils.js:659:15

@(shellhelp2):1:1

shard1:SECONDARY> rs.slaveOk()

shard1:SECONDARY> use yoon

switched to db yoon

shard1:SECONDARY> db.movie.find()

{ "_id" : ObjectId("5d9c7ee9d7a8df8fd023d6ed"), "name" : "hank" }

{ "_id" : ObjectId("5d9d9d5d159fa59c5d01985a"), "hname" : "yoon" }

{ "_id" : ObjectId("5d9d9e33159fa59c5d01985b"), "yname" : "hankyoon" }

{ "_id" : ObjectId("5d9f2aacdaabe0e11aebef86"), "kname" : "shouqi" }

{ "_id" : ObjectId("5d9f2fa0b384f3ba8df3a0ce"), "shouyue" : "yunweibu" }

4777端口:

[root@127.0.0.1 bin]# /opt/mongodb_3_4/bin/mongo --port 4777

MongoDB shell version v3.4.6

connecting to: mongodb://127.0.0.1:4777/

MongoDB server version: 3.4.6

Server has startup warnings: 

2019-10-10T21:07:05.390+0800 I CONTROL  [initandlisten] 

2019-10-10T21:07:05.390+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.

2019-10-10T21:07:05.390+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.

2019-10-10T21:07:05.390+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.

2019-10-10T21:07:05.390+0800 I CONTROL  [initandlisten] 

2019-10-10T21:07:05.390+0800 I CONTROL  [initandlisten] 

2019-10-10T21:07:05.390+0800 I CONTROL  [initandlisten] ** WARNING: You are running on a NUMA machine.

2019-10-10T21:07:05.390+0800 I CONTROL  [initandlisten] **          We suggest launching mongod like this to avoid performance problems:

2019-10-10T21:07:05.390+0800 I CONTROL  [initandlisten] **              numactl --interleave=all mongod [other options]

2019-10-10T21:07:05.390+0800 I CONTROL  [initandlisten] 

shard1:SECONDARY> rs.slaveOk()

shard1:SECONDARY> use yoon

switched to db yoon

shard1:SECONDARY> db.movie.find()

{ "_id" : ObjectId("5d9c7ee9d7a8df8fd023d6ed"), "name" : "hank" }

{ "_id" : ObjectId("5d9d9d5d159fa59c5d01985a"), "hname" : "yoon" }

{ "_id" : ObjectId("5d9d9e33159fa59c5d01985b"), "yname" : "hankyoon" }

{ "_id" : ObjectId("5d9f2aacdaabe0e11aebef86"), "kname" : "shouqi" }

{ "_id" : ObjectId("5d9f2fa0b384f3ba8df3a0ce"), "shouyue" : "yunweibu" }

5777端口:

[root@127.0.0.1 bin]# /opt/mongodb_3_4/bin/mongo --port 5777

MongoDB shell version v3.4.6

connecting to: mongodb://127.0.0.1:5777/

MongoDB server version: 3.4.6

Server has startup warnings: 

2019-10-10T21:15:35.059+0800 I CONTROL  [initandlisten] 

2019-10-10T21:15:35.059+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.

2019-10-10T21:15:35.059+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.

2019-10-10T21:15:35.059+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.

2019-10-10T21:15:35.059+0800 I CONTROL  [initandlisten] 

2019-10-10T21:15:35.060+0800 I CONTROL  [initandlisten] 

2019-10-10T21:15:35.060+0800 I CONTROL  [initandlisten] ** WARNING: You are running on a NUMA machine.

2019-10-10T21:15:35.060+0800 I CONTROL  [initandlisten] **          We suggest launching mongod like this to avoid performance problems:

2019-10-10T21:15:35.060+0800 I CONTROL  [initandlisten] **              numactl --interleave=all mongod [other options]

2019-10-10T21:15:35.060+0800 I CONTROL  [initandlisten] 

shard1:SECONDARY> rs.slaveOk()

shard1:SECONDARY> use yoon

switched to db yoon

shard1:SECONDARY> db.movie.find()

{ "_id" : ObjectId("5d9c7ee9d7a8df8fd023d6ed"), "name" : "hank" }

{ "_id" : ObjectId("5d9d9d5d159fa59c5d01985a"), "hname" : "yoon" }

{ "_id" : ObjectId("5d9d9e33159fa59c5d01985b"), "yname" : "hankyoon" }

{ "_id" : ObjectId("5d9f2aacdaabe0e11aebef86"), "kname" : "shouqi" }

{ "_id" : ObjectId("5d9f2fa0b384f3ba8df3a0ce"), "shouyue" : "yunweibu" }

MongoDB3.2升级至3.4.6升级完成。

但是真正的升级线上需要开发,测试配合来完成,保证升级的可用性。

看完上述内容,你们掌握MongoDB3.2如何升级至3.4.6的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注编程网数据库频道,感谢各位的阅读!

您可能感兴趣的文档:

--结束END--

本文标题: MongoDB3.2如何升级至3.4.6

本文链接: https://lsjlt.com/news/61406.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
  • MongoDB3.2如何升级至3.4.6
    MongoDB3.2如何升级至3.4.6,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。MongoDB 升级测试步骤:1、MongoDB版本升级...
    99+
    2024-04-02
  • php5.6如何升级至7.2.7
    小编给大家分享一下php5.6如何升级至7.2.7,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧![root@localhost hdwiki]# yum list...
    99+
    2023-06-04
  • mac 10.13.6 升级至10.14.6再升级至12.4
    mac 10.13.6 升级至10.14.6再升级至12.4 前几天一个月薪35k的兄弟,给我推了一个人工智能学习网站,看了一段时间挺有意思的。包括语音识别、机器翻译等从基础到实战都有,很详细,分享给...
    99+
    2023-10-23
    macos
  • MySQL5.5升级至5.7
    一、准备工作 新的服务器(10.12.21.184),作为从库 在21.184上下载MySQL5.6、5.7的最新稳定版本的二进制包 host role 10.12.21.120 mast...
    99+
    2024-04-02
  • CentOS7 升级openssl版本(升级至3.0.3)
    首先查看本地openssl版本 openssl version 创建一个放源码的目录(按自己习惯) #这里是我的习惯cd /usr/local/src #去官网获取你想要版本的tar压...
    99+
    2023-09-27
    linux 服务器 ubuntu
  • oracle 11.2.0.1升级至11.2.0.4
    补丁集11.2.0.4版本,似乎仅对购买了Oracle服务的用户开放。找同学分享了一个,因为之前装有11.2.0.1版本,所以将其升级到11.2.0.4版本,升级只需要1、2两个文件:Table 1 Ins...
    99+
    2024-04-02
  • centOS升级python2至pyth
    今天安装了一个centos 6.9  ,查看默认python版本是2.6,所以准备升级,按着以前在ubuntu上的升级步骤:(1)  wget http://www.python.org/ftp/python/3.3.0/Python-3....
    99+
    2023-01-31
    centOS pyth
  • CentOS5.8 升级python至2
    yum install openssl openssl-develtar jxvf Python-2.6.6.tar.bz2 cd Python-2.6.6./configuremake && make install[ro...
    99+
    2023-01-31
    python
  • 如何将CentOS7升级至CentOS8(详细步骤)
    这篇文章以具体的示例来介绍一下从CentOS 7升级值CentOS 8的方法。 事前准备 最小化安装CentOS 7,具体版本如下所示:7.6.1810 [root@liumiao ~]# uname -a lin...
    99+
    2022-06-04
    CentOS7升级至CentOS8 CentOS8升级 CentOS7升级
  • Oracle database 11.2.0.1 升级至 11.2.0.3
    首先下载Oracle 11.2.0.3 Patchset http://yunpan.cn/cHgQuIuxUTThS 访问密码 043f将Patchset上传至服务器[oracle@l...
    99+
    2024-04-02
  • Oracle database 11.2.0.3.0 升级至 11.2.0.3.14
    下载PSU p20299017_112030_Linux-x86-64(DATABASE PATCH SET UPDATE 11.2.0.3.14 (INCLUDES CPUAPR2015...
    99+
    2024-04-02
  • centos6.5系统Python升级至
    1、升级安装Python2.7 解压tar.xz文件:先 xz -d xxx.tar.xz 将 xxx.tar.xz解压成 xxx.tar 然后,再用 tar xvf xxx.tar来解包wget https://www.python.or...
    99+
    2023-01-31
    系统 Python
  • Win10如何下载KB4579311升级至19042.572预览版
    这篇文章将为大家详细讲解有关Win10如何下载KB4579311升级至19042.572预览版,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。一般来说,Beta预览版更新出现的问题较少,不需要删除Softw...
    99+
    2023-06-10
  • 小编教你win7如何升级至win10系统
    Win10在易用性和安全性方面有了极大的提升,除了针对云服务、智能移动设备、等新技术进行融合外,还对固态硬盘、高分辨率屏幕等硬件进行了优化完善与支持;从而吸引了更多的win7用户想升级至win10系统,现在小编就教大家win7如何升级至wi...
    99+
    2023-07-12
  • CentOS7 升级PHP版本至7.4.30
    一、环境准备: 1、服务器事先准备好本地yum源,或者可访问外网。 2、准备好PHP升级包及依赖包。 3、先停止当前的PHP 4、将当前PHP移动至其他目录下作为备份 二、升级步骤 1、将PHP压缩包...
    99+
    2023-10-04
    php 开发语言
  • 如何升级服务器上的PHP版本至5.3
    标题:如何升级服务器上的PHP版本至5.3,需要具体代码示例 在服务器运行的网站中,PHP版本的升级是一个常见的需求。为了适应新的功能和性能优化,升级PHP版本至5.3是一个比较普遍的...
    99+
    2024-03-09
    php 服务器设置 升级php版本 数据丢失
  • MySQL 5.6升级至MySQL 5.7--------版本升级最佳实战
    1. 背景   MySQL 5.7是当前MySQL最新版本,与MySQL 5.6版本相比,有如下特征  * 性能和可扩展性:改进 InnoDB 的可扩展性和临时表的性能,从而实现更快的网...
    99+
    2024-04-02
  • win10 9901怎么升级至win10 9916?win10 9901升级教程
      相信很多升级至win10泄露版9901的朋友发现想要升级为最新版9916却无法安装了,下文小编就为大家带来win10 9901的升级教程,感兴趣的朋友一起去了解下吧。  进入2015年,微软Windows 10技术预...
    99+
    2023-06-10
    win10 win109916 9901 升级 教程 9916
  • 升级至Windows7时升级在62%停止响应(挂起)
    当Windows 7升级在62%停止响应时,可能是由于以下原因之一导致的:1. 硬件兼容性问题:升级过程中可能发现某些硬件设备与Wi...
    99+
    2023-09-08
    Windows7
  • 线上环境MySQL5.5升级至5.6
    本文主要记录了线上环境percona5.5.35升级到5.6.32-78.0的过程。 欢迎转载,请注明作者、出处。 ...
    99+
    2024-04-02
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作