users
--查看数据
:> db.users.find()
{ "_id" : ("f587"), "" : "yekai", "age" : 34 }
--从节点执行操作
:> db.users.({:'',age:25})
not
显示not ,代表当前从节点只读.
--进入9929端口,可以看到仲裁节点的提示符号
@:~$ mongo :9929
shell : 2.4.9
to: :9929/test
:>
》执行故障转移测试:
1)可以杀掉9927的主节点
--再在从节点执行一下查询,发现从节点意见自己变成主节点
:> db.users.find()
{ "_id" : ("f587"), "" : "yekai", "age" : 34 }
--再次执行插入操作
:> db.users.({:'',age:25})
:> db.users.find()
{ "_id" : ("f587"), "" : "yekai", "age" : 34 }
{ "_id" : ("fa09"), "" : "", "age" : 25 }
已经可以插入成功
2)再将9927上线
--9927将变为从节点
@:~$ mongo :9927
shell : 2.4.9
to: :9927/test
:> show ;
Sun Sep 4 13:55:33.333 error: { "$err" : "notand =false", "code" : 13435 } at src/mongo/shell/query.js:128
:> rs.()
:> show
.
users
--查看数据
:> db.users.find()
{ "_id" : ("f587"), "" : "yekai", "age" : 34 }
{ "_id" : ("fa09"), "" : "", "age" : 25 }
仲裁节点的作用是协调选举,监测系统运行状态,提供节点互相通讯的数据信息 。
11、API 使用
》文件准备:
\\mongo\\mongo文件夹及目录下pch.h、.h、.h
/** @file pch.h : include file for standard system include files,*or project specific include files that are used frequently, but*are changed infrequently*//*Copyright 2009 10gen Inc.**Licensed under the Apache License, Version 2.0 (the "License");*you may not use this file except in compliance with the License.*You may obtain a copy of the License at**http://www.apache.org/licenses/LICENSE-2.0**Unless required by applicable law or agreed to in writing, software*distributed under the License is distributed on an "AS IS" BASIS,*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.*See the License for the specific language governing permissions and*limitations under the License.*/#ifndef MONGO_PCH_H#define MONGO_PCH_H// our #define macros must not be active when we include// system headers and boost headers#include "mongo/client/undef_macros.h"#include "mongo/platform/basic.h"#include
- 《最重要的事,只有一件》笔记——目标不是做得更多,而是让自己需要的事情更少
- 黑科技—Java实现根据一张照片进行精确定位
- 【C++ 函数式编程 】C++中的函数组合:用std::function实现编程
- 游戏开发网站
- c++ 质数——数学知识
- 并发编程学习笔记 基于Python
- 线控转向系统Carsim和Simulink联合仿真模型,带Carsim数据库
- 理论基础知识之————KB Kb Kbps 相关单位的区别和换算
- Python趣味编程:从入门到人工智能,从这35个案例开始,越学越有趣!
- 爬虫|Scrapy框架应用——以武汉大学新闻网为例