搭建硬盘

  1. 集群分片有要求,避免同步失败
    1. 硬盘数量相同
    2. 硬盘地址相同

**

  1. 选择 SCSI 磁盘类型,不需要 cpu 参与控制

    1. ![image.png](https://cdn.nlark.com/yuque/0/2020/png/367873/1589360667378-ff5e880b-0d25-4363-ba86-c5f3c6b1b478.png#align=left&display=inline&height=362&margin=%5Bobject%20Object%5D&name=image.png&originHeight=469&originWidth=430&size=68365&status=done&style=none&width=332) ![image.png](https://cdn.nlark.com/yuque/0/2020/png/367873/1589360674511-cf90f793-587f-4dc6-9894-df20af1490ac.png#align=left&display=inline&height=74&margin=%5Bobject%20Object%5D&name=image.png&originHeight=74&originWidth=352&size=4923&status=done&style=none&width=352)
  • 挂载多两个硬盘

给硬盘分区

  • 查看当前硬盘

    fdisk -l

  1. Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
  2. Units = sectors of 1 * 512 = 512 bytes
  3. Sector size (logical/physical): 512 bytes / 512 bytes
  4. I/O size (minimum/optimal): 512 bytes / 512 bytes
  5. Disk label type: dos
  6. Disk identifier: 0x00022f87
  7. Device Boot Start End Blocks Id System
  8. /dev/sda1 * 2048 2099199 1048576 83 Linux
  9. /dev/sda2 2099200 41943039 19921920 8e Linux LVM
  10. ---
  11. Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
  12. Units = sectors of 1 * 512 = 512 bytes
  13. Sector size (logical/physical): 512 bytes / 512 bytes
  14. I/O size (minimum/optimal): 512 bytes / 512 bytes
  15. ---
  16. Disk /dev/sdc: 1073 MB, 1073741824 bytes, 2097152 sectors
  17. Units = sectors of 1 * 512 = 512 bytes
  18. Sector size (logical/physical): 512 bytes / 512 bytes
  19. I/O size (minimum/optimal): 512 bytes / 512 bytes
  • 可以看到多了 /dev/sdb/dev/sdc 两块硬盘
  • 创建分区
    • 仅创建主分区

      fdisk /dev/sdb

  1. Welcome to fdisk (util-linux 2.23.2).
  2. Changes will remain in memory only, until you decide to write them.
  3. Be careful before using the write command.
  4. Device does not contain a recognized partition table
  5. Building a new DOS disklabel with disk identifier 0x06d08c49.
  6. Command (m for help): m
  7. Command action
  8. a toggle a bootable flag
  9. b edit bsd disklabel
  10. c toggle the dos compatibility flag
  11. d delete a partition
  12. g create a new empty GPT partition table
  13. G create an IRIX (SGI) partition table
  14. l list known partition types
  15. m print this menu # 打印命令菜单
  16. n add a new partition # 添加新分区
  17. o create a new empty DOS partition table
  18. p print the partition table # 打印分区表
  19. q quit without saving changes # 退出而不保存
  20. s create a new empty Sun disklabel
  21. t change a partition's system id
  22. u change display/entry units
  23. v verify the partition table
  24. w write table to disk and exit # 把分区表写入硬盘并且退出
  25. x extra functionality (experts only)
  26. Command (m for help): n
  27. Partition type:
  28. p primary (0 primary, 0 extended, 4 free) # 主分区
  29. e extended # 拓展分区
  30. Select (default p): p
  31. Partition number (1-4, default 1): 1 # 分区编号
  32. First sector (2048-2097151, default 2048):
  33. Using default value 2048
  34. Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151):
  35. Using default value 2097151
  36. Partition 1 of type Linux and of size 1023 MiB is set
  37. Command (m for help): w
  38. The partition table has been altered!
  39. Calling ioctl() to re-read partition table.
  40. Syncing disks.
  • 再次键入 fdisk -l 会发现 /dev/sdb 的分区信息 ```shell

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x06d08c49

Device Boot Start End Blocks Id System /dev/sdb1 2048 2097151 1047552 83 Linux

  1. - 格式化分区
  2. > mkfs -t ext4 /dev/sdb1
  3. - 永久挂载硬盘
  4. > vim /etc/fstab
  5. ```shell
  6. # 在后面加载分区对应挂载目录
  7. /dev/sdb1 /mnt/p0 ext4 defaults 0 0
  • 重启

  • 挂载的目录可以访问了

    cd /mnt/p0

  • 对另外的硬盘和其他分片虚拟机也进行上面的操作