-rw-r--r--. 1 root root 39M Sep 22 12:39
/usr/local/mongodb-linux-x86_64-3.0.6.gz
[root@Master local]# tar -zxvf
mongodb-linux-x86_64-3.0.6.gz
mongodb-linux-x86_64-3.0.6/README
mongodb-linux-x86_64-3.0.6/THIRD-PARTY-NOTICES
mongodb-linux-x86_64-3.0.6/GNU-AGPL-3.0
mongodb-linux-x86_64-3.0.6/bin/mongodump
mongodb-linux-x86_64-3.0.6/bin/mongorestore
mongodb-linux-x86_64-3.0.6/bin/mongoexport
mongodb-linux-x86_64-3.0.6/bin/mongoimport
mongodb-linux-x86_64-3.0.6/bin/mongostat
mongodb-linux-x86_64-3.0.6/bin/mongotop
mongodb-linux-x86_64-3.0.6/bin/bsondump
mongodb-linux-x86_64-3.0.6/bin/mongofiles
mongodb-linux-x86_64-3.0.6/bin/mongooplog
mongodb-linux-x86_64-3.0.6/bin/mongoperf
mongodb-linux-x86_64-3.0.6/bin/mongod
mongodb-linux-x86_64-3.0.6/bin/mongos
mongodb-linux-x86_64-3.0.6/bin/mongo
mongodb-linux-x86_64-3.0.6/THIRD-PARTY-NOTICES
mongodb-linux-x86_64-3.0.6/GNU-AGPL-3.0
mongodb-linux-x86_64-3.0.6/bin/mongodump
mongodb-linux-x86_64-3.0.6/bin/mongorestore
mongodb-linux-x86_64-3.0.6/bin/mongoexport
mongodb-linux-x86_64-3.0.6/bin/mongoimport
mongodb-linux-x86_64-3.0.6/bin/mongostat
mongodb-linux-x86_64-3.0.6/bin/mongotop
mongodb-linux-x86_64-3.0.6/bin/bsondump
mongodb-linux-x86_64-3.0.6/bin/mongofiles
mongodb-linux-x86_64-3.0.6/bin/mongooplog
mongodb-linux-x86_64-3.0.6/bin/mongoperf
mongodb-linux-x86_64-3.0.6/bin/mongod
mongodb-linux-x86_64-3.0.6/bin/mongos
mongodb-linux-x86_64-3.0.6/bin/mongo
[root@Master local]# mv
mongodb-linux-x86_64-3.0.6 mongodb
[root@Master local]# cd mongodb
[root@Master mongodb]# ls -lah
total 76K
drwxr-xr-x. 3 root root 4.0K Sep 23 11:26 .
drwxr-xr-x. 19 root root 4.0K Sep 23 11:28 ..
drwxr-xr-x. 2 root root 4.0K Sep 23 11:26 bin
-rw-r--r--. 1 1046 1046 34K Aug 24 08:43 GNU-AGPL-3.0
-rw-r--r--. 1 1046 1046 1.4K Aug 24 08:43 README
-rw-r--r--. 1 1046 1046 23K Aug 24 08:43 THIRD-PARTY-NOTICES
drwxr-xr-x. 3 root root 4.0K Sep 23 11:26 .
drwxr-xr-x. 19 root root 4.0K Sep 23 11:28 ..
drwxr-xr-x. 2 root root 4.0K Sep 23 11:26 bin
-rw-r--r--. 1 1046 1046 34K Aug 24 08:43 GNU-AGPL-3.0
-rw-r--r--. 1 1046 1046 1.4K Aug 24 08:43 README
-rw-r--r--. 1 1046 1046 23K Aug 24 08:43 THIRD-PARTY-NOTICES
[root@Master mongodb]# groupadd
mongo_grp
[root@Master mongodb]# useradd -r -g
mongo_grp mongo_user
[root@Master mongodb]# ls -lah
total 76K
drwxr-xr-x. 3 root root 4.0K Sep 23 11:26 .
drwxr-xr-x. 19 root root 4.0K Sep 23 11:28 ..
drwxr-xr-x. 2 root root 4.0K Sep 23 11:26 bin
-rw-r--r--. 1 1046 1046 34K Aug 24 08:43 GNU-AGPL-3.0
-rw-r--r--. 1 1046 1046 1.4K Aug 24 08:43 README
-rw-r--r--. 1 1046 1046 23K Aug 24 08:43 THIRD-PARTY-NOTICES
drwxr-xr-x. 3 root root 4.0K Sep 23 11:26 .
drwxr-xr-x. 19 root root 4.0K Sep 23 11:28 ..
drwxr-xr-x. 2 root root 4.0K Sep 23 11:26 bin
-rw-r--r--. 1 1046 1046 34K Aug 24 08:43 GNU-AGPL-3.0
-rw-r--r--. 1 1046 1046 1.4K Aug 24 08:43 README
-rw-r--r--. 1 1046 1046 23K Aug 24 08:43 THIRD-PARTY-NOTICES
[root@Master mongodb]# mkdir db
[root@Master mongodb]# mkdir logs
[root@Master mongodb]# ls -lah
total 84K
drwxr-xr-x. 5 root root 4.0K Sep 23 11:30 .
drwxr-xr-x. 19 root root 4.0K Sep 23 11:28 ..
drwxr-xr-x. 2 root root 4.0K Sep 23 11:26 bin
drwxr-xr-x. 2 root root 4.0K Sep 23 11:30 db
-rw-r--r--. 1 1046 1046 34K Aug 24 08:43 GNU-AGPL-3.0
drwxr-xr-x. 2 root root 4.0K Sep 23 11:30 logs
-rw-r--r--. 1 1046 1046 1.4K Aug 24 08:43 README
-rw-r--r--. 1 1046 1046 23K Aug 24 08:43 THIRD-PARTY-NOTICES
drwxr-xr-x. 5 root root 4.0K Sep 23 11:30 .
drwxr-xr-x. 19 root root 4.0K Sep 23 11:28 ..
drwxr-xr-x. 2 root root 4.0K Sep 23 11:26 bin
drwxr-xr-x. 2 root root 4.0K Sep 23 11:30 db
-rw-r--r--. 1 1046 1046 34K Aug 24 08:43 GNU-AGPL-3.0
drwxr-xr-x. 2 root root 4.0K Sep 23 11:30 logs
-rw-r--r--. 1 1046 1046 1.4K Aug 24 08:43 README
-rw-r--r--. 1 1046 1046 23K Aug 24 08:43 THIRD-PARTY-NOTICES
[root@Master mongodb]# chown -R
mongo_user .
[root@Master mongodb]# chgrp -R mongo_grp .
[root@Master mongodb]# echo
"export PATH=$PATH:/usr/local/mongodb/bin" >>/etc/profile
[root@Master mongodb]# source
/etc/profile
[root@Master mongodb]# cd /etc/init.d/
[root@Master init.d]# vim mongod
#!/bin/bash
# mongodb Startup script for the mongodb server
# chkconfig: - 64 36
# description: MongoDB Database Server
# processname: mongodb
# Source function library
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/mongodb
]; then
. /etc/sysconfig/mongodb
fi
prog="mongod"
mongod="/usr/local/mongodb/bin/mongod"
RETVAL=0
start() {
echo -n $"Starting $prog:
"
daemon $mongod "--dbpath /usr/local/mongodb/db --fork --logpath
/usr/local/mongodb/logs/mongodb.log --logappend 2>&1
>>/usr/local/mongodb/logs/mongodb.log"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] &&
touch /var/lock/subsys/$prog
return $RETVAL
}
stop() {
echo -n $"Stopping $prog:
"
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] &&
rm -f /var/lock/subsys/$prog
return $RETVAL
}
reload() {
echo -n $"Reloading $prog:
"
killproc $prog -HUP
RETVAL=$?
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
condrestart)
if [ -f
/var/lock/subsys/$prog ]; then
stop
start
fi
;;
reload)
reload
;;
status)
status $mongod
RETVAL=$?
;;
*)
echo $"Usage:
$0 {start|stop|restart|condrestart|reload|status}"
RETVAL=1
esac
exit $RETVAL
[root@Master init.d]#
chmod +x mongod
[root@Master init.d]#
chkconfig --add mongod
[root@Master init.d]# chkconfig --level 345
mongod on
[root@Master init.d]# service mongod status
mongod is stopped
[root@Master init.d]# service mongod start
Starting mongod:
[ OK ]
[root@Master init.d]#
[root@Master init.d]# mongo
MongoDB shell version: 3.0.6
connecting to: test
Server has startup warnings:
2015-09-23T11:44:33.212+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2015-09-23T11:44:33.212+0800 I CONTROL [initandlisten]
2015-09-23T11:44:33.212+0800 I CONTROL [initandlisten]
2015-09-23T11:44:33.212+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-09-23T11:44:33.212+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-09-23T11:44:33.212+0800 I CONTROL [initandlisten]
2015-09-23T11:44:33.212+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-09-23T11:44:33.212+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-09-23T11:44:33.212+0800 I CONTROL [initandlisten]
> show databases;
local 0.078GB
> exit
bye
connecting to: test
Server has startup warnings:
2015-09-23T11:44:33.212+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2015-09-23T11:44:33.212+0800 I CONTROL [initandlisten]
2015-09-23T11:44:33.212+0800 I CONTROL [initandlisten]
2015-09-23T11:44:33.212+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-09-23T11:44:33.212+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-09-23T11:44:33.212+0800 I CONTROL [initandlisten]
2015-09-23T11:44:33.212+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-09-23T11:44:33.212+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-09-23T11:44:33.212+0800 I CONTROL [initandlisten]
> show databases;
local 0.078GB
> exit
bye
[root@Master init.d]# service mongod stop
Stopping mongod:
[ OK ]
------------------------------------------The
End--------------------------------------------------
No comments:
Post a Comment