mogondb安装
一.安装包准备
下载地址:
https://www.mongodb.com/try/download/community
二.安装
1. 解压安装
tar -zxvf mongodb-linux-x86_64-rhel70-4.4.13.tgz -C /opt/module/
cd /opt/module/
mv mongodb-linux-x86_64-rhel70-4.4.13 mongodb-4.4.13
cd mongodb-4.4.13/
mkdir data
mkdir logs
touch logs/mongodb.log
安装完配置环境变量,不做赘述.
2. 创建配置文件进行配置
[root@dbserver conf]# cat mongodb.conf
dbpath=/opt/module/mongodb-4.4.13/data
logpath=/opt/module/mongodb-4.4.13/logs/mongodb.log
logappend=true
port=27017
bind_ip=0.0.0.0
fork=true
3. 启动服务
[root@dbserver conf]# mongod -f /opt/module/mongodb-4.4.13/conf/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 20903
child process started successfully, parent exiting
4. 创建管理员用户和密码
[root@dbserver conf]# mongo
MongoDB shell version v4.4.13
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("8bd1fadb-26d2-486d-8fdc-540e2dc8af9b") }
MongoDB server version: 4.4.13
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
https://docs.mongodb.com/
Questions? Try the MongoDB Developer Community Forums
https://community.mongodb.com
---
The server generated these startup warnings when booting:
2022-04-20T17:47:59.264+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
2022-04-20T17:47:59.264+08:00: You are running this process as the root user, which is not recommended
2022-04-20T17:47:59.264+08:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never'
2022-04-20T17:47:59.264+08:00: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. We suggest setting it to 'never'
2022-04-20T17:47:59.264+08:00: Soft rlimits too low
2022-04-20T17:47:59.264+08:00: currentValue: 1024
2022-04-20T17:47:59.264+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()
---
> use admin;
switched to db admin
> db.createUser({user:'root',pwd:'root',roles:[{role:'root',db:'admin'}]});
Successfully added user: {
"user" : "root",
"roles" : [
{
"role" : "root",
"db" : "admin"
}
]
}
> exit
bye
配置文件中添加验证:
auth=true
重启mongo:
[root@dbserver conf]# mongod --shutdown -f /opt/module/mongodb-4.4.13/conf/mongodb.conf
killing process with pid: 20903
[root@dbserver conf]# mongod -f /opt/module/mongodb-4.4.13/conf/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 21118
child process started successfully, parent exiting
4. 测试远程连接
每个人都在奋不顾身,都在加倍努力,得过且过只会让你和别人的差距越来越大...
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~