MongoDB 3.2 for RHEL6.4 installation
1、建立mongodb的管理使用者
注意:有必要強調的是,LINUX版本最好是6.4以上,在REDHAT5.5上,我嘗試安裝,最後要求GLIBC版本最低是2.10,要升級GLIBC,風險很大。
[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 mongo2、建立mongodb的安裝目錄
[root@mongo ~]# cd /opt/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的軟體安裝目錄3、mongodb管理使用者登入伺服器,上傳安裝介質並解壓
注意:這裡需要強調,MongoDB的安裝版本必須對應特定的作業系統平臺及版本,這裡我用mongodb-linux-x86_64-rhel62-3.2.7.tgz
[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 soft4、修改管理使用者下的環境變數
[mongo@mongo ~]$ cat .bash_profile
# .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/logs5、檢查mongo對glibc的要求
注意:這裡要求GLIBC版本號必須大於等於2.10
[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 :
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.6、解決libssl.so.10問題
透過mongod的可用性發現libssl.so.10問題,此問題不解決,MongoDB無法啟動
[mongo@mongo ~]$ mongod --help
mongod: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or director
解決libssl.so.10問題,使用root建立軟連結即可
[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.8e7、解決libcrypto.so.10問題
透過mongod的可用性發現libcrypto.so.10問題,此問題不解決,MongoDB無法啟動
解決libcrypto.so.10問題,使用root建立軟連結即可
[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.18、測通MongoDB的mongod可用性
[mongo@mongo ~]$ 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 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 [/<optionalseedhostlist </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 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 pages9、啟動mongodb資料庫
[mongo@mongo ~]$ mongod --dbpath=$MONGO_DATA --logpath=$MONGO_LOGS/mongodb.log --logappend&
[1] 3028
[mongo@mongo ~]$10、檢查mongodb的執行狀態
[root@mongo mongo]# ps -ef|grep 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 mongo]# cd /opt/mongo/logs
[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 27017[root@mongo ~]# netstat -lanp | grep 27017
tcp 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資料庫[mongo@mongo ~]$ mongo
MongoDB shell version: 3.2.7
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
Questions? Try the support group
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]
>登入後,MongoDB要求關閉作業系統的transparent_hugepage特性(這裡可以放在MongoDB安裝前,系統調整時執行),需要以root身份執行以下命令:
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
[root@mongo transparent_hugepage]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
[root@mongo transparent_hugepage]# echo never > /sys/kernel/mm/transparent_hugepage/defrag
12、重啟MongoDB資料庫並測試資料庫可用性
[mongo@mongo ~]$ mongo
MongoDB shell version: 3.2.7
connecting to: test
Server has startup warnings:
2016-06-13T18:58:21.838-0700 I CONTROL [initandlisten]
2016-06-13T18:58:21.839-0700 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-06-13T18:58:21.839-0700 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-06-13T18:58:21.839-0700 I CONTROL [initandlisten]
2016-06-13T18:58:21.839-0700 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-06-13T18:58:21.839-0700 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-06-13T18:58:21.839-0700 I CONTROL [initandlisten]
> use admin
switched to db admin
> db.shutdownServer();
server should be down...
2016-06-13T19:04:21.290-0700 I NETWORK [thread1] trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
2016-06-13T19:04:21.291-0700 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2016-06-13T19:04:21.291-0700 I NETWORK [thread1] reconnect 127.0.0.1:27017 (127.0.0.1) failed failed
> exit
bye
[1]+ Done mongod --dbpath=$MONGO_DATA --logpath=$MONGO_LOGS/mongodb.log --logappend
[mongo@mongo ~]$ mongod --dbpath=$MONGO_DATA --logpath=$MONGO_LOGS/mongodb.log --logappend&
[1] 40476
[mongo@mongo ~]$ mongo
MongoDB shell version: 3.2.7
connecting to: test
>
> show db
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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MongoDB 3.2.7 for rhel6.4 副本集-分片叢集部署MongoDB
- MongoDB 3.2 先睹為快MongoDB
- 【MongoDB】 MongoDB 3.2.x 安裝實踐MongoDB
- MongoDB 3.2 升級至 3.4.6MongoDB
- mongodb單機從3.2升級到4.0.4升級MongoDB
- mongodb 3.2.10 for windows server 2008 R2 installationMongoDBWindowsServer
- MongoDB 3.2的使用者角色許可權介紹和配置MongoDB
- Post Installation for Databases Created after Installation of 10.2.0.4.4Database
- RHEL6.4安裝Oracle 12cR2Oracle
- 3.2
- dubbo2.5-spring4-mybastis3.2-springmvc4-mongodb3.4-redis3.2整合(五)Spring中spring-data-redis的使用ASTS3SpringMVCMongoDBRedis
- dubbo2.5-spring4-mybastis3.2-springmvc4-mongodb3.4-redis3.2整合(九)之spring中定時器quartz的整合ASTS3SpringMVCMongoDBRedis定時器quartz
- LDAP Server InstallationLDAServer
- Mysql MAC installationMySqlMac
- installation tips
- 2.3.3.2 Application InstallationAPP
- .NET Core installation for DockerDocker
- How to cleanup ASM installationASM
- 巨無霸Lomboz 3.2 for Eclipse 3.2出爐了Eclipse
- Oracle 10g installationOracle 10g
- RHEL_PXE_Installation_ServerServer
- ThinkPHP 3.2主要配置PHP
- EJB 3.2新特性
- RUEI for rhel6.4 64bit oracle11g 安裝手冊Oracle
- 10gR2 DATABASE InstallationDatabase
- Mysql_secure_installation詳解MySql
- 3.2 型別轉換型別
- ThinkPHP 3.2 模板研究PHP
- ThinkPHP 3.2 模組的部署PHP
- ThinkPHP 3.2 的變化PHP
- jbpm3.2 總結
- python3.2:字典Python
- Spark 3.2使用體驗Spark
- 3.2點對點ppp
- Include manifest for over-the-air installationAI
- Getting oracle agent installation from oemOracle
- Glassfish2.1.1 installation and deply tips
- oracle10g_client_installation_noteOracleclient