首页 > 数据库 >mongodb副本集模式的单机修改ip(update方式)

mongodb副本集模式的单机修改ip(update方式)

时间:2023-08-09 10:56:58浏览次数:61  
标签:bin mongo mongodb update usr ip services local

环境:
OS:Centos 7
mongodb:4.4.22

 

1.停掉当前运行的mongodb
/usr/local/services/mongodb/bin/mongo localhost:29001
use admin
db.shutdownServer()

 

2.网络层面修改ip地址
[root@localhost network-scripts]# service network restart

 

3.修改参数
修改配置文件,注释掉副本集参数和修改bind_ip参数
vi /home/middle/mongodb/conf/mongo.cnf
##replSet=s1
bind_ip=192.168.1.108,127.0.0.1

 

4.启动mongodb
[root@localhost ~]# /usr/local/services/mongodb/bin/mongod -f /home/middle/mongodb/conf/mongo.cnf

 

5.更新db.system.replset表

/usr/local/services/mongodb/bin/mongo 192.168.1.108:29001
use local
cfg = db.system.replset.findOne({_id: 's1'})
cfg.members[0].host = "192.168.1.108:29001"
db.system.replset.update({_id: 's1'}, cfg)
db.system.replset.find()

 

6.关闭mongodb
/usr/local/services/mongodb/bin/mongo localhost:29001
use admin
db.shutdownServer()

 

7.修改参数后启动
vi /home/middle/mongodb/conf/mongo.cnf
replSet=s1

启动
[root@localhost ~]# /usr/local/services/mongodb/bin/mongod -f /home/middle/mongodb/conf/mongo.cnf

 

8.登录查看

/usr/local/services/mongodb/bin/mongo 192.168.1.108:29001

s1:PRIMARY> rs.conf()
{
        "_id" : "s1",
        "version" : 56419,
        "protocolVersion" : NumberLong(1),
        "writeConcernMajorityJournalDefault" : true,
        "members" : [
                {
                        "_id" : 0,
                        "host" : "192.168.1.108:29001",
                        "arbiterOnly" : false,
                        "buildIndexes" : true,
                        "hidden" : false,
                        "priority" : 1,
                        "tags" : {

                        },
                        "slaveDelay" : NumberLong(0),
                        "votes" : 1
                }
        ],
        "settings" : {
                "chainingAllowed" : true,
                "heartbeatIntervalMillis" : 2000,
                "heartbeatTimeoutSecs" : 10,
                "electionTimeoutMillis" : 10000,
                "catchUpTimeoutMillis" : -1,
                "catchUpTakeoverDelayMillis" : 30000,
                "getLastErrorModes" : {

                },
                "getLastErrorDefaults" : {
                        "w" : 1,
                        "wtimeout" : 0
                },
                "replicaSetId" : ObjectId("64d20b9a0dd2e7e36110962a")
        }
}

 

标签:bin,mongo,mongodb,update,usr,ip,services,local
From: https://www.cnblogs.com/hxlasky/p/17616278.html

相关文章

  • python:升级pip版本(Python 3.11.4)
    一,查看当前pip的版本:[[email protected]]#pip--versionpip23.1.2from/usr/local/soft/python3.11.4/lib/python3.11/site-packages/pip(python3.11)二,升级pip:[[email protected]]#python3-mpipinstall--upgradepipLookinginindexes:http://m......
  • 使用MyEclipse如何部署Descriptor (XML)编辑器?
    Descriptor(XML)Editor编辑器包含了高级的XML编辑功能,在本文中您将了解到这些编辑功能、WebXML编辑等,此功能包含在MyEclipse中可用。MyEclipsev2023.1.2离线版下载MyEclipse技术交流群:742336981欢迎一起进群讨论1.WebXML编辑器MyEclipse WebXML编辑器包括高级XML编......
  • 【JavaScript29】call和apply
    概率每个函数都包含两个非继承而来的方法:apply()和call()call和apply都属于Function.prototype的一个方法,所以每个function实例都有call、apply属性作用call()方法和apply()方法的作用相同:改变this指向区别call():第一个参数是this,其余参数都是直接传递给......
  • 遇到问题--python--爬虫--使用代理ip第二次获取代理ip失败
    情况获取代理ip的代码defferch_proxy_ips():try:api="http://dynamic.goubanjia.com/dynamic/get/12323.html?sep=3"response=urllib.request.urlopen(api,timeout=8)the_page=response.read()content=the_page.decode(&......
  • 【代码块】-Helper-GZIP
    整理代码块代码块整理后存储,供后期使用usingSystem;usingSystem.IO;usingSystem.IO.Compression;usingSystem.Text;publicclassGzipHelper{///<summary>///GZIP解压缩///</summary>///<paramname="data"></param>/......
  • 【JavaScript27】关于Function
    js中所有的函数都是通过Function构建的.在没有修改过原型链的情况下.以下等式是成立的.console.log(fn.proto.constructor===Function.prototype.constructor);console.log(fn.proto.constructor===Function);varfn=newFunction("console.log(123456);");//Funct......
  • 【JavaScript26】继承
    JS中实现继承,只需要改变函数的原型链即可示例functionCat(name){this.name=name;}Cat.prototype.eat_fish=function(fish){console.log(this.name,"在吃",fish);};functionBosiCat(name){this.name=name;}BosiCat.prototype.dance=functi......
  • 【JavaScript25】关于prototype
    老版本的js中是没有类的概念的.js如何构建一个对象的呢?在js中,每一个函数都可以作为构建一个对象的构造方法函数又可以被称为构造函数constructor构造器,构造方法functionPerson(name,age){//给当前对象(内存)进行初始化this.name=name;this.age......
  • TCP/IP 五层模型
    TCP/IP五层模型物理层(PhysicalLayer):物理层是最底层,负责传输比特流(bitstream)以及物理介质的传输方式。它定义了如何在物理媒介上传输原始的比特流,例如通过电缆、光纤或无线传输等。数据链路层(DataLinkLayer):数据链路层位于物理层之上,负责在直接相连的节点之间传输数据帧(Fra......
  • yum update更新报错 Transaction Check Error 解决方法
    yumupdate更新报错TransactionCheckError解决方法yumupdate引起错误TransactionCheckError的原因很多,要根据错误概要去判断具体原因。错误现象:报错内容:file/usr/share/man/man1/gtk-query-immodules-2.0.1.gzfrominstallofgtk2-2.24.31-1.el7.x86_64conflicts......