部署MongoDB分片结合复制集实现对mysql数据库文件分布式存储(第二步)

创建config节点的三个实例

192.168.100.101:

[root@config bin]# cat <>/usr/local/mongodb/bin/mongodb1.conf

    bind_ip=192.168.100.101
    port=27017
    dbpath=/usr/local/mongodb/mongodb1/
    logpath=/usr/local/mongodb/logs/mongodb1.log
    logappend=true
    fork=true
    maxConns=5000
    replSet=configs
    #replication name
    configsvr=true
    END

[root@config bin]# cat <>/usr/local/mongodb/bin/mongodb2.conf

    bind_ip=192.168.100.101
    port=27018
    dbpath=/usr/local/mongodb/mongodb2/
    logpath=/usr/local/mongodb/logs/mongodb2.log
    logappend=true
    fork=true
    maxConns=5000
    replSet=configs
    configsvr=true
    END

[root@config bin]# cat <>/usr/local/mongodb/bin/mongodb3.conf

    bind_ip=192.168.100.101 
    port=27019
    dbpath=/usr/local/mongodb/mongodb3/
    logpath=/usr/local/mongodb/logs/mongodb3.log
    logappend=true
    fork=true
    maxConns=5000
    replSet=configs
    configsvr=true
    END

[root@config bin]# cd
[root@config ~]# mongod -f /usr/local/mongodb/bin/mongodb1.conf
[root@config ~]# mongod -f /usr/local/mongodb/bin/mongodb2.conf
[root@config ~]# mongod -f /usr/local/mongodb/bin/mongodb3.conf
[root@config ~]# netstat -utpln |grep mongod
tcp 0 0 192.168.100.101:27019 0.0.0.0:* LISTEN 2271/mongod
tcp 0 0 192.168.100.101:27017 0.0.0.0:* LISTEN 2440/mongod
tcp 0 0 192.168.100.101:27018 0.0.0.0:* LISTEN 1412/mongod
[root@config ~]# echo -e “/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/bin/mongodb1.conf \n/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/bin/mongodb2.conf\n/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/bin/mongodb3.conf”>>/etc/rc.local
[root@config ~]# chmod +x /etc/rc.local

[root@config ~]# cat <>/etc/init.d/mongodb

    #!/bin/bash
    INSTANCE=\$1
    ACTION=\$2
    case "\$ACTION" in
    'start')
    /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/bin/"\$INSTANCE".conf;;
    'stop')
    /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/bin/"\$INSTANCE".conf --shutdown;;
    'restart')
    /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/bin/"\$INSTANCE".conf --shutdown
    /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/bin/"\$INSTANCE".conf;;
    esac
    END

[root@config ~]# chmod +x /etc/init.d/mongodb

你可能感兴趣的:(MongoDB,数据库,数据库,mongodb,nosql)