Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Install and configure MongoDB 3.0.x version database under Linux

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Description:

Operating system: CentOS 6.x 64-bit

IP address: 192.168.1.111

To achieve the goal:

Install and configure the MongoDB database

Specific actions: first, close SElinux, configure firewall 1, vi / etc/selinux/config#SELINUX=enforcing # comment out # SELINUXTYPE=targeted # comment out SELINUX=disabled # add setenforce 0 # to make the configuration take effect immediately 2, vi / etc/sysconfig/iptables-A RH-Firewall-1-INPUT-m state-- state NEW-m tcp-p tcp-- dport 27017-j ACCEPT # allow port 27017 to restart firewall through firewall / etc/init.d/iptables restart # to make configuration effective 2. Install MongoDB

MongoDB download address: the latest version of https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.6.tgz #

Upload mongodb-linux-x86_64-3.0.6.tgz to the / usr/local/src directory

Cd / usr/local/src # enter the software storage directory tar zxvf mongodb-linux-x86_64-3.0.6.tgz # extract mv mongodb-linux-x86_64-3.0.6 / usr/local/mongodb # move the decompression folder to the MongoDB installation directory mkdir-p / data/mongodb/mongodb_data/ # create MongoDB database storage path mkdir-p / data/mongodb/mongodb_log/ # create MongoDB database log storage path # start MongoDB/usr/local/mongodb/bin/mongod-- port 27017-- fork-- dbpath=/data/mongodb/mongodb_data/-- logpath=/data/mongodb/mongodb_log/mongodb.log-- logappendnetstat-lanp | grep "27017" # check whether MongoDB starts cd / usr/local/mongodb/bin/./mongo # enter MongoDB database console use admin # enter admin database db.shutdownServer () # close MongoDB database exit # exit 3. Set MongoDB database 1, cd / usr/local/mongodb/ # enter MongoDB installation directory vi / usr/local/mongodb/mongodb.conf # Edit port=27017 # port number dbpath=/data/mongodb/mongodb_data/ # database path logpath=/data/mongodb/mongodb_log/mongodb.log # log output file path pidfilepath=/usr/local/mongodb/mongo.pidfork=true # set background running logappend=true # log output mode shardsvr=true#auth=true # enable authentication 2, Cd / usr/local/mongodb/bin//usr/local/mongodb/bin/mongod-- config / usr/local/mongodb/mongodb.conf # launch MongoDB/usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin-- eval "db.shutdownServer ()" # close the MongoDBvi / etc/rc.d/init.d/mongod # settings to boot up and start MongoDBulimit-SHn 655350 pound chkconfig:-64 3 cycles description:mongodcase $1 instart) / usr/local / mongodb/bin/mongod-maxConns 20000-config / usr/local/mongodb/mongodb.conf ; stop) / usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin-- eval "db.shutdownServer ()";; status) / usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin-- eval "db.stats ()";; esacchmod + x / etc/rc.d/init.d/mongod # add script execution permissions chkconfig mongod on # set boot service mongod start # launch MongoDB

Note: if the administrator account password is set, use the following command

Account: root

Password: 123456

/ usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin-eval "db.auth ('root',' 123456'); db.shutdownServer ()" / usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin-eval "db.auth ('root',' 123456') Db.stats () "3, vi / etc/profile # add environment variables, edit, and add the following code export PATH=$PATH:/usr/local/mongodb/binsource / etc/profile # to the last line to make the configuration take effect immediately. Test mongo # enter MongoDB console show dbs # View default database use admin # switch to admin database exit # exit MongoDB console

At this point, the MongoDB database installation and configuration is complete.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report