一、下載mongodb安裝包linux
[root@localhost softs]# pwd /opt/softs [root@localhost softs]# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-3.4.4.tgz
二、解壓安裝mongodb
[root@localhost softs]# tar zxvf mongodb-linux-x86_64-amazon-3.4.4.tgz [root@localhost softs]# mv mongodb-linux-x86_64-amazon-3.4.4 mongodb data:存放數據的目錄 [root@localhost mongodb]# mkdir data logs:存放日誌的目錄 [root@localhost mongodb]# mkdir logs conf:存放配置文件 [root@localhost mongodb]# mkdir conf
三、添加啓動配置文件 vi /opt/softs/mongodb/conf/mongodb.confbash
# 設置數據文件的存放目錄 dbpath = /opt/softs/mongodb/data # 設置日誌文件的存放目錄及其日誌文件名 logpath = /opt/softs/mongodb/logs/mongodb.log # 設置端口號(默認的端口號是 27017) port = 27017 # 設置爲以守護進程的方式運行,即在後臺運行 fork = true # nohttpinterface = true nohttpinterface = true
四、啓動mongodb工具
#進入mongodb的bin目錄下 [root@localhost mongodb]# cd bin/ #按照本身配置的conf文件來啓動 [root@localhost bin]# ./mongod -f ../conf/mongodb.conf about to fork child process, waiting until server is ready for connections. forked process: 2345 child process started successfully, parent exiting #查看是否啓動成功 [root@localhost bin]# ps -aux |grep mongodb root 2345 1.2 4.0 315532 40144 ? Sl 14:49 0:00 ./mongod -f ../conf/mongodb.conf root 2366 0.0 0.0 112664 972 pts/0 R+ 14:49 0:00 grep --color=auto mongodb [root@localhost bin]#
五、mongodb可視化工具下載:https://robomongo.org/downloadurl
一、配置yum源spa
建立一個/etc/yum.repos.d/mongodb-org-4.0.repo
文件rest
[mongodb-org-4.0] name = MongoDB Repository baseurl = https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/ gpgcheck = 1 enabled = 1 gpgkey = https://www.mongodb.org/static/pgp/server-4.0.asc
二、安裝日誌
yum install -y mongodb-org
3.啓動中止重啓code
sudo service mongod start
sudo service mongod stop
sudo service mongod restart
四、設置開機啓動server
sudo chkconfig mongod on
查看修改配置文件 : vi /etc/mongod.conf