linux建立邏輯卷,遠端共享為備份盤

datapeng發表於2014-10-29
    今天給客戶做一個vg,掛載到遠端,供備份使用,現把linux建立vg及lv的進行下說明。
    由於客戶的資料量在增加,可能以後會再擴盤,所我們採用vg的方式,方便以後直接加盤
[root@mytest ~]# fdisk -l
Disk /dev/sda: 896.9 GB, 896998047744 bytes
255 heads, 63 sectors/track, 109053 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes


   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14      109053   875863800   8e  Linux LVM

Disk /dev/sdb: 1797.9 GB, 1797999558656 bytes
255 heads, 63 sectors/track, 218594 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes


可以看到這裡有一個1.7t左右的盤,所以根據計算,我們的pe,應該是64m,即64*65536=4t
建立分割槽:
[root@mytest ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.


The number of cylinders for this disk is set to 218594.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)

Partition number (1-4): 1
First cylinder (1-218594, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-218594, default 218594): 218594
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
重新掃描認一下盤
[root@mytest ~]# partprobe
[root@mytest ~]# df -h
檔案系統              容量  已用 可用 已用% 掛載點
/dev/mapper/VolGroup00-LogVol00
                      747G   64G  645G   9% /
/dev/sda1              99M   13M   82M  14% /boot
tmpfs                  32G     0   32G   0% /dev/shm
[root@mytest ~]# fdisk -l

Disk /dev/sda: 896.9 GB, 896998047744 bytes
255 heads, 63 sectors/track, 109053 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14      109053   875863800   8e  Linux LVM

Disk /dev/sdb: 1797.9 GB, 1797999558656 bytes
255 heads, 63 sectors/track, 218594 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      218594  1755856273+  83  Linux

建立邏輯盤:
[root@mytest ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created
建立備份的vg,注意這裡要加-s 64mb
[root@mytest ~]# vgcreate -s 64mb backupvg /dev/sdb1
  Volume group "backupvg" successfully created
建立備份用的lv
[root@mytest ~]# lvcreate -L 1600G -n backuplv01 backupvg
  Logical volume "backuplv01" created
建立掛載點
[root@mytest ~]# cd /u01
[root@mytest /]# mkdir -p /u02/databackup
[root@mytest /]# cd /dev/backupvg
[root@mytest backupvg]# ls -a
.  ..  backuplv01
格式化邏輯卷(linux5,只能格式化為ext3格式)
[root@mytest dev]# mkfs.ext3 /dev/backupvg/backuplv01
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
209715200 inodes, 419430400 blocks
20971520 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
12800 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
        102400000, 214990848


Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: 

進行掛載
[root@mytest dev]# mount /dev/backupvg/backuplv01 /u02/databackup

由於本盤不是放置到資料庫的機器上的,所以需要透過nfs掛載的方式進行共享
[root@mytest dev]# vi /etc/exports
新增:
/u02/databackup 192.168.10.*(rw,sync,no_root_squash)

開啟nfs服務
[root@mytest dev]# service nfs start
注意,這裡需要把iptables防火牆停止,否則可能連線不上!

在遠端資料伺服器進行掛載
[root@mydata ~]# mount 192.168.10.10:/u02/backup /u02/backup
將遠端/u02/backup掛載到本地端的/u02/backup
這樣就可以直接在oracle資料庫部署備份了,當本地盤用了

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29371470/viewspace-1312731/,如需轉載,請註明出處,否則將追究法律責任。

相關文章