ps -ef|grep mongo #查看mongodb实例数据目录所在位置
root 1525 1389 3 20:44 pts/0 00:00:17
/usr/local/mongodb/bin/mongod –config /data/mongodb/conf/mongo_config.yml
[root@host-172-16-13-12 conf]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 3.9G 0 3.9G 0% /dev
/dev/mapper/centos-root 50G 2.1G 48G 5% /
/dev/vda1 1014M 155M 860M 16% /boot
tmpfs 797M 0 797M 0% /run/user/0
/dev/mapper/VolGroup01-mdb--new 29G 337M 29G 2% /data
[root@host-172-16-13-12 mongodb]# ls /data/mongodb/
conf data logs
pvcreate /dev/vda4 #创建pv卷
Physical volume "/dev/vda4" successfully created.
vgcreate VolGroup02 /dev/vda4 #创建vg
Volume group "VolGroup02" successfully created
[root@host-172-16-13-12 conf]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup01 1 1 0 wz--n- <30.00g 1020.00m
VolGroup02 1 0 0 wz--n- <60.00g <60.00g
centos 1 1 0 wz--n- 50.00g 0
lvcreate --size 59G --name mdb-new2 VolGroup02 #创建lv
Logical volume "mdb-new2" created.
mkfs.xfs /dev/VolGroup02/mdb-new2 #格式化lv
dd if=/dev/VolGroup01/mdb-new |gzip >mdb-snap01.gz #创建快照备份
60817408+0 records in
60817408+0 records out
31138512896 bytes (31 GB) copied, 266.288 s, 117 MB/s
gzip -d -c mdb-snap01.gz |dd of=/dev/VolGroup02/mdb-new2 #恢复快照
60817408+0 records in
60817408+0 records out
31138512896 bytes (31 GB) copied, 837.877 s, 37.2 MB/s
mkdir /srv #创建挂载目录
mount -o nouuid /dev/VolGroup02/mdb-new2 /srv #挂载快照盘
[root@host-172-16-13-12 data]# pwd
/srv/mongodb/data
[root@host-172-16-13-12 mongodb]# du -sh * #查看文件
4.0K conf
303M data
16K logs
/usr/local/mongodb/bin/mongod --config /srv/mongodb/conf/mongo_config.yml & #启动mongodb实例
!ps
ps -ef|grep mongo #查看mongodb实例进程
root 1525 1389 0 20:44 pts/0 00:00:29 /usr/local/mongodb/bin/mongod --config /data/mongodb/conf/mongo_config.yml
root 16641 1389 10 21:33 pts/0 00:00:01 /usr/local/mongodb/bin/mongod --config /srv/mongodb/conf/mongo_config.yml
[root@host-172-16-13-12 mongodb]# mongo localhost:27018 #登陆实例
MongoDB shell version v4.4.17
> show dbs;
admin 0.000GB
config 0.000GB
foo 0.002GB
local 0.000GB
> use foo
switched to db foo
> show tables
bar
> db.bar.count() #查询数据
100000
标签:快照,--,mongodb,dev,mdb,lvm,config,root From: https://www.cnblogs.com/hmysql/p/16944236.html