irpas技术客

CentOS上安装及配置Mongodb_送你一朵小莲花_centos安装mongodb

irpas 7433

参考了这篇博文Centos7 安装MongoDB详细步骤_伴之则安博客的博客-CSDN博客_centos7 mongodb安装,纠正了几个错误能够顺利启动mongodb。

MongoDB是一款数据库软件,MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的。

1. 下载及解压

下载地址?https://·/try/download/community

本次安装调试是在Linux Centos7.9上进行的。顺带科普一下,Centos是Redhat的开源社区版,是属于Redhat的。

?

本次下载的当前版本为5.0.8,可以在点击"Copy Link",在linux上运行:

mkdir /opt/src cd /opt/src wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-5.0.8.tgz tar zxf mongodb-linux-x86_64-rhel70-5.0.8.tgz -C /opt mv /opt/mongodb-linux-x86_64-rhel70-5.0.8 /opt/mongodb-5.0.8 ?2. 配置环境变量 vi /etc/profile #文件最后添加此配置(第一种) export MONGODB_HOME=/opt/mongodb-5.0.8 export PATH=$PATH:${MONGODB_HOME}/bin

#保存退出 source /etc/profile使环境变量生效

3.?建立日志和数据文件夹 cd /opt/mongodb-5.0.8/ mkdir data logs #查看 [root@XXX mongodb-5.0.8]# ls bin data LICENSE-Community.txt logs MPL-2 README THIRD-PARTY-NOTICES 4.?在mongodb-5.0.8 下的bin建立配置文件夹 cd /opt/mongodb-5.0.8/bin vi mongodb.conf # 输入如下配置 port=27017 #端口 bind_ip=0.0.0.0 #默认是127.0.0.1 dbpath=/opt/mongodb-5.0.8/data #数据库存放 logpath=/opt/mongodb-5.0.8/logs/mongodb.log #日志文件 fork=true #设置后台运行 #auth=true #开启认证

如果刚开始配置调试,可以把fork=true注释掉,这样如果有报错就会直接打印出来,便于调试。等测试配置ok后再将该条放开,这样启动的mongodb程序就会在后台运行。

5.?启动mongodb cd /opt/mongodb-5.0.8/bin mongod --config mongodb.conf 6. 启动完可以先本地测试一下连接

输入mongo进入mongo数据库。

输入show dbs; 显示当前所有的数据库

输入exit;退出

[root@XXX bin]# mongo MongoDB shell version v5.0.8 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID("94f66ec4-f583-4522-afd2-6d4f4689c1a1") } MongoDB server version: 5.0.8 ================ Warning: the "mongo" shell has been superseded by "mongosh", which delivers improved usability and compatibility.The "mongo" shell has been deprecated and will be removed in an upcoming release. For installation instructions, see https://docs.mongodb.com/mongodb-shell/install/ ================ --- The server generated these startup warnings when booting: 2022-04-27T13:33:58.142+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted 2022-04-27T13:33:58.142+08:00: You are running this process as the root user, which is not recommended 2022-04-27T13:33:58.142+08:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never' 2022-04-27T13:33:58.142+08:00: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. We suggest setting it to 'never' 2022-04-27T13:33:58.142+08:00: Soft rlimits for open file descriptors too low 2022-04-27T13:33:58.142+08:00: currentValue: 1024 2022-04-27T13:33:58.142+08:00: recommendedMinimum: 64000 --- --- Enable MongoDB's free cloud-based monitoring service, which will then receive and display metrics about your deployment (disk utilization, CPU, operation statistics, etc). The monitoring data will be available on a MongoDB website with a unique URL accessible to you and anyone you share the URL with. MongoDB may use this information to make product improvements and to suggest MongoDB products and deployment options to you. To enable free monitoring, run the following command: db.enableFreeMonitoring() To permanently disable this reminder, run the following command: db.disableFreeMonitoring() --- > show dbs; admin 0.000GB config 0.000GB local 0.000GB steedos 0.004GB > exit bye


1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,会注明原创字样,如未注明都非原创,如有侵权请联系删除!;3.作者投稿可能会经我们编辑修改或补充;4.本站不提供任何储存功能只提供收集或者投稿人的网盘链接。

标签: #centos安装mongodb #参考了这篇博文Centos7 #1 #Centos79上进行的