gpt4 book ai didi

mongodb - 关闭 mongos 进行升级

转载 作者:IT老高 更新时间:2023-10-28 12:31:46 26 4
gpt4 key购买 nike

我正在升级一个 mongo 分片集群,并且是替换 mongos 进程的第一步。我可以直接终止这个进程,还是有更安全的方法在替换它之前将其关闭?

最佳答案

这就是答案。但可能是你误会了。您不能从命令行关闭 mongos,但您必须登录到 shell。这是我自己尝试的结果:

$ mongo --port 27077 (please replace with your own port on mongos instance)

**mongos**> db.shutdownServer({timeoutSecs:30})
shutdown command only works with the admin database; try 'use admin'
mongos> use admin
switched to db admin
mongos> db.shutdownServer({timeoutSecs:30})
2015-02-27T12:53:54.408+0800 DBClientCursor::init call() failed
**server should be down...**
2015-02-27T12:53:54.410+0800 trying reconnect to 127.0.0.1:27077 (127.0.0.1) failed
2015-02-27T12:53:54.410+0800 warning: Failed to connect to 127.0.0.1:27077, reason: errno:111 Connection refused
2015-02-27T12:53:54.410+0800 reconnect 127.0.0.1:27077 (127.0.0.1) failed failed couldn't connect to server 127.0.0.1:27077 (127.0.0.1), connection attempt failed
2015-02-27T12:53:54.413+0800 trying reconnect to 127.0.0.1:27077 (127.0.0.1) failed
2015-02-27T12:53:54.413+0800 warning: Failed to connect to 127.0.0.1:27077, reason: errno:111 Connection refused
2015-02-27T12:53:54.413+0800 reconnect 127.0.0.1:27077 (127.0.0.1) failed failed couldn't connect to server 127.0.0.1:27077 (127.0.0.1), connection attempt failed
>

尝试运行“top”或“htop”以显示您计算机上运行的所有进程。您将看到“mongos”进程已经消失。阅读日志文件。这是我日志的最后两行:

2015-02-27T12:53:54.406+0800 [conn1] terminating, shutdown command received
2015-02-27T12:53:54.406+0800 [conn1] dbexit: shutdown called rc:0 shutdown called

这是我的测试脚本的链接:

https://github.com/babycaseny/QuickStart/blob/master/StartShard.sh

请注意,您必须将 mongod/mongos 命令中的“localhost”替换为您计算机的主机名,否则您将无法配置分片。

另请参阅:

https://groups.google.com/forum/#!topic/mongodb-user/TQLlRI6HG1M

如果您需要命令行来完成这项工作,这里有一个:

mongo admin --port portnumber --eval "db.shutdownServer()"

请注意,您必须在 localhost 中运行该命令。

关于mongodb - 关闭 mongos 进行升级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15884521/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com