mongodb主从同步、数据一致性和高可用分析

【MongoDB】主从同步 上一篇介绍了MongoDB的基础操作。本文主要介绍MongoDB的主从同步Master和Slave的配置方法以及双主机的配置方法 阅读详情

一、副本集(一个主,多个从,而且高可用)

1.  读操作可指定从主节点读取还是从从节点读取;写操作只写主节点,由主节点同步操作到从节点,可指节写多少个节点成功后才认为成功。

2.  主从复制和选主

(1)如果主挂了,mongodb保证只有操作序列为最大的从才能成为新的主,这只保证了数据尽可能地少丢,如果写操作是写1个节点以上成功才认为成功,可保证不丢数据

(2)如果新的主丢了老的主的部分操作,而且老的主又重新加入副本集,这时老的主会回滚操作以保证与新的主状态一致。回滚日志会被记录到文件里,通过工具可手动将回滚操作来新的主上执行,以恢复数据。另外,如果需要的回滚数据超过300M,老的主不会进行回滚,并log异常;如果要强制回滚到300M之前,可采用重新同步数据的方法来保证与新主状态一致,但不能恢复这300M数据了。

(3)mongodb可保证优先级最高的从节点变为主;

(4)优先级为0的从节点不进行选主,即不能成为主;

(5)除了主从节点,还有仲裁者节点,不保存副本数据,只用于选主投票

1.副本集支持手动变更主从关系吗?支持的话,变更会不会出现数据丢失呢?可对比下redis cluster

  (1)You can force a replica set member to become primary by giving it a higher priority value than any other member in the set.(所以是支持的)

  (2)变更不会出现数据丢失,因为mongodb会停止原主的更新操作,直到新主追上最新的plog后并成功变为主,才恢复更新操作(跟redis cluster的no force变更策略一样)。

2.shard 的config server

(1) 数据一致性保证?

    Config servers are special mongod instances that store the metadata for a sharded cluster.  All config servers must be available to deploy a sharded cluster or to make any changes to cluster metadata. Config servers do not run as replica sets. Each sharded cluster must have its own config servers. 

    When writing to the three config servers, a coordinator dispatches the same write commands to the three config servers and collects the results. Differing results indicate an inconsistent writes to the config servers and may require manual intervention. Once the config servers become inconsistent, the balancer will not perform any chunk migration and mongos will not perform auto-splits of chunks.(从这里看,config server是不保证数据一致性的,如果出现不一致,需要人工干预)

(2) 可用性

   The cluster have three config servers. 

   If one or two config servers become unavailable, the cluster’s metadata becomes read only. You can still read and write data from the shards, but no chunk migrations or splits will occur until all three servers are available.

   If all three config servers are unavailable, you can still use the cluster if you do not restart the mongos instances until after the config servers are accessible again. If you restart the mongos instances before the config servers are available, the mongos will be unable to route reads and writes.

   If the name or address that a sharded cluster uses to connect to a config server changes, you must restart every mongod and mongos instance in the sharded cluster. Avoid downtime by using CNAMEs to identify config servers within the MongoDB deployment.

(3)数据大小

   主要保证db的chunk与shard的映射关系,数据量很小,mongos会缓存一份数据,配置数据有变化时,应该是全量同步,因为数据量小。

3.shard的负载匀衡是由mongos的两个后台进程完成的:split和balancer

4.shard 的chunk分裂:chunk达到最大size时,进行对半分裂为两个chunk,这时不进行真正的数据迁移;

   (1)As chunks grow beyond the specified chunk size a mongos instance will attempt to split the chunk in half. 

5.shard 的balance:如时需要对某个shard的chunks进行迁移?如何保证迁移时数据不丢失?

   (1)the balancer will not begin balancing until the distribution of chunks for a sharded collection has reached certain thresholds. The thresholds apply to the difference in number of chunks between the shard with the most chunks for the collection and the shard with the fewest chunks for that collection。(针对单个collection的chunk数量,而不是单个shard,可能会导致单个shard的chunk数量过多)

   (2)When adding a shard, you may set a “maximum size” for that shard. This prevents the balancer from migrating chunks to the shard when the value of mapped exceeds the “maximum size”. Use the maxSize parameter of the addShard command to set the “maximum size” for the shard.

    The value of mapped provides the amount of mapped memory, in megabytes (MB), by the database. Because MongoDB uses memory-mapped files, this value is likely to be to be roughly equivalent to the total size of your database or databases.

   (3)the destination shard starts a synchronization process to ensure that it has the changes to the migrated documents that occurred during the migration. MongoDB briefly pauses all application writes to the source shard before updating the config servers with the new location for the chunk, and resumes the application writes after the update. The migration process ensures consistency and maximizes the availability of chunks during balancing.

   (4)During chunk migration, if the chunk exceeds the specified chunk size or if the number of documents in the chunk exceeds Maximum Number of Documents Per Chunk to Migrate, MongoDB does not migrate the chunk. Instead, MongoDB attempts to split the chunk. If the split is unsuccessful, MongoDB labels the chunk as jumbo to avoid repeated attempts to migrate the chunk.

7. mongodb的副本集,对于网络分区产生的多主问题

  the replica set has no primary and cannot accept writes and all remaining members become read-only. f a majority of the replica set is inaccessible or unavailable, the replica set cannot accept writes and all remaining members become read-only.(可见对于多主的问题的解决方法跟redis cluster是一样的,不会出现多主的问题。)

8. 副本集里的数据同步是采用同步消息队列的方式,而且只有一条消息队列(可控制大小),这里的消息是oplog,而且oplog里的操作是幂等的。从节点可从其他从节点获取oplog,不一定从主节点获取。

9. shard key可以是有序key,或hash key,都支持排序和游标操作

10、请求和连接

       数据库会为每个MongoDB数据库连接创建一个队列,存放这个连接的请求,客户端新发送的请求会被放到队列的末尾。只有队列中的请求都执行完毕,后续的请求才会执行。即对于单个连接来说,请求都是顺序执行不存在并发问题,所以它总能读到自己写的东西。但对于不同的连接就有可能出现读取和写入不一致的问题,在驱动程序使用连接池时要特别注意此行为。

11. 三个config server,当挂掉一个config server时,挂掉一个主mongod,还可以进行主从切换,不影响数据读写功能。这说明主从切换功能,不需要config server支持或写config server

MongoDB副本集群数据同步及主从复制 MongoDB副本集群中,出现了一个新概念:仲裁节点,其实作用等同于哨兵节点,但它并不是副本集群必须存在的节点,因为主节点、副本节点都拥有投票能力,它的存在只是为了维护集群内的平衡,如集群节点为偶数时,可以添加一个仲裁节点,让集群保持奇数特性,确保每轮选举一次就能推出新主,避免多轮无效竞选的现象出现(不了解选举机制的后面会说原理)。执行上述初始化命令,只要看到ok:1这个字段值,说明初始化成功,接着稍等片刻,MongoDB会自动将当前连接的节点,设置为集群的主节点。集合中,可以直接去查询这个集合。 阅读详情

相关推荐

mongodb 主从同步配置(windows)

mongodb 主从同步配置(windows) 以及操作中遇到的错误点总结

铃兰丶物语 2370

mongodb的主从同步配置:实战详细版(建议收藏)

mongodb的主从同步配置

m0_58833554的博客 5342

MongoDB部署高可用集群

MongoDB部署高可用集群

weixin_38203586的博客 1522

MongoDB详解(六)——MongoDB主从同步配置

今天继续给大家介绍Linux运维相关知识,本文主要内容是MongoDB主从同步配置。 一、环境准备 二、主从数据库配置 三、效果检验

永远是少年 6389

MongoDB高可用与分片

MongoDB数据库实战系列,打造精品专栏。

学Java,找哪吒 5125

mongodb和mysql双写数据一致性问题

我们是如何用MongoDB的 如何保证双写一致性? 先写数据库,再写MongoDB 先写MongoDB,再写数据库 用户修改操作如何保存数据 如何清理新增的垃圾数据 定时删除 随机删除

2076

Redis主从哨兵与MongoDB副本集高可用方案对比分析

在现代分布式系统架构中,数据库的高可用性是保障服务连续性的关键因素。Redis和MongoDB作为两种主流的NoSQL数据库,各自提供了强大的高可用解决方案:Redis的主从哨兵(Sentinel)模式和MongoDB的副本集(Replica Set)机制。这两种方案在设计理念、实现方式和应用场景上存在显著差异,理解它们的异同对于架构选型和系统稳定性保障至关重要[ ]。

喝醉酒的小白 1324

MongoDB中的主从同步配置和mongod相关启动命令讲解

MongoDB 主从同步设置 关于MongoDB的安装及启动参数说明可以参考我之前转载的《Ubuntu安装MongoDB》与《Mongodb启动命令mongod参数说明》 主从设置 Master: 192.168.111.103 Port:8001 Slave:192.168.111.104 Port:8001 启动Master 代码如下: mongod –dbpath /data/masterdb/ –master –oplogSize 64 –port 8001 –fork –logpath /var/logs/mongodb/mongod.log 启动Slave 代码如下:

MongoDB 数据一致性详解

数据一致性是指在数据库中,数据在不同的操作和时间点上保持一致的状态。它确保在并发环境中,多个用户或进程对数据的操作不会导致数据的混乱或不一致。数据一致性通常与 ACID(原子性、一致性、隔离性、持久性)原则相关。数据一致性是数据库管理中的一个重要概念,MongoDB 提供了多种机制来确保数据的一致性,包括最终一致性模型、读写关注级别、事务支持和数据复制等。通过合理使用这些机制,开发者可以在 MongoDB 中实现高效且一致的数据管理。希望这篇博客能帮助你深入理解 MongoDB 的数据一致性。

Hesitate_的博客 2342

解决vscode无法运行npm命令的问题(cmd可行)

Powershell以及vscode中npm命令使用不了

无痕坚守本心的博客 2748

从0开始写Vue项目-环境和项目搭建

什么是VueVue.js - 渐进式 JavaScript 框架 | Vue.js (vuejs.org)2.介绍与描述动态构建用户界面的渐进式JavaScript框架作者:尤雨溪3.Vue的特点遵循MVVM模式编码简洁,体积小,运行效率高,适合移动/PC端开发它本身只关注UI,可以引入其它第三方库开发项目4.与其他JS框架的关联借鉴 Angular 的模板和数据绑定技术借鉴 React 的组件化和虚拟DOM技术5.Vue周边库vue-cli:vue脚手架axios。

不愧是暮言的博客 1483

Docker快速安装MongoDB并配置主从同步

Docker快速安装MongoDB并配置主从同步

wangchange的博客 1711

AD24-层次原理图的设计

4)在原理图关联对话框中双击需要放置方块图的子图,即激活方块图的放置,单击母图的空白处进行放置。3)设计-Create Sheet From Sheet,进入原理图关联对话框。4)放置-添加图纸入口,放置方块图的内部I/O端口并进行名称更改。2)放置-页面符,放置页面符,并执行Table完成属性设置。5)执行Ctrl+W,端口和内部I/O端口对应连接。1)创建一个工程并完成子图的每页原理图的设计。1)新建项目,创建Main原理图页。3)放置-的端口,放置方块图的端口。以上,就是层次原理图页的设计。

qq_52761962的博客 4914

全面剖析 MongoDB 高可用架构

MongoDB高可用架构

cbmljs的博客 2943

RADIOML 2018.01A数据集在自动调制识别中的实战应用指南

本文提供了RADIOML 2018.01A数据集在自动调制识别(AMR)任务中的完整实战指南。内容涵盖从数据集介绍、数据获取与解包、高效预处理流程,到构建PyTorch数据管道、模型设计(如1D CNN、ResNet)以及训练调参策略。重点阐述了如何利用该数据集训练鲁棒的AI模型,以应对复杂信道环境和低信噪比挑战,并给出了详细的性能评估方法。

plant的博客 170

传感器采集信息的频率(采样频率)

较高的采集频率通常能提供更详细的信息,但也会增加数据处理和存储的负担。在某些应用中,较高的采样频率可能是必要的,而在其他情况下,则可能会选择适当的低采样频率以降低功耗和数据处理压力。传感器采集信息的频率(采样频率)是指传感器在一定时间内对输入信号进行采样的次数。对于一些需要快速检测和响应的应用,如运动传感器、声音传感器等,高采样频率是至关重要的。高采样频率通常需要更多的功耗和更大的存储容量,因为产生的数据量更大。例如,对于快速运动的对象,较低的采样频率可能无法捕捉到运动的真实轨迹。

chen的博客 5337

MongoDB高可用和分片集群知识

主节点和备节点之间是通过opLog进行同步数据的,opLog是一个固定集合的结构,其中主节点向opLog写入数据,备节点在opLog中读取数据,以达到同步。在大数据发展的时代,数据存储会在多个不同的机器上,要进行分布式的存储,进行分片是一个好的措施,将数据按某种方式进行切分存储在不同的机器上。配置节点: 配置节点不用于存储数据,而是保存了整个分片集群中的元数据,其中包含各个集合的分片策略,以及分片的路由表等。数据分片: 分片用于存储真正的数据,并提供最终的数据读写访问,通常是复制集的形式存在。

paiidds的博客 1950

NVIDIA-SMI has failed because it couldn‘t communicate with the NVIDIA driver. 最全解决方案!详细!

真的折磨了我整整一天,从网上的资料到GPT都翻遍了,终于是解决了!以下方案希望能帮助到你们。

weixin_44124632的博客 1万+

MongoDB 主备切换延迟容忍度与数据一致性机制深度分析

仅在必要时使用,可能导致数据不一致MongoDB 会严格校验数据同步延迟,通过 OpTime 机制确保数据一致性默认配置即可保证零数据丢失,catchUpTimeoutMillis=-1 表示无限等待延迟容忍度取决于业务需求,一般2分钟内可自动切换,10分钟以上需人工介入QFusion 环境使用标准配置,10秒选举超时,无限等待追赶,适合大多数场景需要自动故障切换数据一致性要求高运维团队规模较小原生分片需求需要极快切换速度复杂的复制拓扑成熟的运维团队传统关系型数据。

喝醉酒的小白 1202

如何更好的理解PFC(功率因数校正)

此电路虽然简单,可以在前期设计的无PFC功能的设备上,简单的增加一个合适的电感(适当的选取L和C的值),从而达到具有PFC的作用,但是这种简单的、低成本的无源PFC输出纹波较大,滤波电容两端的直流电压也较低,电流畸变的校正及功率因数补偿的能力都很差,而且L的绕制及铁芯的质量控制不好,会对图像及伴音产生严重的干扰,只能是对于前期无PFC设备使之能进入市场的临时措施。)在t4~t5期间尽管二极管左边电压在逐步上升,但是由于二极管右边的Uc放电缓慢右边的电压Uc仍旧大于左边,二极管仍旧反偏截止。

U_YAO的博客 948

[网络安全自学篇] 二.Chrome浏览器保留密码功能渗透解析及登录加密入门笔记

最近开始学习网络安全相关知识,接触了好多新术语,感觉自己要学习的东西太多,真是学无止境,也发现了好几个默默无闻写着博客、做着开源的大神。接下来系统分享一些网络安全的自学笔记,希望读者们喜欢。 上一篇文章分享了看雪Web安全总结知识和一个异或解密的示例,本篇文章着重讲解Chrome浏览器保留密码功能渗透解析及登录加密入门笔记,结合实际例子一步步实现浏览器漏洞的挖掘。非常基础的文章,希望对入门的博友们有帮助,大神请飘过,谢谢各位看官!

杨秀璋的专栏 2万+

MongoDB副本集高可用

这意味着,即使在主备切换期间,只要写操作被主节点成功记录到操作日志中,那么该写操作就被认为是成功的,从而确保了写操作的顺序性。综上所述,MongoDB副本集在主备切换时确实会考虑数据的一致性,通过保证写操作的顺序和使用“majority”读写操作来确保数据的持久性和一致性。当主节点发生故障时,备节点可以无缝地接管成为新的主节点,确保数据的一致性和服务的连续性。在MongoDB副本集中,主备切换(Primary和Secondary节点的角色互换)是一个重要的功能,用于确保系统的高可用性和数据的一致性。

喝醉酒的小白 1230

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

MongoDB——全面剖析MongoDB高可用架构

本文介绍了 3 种 MongoDB 的高可用架构,Master-Slave 模式,Replica Set 模式,Sharding 模式,这也是常见的架构演进的过程;MongdbDB Master-Slave 已经不推荐,甚至新版已经不支持这种冗余模式;Replica Set 通过数据多副本,组件冗余提高了可靠性,并且通过分布式自动选主算法,减少了停服时间窗,提高了可用性;Sharding 模式通过横向扩容的方式,为用户提供了近乎无限的空间;5、

zhanglongfei1016的专栏 1456

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Linux环境下MongoDB安装与主从集群,高可用集群配置教程

通过本次教程,您学会了如何在Linux系统上安装和配置MongoDB,并成功搭建了一个包含主从复制和仲裁节点的集群系统,最后,通过初始化集群、插入测试数据以及进行高可用性测试,您深入了解了MongoDB集群的运行机制和数据同步过程。这些步骤不仅提高了您对MongoDB的理解,也为您在实际项目中部署高可用性数据库集群打下了良好基础。成功的路上没有捷径,只有不断的努力与坚持。你的支持是我继续前行的动力!"每一次创作都是一次学习的过程,文章中若有不足之处,还请大家多多包容。神秘泣男子。

博客之路,前途漫漫 3622

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

MongoDB高可用架构涉及常用功能整理

MongoDB是一个开源的文档数据库,适用于构建各种类型的应用程序和用例。它是一种NoSQL数据库,意味着它不依赖关系模型,并且不使用SQL查询语言进行数据操作。 MongoDB的特点包括: - 面向文档的数据模型:MongoDB存储的是以JSON风格的文档,可以包含各种类型的数据。文档的结构可以灵活地变化,便于处理复杂的数据。 - 高性能:MongoDB使用了一种称为BSON的二进制数据格式,以及一种称为聚集集合的存储引擎,以提供高性能的数据存储和查询操作。 - 可扩展性:MongoDB可以通过水平扩展

李姓门徒 1575

MongoDB的索引事物和高可用分析

MongoDB是一个基于分布式文件存储的数据库,MongoDB是一个介于关系数据库和非关系数据库(nosql)之间的数据库产品。

CoLiuRs 836
上一篇: 对强一致性的理解
whycold
博客等级 码龄19年 280粉丝 44原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值