MongoDb
官网 安装环境Centos 6.7 x64
安装 Binary安装 curl -o mongo.tar.gz https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.4.2.tgz tar -xvzf mongodb-linux-x86_64-rhel62-3.4.2.tgz cd mongodb-linux-x86_64-rhel62-3.4.2 bin中的就是mongodb的程序,记得将路径加入环境变量 export PATH=<mongodb-install-directory>/bin:$PATH Yum安装创建repo文件在/etc/yum.repos.d/mongodb-org-3.4.repo,内容如下:
[mongodb-org-3.4] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc最新内容参考这里 Yum Install
yum makecache yum list all | grep mongo yum install mongodb-org -y 配置关闭SELINUX
setenforce 0创建数据目录和配置文件
配置文件如下:
#auth = 1 #bind_ip = 192.168.223.144 cpu = 1 dbpath = /mongo/node-27017 #diaglog = 3 directoryperdb = 1 fork = 1 journal = 1 logappend = 1 logpath = /mongo/node-27017/mongod.log maxConns = 3000 oplogSize = 10240 pidfilepath = /mongo/node-27017/mongod.pid port = 27017 profile = 1 #repair = 0 repairpath = /mongo/node-27017 #rest = 0 slowms = 100 smallfiles = 1 #verbose = 1 noscripting = 1 #keyFile = /mongo/mongo_key #autoresync = 1 #fastsync = 1 shardsvr=true #source = 10.21.76.156:27017 #slavedelay = 0 #autoresync = false noobjcheck=true #日志 #syslog = false journalCommitInterval = 100 nohttpinterface = true notablescan = false syncdelay = 60 #pid文件 #是否启动守护模式 #数据库文件 #noprealloc=false storageEngine=wiredTiger #3.0新有的引擎 #wiredTigerCacheSizeGB=12 #wiredTigerStatisticsLogDelaySecs=0 #wiredTigerJournalCompressor=snappy #wiredTigerDirectoryForIndexes=true #wiredTigerCollectionBlockCompressor=snappy #wiredTigerIndexPrefixCompression=1 单实例 启动 mongod -f /data/mongodb_data/cnf/mongo-27107.cnf对mongodb禁用num模式启动
numactl --interleave=all /usr/bin/mongod -f /data/mongodb_data/cnf/mongo-27107.cnf 停止发送Kill来安全停止
kill -2 pid 或者 kill -4 pid通过命令行安全停止
连接Mongodb
mongo localhost:27017关闭mongodb
use admin; db.shutdownServer(); 命令行连接 mongo 192.168.0.249:27017 客户端中的CRUD php基本使用 编译安装扩展官方参考 Mac依赖:
brew install openssl
git clone https://github.com/mongodb/mongo-php-driver.git cd mongo-php-driver/ git submodule sync && git submodule update --init phpize # Centos ./configure --with-php-config=php-config # Mac ./configure --with-php-config=php-config --with-openssl-dir=/usr/local/opt/openssl make all -j 5 make test make install然后在PHP中打开扩展
整合进Yaf 分片 副本集群