Centos install MongoDB database

MongoDB is a database based on distributed file storage. Written in C++ language. Designed to provide scalable high-performance data storage solutions for WEB applications.

MongoDB is a product between relational and non-relational databases. It is the most versatile and most like relational database among non-relational databases.


Turn off the firewall

[root@docker02 yum.repos.d]# systemctl stop firewalld

[root@docker02 yum.repos.d]# systemctl disable firewalld

1. Unzip

[root@docker02 ~]# tar -zxvf mongodb-linux-x86_64-rhel70-4.4.2.tgz 

[root@docker02 ~]# mv mongodb-linux-x86_64-rhel70-4.4.2 /opt/mongodb


root@docker02 bin]# vim /etc/profile

export PATH=$PATH:/opt/mongodb/bin

[root@docker02 bin]# source /etc/profile

[root@docker02 bin]# ls

install_compass  mongo  mongod  mongos


2. Create a database to store directories and logs

[root@docker02 mongodb]# mkdir data/db -p

[root@docker02 data]# touch logs

[root@docker02 data]# ls

db  logs

[root@docker02 mongodb]# ls

bin  data  LICENSE-Community.txt  MPL-2  README  THIRD-PARTY-NOTICES

3. Modify the configuration file

[root@docker02 mongodb]# vim mongodb.conf

[root@docker02 ~]# vim /opt/mongodb/mongodb.conf 

 # mongod.conf

# for documentation of all options, see:

# where to write logging data.

 systemLog:

   destination: file

   logAppend: true

   path: /opt/mongodb/data/logs

# Where and how to store data.

 storage:

   dbPath: /opt/mongodb/data/db

   journal:

     enabled: true

 #  engine:

 #  wiredTiger:

# how the process runs

 processManagement:

   fork: true  # fork and run in background

   pidFilePath: /mongo/mongod.pid  # location of pidfile

   timeZoneInfo: /usr/share/zoneinfo

# network interfaces

 net:

   port: 27017

   bindIp: 0.0.0.0

Note the modification:

dbPath: /opt/mongodb/data/db

path: /opt/mongodb/data/logs

 port: 27017

  bindIp: 0.0.0.0

image.png

4. Start mongodb

[root@docker02 bin]# ./mongod -f ../mongodb.conf

image.png

Or start in the background

[root@docker02 bin]# mongod --dbpath /opt/mongodb/data/db --logpath /opt/mongodb/data/logs --fork

about to fork child process, waiting until server is ready for connections.

forked process: 8132

child process started successfully, parent exiting

image.png

相关阅读:

1、Mysqlbinlog日志的清理与切换

2、mysqldump+binlog恢复被删除的数据

3、Mysql8.0 主从复制

4、Mysql8.0安装实战


image.png


Guess you like

Origin blog.51cto.com/15127516/2657666