# 在mongodb-7.0.8文件下创建数据存储目录和日志存储目录
[root@linux100 module]# cd mongodb-7.0.8
[root@linux100 mongodb-7.0.8]# mkdir -p data
[root@linux100 mongodb-7.0.8]# mkdir -p log
[root@linux100 mongodb-7.0.8]# touch log/mongodb.log
(4)创建启动用的配置文件mongod.conf
perl复制代码
[root@linux100 mongodb-7.0.8]# mdkir config
[root@linux100 mongodb-7.0.8]# vim config/mongod.conf
mongod.conf配置以下内容:
数据存储位置
dbpath=/opt/module/mongodb-7.0.8/data/
日志存储位置
logpath=/opt/module/mongodb-7.0.8/log/mongodb.log
运行时占用端口
port=27017
fork为true指明以后台方式启动
fork=true
3 启动MongoDB及其客户端
perl复制代码
[root@linux100 mongodb-7.0.8]# cd bin
# 启动MongoDB服务端
[root@linux100 bin]# ./mongod -f /opt/module/mongodb-7.0.8/config/mongod.conf
about to fork child process, waiting until server is ready for connections.
forked process: 21418
child process started successfully, parent exiting
# 启动MongoDB客户端,默认连接本机的MongoDB服务(以默认端口连接),并进入到test数据库
[root@linux100 bin]# cd /opt/module/mongosh-2.2.5/bin/
[root@linux100 bin]# ./mongosh
Current Mongosh Log ID: 66285b69ce6a67cac62202d7
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.2.5
Using MongoDB: 7.0.8
Using Mongosh: 2.2.5
For mongosh info see: https://docs.mongodb.com/mongodb-shell/
------
The server generated these startup warnings when booting
2024-04-24T09:07:39.038+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
2024-04-24T09:07:39.038+08:00: You are running this process as the root user, which is not recommended
2024-04-24T09:07:39.038+08:00: This server is bound to localhost. Remote systems will be unable to connect to this server. Start the server with --bind_ip <address> to specify which IP addresses it should serve responses from, or with --bind_ip_all to bind to all interfaces. If this behavior is desired, start the server with --bind_ip 127.0.0.1 to disable this warning
2024-04-24T09:07:39.038+08:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never' in this binary version
2024-04-24T09:07:39.038+08:00: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. We suggest setting it to 'never' in this binary version
2024-04-24T09:07:39.038+08:00: Soft rlimits for open file descriptors too low
------
Deprecation warnings:
- Using mongosh on the current operating system is deprecated, and support may be removed in a future release.
See https://www.mongodb.com/docs/mongodb-shell/install/#supported-operating-systems for documentation on supported platforms.
Enterprise test>