2016年3月27日日曜日

/varの空き領域を増やす_centos6

# df -h /***既存の/varの空き容量を確認***/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos6-lv_root
                       69G   59G  6.4G  91% /
tmpfs                 2.9G   80K  2.9G   1% /dev/shm
/dev/sda1             477M  142M  310M  32% /boot
/dev/mapper/vg_centos6-lv_home
                      174G   61M  165G   1% /home
/dev/mapper/vg_centos6-lvol0
                       60G   32G   25G  57% /var

kvmのイメージファイルを/var/kvm/image以下に保存したい。

# ls /var/kvm/images/
template1.img  www1.img

# du -h /var/kvm/images/
32G     /var/kvm/images/

/varの空き容量を40G増やすことにする。

# lvdisplay
  --- Logical volume ---
  LV Path                /dev/vg_centos6/lv_root
  LV Name                lv_root
  VG Name                vg_centos6
  LV UUID                0GHTft-n48J-prcX-hV1O-fZ1R-ZlL2-dvdAWG
  LV Write Access        read/write
  LV Creation host, time centos6, 2015-12-05 22:27:49 +0900
  LV Status              available
  # open                 1
  LV Size                70.00 GiB
  Current LE             17920
  Segments               3
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
  --- Logical volume ---
  LV Path                /dev/vg_centos6/lv_home
  LV Name                lv_home
  VG Name                vg_centos6
  LV UUID                F6FT0Y-TKse-zeMy-dEwc-JBMW-66fG-x9GxGW
  LV Write Access        read/write
  LV Creation host, time centos6, 2015-12-05 22:28:16 +0900
  LV Status              available
  # open                 1
  LV Size                176.58 GiB
  Current LE             45205
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2
  --- Logical volume ---
  LV Path                /dev/vg_centos6/lv_swap
  LV Name                lv_swap
  VG Name                vg_centos6
  LV UUID                9OSVwv-wmEa-CYcA-aYn0-q3Br-0CmH-tUliqW
  LV Write Access        read/write
  LV Creation host, time centos6, 2015-12-05 22:29:42 +0900
  LV Status              available
  # open                 1
  LV Size                5.81 GiB
  Current LE             1488
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
  --- Logical volume ---
  LV Path                /dev/vg_centos6/lvol0
  LV Name                lvol0
  VG Name                vg_centos6
  LV UUID                aeIEuE-jj2a-pDTV-N2pL-BCSG-W8e5-NX3gw7
  LV Write Access        read/write
  LV Creation host, time centos6, 2016-03-24 12:18:36 +0900
  LV Status              available
  # open                 1
  LV Size                60.00 GiB
  Current LE             15360
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3
# vgdisplay /***空き容量があることを確認***?
  --- Volume group ---
  VG Name               vg_centos6
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  9
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                4
  Open LV               4
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               2.05 TiB
  PE Size               4.00 MiB
  Total PE              536424
  Alloc PE / Size       79973 / 312.39 GiB
  Free  PE / Size       456451 / 1.74 TiB
  VG UUID               l7l1Qm-1a6k-aLuo-f6as-Ad9W-fKUb-rlSp0Q

# lvextend -L +40G /dev/vg_centos6/lvol0 /***/varに割り当てられた論理ボリュームを40G増やす***/
  Size of logical volume vg_centos6/lvol0 changed from 60.00 GiB (15360 extents) to 100.00 GiB (25600 extents).
  Logical volume lvol0 successfully resized

# df -h /***/varはまだ増えていない***/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos6-lv_root
                       69G   59G  6.4G  91% /
tmpfs                 2.9G   80K  2.9G   1% /dev/shm
/dev/sda1             477M  142M  310M  32% /boot
/dev/mapper/vg_centos6-lv_home
                      174G   61M  165G   1% /home
/dev/mapper/vg_centos6-lvol0
                       60G   32G   25G  57% /var

# vgdisplay /***Freeの値は減っている***/
  --- Volume group ---
  VG Name               vg_centos6
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  10
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                4
  Open LV               4
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               2.05 TiB
  PE Size               4.00 MiB
  Total PE              536424
  Alloc PE / Size       90213 / 352.39 GiB
  Free  PE / Size       446211 / 1.70 TiB
  VG UUID               l7l1Qm-1a6k-aLuo-f6as-Ad9W-fKUb-rlSp0Q

[root@centos6 ~]# resize2fs /dev/vg_centos6/lvol0 /***論理ボリュームの容量を/varに反映させる***/
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_centos6/lvol0 is mounted on /var; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 7
Performing an on-line resize of /dev/vg_centos6/lvol0 to 26214400 (4k) blocks.
The filesystem on /dev/vg_centos6/lvol0 is now 26214400 blocks long.

# df -h /***/varの空き容量が増えている***/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos6-lv_root
                       69G   59G  6.4G  91% /
tmpfs                 2.9G   80K  2.9G   1% /dev/shm
/dev/sda1             477M  142M  310M  32% /boot
/dev/mapper/vg_centos6-lv_home
                      174G   61M  165G   1% /home
/dev/mapper/vg_centos6-lvol0
                       99G   32G   62G  34% /var

#

2016年3月26日土曜日

論理ボリュームを作成して/varの空き容量を増やす_centos6

# vgdisplay /***空き容量があることとボリュームグループ名を確認***/
  --- Volume group ---
  VG Name               vg_centos6
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               2.05 TiB
  PE Size               4.00 MiB
  Total PE              536424
  Alloc PE / Size       62053 / 242.39 GiB
  Free  PE / Size       474371 / 1.81 TiB 
  VG UUID               l7l1Qm-1a6k-aLuo-f6as-Ad9W-fKUb-rlSp0Q
# lvcreate -L 20G /dev/vg_centos6 /***論理ボリュームを作成。lvol0が新規作成される***/
  Logical volume "lvol0" created.
# lvdisplay /***論理ボリュームlvol0が作成されていることを確認***/
  --- Logical volume ---
  LV Path                /dev/vg_centos6/lv_root
  LV Name                lv_root
  VG Name                vg_centos6
  LV UUID                0GHTft-n48J-prcX-hV1O-fZ1R-ZlL2-dvdAWG
  LV Write Access        read/write
  LV Creation host, time centos6, 2015-12-05 22:27:49 +0900
  LV Status              available
  # open                 1
  LV Size                60.00 GiB
  Current LE             15360
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
  --- Logical volume ---
  LV Path                /dev/vg_centos6/lv_home
  LV Name                lv_home
  VG Name                vg_centos6
  LV UUID                F6FT0Y-TKse-zeMy-dEwc-JBMW-66fG-x9GxGW
  LV Write Access        read/write
  LV Creation host, time centos6, 2015-12-05 22:28:16 +0900
  LV Status              available
  # open                 1
  LV Size                176.58 GiB
  Current LE             45205
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2
  --- Logical volume ---
  LV Path                /dev/vg_centos6/lv_swap
  LV Name                lv_swap
  VG Name                vg_centos6
  LV UUID                9OSVwv-wmEa-CYcA-aYn0-q3Br-0CmH-tUliqW
  LV Write Access        read/write
  LV Creation host, time centos6, 2015-12-05 22:29:42 +0900
  LV Status              available
  # open                 1
  LV Size                5.81 GiB
  Current LE             1488
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
  --- Logical volume ---
  LV Path                /dev/vg_centos6/lvol0
  LV Name                lvol0
  VG Name                vg_centos6
  LV UUID                aeIEuE-jj2a-pDTV-N2pL-BCSG-W8e5-NX3gw7
  LV Write Access        read/write
  LV Creation host, time centos6, 2016-03-24 12:18:36 +0900
  LV Status              available
  # open                 0
  LV Size                20.00 GiB
  Current LE             5120
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

# mkfs -t ext3 /dev/vg_centos6/lvol0 /***作成した論理ボリュームに対してファイルシステムを作成***/
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=1 blocks, Stripe width=0 blocks
1310720 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
160 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
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: dodone
This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
# mount /dev/vg_centos6/lvol0 /var /***論理ボリュームを/varにマウント***/
# df -h /***/varに空き容量があることを確認***/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos6-lv_root
                       59G   59G     0 100% /
tmpfs                 2.9G   80K  2.9G   1% /dev/shm
/dev/sda1             477M  142M  310M  32% /boot
/dev/mapper/vg_centos6-lv_home
                      174G   61M  165G   1% /home
/dev/mapper/vg_centos6-lvol0
                       20G  173M   19G   1% /var

# echo /dev/vg_centos6/lvol0 /var ext3 defaults 1 1 >> /etc/fstab /***再起動後もマウントされる状態にする***/


参考:論理ボリューム追加

2016年3月22日火曜日

virt-cloneコマンド実行後、空き領域が足りないエラーが出たのでディスク増設実施

ゲストOSのクローン作成をするも空き領域が足りない。
# virt-clone -o www -n www2 -f /var/kvm/images/www2.img

ERROR    ディスクを作成するための十分な空き領域がありません。 30720 MBの要求 > 13898 MBの空き

サーバーシャットダウン後、物理ディスク(2TB)を追加して起動。
以下のサイトを参考にして/extdisk1に1.7T追加されるようになった。
http://kajuhome.com/disk_extension.shtml

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos6-lv_root
                       50G   43G  4.3G  91% /
tmpfs                 2.9G   84K  2.9G   1% /dev/shm
/dev/sda1             477M  142M  310M  32% /boot
/dev/mapper/vg_centos6-lv_home
                      174G   61M  165G   1% /home
/dev/sdb1             1.8T  196M  1.7T   1% /extdisk1 /***/extdisk1を作成してmountコマンド実施済***/

その後virt-clone を実行するも変わらず。
たぶん
/dev/mapper/vg_centos6-lv_root
の領域を増やす必要があると予測。
http://j-caw.co.jp/blog/?p=991
を参考に
/dev/mapper/vg_centos6-lv_root
の領域をふやしてみた。
以下実行手順

# umount /dev/sdb1 ***df -hで/dev/sdb1を/extdisk1からはずす**/

# df -h /***/dev/sdb1が表示されないことを確認***/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos6-lv_root
                       50G   43G  4.3G  91% /
tmpfs                 2.9G   84K  2.9G   1% /dev/shm
/dev/sda1             477M  142M  310M  32% /boot
/dev/mapper/vg_centos6-lv_home
                      174G   61M  165G   1% /home
# pvcreate /dev/sdb1 /***物理ディスク作成***/
  Physical volume "/dev/sdb1" successfully created

# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               vg_centos6
  PV Size               232.40 GiB / not usable 2.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              59493
  Free PE               0
  Allocated PE          59493
  PV UUID               4y7MhE-FqgU-sNBF-fRca-E2cR-mm72-jpkc4Q
  "/dev/sdb1" is a new physical volume of "1.82 TiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name
  PV Size               1.82 TiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               SdhrPT-uhoB-scAS-0vdG-BOnD-S27d-AibzTf
# vgdisplay
  --- Volume group ---
  VG Name               vg_centos6
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               232.39 GiB
  PE Size               4.00 MiB
  Total PE              59493
  Alloc PE / Size       59493 / 232.39 GiB
  Free  PE / Size       0 / 0
  VG UUID               l7l1Qm-1a6k-aLuo-f6as-Ad9W-fKUb-rlSp0Q
# lvdisplay /dev/mapper/vg_centos6-lv_root /***LV Sizeは50GB***/
  --- Logical volume ---
  LV Path                /dev/vg_centos6/lv_root
  LV Name                lv_root
  VG Name                vg_centos6
  LV UUID                0GHTft-n48J-prcX-hV1O-fZ1R-ZlL2-dvdAWG
  LV Write Access        read/write
  LV Creation host, time centos6, 2015-12-05 22:27:49 +0900
  LV Status              available
  # open                 1
  LV Size                50.00 GiB
  Current LE             12800
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

# vgdisplay
  --- Volume group ---
  VG Name               vg_centos6
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               232.39 GiB
  PE Size               4.00 MiB
  Total PE              59493
  Alloc PE / Size       59493 / 232.39 GiB
  Free  PE / Size       0 / 0
  VG UUID               l7l1Qm-1a6k-aLuo-f6as-Ad9W-fKUb-rlSp0Q

# pvdisplay /***既存のVG Nameと新規作成のPV Nameを確認***/
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               vg_centos6
  PV Size               232.40 GiB / not usable 2.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              59493
  Free PE               0
  Allocated PE          59493
  PV UUID               4y7MhE-FqgU-sNBF-fRca-E2cR-mm72-jpkc4Q
  "/dev/sdb1" is a new physical volume of "1.82 TiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name
  PV Size               1.82 TiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               SdhrPT-uhoB-scAS-0vdG-BOnD-S27d-AibzTf
# vgextend vg_centos6 /dev/sdb1 /***ボリュームグループを拡張***/
  Volume group "vg_centos6" successfully extended
# vgdisplay /***Free  PE / Sizeが増えている***/
  --- Volume group ---
  VG Name               vg_centos6
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               2.05 TiB
  PE Size               4.00 MiB
  Total PE              536424
  Alloc PE / Size       59493 / 232.39 GiB
  Free  PE / Size       476931 / 1.82 TiB
  VG UUID               l7l1Qm-1a6k-aLuo-f6as-Ad9W-fKUb-rlSp0Q
# lvextend -L+10G /dev/mapper/vg_centos6-lv_root /***10G拡張する***/
(参考 https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/6/html/Logical_Volume_Manager_Administration/lv_extend.html
  Size of logical volume vg_centos6/lv_root changed from 50.00 GiB (12800 extents) to 60.00 GiB (15360 extents).
  Logical volume lv_root successfully resized
# lvdisplay /***LV Sizeが10G増えて60となっている***/
  --- Logical volume ---
  LV Path                /dev/vg_centos6/lv_root
  LV Name                lv_root
  VG Name                vg_centos6
  LV UUID                0GHTft-n48J-prcX-hV1O-fZ1R-ZlL2-dvdAWG
  LV Write Access        read/write
  LV Creation host, time centos6, 2015-12-05 22:27:49 +0900
  LV Status              available
  # open                 1
  LV Size                60.00 GiB
  Current LE             15360
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
  --- Logical volume ---
  LV Path                /dev/vg_centos6/lv_home
  LV Name                lv_home
  VG Name                vg_centos6
  LV UUID                F6FT0Y-TKse-zeMy-dEwc-JBMW-66fG-x9GxGW
  LV Write Access        read/write
  LV Creation host, time centos6, 2015-12-05 22:28:16 +0900
  LV Status              available
  # open                 1
  LV Size                176.58 GiB
  Current LE             45205
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2
  --- Logical volume ---
  LV Path                /dev/vg_centos6/lv_swap
  LV Name                lv_swap
  VG Name                vg_centos6
  LV UUID                9OSVwv-wmEa-CYcA-aYn0-q3Br-0CmH-tUliqW
  LV Write Access        read/write
  LV Creation host, time centos6, 2015-12-05 22:29:42 +0900
  LV Status              available
  # open                 1
  LV Size                5.81 GiB
  Current LE             1488
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
# df -h /***/dev/mapper/vg_centos6-lv_rootは50Gのままで増えていない***/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos6-lv_root
                       50G   43G  4.3G  91% /
tmpfs                 2.9G   80K  2.9G   1% /dev/shm
/dev/sda1             477M  142M  310M  32% /boot
/dev/mapper/vg_centos6-lv_home
                      174G   61M  165G   1% /home
# resize2fs /dev/mapper/vg_centos6-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_centos6-lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 4
Performing an on-line resize of /dev/mapper/vg_centos6-lv_root to 15728640 (4k) blocks.
The filesystem on /dev/mapper/vg_centos6-lv_root is now 15728640 blocks long.
# df -h /***resize2fs実行後は/dev/mapper/vg_centos6-lv_rootは59Gと約10G増えている***/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos6-lv_root
                       59G   43G   14G  76% /
tmpfs                 2.9G   80K  2.9G   1% /dev/shm
/dev/sda1             477M  142M  310M  32% /boot
/dev/mapper/vg_centos6-lv_home
                      174G   61M  165G   1% /home

空き領域が増えたところで、再度virt-cloneを実行。
でも、状況変わらず。
# virt-clone -o www -n www2 -f /var/kvm/images/www2.img
ERROR    ディスクを作成するための十分な空き領域がありません。 30720 MBの要求 > 13898 MBの空き

保存先の/var以下を明示的に容量を増やせば解決か??

kvm構築環境にてcentosを再起動後、ネットワーク接続ができない

利用環境

centos6(KVMでゲストOS1つあり。)-----windows 7
windows7からteratermでcentos6に接続。
KVMは下記を参照して作成済。
KVMインストール

-----------------

物理ディスク増設のため、一旦centosをシャットダウン。
ディスクとりつけてからcentosへアクセスするも失敗。

#ifconfig
仮想NICのbr0が表示されない
#ifconfig
仮想NICのbr0は表示。
ただし、ipアドレスが表示されない。
本来はbr0のipアドレスをtetatermで指定すればアクセスできる環境だった。

仮想NICの
以下3つのコマンドを実施するも改善せず。
#shotdown -r now
#/etc/rc.d/init.d/network restart
#service network restart

以下の対処を実施して現象改善。
参考
http://blog.livedoor.jp/hide_system/archives/51888446.html

ホストOSに直接ログオンして実施。

#ifconfig -a
eth0      Link encap:Ethernet  HWaddr xx:cc:bb:aa:ss:dd /***HWaddrの値をコピーしておく***/
#vi /etc/sysconfig/network-scripts/ifcfg-eth0
---
~~~
HWADDR=xx:cc:bb:aa:ss:dd /***追加。HWaddrの値をペースト***/
---
#vi /etc/sysconfig/network-scripts/ifcfg-br0
---
~~~
#HWADDR=xx:cc:bb:aa:ss:dd /***#を追記してコメントアウト***/
~~~
---

#shutdown -h now /***シャットダウン***/

起動後、ifconfigを実行するとbr0からipアドレスが表示されていることを確認。
その後windows7からteratermでbr0に表示されたipアドレスでアクセスできることを確認。