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

3、安装:

 tar xf mongodb-linux-x86_64-3.2..tgz
cd mongodb-linux-x86_64-3.2.
cp -r * /home/mongodb

为了便于命令启动,需要编辑全局变量PATH

 vim /etc/profile.d/mongo.sh
export PATH=$PATH:/home/mongodb/bin
source /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 - 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 (=) value of slow for profile and console
log
--profile arg =off =slow, =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 % 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 ; 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 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 (=) .ns file size (in MB) for new databases
--quota limits each database to a certain
number of files ( default)
--quotaFiles arg number of files allowed per db, implies
--quota
--smallfiles use a smaller default file size
--syncdelay arg (=) seconds between disk syncs (=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 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 / of physical
RAM
--wiredTigerStatisticsLogDelaySecs arg (=)
seconds to wait between each write to a
statistics file in the dbpath; 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 (=)
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.0.0:* LISTEN /mongod

以上可看出端口27017已经运行

5、测试

启动mongodb的shell:

 [root@test ~]# mongo
MongoDB shell version: 3.2.
connecting to: test
Server has startup warnings:
--25T16::52.960+ I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
--25T16::52.960+ I CONTROL [initandlisten]
--25T16::52.960+ I CONTROL [initandlisten]
--25T16::52.960+ I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
--25T16::52.960+ I CONTROL [initandlisten] ** We suggest setting it to 'never'
--25T16::52.960+ I CONTROL [initandlisten]
--25T16::52.960+ I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
--25T16::52.960+ I CONTROL [initandlisten] ** We suggest setting it to 'never'
--25T16::52.960+ 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 : } ) list objects in foo where a ==
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 .000GB
>

至此,MongoDB3.2.1安装完毕。

CentOS6.5上源码安装MongoDB3.2.1的更多相关文章

  1. Centos6.6上源码安装Nodejs V4版本

    本来就是想在vps上装一个Ghost博客,这个博客依赖的是Nodejs,然后推荐的是V4版本.然后我就对着官网的步骤安装,发现根本没有Centos6 i386的资源了(64位的还是有的), 我只能在那 ...

  2. 在centos6.8上源码安装MySQL

    1.安装环境:软件包:mysql-5.6.31.tar.gz 需求相关选项: 安装基目录basedir:/mydb/mysql31数据存放目录datadir:/mydb/mysql31/data端口号 ...

  3. CentOS6.5下源码安装多个MySQL实例及复制搭建

    多实例安装本节是在CentOS6.5下源码安装MySQL5.6.35的基础上,在同一台机器增加一个MySQL实例.参考Centos中安装多个mysql数据的配置实例,安装目录为/usr/local/m ...

  4. [原创]在Centos7.2上源码安装PHP、Nginx、Zentao禅道

    版本 操作系统:CentOS Linux release 7.2.1511 (Core) PHP:5.6.33 Nginx:1.12.2 MySQL:5.6.38(192.168.1.103的Wind ...

  5. centos上源码安装clang 3.8

    之前想在centos系统上安装clang 3.6版本,由于yum上版本太低,想通过源码编译安装.按照网上说的源码安装步骤,下好llvm.clang.clang-tools-extra和compiler ...

  6. CentOS6.5下源码安装MySQL5.6.35

    接上一篇文章使用RPM包安装MySQL,确实很方便.但是安装后却不知道各文件保存在哪个文件夹下!尝试使用源码安装~本文主要参考:CentOS 6.4下编译安装MySQL 5.6.14一.卸载旧版本 . ...

  7. 在Ubuntu Server上源码安装OpenERP 8.0,并配置wsgi和nginx运行环境

    原文: How to install OpenERP 8.0 Alpha on a fresh Debian / Ubuntu server. OpenERP的安装,可以有多种方式,通过添加源,到 h ...

  8. centos7上源码安装mysql5.7.11

    由于初学,安装这玩意搞了三天,其间各种报错难以解决,网上各种解答误导.最好的办法还是使用官方的英文文档,建议初学者一定要使用官方的文档,特别是下面两个页面作为初学者一定要细看: Installing ...

  9. 在Ubuntu 12 服务器上源码安装 OpenERP 8.0

    原文:http://vivianyw.blog.163.com/blog/static/134547422201421112349489/ 1. 安装SSH: sudo apt-get install ...

随机推荐

  1. nodejs单元测试

    前言: 之前一直听说过单元测试,但是具体怎么做,也没有深入研究,感觉测试是一件很麻烦的事,花费时间.可能是自己太懒了,一看到测试那么多陌生的东西就不想弄了. 然后一拖再拖,直到最近,换了一家公司,然后 ...

  2. B2B商城网站前端开发

    最近在时间很忙,在弄一个B2B商城,运用到的easyUI+javaWEB(maven)+JQuery+Scss+JavaScript+其他框架(sea.js模块化等),我负责前端这块:后期的重要的前端 ...

  3. nginx-my

    #user nobody; 3 worker_processes 1; 4 5 error_log logs/error.log; 6 #error_log logs/error.log notice ...

  4. 关于Android 打开新的Activity 虚拟键盘的弹出与不弹出

    关于Android 打开新的Activity 虚拟键盘的弹出与不弹出 打开Activity 时  在相应的情况 弹出虚拟键盘 或者 隐藏虚拟键盘 会给用户非常好的用户体验 , 实现起来也比较简单 只需 ...

  5. CentOS下安装Redis及Redis的PHP扩展

    1.安装Redis 1.1 如果没有安装wget,安装wget yum install wget 1.2 在http://redis.io/download页面查看redis版本,并下载安装 wget ...

  6. MVC 访问IFrame页面Session过期后跳转到登录页面

    Web端开发时,用户登录后往往会通过Session来保存用户信息,Session存放在服务器,当用户长时间不操作的时候,我们会希望服务器保存的Session过期,这个时候,因为Session中的用户信 ...

  7. JavaScript的学习5

    一.DOM对象 1.DOM对象:Document  Object  Model  文档对象模型,主要是用来提供了操作HTML文档的属性与方法 2.DOM的分类: a.核心DOM:为操作XML和HTML ...

  8. system verilog的一些总结(从其他博客复制来的)

    转载自 http://blog.sina.com.cn/s/blog_e7fec2630101f5t9.html SystemVerilog是一种硬件描述和验证语言(HDVL),它基于IEEE 136 ...

  9. SIP 解析

    1 general-header类: 为描述消息基本属性的通用头域,可用于请求消息或响应消息:通用头域的域名只有在协议版本改变时才可有效地扩展.不过,通信中的所有方均认为是“通用头域”的新的头域也可认 ...

  10. C++设计模式-Prototype原型模式

    作用: 用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象. Prototype模式提供了一个通过已存在对象进行新对象创建的接口(Clone), Clone()实现和具体的语言相关,在C+ ...