Mongodb distributed cluster (2. Replica set) and mongodb cluster copyOverview
Replica set is a type of master-slave replication. It is a master-slave replication that comes with the Failover function. It solves the disadvantages of the master-slave replication and does not require human intervention when the master server fails, the system automatically selects a
1. Master-slave replication is MongoDB The most commonly used replication method, which is very flexible and can be used for backup, failure recovery, read extension, etc.2 The most basic way to set up is to establish a master node and one or more slave nodes, each from the node to know the address of the master node. The primary server is started by running Mongod–master. Running mongod–slave–source m
1.MongoDB data is basically called a document, similar to a row in a relational database;2. Similarly, a set (Collection) is a table of dynamic mode (schame);An instance of 3.MongoDB can have multiple databases that are independent of each other, and no database contains multiple collections;4. Each document has a key, which is unique in the set where the key is
Use MongoDb Extension for Yii 2 to connect to the mongodb distributed service, mongodbyii
1. connect to a common mongodb instance. Refer to the MongoDb Extension documentation as follows:
Http://www.yiiframework.com/doc-2.0/ext-mongodb
this, we can learn on that platform. Download MongoDB: http://www.mongodb.org/downloads, our website is installed.
1. decompress and install: extract the downloaded MongoDB to the desired path, for example, d: \ mongodb.
2. Create a folder: create a data storage folder, for example, d: \
To see which databases are available:Show DBSSwitch to that library:Use library name Use LocalUse also has a function of "Create a Database" Use testTo delete a database:Db.dropdatabase ();To view a collection:Show collectionsTo create a collection:Db.createcollection ("user");Implicitly created, inserted directly into the collection, she will automatically create the collectionDb. user. Insert ({ID:1, Name: "Lisi"});To delete a collection:Db. user. Drop ();Insert:Db. user. Insert ({ID:1, Name:
1. master-slave replication is the most common replication method for MongoDB. This method is flexible, the most basic setting method for backup, fault recovery, and read expansion is to create one master node and one or more slave nodes. Each slave node needs to know the address of the master node. After running mongodmaster, the master server is started. Run mongodslavesourcemaster_add
1. master-slave replication is the most common replication metho
• MongoDB STARTUP configuration
1. startup Item mongod -- help
1.1 Use the config configuration file to start the database and change the port to 8888.
Mongodb. conf file
Dbpath = D: \ app \ upload data
Port = 8888
Start File
Mongod.exe -- config mongodb. conf
Shell File
Mongo 127.0.0.1: 8888
2. Stop
/mongodb/logs/mongodb.log5. Setting up the configuration file# vi/doiido/mongodb/bin/mongodb.confDbpath=/doiido/mongodb/dataLogpath=/doiido/mongodb/logs/mongodb.logport=27017Fork=trueNohttpinterface=true6. Start MongoDB#/doiido/mongodb
database backups. Execute the command, and the result example is as follows:
Copy Code code as follows:
Db.runcommand ({fsync:1,lock:1})
{"ErrMsg": "Access denied; Use admin db "," OK ": 0}
Use admin
> Db.runcommand ({fsync:1,lock:1})
{
"Info": "Now locked against writes, use Db.fsyncunlock () to unlock",
"Seealso": "Http://www.mongodb.org/display/DOCS/fsync+Command",
"OK": 1
}
5. View current lock status
Copy Code code as follows:
There are many ways to install MongoDB, you can install the source code, and you can use the Yum source installation method in CentOS. Since MongoDB is updated more quickly, I prefer to use the Yum source installation method. The installation steps under 64-bit CentOS are as follows:1. Preparatory work
Run the Yum command to view MongoDB package informa
I will talk about the replica set in the previous phase. The primary features of the replica set are embodied in two aspects: 1. the replica set does not have a specific primary database. 2. If there is a fault such as a crash, the cluster selects a database as the primary database, which provides the automatic fault recovery function. Next we will perform the following operations: in the folder, copy mongodb1_db2
I will talk about the replica set in
Directory 1. Introduction 2. 3.MongoDB installation Process Use of 4.MongoDB 5.MongoDB Add Administrator account 6.RoboMongo installation Process 7.RoboMongo Management Database 8. Summary 1 Introduction Mongo DB is a non-relational database (NOSQL) that is currently very po
.
#notablescan = True
# Close data file pre-allocation
# Disable data File preallocation.
#noprealloc = True
# Specify the size of the. ns file for the new database, in MB
# specify. ns file size for new databases.
# nssize =
# Accout token for Mongo monitoring server.
#mms-token =
# MONGO the name of the monitoring server
# server name for Mongo monitoring server.
#mms-name =
# MONGO The ping interval of the monitoring server
# Ping interval for
!" "}Return Json.dumps (res, ensure_ascii=false)Server.run (port=8989,debug=true) #启动服务, this need to note that after starting the service if the modified script to run a direct restart, you can not click the right button again to run, otherwise the interface conflict will be reported, because the original running service does not stop5 modifying ExcelImport xlrdFrom xlutils import Copy #修改excel需要导入该模块Book1 = Xlrd.open_workbook (' Ex.xls ') #1, open the original ExcelNew_book = Copy.copy (Book1)
The cate_no value is 6, 2, 9, 13, 19, WHEREcate_noin (6, 7, 8) member nbsp; a field in the table named cate_no is of the string type. When the cate_no nbsp; value is nbsp; 6, 2, 9, 13, 19 nbsp; (the numerical order is out of order ). SELECT nbsp; * nbsp; FROM nbsp; th
(1, num_num + 1)Print "BEFORE:", fac_list
I = 0
While I If num_num % fac_list [I] = 0: # Check whether the input number can be divisible by an element in the list.Del fac_list [I]I = I + 1
Print "AFTER:", fac_list[Execution result]Enter a number: 12BEFORE: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]AFTER: [2, 4, 5, 7, 8, 9, 10, 11]
Mongodb provides an interesting "Multi-key" feature that automatically indexes the array values of objects. Tags are a good example. Suppose you have an article that contains many classification tags:
$ dbshell> db.articles.save( { name: "Warm Weather", author: "Steve",tags: ['weather', 'hot', 'record', 'april'] } )> db.articles.find(){"name" : "Warm Weather" , "author" : "Steve" ,"tags" : ["weather","hot","record","april"] ,"_id" : "497ce4051ca9ca6d3
The sum of factorialEnter N, calculate s=1! +2! +3! + ... +n! The last 6 bits (excluding the leading 0). N≤10 6, n! SaidThe product of the first n positive integers.Sample input:10Sample output:Package Demo;import Java.util.scanner;public class Demo02 {public static void main (string[] args) {Scanner in=new Scanner ( system.in); int n=in.nextint (); Long sum=0;fo
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.