mongodb config replicat

1.WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always' https://docs.mongodb.com/manual/tutorial/transparent-huge-pages/php

2.mongodb.config (replica)mongodb

dbpath=/usr/local/mongodb/data
logpath=/usr/local/mongodb/log/mongodb.log
pidfilepath=/usr/local/mongodb/log/mongodb.pid

port=12345

logappend=true
#fork=true
#journal=true
#oplogSize=2048
#smallfiles=true

replSet=dbSet

3.php7 mongodb configphp7

$mongodbDsn = 'mongodb://192.168.28.89:12345,192.168.28.89:12346,192.168.28.89:12347';
$options = array(
                        'replicaSet'     => 'dbSet',   //此處replicaSet的值應和上面配置的replSet保持一致
                        'readPreference' => 'primary'
                );
$manager = new  MongoDB\Driver\Manager($mongodbDsn,$options);
$command = new \MongoDB\Driver\Command(['ping' => 1]);
$manager->executeCommand('db', $command);
相關文章
相關標籤/搜索