CentOS6.x安装mongodb3.4.x
一、系统及安装说明
系统:CentOS6.x_x64,mongodb-3.4.10。mongodb官方下载地址 https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.4.10.tgz。本次安装选择编辑yum安装。
二、配置官方yum库
1>创建yum安装库文件
#vim /etc/yum.repos.d/mongodb-org-3.4.repo #创建之后可以直接使用yum安装 [mongodb-org-3.4] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
当设置gpgcheck=0时,gpgkey路径可以不设置
2>yum安装
#yum install -y mongodb-org #当出现以下即为安装中 updates/primary_db | 5.3 MB 00:01 Resolving Dependencies --> Running transaction check ---> Package mongodb-org.x86_64 0:3.4.10-1.el6 will be installed --> Processing Dependency: mongodb-org-tools = 3.4.10 for package: mongodb-org-3.4.10-1.el6.x86_64 --> Processing Dependency: mongodb-org-shell = 3.4.10 for package: mongodb-org-3.4.10-1.el6.x86_64 --> Processing Dependency: mongodb-org-server = 3.4.10 for package: mongodb-org-3.4.10-1.el6.x86_64 --> Processing Dependency: mongodb-org-mongos = 3.4.10 for package: mongodb-org-3.4.10-1.el6.x86_64 --> Running transaction check ---> Package mongodb-org-mongos.x86_64 0:3.4.10-1.el6 will be installed ---> Package mongodb-org-server.x86_64 0:3.4.10-1.el6 will be installed ---> Package mongodb-org-shell.x86_64 0:3.4.10-1.el6 will be installed ---> Package mongodb-org-tools.x86_64 0:3.4.10-1.el6 will be installed --> Finished Dependency ResolutionDependencies Resolved=====================================================================================================================================================================================================================================================================Package Arch Version Repository Size ===================================================================================================================================================================================================================================================================== Installing:mongodb-org x86_64 3.4.10-1.el6 mongodb-org-3.4 5.8 k Installing for dependencies:mongodb-org-mongos x86_64 3.4.10-1.el6 mongodb-org-3.4 12 Mmongodb-org-server x86_64 3.4.10-1.el6 mongodb-org-3.4 20 Mmongodb-org-shell x86_64 3.4.10-1.el6 mongodb-org-3.4 11 Mmongodb-org-tools x86_64 3.4.10-1.el6 mongodb-org-3.4 49 MTransaction Summary ===================================================================================================================================================================================================================================================================== Install 5 Package(s)Total size: 91 M Total download size: 69 M Installed size: 258 M Downloading Packages: (1/2): mongodb-org-server-3.4.10-1.el6.x86_64.rpm | 20 MB 00:03 (2/2): mongodb-org-tools-3.4.10-1.el6.x86_64.rpm | 49 MB 00:15 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 3.4 MB/s | 69 MB 00:19
三、自定义安装配置
1>安装成功后,数据和日志目录默认是在 /var/lib/mongo 和 /var/log/mongodb,为方便管理我们可进行自定义。以 /data/mongodb 为例
2>编辑/etc/mongod.conf
#vim /etc/mongod.conf # mongod.conf# for documentation of all options, see: # http://docs.mongodb.org/manual/reference/configuration-options/# where to write logging data. systemLog:destination: filelogAppend: truepath: /data/mongodb/log/mongod.log# Where and how to store data. storage:dbPath: /data/mongodb/datajournal:enabled: true # engine: # mmapv1: # wiredTiger:# how the process runs processManagement:fork: true # fork and run in backgroundpidFilePath: /var/run/mongodb/mongod.pid # location of pidfile# network interfaces net:port: 27017bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.#security:#operationProfiling:#replication:#sharding:## Enterprise-Only Options#auditLog:#snmp
3>创建目录
#mkdir -p /data/mongodb/data #mkdir -p /data/mongodb/log #chown mongod.mongod /data/mongodb -R #修改权限,否则mongo有可能启动不了
四、启动并测试
1>启动mongod
#service mongod start|stop|restart
2>添加到开机启动项
#chkconfig --add mongod #chkconfig mongod on
3>登录测试
#mongo --host 127.0.0.1MongoDB shell version v3.4.10 connecting to: mongodb://127.0.0.1:27017/ MongoDB server version: 3.4.10 Server has startup warnings: 2017-12-06T10:41:30.462+0800 I STORAGE [initandlisten] 2017-12-06T10:41:30.462+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine 2017-12-06T10:41:30.462+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem 2017-12-06T10:41:30.901+0800 I CONTROL [initandlisten] 2017-12-06T10:41:30.902+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2017-12-06T10:41:30.902+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2017-12-06T10:41:30.902+0800 I CONTROL [initandlisten] 2017-12-06T10:41:30.902+0800 I CONTROL [initandlisten] 2017-12-06T10:41:30.902+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2017-12-06T10:41:30.902+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2017-12-06T10:41:30.902+0800 I CONTROL [initandlisten] 2017-12-06T10:41:30.902+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2017-12-06T10:41:30.902+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2017-12-06T10:41:30.902+0800 I CONTROL [initandlisten] 2017-12-06T10:41:30.902+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 1024 processes, 65535 files. Number of processes should be at least 32767.5 : 0.5 times number of files. 2017-12-06T10:41:30.902+0800 I CONTROL [initandlisten] > show dbs admin 0.000GB local 0.000GB >
五、问题排错
1> 登录mongodb数据库时,如果出现以下错误
MongoDB shell version v3.4.10 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 3.4.10 Server has startup warnings: 2017-12-06T10:46:46.575+0800 I STORAGE [initandlisten] 2017-12-06T10:46:46.575+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine 2017-12-06T10:46:46.575+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem 2017-12-06T10:46:46.955+0800 I CONTROL [initandlisten] 2017-12-06T10:46:46.955+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2017-12-06T10:46:46.955+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2017-12-06T10:46:46.955+0800 I CONTROL [initandlisten] 2017-12-06T10:46:46.956+0800 I CONTROL [initandlisten] 2017-12-06T10:46:46.956+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2017-12-06T10:46:46.956+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2017-12-06T10:46:46.956+0800 I CONTROL [initandlisten] 2017-12-06T10:46:46.956+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2017-12-06T10:46:46.956+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2017-12-06T10:46:46.956+0800 I CONTROL [initandlisten] 2017-12-06T10:46:46.956+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 1024 processes, 65535 files. Number of processes should be at least 32767.5 : 0.5 times number of files.
环境不通解决办法也不通,详情请参照官方文档 https://docs.mongodb.com/manual/tutorial/transparent-huge-pages/
2>创建脚本
# vim /etc/init.d/disable-transparent-hugepages
#!/bin/bash### BEGIN INIT INFO # Provides: disable-transparent-hugepages # Required-Start: $local_fs # Required-Stop: # X-Start-Before: mongod mongodb-mms-automation-agent # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Disable Linux transparent huge pages # Description: Disable Linux transparent huge pages, to improve # database performance. ### END INIT INFO case $1 instart)if [ -d /sys/kernel/mm/transparent_hugepage ]; thenthp_path=/sys/kernel/mm/transparent_hugepage elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; thenthp_path=/sys/kernel/mm/redhat_transparent_hugepage elsereturn 0fiecho 'never' > ${thp_path}/enabled echo 'never' > ${thp_path}/defrag re='^[0-1]+$'if [[ $(cat ${thp_path}/khugepaged/defrag) =~ $re ]]then# RHEL 7echo 0 > ${thp_path}/khugepaged/defrag else# RHEL 6echo 'no' > ${thp_path}/khugepaged/defrag fiunset re unset thp_path ;;esac
添加到开机服务
#chmod +x /etc/init.d/disable-transparent-hugepages #chkconfig --add disable-transparent-hugepages
3>创建编辑 /etc/tune-profiles/no-thp/ktune.sh
#vim /etc/tune-profiles/no-thp/ktune.sh
#echo "set_transparent_hugepages never" > ktune.sh #chmod +x ktune.sh #tuned-adm profile no-thp #如果提示找不到命令请执行yum install tuned -y
#vim /etc/security/limits.conf
添加
mongod soft nofile 64000 mongod hard nofile 64000 mongod soft nproc 32000 mongod hard nproc 32000
重启系统 sudo reboot
转载于:https://blog.51cto.com/shhlamp/2047822
CentOS6.x安装mongodb3.4.x相关推荐
- CentOS6.5上源码安装MongoDB3.2.1
CentOS6.5上源码安装MongoDB3.2.1 [日期:2016-01-27] 来源:Linux社区 作者:darren-lee [字体:大 中 小] 1.环境准备: 1 mkdir /hom ...
- centos6一键安装vsftpd脚本
centos6一键安装vsftpd脚本 手动安装vsftpd参考教程:Centos下安装Vsftpd的图文教程 vsftpd脚本功能: 1.安装 (命令执行:sh xxx.sh)2.添加ftp用户 ( ...
- linux卸载hadoop版本,centos6.5 安装hadoop1.2.1的教程详解【亲测版】
本篇只简单介绍安装步骤 1. 角色分配 10.11.84.4 web-crawler--1.novalocal master/slave 10.11.84.5 web-crawler--2.noval ...
- centos6.8 安装nginx
centos6.8 安装nginx需要编译nginx源码,不过没啥大不了的,按照步骤来,肯定能成功. 1.安装必要的依赖: yum install -y gcc-c++yum install -y p ...
- centos6.8安装 gitlab 9.3.5及使用
centos6.8安装 gitlab 9.3.5及使用 环境准备: [root@caosm03 conf]# cat /etc/issue CentOS release 6.8 (Final) Ker ...
- Centos6.6安装zabbix server 3.2
2019独角兽企业重金招聘Python工程师标准>>> Centos6.6安装zabbix server 3.2 mysql,php,tengine 安装包和表分区脚本下载:http ...
- CentOS-6.3安装配置SVN
安装说明 系统环境:CentOS-6.3 安装方式:yum install (源码安装容易产生版本兼容的问题) 安装软件:系统自动下载SVN软件 检查已安装版本 #检查是否安装了低版本的SVN [ro ...
- centos6.5安装docker
centos6.5 安装docker 防伪码:吃的苦中苦,方为人上人! 前言:在当今的主流社会中,docker和openstatick是一大主流方向,下面为大家讲解理论知识和实际操作现实中的docke ...
- LInux CentOS6 无人值守安装实例(原作)
Linux CentOS6 无人值守安装: 繁重多台服务器安装是一件既没有技术含量有大量浪费时间的过程,无人值守安装是一个可以很方便的定制多台服务器的优选解决方案,一下就来介绍下我的无人值守安装案例: ...
最新文章
- 伯克利新无监督强化学习方法:减少混沌所产生的突现行为
- codeup:问题 D: 最短路径
- ASP.NET常见错误,原因及解决方法(2003版)_不断更新.....
- 完美解决api-ms-win-crt-runtime-l1-1-0.dll 丢失问题
- 使用POI导出百万级数据到excel的解决方案
- boost::fusion::flatten用法的测试程序
- 突击计划——银行利息
- ddmmyy日期格式是多少_如何在Excel 2013/2016/2019中将mmddyyyy文本转换为普通日期格式...
- Spring Data JPA 梳理 - JPA是什么
- 【CF703-Div2-C1/2】C2. Guessing the Greatest(交互题-思维+二分)
- cad填充密度怎么调整_CAD填充图案时无法正常填充看似封闭的区域怎么解决?
- 联想y430完全拆机图解_联想Y430P笔记本拆机加内存和SSD图文教程
- 完美解决VS2003.Net fatal error LNK1201: 写入程序数据库“.pdb”时出错我的开发环境是Win7旗舰64位+VS2003.Net,经常卡pdb错误,文末给出一个完美的解决
- Spark中组件Mllib的学习27之逻辑回归-多元逻辑回归,较大数据集,带预测准确度计算
- 【缓存】缓存更新策略
- Android Studio 全局搜索快捷键
- Font Awesome文字图标的使用
- 几何分布的期望和方差公式推导_平方差公式证明推导过程及运用详解(数学简便计算方法之一)...
- GitHub 颜值这么高的播放器,太爱了!
- jzoj3424. 【NOIP2013模拟】粉刷匠