mongodb高可用集群副本集方式搭建

下载wget http://downloads.mongodb.org/linux/mongodb-linux-x86_64-rhel70-v4.2-latest.tgz解压缩tar zxvf mongodb-linux-x86_64-rhel70-v4.2-latest.tgz -C /opt/module/重命名mv /opt/module/mongodb-linux-x86_6...
摘要由CSDN通过智能技术生成

下载

wget http://downloads.mongodb.org/linux/mongodb-linux-x86_64-rhel70-v4.2-latest.tgz

解压缩

tar zxvf mongodb-linux-x86_64-rhel70-v4.2-latest.tgz -C /opt/module/

重命名

mv /opt/module/mongodb-linux-x86_64-rhel70-4.2.0-81-g7897a0a /opt/module/mongodb

增加环境变量

## MONGODB_HOME
export MONGODB_HOME= /opt/module/mongodb
export PATH=$PATH:$MONGODB_HOME/bin

启动

[hadoop@hadoop11 mongodb]$ mkdir data
[hadoop@hadoop11 mongodb]$ mongod --dbpath=./data --logpath=./data/mongo.log --bind_ip=hadoop11 --fork --replSet=xiechuan
about to fork child process, waiting until server is ready for connections.
forked process: 11614
child process started successfully, parent exiting

配置

cfg = {
   _id: "xiechuan",
   members: [
   {
     _id: 0,
     host: 'hadoop11:27017',
     priority: 3
   },
   {
     _id: 1,
     host: 'hadoop12:27017',
     priority: 2
   },
   {
     _id: 2,
     host: 'hadoop13:27017',
     priority: 1
   },
   {
     _id: 3,
     host: 'hadoop14:27017',
     arbiterOnly: true
   }
  ]
 };
[hadoop@hadoop11 mongodb]$ mongo hadoop11:27017
> use admin
switched to db admin
> cfg = {
... _id: "xiechuan",
... members: [
...   {
...     _id: 0,
...     host: 'hadoop11:27017',
...     priority: 3
...   },
...   {
...     _id: 1,
...     host: 'hadoop12:27017',
...     priority: 2
...   },
...   {
...     _id: 2,
...     host: 'hadoop13:27017',
...     priority: 1
...   },
...   {
...     _id: 3,
...     host: 'hadoop14:27017',
...     arbiterOnly: true
...   }
...  ]
... };
{
	"_id" : "xiechuan",
	"members" : [
		{
			"_id" : 0,
			"host" : "hadoop11:27017",
			"priority" : 3
		},
		{
			"_id" : 1,
			"host" : "hadoop12:27017",
			"priority" : 2
		},
		{
			"_id" : 2,
			"host" : "hadoop13:27017",
			"priority" : 1
		},
		{
			"_id" : 3,
			"host" : "hadoop14:27017",
			"arbiterOnly" : true
		}
	]
}
> rs.initiate(cfg)
{
	"ok" : 1,
	"$clusterTime" : {
		"clusterTime" : Timestamp(1566798881, 1),
		"signature" : {
			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
			"keyId" 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值