mongo(五)副本集
mongo(五)副本集
配置文件
# mongod.conf #where to log
logpath=/home/data/db/mongodb2.log logappend=true # fork and run in background
fork=true port=33197 dbpath=/home/yuxianda/data/db/db2 # location of pidfile
pidfilepath=/home/yuxianda/data/db/mongod2.pid # Listen to local interface only. Comment out to listen on all interfaces.
bind_ip=127.0.0.1 #datebase in diffrent file
directoryperdb=true # fsync time
#syncdelay=5 # Disables write-ahead journaling
# nojournal=true # Enables periodic logging of CPU utilization and I/O wait
#cpu=true # Turn on/off security. Off is currently the default
#noauth=true
#auth=true # Verbose logging output.
#verbose=true # Inspect all client data for validity on receipt (useful for
# developing drivers)
#objcheck=true # Enable db quota management
#quota=true # Set oplogging level where n is
# 0=off (default)
# 1=W
# 2=R
# 3=both
# 7=W+some reads
#diaglog=0 # Ignore query hints
#nohints=true # Enable the HTTP interface (Defaults to port 28017).
#httpinterface=true # Turns off server-side scripting. This will result in greatly limited
# functionality
#noscripting=true # Turns off table scans. Any query that would do a table scan fails.
#notablescan=true # Disable data file preallocation.
#noprealloc=true # Specify .ns file size for new databases.
# nssize=<size> # Replication Options # in replicated mongo databases, specify the replica set name here
replSet=android-test
# maximum size in megabytes for replication operation log
#oplogSize=1024
# path to a key file storing authentication info for connections
# between replica set members
#keyFile=/path/to/keyfile
mongo.conf
执行配置
设定副本集合:
db.runCommand({"replSetInitiate":{
"_id":"android-test",
"members":[
{
"_id":1,
"host":"127.0.0.1:33198"
},
{
"_id":2,
"host":"127.0.0.1:33197"
},
{
"_id":3,
"host":"127.0.0.1:33196"
}
]}})
增加仲裁节点
#!/usr/bin/env python
#-*- encoding:utf-8 -*- from pymongo import MongoClient, MongoReplicaSetClient dbList = '127.0.0.1:33198,127.0.0.1:33197,127.0.0.1:33196' def init(dbname):
try:
client = MongoReplicaSetClient(dbList, replicaSet='android- test')
db = client[dbname]
return db
except Exception as e:
print 'error:%s'%e
return False if __name__ == '__main__':
db = init('test')
print db.appinfo.find_one()
mongo(五)副本集的更多相关文章
- mongodb 系列 ~ mongo的副本集(2)
一 简介:来试试更改副本集的oplog问题二 背景: oplog的作用类似于mysql的binlog,传递增量操作到从节点 三 oplog介绍 1 oplog在local库: 1 mas ...
- mongodb 系列 ~ mongo的副本集(3)
一 简介:今天咱们来聊聊mongodb复制的具体一些案例 二 副本集 1 当mongodb采用全量复制时,如何观察全量复制的进度 对比文件本身和primary大小 2 mongodb全量复制的过程 旧 ...
- mongo转换副本集
本文介绍如何把独立的mongo实例转换成包含3个成员的副本集.开发和测试使用独立实例,生产使用副本集.如何安装独立的mongo实例本文不再赘述. 如果在部署副本集时还没有安装mongo实例,可以查看部 ...
- Mongo分片+副本集集群搭建
一. 概念简单描述 1. MongoDB分片集群包含组件: mongos,configserver,shardding分片 2. Mongos:路由服务是Sharded cluster的访问入口,本身 ...
- mongo学习- 副本集 大多数原则
副本集中有一个重要的概念“大多数”,意思是说,选择主节点需要大多数决定(本人亲自做了实验) 步骤: 1.开启副本集(如果没有配置好 副本集的 亲参考我的上篇文章 https://www.cnblog ...
- mongo学习- 副本集配置(事故自动转移)
一.安装mongodb 二.复制2份 三.启动 (1)mongod --config C:\mongofuben\zhu\conf\mongodb.config --replSet haibin/12 ...
- mongodb(副本集)
副本集是mongo下的一种集群配置方式: 1.通过oplog的方式将主节点数据同步到副本节点,oplog不记录查询语句(因为不改变数据): 2.mongo的副本集可以有一个主节点,多个副本节点,主节点 ...
- MongoDB副本集的搭建
副本集是mongodb提供的一种高可用解决方案.相对于原来的主从复制,副本集能自动感知primary节点的下线,并提升其中一个Secondary作为Primary. 整个过程对业务透明,同时也大大降低 ...
- mongodb副本集的从库永久性设置setSlaveOk
今天在生产环境下面搭了一个mongo的副本集,但开发那边要求副本集读写分离. 坑爹的是每次上副本集的时候都要设置db.getMongo().setSlaveOk()才能访问数据.感觉很是苦逼. 后来开 ...
随机推荐
- 理解docker容器和镜像(layer,ufs)和docker命令解释
博客好文1:http://blog.csdn.net/x931100537/article/details/49633107(理解docker容器和镜像,理解简单,从原理入手,什么是layer,什么是 ...
- Gradle Android Studio basic
1. change gradle version in gradle/wrapper/gradle-wrapper.properties change distributionUrl=http\:/ ...
- (五) 一起学 Unix 环境高级编程 (APUE) 之 进程环境
. . . . . 目录 (一) 一起学 Unix 环境高级编程 (APUE) 之 标准IO (二) 一起学 Unix 环境高级编程 (APUE) 之 文件 IO (三) 一起学 Unix 环境高级编 ...
- [原创]Spring MVC 学习 之 - URL参数传递
原文参考地址: http://www.cnblogs.com/rhythmK/p/3971191.html 目的和缘由: 本人想做一个分享的页面,分析给朋友注册,注册按分享ID进行级联; 过程: 很多 ...
- Python笔记——break的注意事项
在python中有个控制流的语句:break 它是用来终止循环语句的,不管此时循环体进行到哪,只要碰到break都停止执行循环语句. 1.举例脚本: #!/usr/bin/env python for ...
- 02-JAVA中的基本语法
第一个动手动脑: 首先用枚举类型定义两个变量,然后判断两个变量是否引用同一对象,在判断枚举类型是否是原始数据类型,再从字符串中转换,最后列出所有的对象. 很明显,这两个变量都是枚举类型,但是这两个变量 ...
- shell脚本学习--shell中的变量$
$$ :Shell本身的PID(ProcessID) $! :Shell最后运行的后台Process的PID $? :最后运行的命令的结束代码(返回值) $- :使用Set命令设定的Flag一览 $* ...
- linux /usr/bin/ld: cannot find -lxxx
在linux环境编译应用程式或lib的source code时出现如下错误:/usr/bin/ld: cannot find -lxxx 这些讯息会随着编译不同类型的source code 而有不同的 ...
- 一些有意思的APP
1.简书:一个优雅的写作/阅读平台. 2.知乎:知识分享社区: 3.behance:设计者的圈子: 4.海词词典:电脑.手机同步查询的好帮手(电脑端快捷键:双击 Alt 弹出/关闭查询框,非常方便) ...
- shell 脚本注意事项
设脚本名为test.sh 第一行应该为#! /bin/bash 1.运行和调试的结果是不一样的 调试 sh -x test.sh 这时在计算两个数的和sum=$[$a+$b]时得到sum=3+4,而 ...