Home Database Mysql Tutorial 搭建ReplicaSet复制集

搭建ReplicaSet复制集

Jun 07, 2016 pm 03:54 PM
mongodb copy Install build

1、在MongoDB的同级安装目录下创建数据目录,目录结构如下: /data/rs0 /data/rs1 /data/rs2 2、使用命令行启动mongod的三个实例,打开三个命令行窗口,分别输入命令如下: mongod --port 10000 --dbpath E:/field/replset/data/rs0 --replSet rscx --smallfi

1、在MongoDB的同级安装目录下创建数据目录,目录结构如下: /data/rs0 /data/rs1 /data/rs2   2、使用命令行启动mongod的三个实例,打开三个命令行窗口,分别输入命令如下:
mongod --port 10000 --dbpath E:/field/replset/data/rs0 --replSet rscx --smallfiles --oplogSize 128
mongod --port 10001 --dbpath E:/field/replset/data/rs1 --replSet rscx --smallfiles --oplogSize 128
mongod --port 10002 --dbpath E:/field/replset/data/rs2 --replSet rscx --smallfiles --oplogSize 128
  执行完上面的命令后,MongoDB的实例服务已经启动了,我们可以在刚刚创建数据目录下,看到MongoDB自动生成的一些数据配置文件。但同时我们也会发现命令行上会不停的打出“replSet can't get local.system.replset config from self or any seed”,这是因为集合loccal.system.replset还没有任何配置信息,我们还需要在命令行执行rs.initiate来进行初始化。      打开一个命令行窗口,我们连接到第一个实例。
mongo --port 10000
  在命令行继续输入mongodb replicate sets的配置信息,然后执行rs.initiate( rsconf )初始化配置信息。
rsconf = { _id: "rs0", members: [ { _id: 0, host: ":27017" } ] } rs.initiate( rsconf )
     在这一步,如果读者不小心,在执行rs.initialte方法时,忘记了加参数,可以通过rs.reconfig(rsconf)来重新初始化配置文件。        接下来,运行rs.conf()命令,我们能够看到会显示如下所示的复制集信息。
rscx:PRIMARY> rs.conf() { "_id" : "rscx", "version" : 2, "members" : [ { "_id" : 0, "host" : "favpc:10000" } ] }
  接下来,继续运行下面的命令,将另外两个配置集加到复制集中。
rs.add("favpc":10001) rs.add("favpc":10002)
  至此,Replica Sets复制集就搭建成功了。我们也可以看到mongodb复制集的命令行窗口不再打印replSet can't get local.system.replset config from self or any seed“,取而代       之的是打印的复制集的连接信息。
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Which version is generally used for mongodb? Which version is generally used for mongodb? Apr 07, 2024 pm 05:48 PM

It is recommended to use the latest version of MongoDB (currently 5.0) as it provides the latest features and improvements. When selecting a version, you need to consider functional requirements, compatibility, stability, and community support. For example, the latest version has features such as transactions and aggregation pipeline optimization. Make sure the version is compatible with the application. For production environments, choose the long-term support version. The latest version has more active community support.

The difference between nodejs and vuejs The difference between nodejs and vuejs Apr 21, 2024 am 04:17 AM

Node.js is a server-side JavaScript runtime, while Vue.js is a client-side JavaScript framework for creating interactive user interfaces. Node.js is used for server-side development, such as back-end service API development and data processing, while Vue.js is used for client-side development, such as single-page applications and responsive user interfaces.

How to Install and Run the Ubuntu Notes App on Ubuntu 24.04 How to Install and Run the Ubuntu Notes App on Ubuntu 24.04 Mar 22, 2024 pm 04:40 PM

While studying in high school, some students take very clear and accurate notes, taking more notes than others in the same class. For some, note-taking is a hobby, while for others, it is a necessity when they easily forget small information about anything important. Microsoft's NTFS application is particularly useful for students who wish to save important notes beyond regular lectures. In this article, we will describe the installation of Ubuntu applications on Ubuntu24. Updating the Ubuntu System Before installing the Ubuntu installer, on Ubuntu24 we need to ensure that the newly configured system has been updated. We can use the most famous "a" in Ubuntu system

How to install Podman on Ubuntu 24.04 How to install Podman on Ubuntu 24.04 Mar 22, 2024 am 11:26 AM

If you have used Docker, you must understand daemons, containers, and their functions. A daemon is a service that runs in the background when a container is already in use in any system. Podman is a free management tool for managing and creating containers without relying on any daemon such as Docker. Therefore, it has advantages in managing containers without the need for long-term backend services. Additionally, Podman does not require root-level permissions to be used. This guide discusses in detail how to install Podman on Ubuntu24. To update the system, we first need to update the system and open the Terminal shell of Ubuntu24. During both installation and upgrade processes, we need to use the command line. a simple

Where is the database created by mongodb? Where is the database created by mongodb? Apr 07, 2024 pm 05:39 PM

The data of the MongoDB database is stored in the specified data directory, which can be located in the local file system, network file system or cloud storage. The specific location is as follows: Local file system: The default path is Linux/macOS:/data/db, Windows: C:\data\db. Network file system: The path depends on the file system. Cloud Storage: The path is determined by the cloud storage provider.

What are the advantages of mongodb database What are the advantages of mongodb database Apr 07, 2024 pm 05:21 PM

The MongoDB database is known for its flexibility, scalability, and high performance. Its advantages include: a document data model that allows data to be stored in a flexible and unstructured way. Horizontal scalability to multiple servers via sharding. Query flexibility, supporting complex queries and aggregation operations. Data replication and fault tolerance ensure data redundancy and high availability. JSON support for easy integration with front-end applications. High performance for fast response even when processing large amounts of data. Open source, customizable and free to use.

Detailed steps to install Go language on Win7 computer Detailed steps to install Go language on Win7 computer Mar 27, 2024 pm 02:00 PM

Detailed steps to install Go language on Win7 computer Go (also known as Golang) is an open source programming language developed by Google. It is simple, efficient and has excellent concurrency performance. It is suitable for the development of cloud services, network applications and back-end systems. . Installing the Go language on a Win7 computer allows you to quickly get started with the language and start writing Go programs. The following will introduce in detail the steps to install the Go language on a Win7 computer, and attach specific code examples. Step 1: Download the Go language installation package and visit the Go official website

How to install Go language under Win7 system? How to install Go language under Win7 system? Mar 27, 2024 pm 01:42 PM

Installing Go language under Win7 system is a relatively simple operation. Just follow the following steps to successfully install it. The following will introduce in detail how to install Go language under Win7 system. Step 1: Download the Go language installation package. First, open the Go language official website (https://golang.org/) and enter the download page. On the download page, select the installation package version compatible with Win7 system to download. Click the Download button and wait for the installation package to download. Step 2: Install Go language

See all articles