Changetorootsu
Change to root su-##or ## sudo-I add yum repo/etc/yum. repos. d/10gen-mongodb.repo [10gen] name = 10gen Repository baseurl = http://downloads-distro.mongodb.org/repo/redhat/ OS /i686 gpgcheck = 0 install mongodb yum install mongo-10gen mongo-10
Change to root
Su-# OR # sudo-I
Add yum repo
/Etc/yum. repos. d/10gen-mongodb.repo [10gen] name = 10gen Repository baseurl = http://downloads-distro.mongodb.org/repo/redhat/ OS /i686 gpgcheck = 0
Install mongodb
Yum install mongo-10gen mongo-10gen-server
Configure MongoDB
Vi/etc/mongod. conf logpath =/var/log/mongo/mongod. log port = 27017 dbpath =/var/lib/mongo
Start MongoDB Server
Service Producer d start ##or ##/etc/init. d/producer d start
Start MongoDB on boot
Chkconfig -- levels 235 mongod on
Test MongoDB Server
Mongo use test switched to db test db. foo. find () db. foo. save ({a: 1}) db. foo. find ()
Open MongoDB Port (27017) on Iptables Firewall
/Etc/sysconfig/iptables-a input-m state -- state NEW-m tcp-p tcp -- dport 27017-j ACCEPT
Restart Iptables Firewall
Service iptables restart ##or ##/etc/init. d/iptables restart
Test remote connection
Mongo server: port/database ## Example # mongo 10.0.10.45: 27017/test
Nodejs
Cd ~ Wget https://raw.github.com/isaacs/nave/master/nave.sh chmod + x nave. sh./nave. sh install 0.10.21./nave. sh use 0.10.21 node-v
Original article address: Install mongodb in centos. Thank you for sharing it with me.