mongodb学习日记(二)--mongodb搭建
1、mongodb单机版rpm方式搭建
硬件条件:centos 双核4G阿里云服务器
rpm方式安装简单
(1)配置下载环境
命令:
vim /etc/yum.repos.d/mongodb-org-4.4.repo
[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
(2)下载
yum install --downloaddir=/media/mongodb-rpm-package/ --downloadonly mongodb-org
(3)安装
cd /media
rpm -ivh mongodb-rpm-package/*
mkdir -p /media/mongodb
mkdir -p /media/mongodb/mongo
mkdir -p /media/mongodb/log
touch /media/mongodb/log/mongod.log
chown -R mongod:mongod /media/mongodb
编辑配置文件
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /media/mongodb/log/mongod.log
# Where and how to store data.
storage:
dbPath: /media/mongodb/mongo
journal:
enabled: true
# engine:
# wiredTiger:
# how the process runs
processManagement:
fork: true # fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options
#auditLog:
cd /usr/lib/systemd/system
vim mongod.service
生效配置:
#开机自启动
systemctl enable mongod.service
systemctl daemon-reload
(6)启动mongodb并创建用户
systemctl start mongod.service
(7)添加密码配置再重启
vim /etc/mongod.conf
添加:
security:
authorization: enabled
然后:
systemctl restart mongod.service
单价版搭建就结束了,能正常使用,下节介绍集群搭建的两种主流方式
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。