码迷,mamicode.com
首页 > 数据库 > 详细

MongoDB安装

时间:2020-03-05 16:43:11      阅读:76      评论:0      收藏:0      [点我收藏+]

标签:database   form   bpa   cti   变量   配置文件   提示   code   vim   

MongoDB安装

1.上传mongodb包

[root@long ~]# ll
-rw-r--r-- 1 root root 100351280 Jul  6  2019 mongodb-linux-x86_64-3.6.13.tgz

2.文件放于/usr/local/mongodb目录下

cd /usr/local
tar xf mongodb-linux-x86_64-3.6.13.tgz   #解压文件
mv mongodb-linux-x86_64-3.6.13/ /usr/local/mongodb  #移动文件

3.配置环境变量

vi /etc/profile  

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

4.mongdb启动配置

#创建db和log目录
  cd /usr/local/mongodb
  mkdir data
  cd data
  mkdir db
  mkdir log

#进入mongodb的bin目录,配置文件可以自定义位置,我就把它放在了bin目录下
  cd /usr/local/mongodb/bin

[root@long bin]# vim mongodb.conf 

dbpath = /usr/local/mongodb/data/db #数据文件存放目录  
logpath = /usr/local/mongodb/logs/mongodb.log #日志文件存放目录  
port = 27017  #端口  
fork = true  #以守护程序的方式启用,即在后台运行  
#nohttpinterface = true 
#网上很多添加这句nohttpinterface=true,但是启动会报错,所以就去掉了

加上nohttpinterface = true启动报错提示如下:
[root@long bin]# ./mongod -f mongodb.conf
Error parsing INI config file: unrecognised option 'nohttpinterface'
try './mongod --help' for more information

注释掉后启动
[root@long bin]# ./mongod -f ./mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 8092
child process started successfully, parent exiting

[root@long bin]# ps aux|grep mongo
root      8092  0.2  4.3 989232 44372 ?        Sl   10:39   0:03 ./mongod -f ./mongodb.conf
root      8173  0.0  0.0 112660   968 pts/0    R+   11:03   0:00 grep --color=auto mongo

5.进入mongo

[root@long bin]# ./mongo
MongoDB shell version v3.6.13
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("09444513-20f8-4f53-a48f-d783b5526d6d") }
MongoDB server version: 3.6.13
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
    http://docs.mongodb.org/
Questions? Try the support group
    http://groups.google.com/group/mongodb-user
Server has startup warnings: 
2020-03-05T10:39:57.588+0800 I STORAGE  [initandlisten] 
2020-03-05T10:39:57.588+0800 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2020-03-05T10:39:57.588+0800 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2020-03-05T10:39:58.282+0800 I CONTROL  [initandlisten] 
2020-03-05T10:39:58.282+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-03-05T10:39:58.282+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2020-03-05T10:39:58.282+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2020-03-05T10:39:58.282+0800 I CONTROL  [initandlisten] 
2020-03-05T10:39:58.282+0800 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2020-03-05T10:39:58.282+0800 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server. 
2020-03-05T10:39:58.282+0800 I CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP 
2020-03-05T10:39:58.282+0800 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
2020-03-05T10:39:58.282+0800 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
2020-03-05T10:39:58.282+0800 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
2020-03-05T10:39:58.282+0800 I CONTROL  [initandlisten] 
2020-03-05T10:39:58.283+0800 I CONTROL  [initandlisten] 
2020-03-05T10:39:58.283+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2020-03-05T10:39:58.283+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2020-03-05T10:39:58.283+0800 I CONTROL  [initandlisten] 
2020-03-05T10:39:58.283+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2020-03-05T10:39:58.283+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2020-03-05T10:39:58.283+0800 I CONTROL  [initandlisten] 
2020-03-05T10:39:58.283+0800 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 3895 processes, 65535 files. Number of processes should be at least 32767.5 : 0.5 times number of files.
2020-03-05T10:39:58.283+0800 I CONTROL  [initandlisten] 
> 

MongoDB安装

标签:database   form   bpa   cti   变量   配置文件   提示   code   vim   

原文地址:https://www.cnblogs.com/longren/p/12420965.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!