去官网下载对应版本,我这里下载的Centos8对应版本mongodb-linux-x86_64-rhel80-4.2.8.tgz包
使用rz命令或xftp工具,将压缩包上传至当前用户temp目录中
[root@localhost temp]# rz [root@localhost temp]# ll -rw-r--r--. 1 root root 132608624 6月 30 16:01 mongodb-linux-x86_64-rhel80-4.2.8.tgz执行命令:tar -zxvf mongodb-linux-x86_64-rhel80-4.2.8.tgz -C /usr/local/解压到指定目录 执行命令:mv mongodb-linux-x86_64-rhel80-4.2.8/ mongodb进行重命名
[root@localhost local]# mv mongodb-linux-x86_64-rhel80-4.2.8/ mongodb [root@localhost local]# ll 总用量 0 ... drwxr-xr-x. 3 root root 135 6月 30 16:19 mongodb在mongodb目录下mkdir data,再进入data目录下mkdir db,创建好数据目录
[root@localhost data]# ll 总用量 0 drwxr-xr-x. 2 root root 6 6月 30 16:26 db [root@localhost data]# pwd /usr/local/mongodb/data在mongodb目录下mkdir log,再进入log目录下touch mongodb.log,创建好日志文件
[root@localhost log]# ll 总用量 0 -rw-r--r--. 1 root root 0 6月 30 16:29 mongodb.log [root@localhost log]# pwd /usr/local/mongodb/log在mongodb目录下mkdir etc,再进入etc目录下touch mongodb.conf,创建好日志文件
[root@localhost etc]# ll 总用量 0 -rw-r--r--. 1 root root 0 6月 30 16:36 mongodb.conf [root@localhost etc]# pwd /usr/local/mongodb/etc在mongodb.conf中增加如下配置信息
dbpath=/usr/local/mongodb/data/db/ logpath=/usr/local/mongodb/log/mongodb.log port=27017 fork=true在bin目录下,执行命令:./mongod --config /usr/local/mongodb/etc/mongodb.conf
[root@localhost bin]# ./mongod --config /usr/local/mongodb/etc/mongodb.conf about to fork child process, waiting until server is ready for connections. forked process: 1966 child process started successfully, parent exiting在bin目录下,执行命令:./mongod --shutdown --dbpath /usr/local/mongodb/data/db/
[root@localhost bin]# ./mongod --shutdown --dbpath /usr/local/mongodb/data/db/ 2020-06-30T16:45:51.874+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none' 2020-06-30T16:45:51.881+0000 W ASIO [main] No TransportLayer configured during NetworkInterface startup killing process with pid: 1966