基于Linux平台MongoDB分片的conf文件

mongodb Config Server的配置文件 (只需更改bindIP)

systemLog:
  destination: file
  path: "/opt/servers/mongodb_demo/standalone/logs/mongologs.log"
  logAppend: true
storage:
  dbPath: "/opt/servers/mongodb_demo/standalone/data/db/"
  journal:
    enabled: true
processManagement:
  fork: true
#开启安全认证则去掉#
#security:
#  keyFile: "/opt/servers/mongodb_demo/standalone/key/keyfile"
#  authorization: enabled
net:  
    #服务实例绑定所有IP,有副作用,副本集初始化的时候,节点名字会自动设置为本地域名,而不是ip  
    #bindIpAll: true  
    #服务实例绑定的IP  
    bindIp: localhost,192.168.203.135
    #bindIp  
    #绑定的端口  
    port: 27022
replication:  
    #副本集的名称  
    replSetName: itcast
sharding:
    clusterRole: configsvr
   

shard 的配置文件(只需更改replSetName;port;bindIP)

systemLog:
  destination: file
  path: "/opt/servers/mongodb_demo/shard/logs/shard1.log"
  logAppend: true
storage:
  dbPath: "/opt/servers/mongodb_demo/shard/data/data1/"
  journal:
    enabled: true
processManagement:
  fork: true
#开启安全认证则去掉#
#security:
#  keyFile: "/opt/servers/mongodb_demo/shard/key/keyfile1"
#  authorization: enabled
net:  
    #服务实例绑定所有IP,有副作用,副本集初始化的时候,节点名字会自动设置为本地域名,而不是ip  
    #bindIpAll: true  
    #服务实例绑定的IP  
  bindIp: localhost,192.168.203.135
    #bindIp  
    #绑定的端口  
  port: 27018
replication:  
    #副本集的名称  
  replSetName: shart1
  oplogSizeMB: 2048
sharding:
  clusterRole: shardsvr
   

 mongos(只需更改port;bindIP)

sharding:
  configDB: itcast/192.168.203.135:27022,192.168.203.136:27022,192.168.203.137:27022
systemLog:
  destination: file
  path: "/opt/servers/mongodb_demo/mongos/logs/mongos.log"
  logAppend: true
processManagement:
  fork: true
#开启安全认证则去掉#
#security:
#  keyFile: "/opt/servers/mongodb_demo/mongos/key/keyfile"
net:  
    #服务实例绑定所有IP,有副作用,副本集初始化的时候,节点名字会自动设置为本地域名,而不是ip  
    #bindIpAll: true  
    #服务实例绑定的IP  
    bindIp: localhost,192.168.203.135
    port: 27021

最后关闭mongodb需要安装psmisc

yum install psmisc

安装完之后可以使用killall 命令 快速关闭多个进程

killall mongod

killall mongos

需注意:一定要关防火墙,出现错误查看路径,权限,最后找不出毛病可以查看日志文件

systemctl stop firewalld.service #暂时关闭防火墙
firewall-cmd --state             #查看防火墙状态

启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
在开机时启用一个服务:systemctl enable firewalld.servic
在开机时禁用一个服务:systemctl disable firewalld.servicefirewall-cmd --zone=public --add-port=28128/tcp --permanent  #开放28128端口
firewall-cmd --reload        #立即生效
user admin
db.system.users.find().pretty()#查看用户
nmtui                          #命令更改主机名和IP地址

#改变优先级:
conf_temp=rs.config()
conf_temp.members[0].priority=2
rs.reconfig(conf_temp)


mongo
mongod -f /opt/servers/mongodb_demo/mongodb/conf/mongod.conf
mongod -f /opt/servers/mongodb_demo/shard/conf/shard1.conf
mongos -f /opt/servers/mongodb_demo/mongos/conf/mongos.conf
mongo --host 192.168.203.135:27018
cd /opt/servers/mongodb_demo/mongodb/bin
source ~/.bash_profile
mongod -f /opt/servers/mongodb_demo/mongodb/conf/mongod.conf/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值