Install MongoDB on Linux systems

In the default CentOS installed MariaDB, MySQL is the branch, but the need for, or to install MySQL in the system, and after the installation is complete, you can directly overwrite MariaDB.

1. Download the latest stable version of MongoDB

[root@spirit-of-fire ~]# wget http://downloads.mongodb.org/linux/mongodb-linux-x86_64-amazon-latest.tgz

2. Unzip the downloaded file (not compile the downloaded file itself is a binary executable file compiled)

[root@spirit-of-fire ~]# tar -zxvf mongodb-linux-x86_64-amazon-latest.tgz

3. Go to the folder MongoDB

[root@spirit-of-fire ~]# cd 解压后的MongoDB文件夹

4. Create a folder MongoDB and the MongoDB file into the directory specified directory

[root@spirit-of-fire mongodb-linux-x86_64-amazon-4.3.0-1141-g1fa4766]# mkdir /usr/local/mongodb

[root@spirit-of-fire mongodb-linux-x86_64-amazon-4.3.0-1141-g1fa4766]# mv * /usr/local/mongodb/

5. Add the configuration file:

New mongodb.conf configuration files, start by this configuration file.

vim /etc/mongodb.conf

dbpath=/usr/local/mongodb/data/db
logpath=/usr/local/mongodb/logs/mongodb.logs
logappend=true
bind_ip=0.0.0.0
port=27017
fork=true
##auth = true # 先关闭, 创建好用户再启动

6. configure the environment variables: Modify / etc / profile, add the following

vim /etc/profile

export MONGODB_HOME=/usr/local/mongodb
export PATH=$MONGODB_HOME/bin:$PATH

Refresh Profile

source /etc/profile

7. Start mongodb Service

[root@spirit-of-fire mongodb]# ./bin/mongod --dbpath /usr/local/mongodb/data/ --logpath /usr/local/mongodb/logs/mongodb.log --fork --port 27017

This entry represents a start statement mongo server configuration data storage locations --dbpath (usr / local / mongodb / data) and log storage location --logpaht (usr / local / mongodb / logs / mongodb.log) and background --folk

8. Review process mongo

[root@spirit-of-fire mongodb]# netstat -lnp | grep mongo

Use ./bin/mongoa bootable mongo console

Guess you like

Origin www.cnblogs.com/zilongmao/p/11415197.html