MariaDB集群搭建

粗陋的记录一下

shard1:
config = {_id : "shard1",members : [{_id : 0, host : "192.168.0.120:27001" }, {_id : 1, host : "192.168.0.121:27001", arbiterOnly: true }, {_id : 2, host : "192.168.0.122:27001" }]}

rs.initiate(config);

shard2:
config = {_id : "shard2",members : [{_id : 0, host : "192.168.0.120:27002" }, {_id : 1, host : "192.168.0.121:27002" }, {_id : 2, host : "192.168.0.122:27002", arbiterOnly: true }]}
仲裁不能再同一台服务器上换下就可以

shard3:
config = {_id : "shard3",members : [{_id : 0, host : "192.168.0.120:27003", arbiterOnly: true}, {_id : 1, host : "192.168.0.121:27003"  }, {_id : 2, host : "192.168.0.122:27003" }]}

server:
config = {_id : "configs",members : [{_id : 0, host : "192.168.0.120:21000" }, {_id : 1, host : "192.168.0.121:21000" }, {_id : 2, host : "192.168.0.122:21000" }]}

13 21 32
12 23 31

pidfilepath = /data/mongodb/mongos/log/mongos.pid
logpath = /data/mongodb/mongos/log/mongos.log
logappend = true

bind_ip = 0.0.0.0
port = 20000
fork = true

#监听的配置服务器,只能有1个或者3个 configs为配置服务器的副本集名字
configdb = configs/172.25.34.210:21000,172.25.34.211:21000,172.25.34.212:21000
 
#设置最大连接数
maxConns=20000


sh.addShard("shard1/192.168.0.120:27001,192.168.0.121:27001,192.168.0.122:27001")
sh.addShard("shard2/192.168.0.120:27002,192.168.0.121:27002,192.168.0.122:27002")
sh.addShard("shard3/192.168.0.120:27003,192.168.0.121:27003,192.168.0.122:27003")



./mongod -f /opt/mongodb/mongodb-linux-x86_64-4.0.10/conf/config.conf
./mongod -f /opt/mongodb/mongodb-linux-x86_64-4.0.10/conf/shard1.conf
./mongod -f /opt/mongodb/mongodb-linux-x86_64-4.0.10/conf/shard2.conf
./mongod -f /opt/mongodb/mongodb-linux-x86_64-4.0.10/conf/shard3.conf
./mongos -f /opt/mongodb/mongodb-linux-x86_64-4.0.10/conf/mongos.conf


use admin
db.runCommand( { enablesharding :"kaliarchdb"});    #开启kaliarch库分片功能
db.runCommand( { shardcollection : "kaliarchdb.table1",key : {_id:"hashed"} } )    #指定数据库里需要分片的集合tables和片键_id

for (var i = 1; i <= 10000; i++) db.table1.save({id:i,"test2":"testval1"});
db.table1.stats();
rs.status();

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值