7月7日为采集系统进行扩容,当时并没有设置系统启动时自动挂接数据设备;昨日云商在线迁移资源,迁移完成后数据库无法自动启动,今天补充完善之;
基本步骤 @ Help on QingCloud
- 挂接硬盘;
- fdisk 分区;
- mkfs 格式化设备(build a Linux file system);
- 挂接设备;
fdisk -l(分区之前)
[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:表示盘名,我们就是要对这块盘进行分区;
fdisk /dev/sdc(实施分区)
[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(分区之后)
[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:表示盘名,这块盘已经分好区;
- /dev/sdc1:设备名,这就是我们要挂接的设备;
mkfs -t ext4 /dev/sdc1(在设备上建文件系统)
[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)在关机、开机过程中可能发生改变,所以要设置系统启动时自动挂载,推荐使用 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” 检查是否正确;
网友评论