mkdir -p /usr/local/mongodb/mongos/log
mkdir -p /usr/local/mongodb/config/data
mkdir -p /usr/local/mongodb/config/log
mkdir -p /usr/local/mongodb/shard1/data
mkdir -p /usr/local/mongodb/shard1/log
mkdir -p /usr/local/mongodb/shard2/data
mkdir -p /usr/local/mongodb/shard2/log
mkdir -p /usr/local/mongodb/shard3/data
mkdir -p /usr/local/mongodb/shard3/log
修改权限:
chown -R mongod:mongod /usr/local/mongodb
chown -R mongod:mongod /usr/local/mongodb/conf
chown -R mongod:mongod /usr/local/mongodb/mongos/log
chown -R mongod:mongod /usr/local/mongodb/config/data
chown -R mongod:mongod /usr/local/mongodb/config/log
chown -R mongod:mongod /usr/local/mongodb/shard1/data
chown -R mongod:mongod /usr/local/mongodb/shard1/log
chown -R mongod:mongod /usr/local/mongodb/shard2/data
chown -R mongod:mongod /usr/local/mongodb/shard2/log
chown -R mongod:mongod /usr/local/mongodb/shard3/data
chown -R mongod:mongod /usr/local/mongodb/shard3/log
分别建立
vi /usr/local/mongodb/conf/config.conf
vi /usr/local/mongodb/conf/shard1.conf
vi /usr/local/mongodb/conf/shard2.conf
vi /usr/local/mongodb/conf/shard3.conf
vi /usr/local/mongodb/conf/shard4.conf
vi /usr/local/mongodb/conf/mongos.conf
其文件内容见本文附件
配置参考 http://www.ywnds.com/?p=6502
开始构建:
1:启动 configserver 先分别在 3 台机器上执行
numactl --interleave=all mongod -f /usr/local/mongodb/conf/config.conf
任意找 1 台机器,连接到 config server:
mongo --port 21000
在客户端执行
#config 变量
config = {
_id : "configs",
members : [
{_id : 0, host : "192.168.229.41:21000" },
{_id : 1, host : "192.168.229.42:21000" },
{_id : 2, host : "192.168.229.44:21000" }
]
评论0
最新资源