当前位置:Gxlcms > mysql > mongoDB分布式、非关系型数据库(一)

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

时间:2021-07-01 10:21:17 帮助过:55人阅读

一、准备环境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

人气教程排行