search
HomeDatabaseMysql Tutorial mongoDB 分布式、非关系型数据库(一)

一、准备环境1、下载最新版mongodb_64位安装包:http://www.mongodb.org/downloads2、解压安装配置:#tarzxvfmongodb-linux-x86_64-2.2.3.tgz-C/usr/local/#mvmo

 一、准备环境

http://s2t148.blog.51cto.com

1、下载最新版mongodb_64位安装包:

   

 

2、解压安装配置:

# tar zxvf mongodb-linux-x86_64-2.2.3.tgz -C /usr/local/      

# mv mongodb-linux-x86_64-2.2.3/ mongodb           

# mkdir data_mongo

# cd data_mongo

# mkdir config

# mkdir ku1-zu

# mkdir ku2-bei

# mkdir ku3-abr

# mkdir logs

# cd ../mongodb/

# mkdir conf

# cd conf/

# touch ku1-zu.conf

# touch ku2-bei.conf

# touch ku3-abr.conf

# touch config.conf

# touch mongos.conf


【192.168.10.20上的配置文件】

# vi ku1-zu.conf 

logpath = /usr/local/data_mongo/logs/ku1.log

logappend = true

dbpath = /usr/local/data_mongo/ku1_zu

shardsvr = true

replSet = rs1

bind_ip = 127.0.0.1,192.168.10.20

maxConns = 5000

fork = true

port = 27011

oplogSize = 1000

profile = 1

slowms = 500

rest = true

directoryperdb = true

journal = true

 

# vi ku2-bei.conf 

logpath = /usr/local/data_mongo/logs/ku2.log

logappend = true

dbpath = /usr/local/data_mongo/ku2_bei

shardsvr = true

replSet = rs2

bind_ip = 127.0.0.1,192.168.10.20

maxConns = 5000

fork = true

port = 27013

oplogSize = 1000

profile = 1

slowms = 500

rest = true

directoryperdb = true

journal = true

 

vi ku3-abr.conf

logpath = /usr/local/data_mongo/logs/ku3.log

logappend = true

dbpath = /usr/local/data_mongo/ku3_abr

shardsvr = true

replSet = rs3

bind_ip = 127.0.0.1,192.168.10.20

maxConns = 5000

fork = true

port = 27015

 

vi config.conf

logpath = /usr/local/data_mongo/logs/config.log

logappend = true

dbpath = /usr/local/data_mongo/config

configsvr = true

bind_ip = 127.0.0.1,192.168.10.20

fork = true

port = 20000

 

vi mongos.conf

configdb = 192.168.10.20:20000,192.168.10.21:20000,192.168.10.22:20000

logpath = /usr/local/data_mongo/logs/mongos.log

logappend = true

chunkSize  = 10

fork = true

maxConns = 6000

port = 30000

 

【192.168.10.21上的配置文件】[config.conf、mongos.conf 与10.20几乎一致略]

vi ku1-abr.conf

logpath = /usr/local/data_mongo/logs/ku1.log

logappend = true

dbpath = /usr/local/data_mongo/ku1_abr

shardsvr = true

replSet = rs1

bind_ip = 127.0.0.1,192.168.10.21

maxConns = 5000

fork = true

port = 27011

 

vi ku2-zu.conf

logpath = /usr/local/data_mongo/logs/ku2.log

logappend = true

dbpath = /usr/local/data_mongo/ku2_zu

shardsvr = true

replSet = rs2

bind_ip = 127.0.0.1,192.168.10.21

maxConns = 5000

fork = true

port = 27013

oplogSize = 1000

profile = 1

slowms = 500

rest = true

directoryperdb = true

journal = true

 

vi ku3-bei.conf

logpath = /usr/local/data_mongo/logs/ku3.log

logappend = true

dbpath = /usr/local/data_mongo/ku3_bei

shardsvr = true

replSet = rs3

bind_ip = 127.0.0.1,192.168.10.21

maxConns = 5000

fork = true

port = 27015

oplogSize = 1000

profile = 1

slowms = 500

rest = true

directoryperdb = true

journal = true

 

【192.168.10.22上的配置文件】[config.conf、mongos.conf 与10.20几乎一致略]

 vi ku1-bei.conf

  logpath = /usr/local/data_mongo/logs/ku1.log

logappend = true

dbpath = /usr/local/data_mongo/ku1_bei

shardsvr = true

replSet = rs1

bind_ip = 127.0.0.1,192.168.10.22

maxConns = 5000

fork = true

port = 27011

oplogSize = 1000

profile = 1

slowms = 500

rest = true

directoryperdb = true

journal = true


vi ku2-abr.conf

ogpath = /usr/local/data_mongo/logs/ku2.log

logappend = true

dbpath = /usr/local/data_mongo/ku2_abr

shardsvr = true

replSet = rs2

bind_ip = 127.0.0.1,192.168.10.22

maxConns = 5000

fork = true

port = 27013

 

vi  ku3-zu.conf

logpath = /usr/local/data_mongo/logs/ku3.log

logappend = true

dbpath = /usr/local/data_mongo/ku3-zu

shardsvr = true

replSet = rs3

bind_ip = 127.0.0.1,192.168.10.22

maxConns = 5000

fork = true

port = 27015

oplogSize = 1000

profile = 1

slowms = 500

rest = true

directoryperdb = true

journal = true

 

3、启动:【这是192.168.10.20、其他两台都一样启动、但都必须先启动shard 也就是自定义的 ku1 ku2 ku3;再启动config 和 mongos 略】

/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/conf/ku1-zu.conf

/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/conf/ku2-bei.conf

/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/conf/ku3-abr.conf

 /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/conf/config.conf

 /usr/local/mongodb/bin/mongos -f /usr/local/mongodb/conf/mongos.conf

 

4、4-1 配置congif和路由:【ku1 ku2 ku3 每个库群 随便找一台进去对应的端口进行配置】

例如:ku1 我在192.168.10.20 上进行初始化副本集

# /usr/local/mongodb/bin/mongo --port 27011

Statement
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
What Are the Limitations of Using Views in MySQL?What Are the Limitations of Using Views in MySQL?May 14, 2025 am 12:10 AM

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

Securing Your MySQL Database: Adding Users and Granting PrivilegesSecuring Your MySQL Database: Adding Users and Granting PrivilegesMay 14, 2025 am 12:09 AM

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

What Factors Influence the Number of Triggers I Can Use in MySQL?What Factors Influence the Number of Triggers I Can Use in MySQL?May 14, 2025 am 12:08 AM

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

MySQL: Is it safe to store BLOB?MySQL: Is it safe to store BLOB?May 14, 2025 am 12:07 AM

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

MySQL: Adding a user through a PHP web interfaceMySQL: Adding a user through a PHP web interfaceMay 14, 2025 am 12:04 AM

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

See all articles

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool