CentOS6.5上源码安装MongoDB3.2.1
2016-01-25 16:25
507 查看
1、环境准备:
mkdir /home/mongodb #创建MongoDB程序存放目录 mkdir /data/mongodata -p #创建数据存放目录 mkdir /data/log/mongolog -p #创建日志存放目录
2、下载:
curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.1.tgz[/code]
3、安装:tar xf mongodb-linux-x86_64-3.2.1.tgz cd mongodb-linux-x86_64-3.2.1 cp -r * /home/mongodb
为了便于命令启动,需要编辑全局变量PATHvim /etc/profile.d/mongo.sh export PATH=$PATH:/home/mongodb/binsource /etc/profile.d/mongo.sh
4、启动服务
首先查看mongod的帮助信息[root@test ~]# mongod --help Options: General options: -h [ --help ] show this usage information --version show version information -f [ --config ] arg configuration file specifying additional options -v [ --verbose ] [=arg(=v)] be more verbose (include multiple times for more verbosity e.g. -vvvvv) --quiet quieter output --port arg #指定mongodb服务的端口号,默认为:27017 13 --bind_ip arg #在多网卡的机器上指定mongodb服务绑定到哪一个ip上 15 --ipv6 enable IPv6 support (disabled by default) --maxConns arg #指定最大客户端连接数 19 --logpath arg #指定日志文件路径,必须是一个文件,而不是目录 20 --syslog log to system's syslog facility instead of file or stdout --syslogFacility arg syslog facility used for mongodb syslog message --logappend #以追加的方式打印日志到--logpath参数指定的日志文件中 28 --logRotate arg set the log rotation behavior (rename|reopen) --timeStampFormat arg Desired format for timestamps in log messages. One of ctime, iso8601-utc or iso8601-local --pidfilepath arg full path to pidfile (if not set, no pidfile is created) --keyFile arg private key for cluster authentication --setParameter arg Set a configurable parameter --httpinterface enable http interface --clusterAuthMode arg Authentication mode used for cluster authentication. Alternatives are (keyFile|sendKeyFile|sendX509|x509) --nounixsocket disable listening on unix sockets --unixSocketPrefix arg alternative directory for UNIX domain sockets (defaults to /tmp) --filePermissions arg permissions to set on UNIX domain socket file - 0700 by default --fork #以daemon的形式运行服务进程 --auth run with security --noauth run without security --jsonp allow JSONP access via http (has security implications) --rest turn on simple rest api --slowms arg (=100) value of slow for profile and console log --profile arg 0=off 1=slow, 2=all --cpu periodically show cpu and iowait utilization --sysinfo print some diagnostic system information --noIndexBuildRetry don't retry any index builds that were interrupted by shutdown --noscripting disable scripting engine --notablescan do not allow table scans --shutdown kill a running server (for init scripts) Replication options: --oplogSize arg size to use (in MB) for replication op log. default is 5% of disk space (i.e. large is good) Master/slave options (old; use replica sets instead): --master master mode --slave slave mode --source arg when slave: specify master as <server:port> --only arg when slave: specify a single database to replicate --slavedelay arg specify delay (in seconds) to be used when applying master ops to slave --autoresync automatically resync if slave data is stale Replica set options: --replSet arg arg is <setname>[/<optionalseedhostlist >] --replIndexPrefetch arg specify index prefetching behavior (if secondary) [none|_id_only|all] --enableMajorityReadConcern enables majority readConcern Sharding options: --configsvr declare this is a config db of a cluster; default port 27019; default dir /data/configdb --configsvrMode arg Controls what config server protocol is in use. When set to "sccc" keeps server in legacy SyncClusterConnection mode even when the service is running as a replSet --shardsvr declare this is a shard db of a cluster; default port 27018 Storage options: --storageEngine arg what storage engine to use - defaults to wiredTiger if no data files present --dbpath arg #指定数据目录路径 --directoryperdb each database will be stored in a separate directory --noprealloc disable data file preallocation - will often hurt performance --nssize arg (=16) .ns file size (in MB) for new databases --quota limits each database to a certain number of files (8 default) --quotaFiles arg number of files allowed per db, implies --quota --smallfiles use a smaller default file size --syncdelay arg (=60) seconds between disk syncs (0=never, but not recommended) --upgrade upgrade db if needed --repair run repair on all dbs --repairpath arg root directory for repair files - defaults to dbpath --journal enable journaling --nojournal disable journaling (journaling is on by default for 64 bit) --journalOptions arg journal diagnostic options --journalCommitInterval arg how often to group/batch commit (ms) WiredTiger options: --wiredTigerCacheSizeGB arg maximum amount of memory to allocate for cache; defaults to 1/2 of physical RAM --wiredTigerStatisticsLogDelaySecs arg (=0) seconds to wait between each write to a statistics file in the dbpath; 0 means do not log statistics --wiredTigerJournalCompressor arg (=snappy) use a compressor for log records [none|snappy|zlib] --wiredTigerDirectoryForIndexes Put indexes and data in different directories --wiredTigerCollectionBlockCompressor arg (=snappy) block compression algorithm for collection data [none|snappy|zlib] --wiredTigerIndexPrefixCompression arg (=1) use prefix compression on row-store leaf pages
启动服务示例:mongod --dbpath=/data/mongodata --logpath=/data/log/mongolog/mongodb.log --logappend --fork
查看是否启动:netstat -tnlp | grep mongod tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 17909/mongod
以上可看出端口27017已经运行
5、测试
启动mongodb的shell:[root@test ~]# mongo MongoDB shell version: 3.2.1 connecting to: test Server has startup warnings: 2016-01-25T16:12:52.960+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 2016-01-25T16:12:52.960+0800 I CONTROL [initandlisten] 2016-01-25T16:12:52.960+0800 I CONTROL [initandlisten] 2016-01-25T16:12:52.960+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2016-01-25T16:12:52.960+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2016-01-25T16:12:52.960+0800 I CONTROL [initandlisten] 2016-01-25T16:12:52.960+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2016-01-25T16:12:52.960+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2016-01-25T16:12:52.960+0800 I CONTROL [initandlisten] > help db.help() help on db methods db.mycoll.help() help on collection methods sh.help() sharding helpers rs.help() replica set helpers help admin administrative help help connect connecting to a db help help keys key shortcuts help misc misc things to know help mr mapreduce show dbs show database names show collections show collections in current database show users show users in current database show profile show most recent system.profile entries with time >= 1ms show logs show the accessible logger names show log [name] prints out the last segment of log in memory, 'global' is default use <db_name> set current database db.foo.find() list objects in collection foo db.foo.find( { a : 1 } ) list objects in foo where a == 1 it result of the last line evaluated; use to further iterate DBQuery.shellBatchSize = x set default number of items to display on shell exit quit the mongo shell > show dbs local 0.000GB >
至此,MongoDB3.2.1安装完毕。
相关文章推荐
- mongodb3.2二进制单机版安装
- MongoDB 2.6配置副本集,支持端口号修改和用户登录认证
- mongodb 数据备份,还原笔记
- MongoDB常用命令
- mongodb 最佳实践
- spring-data-mongodb的同字段索引多条件查询
- 1.mongodb在centos上面安装
- ubuntu 64位下轻松安装mongodb
- mongodb3.2系统性学习——2、write concern mongodb 写安全机制
- MongoDB时间类型
- MongoDB的三种启动方式
- MongoDb的安装
- MongodbVUE使用手册和Mongodb的坑
- Ubuntu 15.10安装mongodb
- 操作3 mongodb和mysql 开启慢查询日志 ,以及mongodb从配置文件启动
- MongoDB基本操作(增删改查)
- 1.centos下安装mongodb
- Windows系统mongoDB启动
- MongoDB架构指南(一)
- 提前为部署MongoDB做好准备:容量计划和监控、注意事项