CentOS7.4安装部署mongodb4.2.8
文章目录环境下载安装包配置启动mongodb连接测试环境下载安装包官网地址:https://www.mongodb.com/try/download/community下载地址:https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.8.tgz下载后上传到服务器中我这里上传至/opt目录下,解压,将解压后文件夹简化命名[ro
·
环境
下载安装包
官网地址:
https://www.mongodb.com/try/download/community
下载地址:
https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.8.tgz
下载后上传到服务器中
我这里上传至/opt
目录下,解压,将解压后文件夹简化命名
[root@manager opt]# tar -xvf mongodb-linux-x86_64-rhel70-4.2.8.tgz
[root@manager opt]# ll
-rw-r--r-- 1 root root 132768194 Jul 17 20:08 mongodb-linux-x86_64-rhel70-4.2.8.tgz
drwxr-xr-x 3 root root 135 Jul 17 20:20 mongodb-linux-x86_64-rhel70-4.2.8
[root@manager opt]# mv mongodb-linux-x86_64-rhel70-4.2.8 mongodb-4.2.8
[root@manager opt]# ll
drwxr-xr-x 3 root root 135 Jul 17 20:20 mongodb-4.2.8
-rw-r--r-- 1 root root 132768194 Jul 17 20:08 mongodb-linux-x86_64-rhel70-4.2.8.tgz
配置
增加环境变量
编辑/etc/profile
文件
export MONGODB_HOME=/opt/mongodb-4.2.8
export PATH=$PATH:$MONGODB_HOME/bin
保存退出,使用source
使用改变生效
[root@manager mongodb-4.2.8]# source /etc/profile
创建存放数据和日志的目录
[root@manager mongodb-4.2.8]# mkdir data
[root@manager mongodb-4.2.8]# mkdir logs
[root@manager mongodb-4.2.8]# touch logs/mongo.log
创建配置文件mongo.conf
[root@manager mongodb-4.2.8]# touch mongo.conf
[root@manager mongodb-4.2.8]# vim mongo.conf
dbpath=/opt/mongodb-4.2.8/data
logpath=/opt/mongodb-4.2.8/logs/mongo.log
logappend=true
journal=true
quiet=true
#后台运行
port=27017
fork=true
#允许任何IP进行连接auth=false #是否授权连接
bind_ip=0.0.0.0
#是否授权连接
auth=false
启动mongodb
启动指定配置文件
[root@manager mongodb-4.2.8]# ./bin/mongod -f mongo.conf
about to fork child process, waiting until server is ready for connections.
forked process: 1275
child process started successfully, parent exiting
查询端口
[root@manager mongodb-4.2.8]# netstat -antp | grep 27017
tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 1275/./bin/mongod
连接测试
[root@manager mongodb-4.2.8]# ./bin/mongo
MongoDB shell version v4.2.8
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("6a6c5e36-c7c5-4204-8856-f801c912c6ee") }
MongoDB server version: 4.2.8
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
Server has startup warnings:
2020-07-17T20:41:51.279+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2020-07-17T20:41:51.279+0800 I CONTROL [initandlisten]
2020-07-17T20:41:51.279+0800 I CONTROL [initandlisten]
2020-07-17T20:41:51.279+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2020-07-17T20:41:51.279+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2020-07-17T20:41:51.279+0800 I CONTROL [initandlisten]
2020-07-17T20:41:51.279+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2020-07-17T20:41:51.279+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2020-07-17T20:41:51.279+0800 I CONTROL [initandlisten]
---
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()
---
>
上面有提示透明大页的警告,可通过以下方法关闭
执行如下命令临时关闭
[root@manager mongodb-4.2.8]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
修改如下配置文件,开机关闭
[root@manager mongodb-4.2.8]# vim /etc/rc.local
在结尾处增加以下判断
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
执行如下命令查看透明大页是否已经关闭,若显示always madvise [never]
说明透明大页已经关闭
[root@manager mongodb-4.2.8]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
已为社区贡献1条内容
所有评论(0)