mongodb 下载官网地址
https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.12.tgz
解压mongodb
[root@localhost opt]# ls
hazelcast-3.10.2.tar.gz jdk-8u171-linux-x64.tar.gz logstash-6.4.0.tar.gz nginx-1.15.1.tar.gz pcre-8.40.tar.gz zlib-1.2.11 zookeeper-3.4.10.tar.gz
hazelcast-management-center-3.10.1.tar.gz kafka_2.11-1.1.0.tgz mongodb-linux-x86_64-3.2.12.tgz pcre-8.40 redis-4.0.10.tar.gz zlib-1.2.11.tar.gz
[root@localhost opt]# tar zxvf mongodb-linux-x86_64-3.2.12.tgz
将mongodb 移动到你想安装的目录
[root@localhost opt]# mv mongodb-linux-x86_64-3.2.12 /usr/local/mongodb
在mongodb目录下创建日志、数据等存放文件夹
[root@localhost mongodb]# cd /usr/local/mongodb/
[root@localhost mongodb]# mkdir data/db
[root@localhost mongodb]# mkdir logs
[root@localhost mongodb]# ls
bin data GNU-AGPL-3.0 logs MPL-2 README THIRD-PARTY-NOTICES
创建配置文件
[root@localhost mongodb]# cd bin/
[root@localhost bin]# vim mongodb.yml
mongodb.yml
#日志文件存放地址配置
systemLog:
destination: file
path: "/usr/local/mongodb/logs/mongodb.log"
logAppend: true
#数据存放地址配置
storage:
dbPath: "/usr/local/mongodb/data/db"
journal:
enabled: true
#守护进程运行
processManagement:
fork: true
#ip端口绑定
net:
bindIp: 192.168.126.130
port: 27017
更多配置相关信息推荐参考大神的博客 很详细的讲解了每个配置的意义 地址:
https://www.cnblogs.com/phpandmysql/p/7763394.html
需要注意的是 请给data\db logs等文件夹相关权限否则启动会报错。
启动mongodb
[root@localhost mongodb]# cd bin/
[root@localhost bin]# vim mongodb.yml
[root@localhost bin]# ls
bsondump mongo mongod mongodb.yml mongodump mongoexport mongofiles mongoimport mongooplog mongoperf mongorestore mongos mongostat mongotop
[root@localhost bin]# ./mongod --config mongodb.yml
通过客户端直接操作mongo
[root@localhost bin]# ls
bsondump mongo mongod mongodb.yml mongodump mongoexport mongofiles mongoimport mongooplog mongoperf mongorestore mongos mongostat mongotop
[root@localhost bin]# ./mongo 192.168.126.130:27017/test
MongoDB shell version: 3.2.12
connecting to: 192.168.126.130:27017/test
Server has startup warnings:
2018-09-18T10:09:47.370+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-09-18T10:09:47.370+0800 I CONTROL [initandlisten]
2018-09-18T10:09:47.371+0800 I CONTROL [initandlisten]
2018-09-18T10:09:47.371+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2018-09-18T10:09:47.371+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2018-09-18T10:09:47.371+0800 I C
版权声明:本文为DanKanHu原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。