当前位置: 首页 > 工具软件 > bk-cmdb > 使用案例 >

腾讯蓝鲸bk_cmdb本地开发IP地址变更操作

冉德元
2023-12-01

项目地址 https://github.com/Tencent/bk-cmdb

场景: 在已经配置了mongodb并启动cmdb服务后,本机ip地址发生变化

1.停止cmdb服务

注意:使用stop.sh停止cmdb后,用ps -ef确保cmdb所有服务真的停了,有时可能停不掉,需要手动kill

2.更改mongodb的节点ip

例如: 新的服务地址为192.168.5.199

一 修改mongodb的配置文件中的bindIp字段修改为192.168.5.199

二 重启mongodb

三 配置新的节点信息

在mongo client中输入两条命令

cfg={ _id:"rs0", members:[ {_id:1,host:'192.168.5.199:27017',priority:1}]}

强制应用

rs.reconfig(cfg,{"force":true})

然后rs.status()确认状态正常,以及节点ip是否已经更改为192.168.3.100

例:

rs0:PRIMARY> rs.status()
{
	"set" : "rs0",
	"date" : ISODate("2021-05-11T03:11:20.097Z"),
	"myState" : 1,
	"term" : NumberLong(32),
	"syncingTo" : "",
	"syncSourceHost" : "",
	"syncSourceId" : -1,
	"heartbeatIntervalMillis" : NumberLong(2000),
	"majorityVoteCount" : 1,
	"writeMajorityCount" : 1,
	"optimes" : {
		"lastCommittedOpTime" : {
			"ts" : Timestamp(1620702671, 1),
			"t" : NumberLong(32)
		},
		"lastCommittedWallTime" : ISODate("2021-05-11T03:11:11.885Z"),
		"readConcernMajorityOpTime" : {
			"ts" : Timestamp(1620702671, 1),
			"t" : NumberLong(32)
		},
		"readConcernMajorityWallTime" : ISODate("2021-05-11T03:11:11.885Z"),
		"appliedOpTime" : {
			"ts" : Timestamp(1620702671, 1),
			"t" : NumberLong(32)
		},
		"durableOpTime" : {
			"ts" : Timestamp(1620702671, 1),
			"t" : NumberLong(32)
		},
		"lastAppliedWallTime" : ISODate("2021-05-11T03:11:11.885Z"),
		"lastDurableWallTime" : ISODate("2021-05-11T03:11:11.885Z")
	},
	"lastStableRecoveryTimestamp" : Timestamp(1620702651, 1),
	"lastStableCheckpointTimestamp" : Timestamp(1620702651, 1),
	"electionCandidateMetrics" : {
		"lastElectionReason" : "electionTimeout",
		"lastElectionDate" : ISODate("2021-05-11T03:08:00.972Z"),
		"electionTerm" : NumberLong(32),
		"lastCommittedOpTimeAtElection" : {
			"ts" : Timestamp(0, 0),
			"t" : NumberLong(-1)
		},
		"lastSeenOpTimeAtElection" : {
			"ts" : Timestamp(1620702473, 1),
			"t" : NumberLong(31)
		},
		"numVotesNeeded" : 1,
		"priorityAtElection" : 5,
		"electionTimeoutMillis" : NumberLong(10000),
		"newTermStartDate" : ISODate("2021-05-11T03:08:00.979Z"),
		"wMajorityWriteAvailabilityDate" : ISODate("2021-05-11T03:08:01.087Z")
	},
	"members" : [
		{
			"_id" : 0,
			"name" : "192.168.5.199:27017",
			"health" : 1,
			"state" : 1,
			"stateStr" : "PRIMARY",
			"uptime" : 201,
			"optime" : {
				"ts" : Timestamp(1620702671, 1),
				"t" : NumberLong(32)
			},
			"optimeDate" : ISODate("2021-05-11T03:11:11Z"),
			"syncingTo" : "",
			"syncSourceHost" : "",
			"syncSourceId" : -1,
			"infoMessage" : "",
			"electionTime" : Timestamp(1620702480, 1),
			"electionDate" : ISODate("2021-05-11T03:08:00Z"),
			"configVersion" : 67365,
			"self" : true,
			"lastHeartbeatMessage" : ""
		}
	],
	"ok" : 1,
	"$clusterTime" : {
		"clusterTime" : Timestamp(1620702671, 1),
		"signature" : {
			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
			"keyId" : NumberLong(0)
		}
	},
	"operationTime" : Timestamp(1620702671, 1)
}

3.重启redis zk

4.更改init.py中的地址参数

5.启动cmdb

 类似资料: