7月7日為采集系統(tǒng)進行擴容,當時并沒有設置系統(tǒng)啟動時自動掛接數(shù)據(jù)設備;昨日云商在線遷移資源,遷移完成后數(shù)據(jù)庫無法自動啟動,今天補充完善之;
基本步驟 @ Help on QingCloud
- 掛接硬盤;
- fdisk 分區(qū);
- mkfs 格式化設備(build a Linux file system);
- 掛接設備;
fdisk -l(分區(qū)之前)
[root@i-t9qmslrt /]# fdisk -l
Disk /dev/sdb: 4294 MB, 4294967296 bytes
133 heads, 62 sectors/track, 1017 cylinders
Units = cylinders of 8246 * 512 = 4221952 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00099acb
Device Boot Start End Blocks Id System
/dev/sda1 * 1 2611 20970496 83 Linux
Disk /dev/sdc: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
- Disk /dev/sdc:表示盤名,我們就是要對這塊盤進行分區(qū);
fdisk /dev/sdc(實施分區(qū))
[root@i-t9qmslrt /]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xc813aa14.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): c
DOS Compatibility flag is not set
Command (m for help): u
Changing display/entry units to sectors
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-209715199, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):
Using default value 209715199
Command (m for help): wq
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
fdisk -l(分區(qū)之后)
[root@i-t9qmslrt /]# fdisk -l
Disk /dev/sdb: 4294 MB, 4294967296 bytes
133 heads, 62 sectors/track, 1017 cylinders
Units = cylinders of 8246 * 512 = 4221952 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00099acb
Device Boot Start End Blocks Id System
/dev/sda1 * 1 2611 20970496 83 Linux
Disk /dev/sdc: 107.4 GB, 107374182400 bytes
43 heads, 44 sectors/track, 110843 cylinders
Units = cylinders of 1892 * 512 = 968704 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc813aa14
Device Boot Start End Blocks Id System
/dev/sdc1 2 110844 104856576 83 Linux
- Disk /dev/sdc:表示盤名,這塊盤已經(jīng)分好區(qū);
- /dev/sdc1:設備名,這就是我們要掛接的設備;
mkfs -t ext4 /dev/sdc1(在設備上建文件系統(tǒng))
[root@i-t9qmslrt /]# mkfs -t ext4 /dev/sdc1
mke2fs 1.41.12 (17-May-2010)
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26214144 blocks
1310707 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
掛接設備
# mkdir -p /mnt/spiderdata && mount -t ext4 /dev/sdc1 /mnt/spiderdata
mount 命令的一般格式為:
mount -t vfstype device dir
- vfstype 表示支持的 filesystem type;通過 mount 檢查掛接結果(View All Mounts)
mount
/dev/sda1 on / type ext4 (rw,barrier=1)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sdc1 on /mnt/spiderdata type ext4 (rw)
如何自動掛載?
由于在云中設備的順序編碼(如:/dev/sdc1)在關機、開機過程中可能發(fā)生改變,所以要設置系統(tǒng)啟動時自動掛載,推薦使用 UUID 或者 LABEL 的方式來指定,而不要使用在 /etc/fstab 中直接指定 /dev/sdc1 這樣的寫法;
blkid /dev/sdc1
/dev/sdc1: UUID="5228e18f-0949-43ef-ad40-c2a83a6eb5ed" TYPE="ext4"
- 編輯 /etc/fstab,加入
UUID=5228e18f-0949-43ef-ad40-c2a83a6eb5ed /mnt/spiderdata ext4 defaults 0 2 - man fstab 可以查看六個字段的含義;
- 修改完 fstab,使用 “mount -a” 檢查是否正確;