percona分支mongodb3.4二进制安装 on Centos6.8
percona分支mongodb3.4二进制安装 on Centos6.8
xxj123gogo 发表于4个月前
percona分支mongodb3.4二进制安装 on Centos6.8
  • 发表于 4个月前
  • 阅读 27
  • 收藏 0
  • 点赞 0
  • 评论 0

腾讯云 技术升级10大核心产品年终让利>>>   

说明

版本:percona 分支的mongodb3.4的二进制版本
percona-server-mongodb-3.4.6-1.7-centos6-x86_64.tar.gz

目录规划:
安装目录: /data/opt/
数据文件目录: /data/mongo
配置文件: /etc/mongod.conf

  • 增加用户和组

groupadd mongodb  &&  useradd -g mongodb mongodb

  • 解压

tar zxvf percona-server-mongodb-3.4.6-1.7-trusty-x86_64.tar.gz -C /data/opt/

  • 创建相关目录

mkdir -p /data/mongo/{db,log,tmp}

  • 更改属性

chown -R mongodb:mongodb /data/opt/percona-server-mongodb-3.4.6-1.7/
chown -R mongodb:mongodb /data/mongo

  • 配置环境变量

echo "PATH=$PATH:/data/opt/percona-server-mongodb-3.4.6-1.7">>/etc/profile
source /etc/profile

  • 创建mongodb配置文件

cat /etc/mongod.conf 

storage:
  dbPath: /data/mongo/db
  journal:
    enabled: true
  engine: wiredTiger
systemLog:
  destination: file
  logAppend: true
  path: /data/mongo/log/mongod.log
processManagement:
  fork: true  
  pidFilePath: /data/mongo/tmp/mongod.pid
net:
  port: 27017
  bindIp: 192.168.1.235,127.0.0.1
security:
  authorization: disabled
  • 内核优化
echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag;
echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled;
echo never > /sys/kernel/mm/transparent_hugepage/enabled;
echo never > /sys/kernel/mm/transparent_hugepage/defrag;
建议写到 /etc/rc.local 中,重启后也可生效
vim /etc/rc.local
echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag
echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
  • 启动mongodb

mongod --config /etc/mongod.conf

  • 初始化认证脚本

percona-server-mongodb-enable-auth.sh 

We have detected authentication is not enabled.
Would you like help creating your first user?
Please note that mongodb service could be restarted during this action
Would you like to proceed?(Y/n)y
Percona Server for MongoDB shell version v3.4.6-1.7
connecting to: mongodb://localhost/admin
Percona Server for MongoDB server version: v3.4.6-1.7
Successfully added user: { "user" : "dba", "roles" : [ "root" ] }
bye
User has been created successfully!
User:dba
Password:tLjMotpKbLbZVTafOkiGuybV9YXXQRA9
It is needed to restart mongod service.
Once service is restarted authentication will be enabled

重启后就需要认证登录了

> use admin 
switched to db admin
> db.auth("dba","tLjMotpKbLbZVTafOkiGuybV9YXXQRA9")
1
> 
> 
> show dbs
admin  0.000GB
local  0.000GB

 

标签: MongoDB
共有 人打赏支持
粉丝 0
博文 38
码字总数 53803
×
xxj123gogo
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: