[root@mongo ~]# uname -a
Linux mongo 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@mongo ~]#
[root@mongo ~]#useradd -u 500 mongo
[root@mongo ~]#passwd mongo[root@mongo ~]#chown -R mongo:mongo /opt/mongo
[root@mongo ~]#chmod -R 775 /opt/mongo
[mongo@mongo mongo]$ ls
soft
[mongo@mongo mongo]$ mkdir data
[mongo@mongo mongo]$ ls
data soft
[mongo@mongo mongo]$ mkdir logs
[mongo@mongo mongo]$ ls
data logs soft
[mongo@mongo mongo]$ ls -l
total 12
drwxrwxr-x. 2 mongo mongo 4096 Jun 11 01:08 data #MongoDB的数据文件存放目录
drwxrwxr-x. 2 mongo mongo 4096 Jun 11 01:08 logs #MongoDB的日志文件存放目录,类似ORACLE的ALERT日志文件
drwxrwxr-x. 2 mongo mongo 4096 Jun 11 01:08 soft #MongoDB的软件安装目录[mongo@mongo ~]$ cd /opt/mongo/
[mongo@mongo mongo]$ ls
mongodb-linux-x86_64-rhel62-3.2.7.tgz
[mongo@mongo mongo]$ tar -xvf mongodb-linux-x86_64-rhel62-3.2.7.tgz
mongodb-linux-x86_64-rhel62-3.2.7/README
mongodb-linux-x86_64-rhel62-3.2.7/THIRD-PARTY-NOTICES
mongodb-linux-x86_64-rhel62-3.2.7/MPL-2
mongodb-linux-x86_64-rhel62-3.2.7/GNU-AGPL-3.0
mongodb-linux-x86_64-rhel62-3.2.7/bin/mongodump
mongodb-linux-x86_64-rhel62-3.2.7/bin/mongorestore
mongodb-linux-x86_64-rhel62-3.2.7/bin/mongoexport
mongodb-linux-x86_64-rhel62-3.2.7/bin/mongoimport
mongodb-linux-x86_64-rhel62-3.2.7/bin/mongostat
mongodb-linux-x86_64-rhel62-3.2.7/bin/mongotop
mongodb-linux-x86_64-rhel62-3.2.7/bin/bsondump
mongodb-linux-x86_64-rhel62-3.2.7/bin/mongofiles
mongodb-linux-x86_64-rhel62-3.2.7/bin/mongooplog
mongodb-linux-x86_64-rhel62-3.2.7/bin/mongoperf
mongodb-linux-x86_64-rhel62-3.2.7/bin/mongod
mongodb-linux-x86_64-rhel62-3.2.7/bin/mongos
mongodb-linux-x86_64-rhel62-3.2.7/bin/mongo
[mongo@mongo ~]$mv mongodb-linux-x86_64-rhel62-3.2.7 soft# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export PATH=$PATH:/opt/mongo/soft/bin
export MONGO_BASE=/opt/mongo
export MONGO_DATA=/opt/mongo/data
export MONGO_LOGS=/opt/mongo/logs[root@mongo ~]# rpm -qi glibc
Name : glibc Relocations: (not relocatable)
Version : 2.12 Vendor: Red Hat, Inc.
Release : 1.107.el6 Build Date: Tue 20 Nov 2012 08:22:45 PM PST
Install Date: Sat 11 Jun 2016 08:41:30 AM PDT Build Host: x86-023.build.eng.bos.redhat.com
Group : System Environment/Libraries Source RPM: glibc-2.12-1.107.el6.src.rpm
Size : 12947270 License: LGPLv2+ and LGPLv2+ with exceptions and GPLv2+
Signature : RSA/8, Tue 29 Jan 2013 07:00:11 AM PST, Key ID 199e2f91fd431d51
Packager : Red Hat, Inc.
URL : http://sources.redhat.com/glibc/
Summary : The GNU libc libraries
Description :
The glibc package contains standard libraries which are used by
multiple programs on the system. In order to save disk space and
memory, as well as to make upgrading easier, common system code is
kept in one place and shared between programs. This particular package
contains the most important sets of shared libraries: the standard C
library and the standard math library. Without these two libraries, a
Linux system will not function.[root@mongo lib]# pwd
/usr/lib
[root@mongo lib]# ls -l libss*
-rwxr-xr-x 1 root root 205052 Jul 20 2009 libssl3.so
-rw-r--r-- 1 root root 448536 Sep 4 2009 libssl.a
lrwxrwxrwx 1 root root 26 Feb 18 2014 libssl.so -> ../../lib/libssl.so.0.9.8e
[root@mongo lib64]# pwd
/lib64
[root@mongo lib64]# ln -s /lib64/libssl.so.0.9.8e /usr/lib/libssl.so.10
[root@mongo lib]# ls -l libss*
-rwxr-xr-x 1 root root 205052 Jul 20 2009 libssl3.so
-rw-r--r-- 1 root root 448536 Sep 4 2009 libssl.a
lrwxrwxrwx 1 root root 26 Feb 18 2014 libssl.so -> ../../lib/libssl.so.0.9.8e
lrwxrwxrwx 1 root root 23 Jun 11 11:36 libssl.so.10 -> /lib64/libssl.so.0.9.8e[root@mongo lib]# pwd
/usr/lib
[root@mongo lib]# ls -l libcryp*
-rw-r--r-- 1 root root 47750 Sep 4 2009 libcrypt.a
-rw-r--r-- 1 root root 2416230 Sep 4 2009 libcrypto.a
lrwxrwxrwx 1 root root 29 Feb 18 2014 libcrypto.so -> ../../lib/libcrypto.so.0.9.8e
lrwxrwxrwx 1 root root 22 Feb 18 2014 libcryptsetup.so.0 -> libcryptsetup.so.0.0.0
-rwxr-xr-x 1 root root 51276 Jul 2 2009 libcryptsetup.so.0.0.0
lrwxrwxrwx 1 root root 23 Feb 18 2014 libcrypt.so -> ../../lib/libcrypt.so.1
[root@mongo lib64]# pwd
/lib64
[root@mongo lib64]# ln -s /lib64/libcrypto.so.0.9.8e /usr/lib/libcrypto.so.10
[root@mongo lib]# ls -l libcryp*
-rw-r--r-- 1 root root 47750 Sep 4 2009 libcrypt.a
-rw-r--r-- 1 root root 2416230 Sep 4 2009 libcrypto.a
lrwxrwxrwx 1 root root 29 Feb 18 2014 libcrypto.so -> ../../lib/libcrypto.so.0.9.8e
lrwxrwxrwx 1 root root 26 Jun 11 11:43 libcrypto.so.10 -> /lib64/libcrypto.so.0.9.8e
lrwxrwxrwx 1 root root 22 Feb 18 2014 libcryptsetup.so.0 -> libcryptsetup.so.0.0.0
-rwxr-xr-x 1 root root 51276 Jul 2 2009 libcryptsetup.so.0.0.0
lrwxrwxrwx 1 root root 23 Feb 18 2014 libcrypt.so -> ../../lib/libcrypt.so.1Options:
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 specify port number - 27017 by default
--bind_ip arg comma separated list of ip addresses to
listen on - all local ips by default
--ipv6 enable IPv6 support (disabled by
default)
--maxConns arg max number of simultaneous connections
- 1000000 by default
--logpath arg log file to send write to instead of
stdout - has to be a file, not
directory
--syslog log to system's syslog facility instead
of file or stdout
--syslogFacility arg syslog facility used for mongodb syslog
message
--logappend append to logpath instead of
over-writing
--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
--noauth run without security
--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 fork server process
--auth run with 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
--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 [/
>]
--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 directory for datafiles - defaults to
/data/db
--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[1] 3028
[mongo@mongo ~]$mongo 3028 1 1 01:31 pts/0 00:00:00 mongod --dbpath=/opt/mongo/data --logpath=/opt/mongo/logs/mongodb.log --logappend
root 3059 2443 0 01:32 pts/0 00:00:00 grep mongo[root@mongo logs]# cat mongodb.log
2016-06-11T01:31:19.106-0700 I CONTROL [initandlisten] MongoDB starting : pid=3028 port=27017 dbpath=/opt/mongo/data 64-bit host=mongo
2016-06-11T01:31:19.107-0700 I CONTROL [initandlisten] db version v3.2.7
2016-06-11T01:31:19.107-0700 I CONTROL [initandlisten] git version: 4249c1d2b5999ebbf1fdf3bc0e0e3b3ff5c0aaf2
2016-06-11T01:31:19.107-0700 I CONTROL [initandlisten] allocator: tcmalloc
2016-06-11T01:31:19.107-0700 I CONTROL [initandlisten] modules: none
2016-06-11T01:31:19.107-0700 I CONTROL [initandlisten] build environment:
2016-06-11T01:31:19.107-0700 I CONTROL [initandlisten] distarch: x86_64
2016-06-11T01:31:19.107-0700 I CONTROL [initandlisten] target_arch: x86_64
2016-06-11T01:31:19.107-0700 I CONTROL [initandlisten] options: { storage: { dbPath: "/opt/mongo/data" }, systemLog: { destination: "file", logAppend: true, path: "/opt/mongo/logs/mongodb.log" } }
2016-06-11T01:31:19.139-0700 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2016-06-11T01:31:19.186-0700 I CONTROL [initandlisten]
2016-06-11T01:31:19.186-0700 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-06-11T01:31:19.186-0700 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-06-11T01:31:19.186-0700 I CONTROL [initandlisten]
2016-06-11T01:31:19.186-0700 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-06-11T01:31:19.186-0700 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-06-11T01:31:19.186-0700 I CONTROL [initandlisten]
2016-06-11T01:31:19.187-0700 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/opt/mongo/data/diagnostic.data'
2016-06-11T01:31:19.187-0700 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-06-11T01:31:19.194-0700 I NETWORK [initandlisten] waiting for connections on port 27017tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 3028/mongod
tcp 0 0 127.0.0.1:39769 127.0.0.1:27017 ESTABLISHED 3099/mongo
tcp 0 0 127.0.0.1:27017 127.0.0.1:39769 ESTABLISHED 3028/mongod
unix 2 [ ACC ] STREAM LISTENING 23441 3028/mongod /tmp/mongodb-27017.sock
11、登录MongoDB数据库MongoDB shell version: 3.2.7
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
Server has startup warnings:
2016-06-11T01:31:19.186-0700 I CONTROL [initandlisten]
2016-06-11T01:31:19.186-0700 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-06-11T01:31:19.186-0700 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-06-11T01:31:19.186-0700 I CONTROL [initandlisten]
2016-06-11T01:31:19.186-0700 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-06-11T01:31:19.186-0700 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-06-11T01:31:19.186-0700 I CONTROL [initandlisten]
>local 0.000GB
> use zhul
switched to db zhul
> show dbs
local 0.000GB
> db.createCollection("test")
{ "ok" : 1 }
> show dbs
local 0.000GB
zhul 0.000GB来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29357786/viewspace-2119891/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29357786/viewspace-2119891/