LVM-HOWTO/学习笔记(三)

本文详细介绍了在现有数据中心系统中增加SCSI硬盘的过程,并通过分区、创建物理卷、扩展卷组等步骤成功增加了存储容量。同时,文章还展示了如何利用e2fsadm命令调整文件系统大小,确保数据安全性和高效访问。通过增加存储资源和优化文件系统配置,提升了系统整体性能。

  

1.         在现有的系统中附加新的scsi硬盘

A data centre machine has 6 disks attached as follows:

# pvscan

pvscan -- ACTIVE   PV "/dev/sda"  of VG "dev"   [1.95 GB / 0 free]

pvscan -- ACTIVE   PV "/dev/sdb"  of VG "sales" [1.95 GB / 0 free]

pvscan -- ACTIVE   PV "/dev/sdc"  of VG "ops"   [1.95 GB / 44 MB free]

pvscan -- ACTIVE   PV "/dev/sdd"  of VG "dev"   [1.95 GB / 0 free]

pvscan -- ACTIVE   PV "/dev/sde1" of VG "ops"   [996 MB / 52 MB free]

pvscan -- ACTIVE   PV "/dev/sde2" of VG "sales" [996 MB / 944 MB free]

pvscan -- ACTIVE   PV "/dev/sdf1" of VG "ops"   [996 MB / 0 free]

pvscan -- ACTIVE   PV "/dev/sdf2" of VG "dev"   [996 MB / 72 MB free]

pvscan -- total: 8 [11.72 GB] / in use: 8 [11.72 GB] / in no VG: 0 [0]

# df
Filesystem           1k-blocks      Used Available Use% Mounted on

/dev/dev/cvs           1342492    516468    757828  41% /mnt/dev/cvs

/dev/dev/users         2064208   2060036      4172 100% /mnt/dev/users

/dev/dev/build         1548144   1023041    525103  66% /mnt/dev/build

/dev/ops/databases     2890692   2302417    588275  79% /mnt/ops/databases

/dev/sales/users       2064208    871214   1192994  42% /mnt/sales/users

/dev/ops/batch         1032088    897122    134966  86% /mnt/ops/batch

准备磁盘分区

# fdisk /dev/sdg

 

Device contains neither a valid DOS partition table, nor Sun or SGI

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.

 

Command (m for help): n
Command action

   e   extended

   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1000, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1000, default 1000): 500

 

Command (m for help): n
Command action

   e   extended

   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (501-1000, default 501): 
Using default value 501
Last cylinder or +size or +sizeM or +sizeK (501-1000, default 1000): 
Using default value 1000

 

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Unknown)

 

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 8e (Unknown)

 

Command (m for help): w
The partition table has been altered!

 

Calling ioctl() to re-read partition table.

 

WARNING: If you have created or modified any DOS 6.x partitions,

please see the fdisk manual page for additional information

 

Next physical volumes are created on this partition:

# pvcreate /dev/sdg1

pvcreate -- physical volume "/dev/sdg1" successfully created

 

# pvcreate /dev/sdg2

pvcreate -- physical volume "/dev/sdg2" successfully created

vg中添加新的磁盘

The volumes are then added to the dev and ops volume groups:

# vgextend ops /dev/sdg1

vgextend -- INFO: maximum logical volume size is 255.99 Gigabyte

vgextend -- doing automatic backup of volume group "ops"

vgextend -- volume group "ops" successfully extended

 

# vgextend dev /dev/sdg2

vgextend -- INFO: maximum logical volume size is 255.99 Gigabyte

vgextend -- doing automatic backup of volume group "dev"

vgextend -- volume group "dev" successfully extended

 

# pvscan

pvscan -- reading all physical volumes (this may take a while...)

pvscan -- ACTIVE   PV "/dev/sda"  of VG "dev"   [1.95 GB / 0 free]

pvscan -- ACTIVE   PV "/dev/sdb"  of VG "sales" [1.95 GB / 0 free]

pvscan -- ACTIVE   PV "/dev/sdc"  of VG "ops"   [1.95 GB / 44 MB free]

pvscan -- ACTIVE   PV "/dev/sdd"  of VG "dev"   [1.95 GB / 0 free]

pvscan -- ACTIVE   PV "/dev/sde1" of VG "ops"   [996 MB / 52 MB free]

pvscan -- ACTIVE   PV "/dev/sde2" of VG "sales" [996 MB / 944 MB free]

pvscan -- ACTIVE   PV "/dev/sdf1" of VG "ops"   [996 MB / 0 free]

pvscan -- ACTIVE   PV "/dev/sdf2" of VG "dev"   [996 MB / 72 MB free]

pvscan -- ACTIVE   PV "/dev/sdg1" of VG "ops"   [996 MB / 996 MB free]

pvscan -- ACTIVE   PV "/dev/sdg2" of VG "dev"   [996 MB / 996 MB free]

pvscan -- total: 10 [13.67 GB] / in use: 10 [13.67 GB] / in no VG: 0 [0]

扩展文件系统

# umount /mnt/ops/batch

# umount /mnt/dev/users

We then use the e2fsadm command to resize the logical volume and the ext2 file system on one operation. We are using ext2resize instead of resize2fs (which is the default command for e2fsadm) so we define the environment variable E2FSADM_RESIZE_CMD to tell e2fsadm to use that command.

# export E2FSADM_RESIZE_CMD=ext2resize

# e2fsadm /dev/ops/batch -L+500M

e2fsck 1.18, 11-Nov-1999 for EXT2 FS 0.5b, 95/08/09

Pass 1: Checking inodes, blocks, and sizes

Pass 2: Checking directory structure

Pass 3: Checking directory connectivity

Pass 4: Checking reference counts

Pass 5: Checking group summary information

/dev/ops/batch: 11/131072 files (0.0<!--  non-contiguous), 4127/262144 blocks

lvextend -- extending logical volume "/dev/ops/batch" to 1.49 GB

lvextend -- doing automatic backup of volume group "ops"

lvextend -- logical volume "/dev/ops/batch" successfully extended

 

ext2resize v1.1.15 - 2000/08/08 for EXT2FS 0.5b

e2fsadm -- ext2fs in logical volume "/dev/ops/batch" successfully extended to 1.49 GB

 

 

# e2fsadm /dev/dev/users -L+900M

e2fsck 1.18, 11-Nov-1999 for EXT2 FS 0.5b, 95/08/09

Pass 1: Checking inodes, blocks, and sizes

Pass 2: Checking directory structure

Pass 3: Checking directory connectivity

Pass 4: Checking reference counts

Pass 5: Checking group summary information

/dev/dev/users: 12/262144 files (0.0% non-contiguous), 275245/524288 blocks

lvextend -- extending logical volume "/dev/dev/users" to 2.88 GB

lvextend -- doing automatic backup of volume group "dev"

lvextend -- logical volume "/dev/dev/users" successfully extended

 

ext2resize v1.1.15 - 2000/08/08 for EXT2FS 0.5b

e2fsadm -- ext2fs in logical volume "/dev/dev/users" successfully extended to 2.88 GB

# mount /dev/ops/batch

# mount /dev/dev/users

# df
Filesystem           1k-blocks      Used Available Use% Mounted on

/dev/dev/cvs           1342492    516468    757828  41% /mnt/dev/cvs

/dev/dev/users         2969360   2060036    909324  69% /mnt/dev/users

/dev/dev/build         1548144   1023041    525103  66% /mnt/dev/build

/dev/ops/databases     2890692   2302417    588275  79% /mnt/ops/databases

/dev/sales/users       2064208    871214   1192994  42% /mnt/sales/users

/dev/ops/batch         1535856    897122    638734  58% /mnt/ops/batch

 

<think>我们使用openstack-config命令来设置Cinder配置文件中的LVM后端参数。用户要求设置以下参数:1.volume_group=cinder-volumes2.iscsi_protocol=iscsi3.iscsi_helper=lioadm注意:这些参数都是在[lvm]配置节下设置的。步骤:1.确保已经创建了名为`cinder-volumes`的LVM卷组(如果尚未创建,需要先创建)。2.使用openstack-config命令设置参数。3.重启CinderVolume服务使配置生效。具体命令如下:</think>### 配置 Cinder LVM 后端参数 要使用 `openstack-config` 命令配置 Cinder LVM 后端,请执行以下命令序列: ```bash # 设置卷组名称 openstack-config --set /etc/cinder/cinder.conf lvm volume_group cinder-volumes # 设置 iSCSI 协议类型 openstack-config --set /etc/cinder/cinder.conf lvm iscsi_protocol iscsi # 设置 iSCSI 管理工具 openstack-config --set /etc/cinder/cinder.conf lvm iscsi_helper lioadm # 启用 LVM 后端(若未启用) openstack-config --set /etc/cinder/cinder.conf DEFAULT enabled_backends lvm # 重启服务使配置生效 systemctl restart openstack-cinder-volume target systemctl enable openstack-cinder-volume target ``` #### 参数说明: 1. **`volume_group = cinder-volumes`** - 指定 LVM 使用的卷组名称,必须与系统中已创建的卷组一致 - 创建卷组示例: ```bash pvcreate /dev/sdb # 创建物理卷 vgcreate cinder-volumes /dev/sdb # 创建卷组[^5] ``` 2. **`iscsi_protocol = iscsi`** - 定义 iSCSI 协议类型(默认为 iscsi) - 支持值:`iscsi`(标准协议)或 `iser`(RDMA 加速) 3. **`iscsi_helper = lioadm`** - 指定 iSCSI 目标管理工具 - 常用选项:`lioadm`(LIO 内核目标)或 `tgtadm`(TGT 用户空间目标) #### 验证配置: ```bash # 检查配置节 grep -A 5 '[lvm]' /etc/cinder/cinder.conf # 预期输出 [lvm] volume_group = cinder-volumes iscsi_protocol = iscsi iscsi_helper = lioadm ``` #### 创建 Cinder 用户和服务端点(若未配置): ```bash # 创建 cinder 用户 openstack user create --domain default --password CINDER_PASS cinder # 添加 admin 角色 openstack role add --project service --user cinder admin # 创建服务端点 openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2 openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3 ``` #### 注意事项: 1. **权限要求**:所有命令需以 root 权限执行 2. **服务依赖**:必须同时重启 `target` 服务(iSCSI 目标服务) 3. **空间验证**:执行 `vgs cinder-volumes` 确认卷组可用空间 4. **防火墙**:确保 iSCSI 端口(TCP 3260)在节点间可访问 [^1]: [OpenStack 官方存储指南](https://docs.openstack.org/cinder/latest/configuration/block-storage/backends.html) [^2]: [Cinder LVM 配置参考](https://docs.openstack.org/cinder/latest/configuration/block-storage/configuring-lvm-driver.html)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值