FastNetMon

Wednesday, 27 November 2013

Установка OpenVSwitch 1.9 на CentOS 6

Зависимости:
yum install -y rpm-build
yum groupinstall -y "Development Tools"
yum install -y openssl-devel

Стягиваем код и собираем окружение:
cd /usr/src
wget http://openvswitch.org/releases/openvswitch-1.9.0.tar.gz

mkdir -p /root/rpmbuild/SOURCES
cp openvswitch-1.9.0.tar.gz /root/rpmbuild/SOURCES
cd /root/rpmbuild/SOURCES
tar -xvf openvswitch-1.9.0.tar.gz
Далее нужно удалить одну зависимость на строке Requires удаляем openvswitch-kmod:

vim ./openvswitch-1.9.0/rhel/openvswitch.spec
Собираем:
cd openvswitch-1.9.0
rpmbuild -bb -D `uname -r` rhel/openvswitch.spec
Устанавливаем:
yum localinstall /root/rpmbuild/RPMS/x86_64/openvswitch-1.9.0-1.x86_64.rpm
Запускаем (в автозагрузку он добавился уже сам):
/etc/init.d/openvswitch start
/etc/openvswitch/conf.db does not exist ... (warning).
Creating empty database /etc/openvswitch/conf.db           [  OK  ]
Starting ovsdb-server                                      [  OK  ]
Configuring Open vSwitch system IDs                        [  OK  ]
Starting ovs-vswitchd                                      [  OK  ]
Enabling gre with iptables                                 [  OK  ]
Источник: http://fvtool.wordpress.com/2013/04/24/install-kvm-on-centos-6-3-installing-open-vswitch/

Открытая вакцина против ВИЧ - Immunity Project

Настоящая попытка изменить мир http://www.immunityproject.org/ !!! Чудесный проект, чудесная идея и потрясающие люди! 

Thursday, 21 November 2013

Latency Based Routing - новости из мира Load Balancing :)

Как выглядит блок Anycast в RIPE?

Вот примерно так:
whois 31.131.255.10|tail -n 10
route:          31.131.255.0/24
descr:          Selectel Anycast
origin:         AS49505
mnt-by:         MNT-SELECTEL
source:         RIPE # Filtered
Честно говоря, не понятно одно - везде поднимать свою AS и нельзя использовать AS апстримов/провайдеров? Как тогда завернуть один блок IP в несколько разных ASN, причем, одновременно.

How to build rpm package for RHEL5 on RHEL6 system?

# emulate: "/usr/bin/rpmbuild-md5" from fedora-packager
rpmbuild --define "_source_filedigest_algorithm 1" --define "_binary_filedigest_algorithm 1" --define "_binary_payload w9.gzdio"  --define "_source_payload w9.gzdio" --define "_default_patch_fuzz 2"-bb e2fsprogs.spec


Wednesday, 20 November 2013

How I can mount one file (not an folder) to another?

Create file with content:
echo "my important data" > /tmp/shadow

Check it content:
cat  /tmp/shadow
my important data

Create blank file, it will be mount point, it content can be any (we need only inode, right):
rm -f /tmp/shadowcopy
touch /tmp/shadowcopy

This file instantly blank:
cat /tmp/shadowcopy|wc -l
0

Mount file /tmp/shadow to /tmp/shadowcopy:
mount --bind /tmp/shadow /tmp/shadowcopy 

Welcome, all forks fine:
cat /tmp/shadow
my important data

cat /tmp/shadowcopy
my important data

You can add line into source file:
echo "new line" >> /tmp/shadow

And this line can be found in both files (source and mounted):
cat /tmp/shadow
my important data
new line

cat /tmp/shadowcopy
my important data
new line
 If you add any content to destination file, it will show in source. This mechanic looks like hard links. 

At finish you MUST unmount destination file:
umount /tmp/shadowcopy






Tuesday, 19 November 2013

Installing actual Gentoo from stage3 on OpenVZ withou any strange templates, only from stage3

0. Set our container number for preventing hardcoding in my commands:

export CTID=19484

1. Download stage3 into OpenVZ template folder (you can get actual link from here http://distfiles.gentoo.org/releases/amd64/autobuilds/latest-stage3-amd64.txt). Be careful - you must set downloaded file name to gento-bla-bla-bla:
cd /vz/template/cache
wget http://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3/stage3-amd64-20131031.tar.bz2 -Ogentoo-stage3-amd64-20131031.tar.bz2

2. Create container using stage3 template.

vzctl create $CTID --hostname gentoo-forever.com --ipadd 78.47.xx.xx --ostemplate gentoo-stage3-amd64-20131031 --layout ploop --disk 10G

3. Start container for removing udev (udev and openvz are natural enemies): 

vzctl start $CTID
vzctl exec $CTID 'rm -f /etc/init.d/udev'
vzctl exec  $CTID 'rm -f /etc/init.d/udev-mount'

4. Start container for production:
vzctl start 19484;
vzctl enter 19484
5. Enable ssh:
/etc/init.d/sshd start

6. First steps in Gentoo - getting portage tree!
 emerge --sync


How to mount multiple disks to OpenVZ ploop container?

Hello, OpenVZ admin! :)

In many cases you can want ability to mount an additional ploop devices in OpenVZ container (be care! This guide works only with ploop), i.e. add separate as /data or /mnt. It's not so obviously but I can help you. My test container number (CTID) is 19484, be careful because this number is another in your case!  

At first, you must select path where you plans save additional disk images. In my case, it's /storage folder on hardware node.

1. We must create subfolder for saving additional disk data (image + description file). I recommend to name it with CTID.

mkdir /storage
mkdir /storage/19484

2. Create ploop device with defined size in this folder.
ploop init -s 10G -f ploop1 -v 2 /storage/19484/additional_disk_image -t ext4

3. Please stop container (it's needed because we manipulate with container root filesystem and it's so dangerous):



vzctl stop 19484

4.  We must add hook scripts for mount and umount this disk to container root mount point.

Please create file /etc/vz/conf/19484.mount with following content:
#!/bin/bash 
ploop mount -m /vz/root/$VEID/mnt  /storage/$VEID/DiskDescriptor.xml
And file  /etc/vz/conf/19484.umount with following content (we must add exit 0 because at first start vzctl will tries to umount disk and we got an error):


#!/bin/bash 
ploop umount /storage/$VEID/DiskDescriptor.xml
exit 0
Add execution flag to both files:
chmod +x /etc/vz/conf/19484.mount /etc/vz/conf/19484.umount
5. Start container:
vzctl start 19484
At first startups you must got error message because vzctl can't unmount additional disk at startup (so strange feature, really! What reason to umount disks at startup?) . It's ok, you can sefely ignore. At next start/restart you did not got any errors.   
Error in ploop_umount_image (ploop.c:1579): Image /storage/19484/additional_disk_image is not mounted
At second and next start's you can see no error:
vzctl start 19484
Starting container...
Opening delta /vz/private/19484/root.hdd/root.hdd
Adding delta dev=/dev/ploop18662 img=/vz/private/19484/root.hdd/root.hdd (rw)
/dev/ploop18662p1: clean, 36570/144288 files, 228564/576251 blocks
Mounting /dev/ploop18662p1 at /vz/root/19484 fstype=ext4 data='balloon_ino=12,'
Opening delta /storage/19484/additional_disk_image
Adding delta dev=/dev/ploop50284 img=/storage/19484/additional_disk_image (rw)
Mounting /dev/ploop50284p1 at /vz/root/19484/mnt fstype=ext4 data='balloon_ino=12,'
Container is mounted
Adding IP address(es): 78.47.76.28
Setting CPU units: 1000
Container start in progress...
Check new disk in container:
vzctl exec 19484 'df -h'
Filesystem         Size  Used Avail Use% Mounted on
/dev/ploop18662p1  2.2G  858M  1.3G  41% /
/dev/ploop50284p1  9.9G  164M  9.2G   2% /mnt
none               136M  4.0K  136M   1% /dev
none                28M 1020K   27M   4% /run
none               5.0M     0  5.0M   0% /run/lock
none                52M     0   52M   0% /run/shm
none               100M     0  100M   0% /run/user
It's important, you don't need any quota setup because ploop is complete filesystem and it's limited by standard linux mechanic like native hard drive.

Mounting additional disk as read only

If you want you can mount additional disk as read only. You must add -r flag to ploop mount command.

In read only case you will see something like this while containers starts:
vzctl start 19484
Starting container...
Opening delta /vz/private/19484/root.hdd/root.hdd
Adding delta dev=/dev/ploop18662 img=/vz/private/19484/root.hdd/root.hdd (rw)
/dev/ploop18662p1: clean, 36570/144288 files, 228582/576251 blocks (check in 4 mounts)
Mounting /dev/ploop18662p1 at /vz/root/19484 fstype=ext4 data='balloon_ino=12,'
Opening delta /storage/19484/additional_disk_image
Adding delta dev=/dev/ploop50284 img=/storage/19484/additional_disk_image (ro)
Mounting /dev/ploop50284p1 at /vz/root/19484/mnt fstype=ext4 data='balloon_ino=12,' ro
Container is mounted
Adding IP address(es): 78.47.76.28
Setting CPU units: 1000
Container start in progress...

Monday, 18 November 2013

OpenVZ DiskDescriptor.xml - что есть что?

<?xml version="1.0"?>
<Parallels_disk_image>
  <Disk_Parameters>
    <Disk_size>8388608</Disk_size>
    <Cylinders>8322</Cylinders>
    <Heads>16</Heads>
    <Sectors>63</Sectors>
    <Padding>0</Padding>
  </Disk_Parameters>
  <StorageData>
    <Storage>
      <Start>0</Start>
      <End>8388608</End>
      <Blocksize>2048</Blocksize>
      <Image>
        <GUID>{5fbaabe3-6958-40ff-92a7-860e329aab41}</GUID>
        <Type>Compressed</Type>
        <File>root.hdd</File>
      </Image>
    </Storage>
  </StorageData>
  <Snapshots>
    <TopGUID>{5fbaabe3-6958-40ff-92a7-860e329aab41}</TopGUID>
    <Shot>
      <GUID>{5fbaabe3-6958-40ff-92a7-860e329aab41}</GUID>
      <ParentGUID>{00000000-0000-0000-0000-000000000000}</ParentGUID>
    </Shot>
  </Snapshots>
</Parallels_disk_image>

Что же есть из себя 5fbaabe3-6958-40ff-92a7-860e329aab41? Не понятно! Это не GUID таблицы GPT,  которую использует ploop потому что:

 cat /vz/private/19484/root.hdd/DiskDescriptor.xml|grep UID -i
        <GUID>{5fbaabe3-6958-40ff-92a7-860e329aab41}</GUID>
    <TopGUID>{5fbaabe3-6958-40ff-92a7-860e329aab41}</TopGUID>
      <GUID>{5fbaabe3-6958-40ff-92a7-860e329aab41}</GUID>

Обойдем все диски и получим из GPT GUID: 
for i in `find /dev/ploop*|egrep -v 'p1$'`;do sgdisk -p $i |grep GUID;done
Disk identifier (GUID): A821C1C0-DB6E-4F32-ABC5-D05B7CF9A1DE
Disk identifier (GUID): BC1A5685-36FE-47E4-96E8-240307329FAF
Disk identifier (GUID): AA41E391-374A-44E3-A46C-FF32435131F9
Disk identifier (GUID): 113F3E0A-AE6A-4DB7-B68A-FC3FA05230B6
Disk identifier (GUID): 747F78F7-2A98-49D0-8D7E-98910EB282D3
Disk identifier (GUID): 50D6C777-0FEA-401E-86D2-15F4AA853605
Disk identifier (GUID): 099821D1-9ABF-4183-879F-107602ADA5D7
Disk identifier (GUID): B1C96257-86A2-4A82-8391-8F7A30EA7BAE
Disk identifier (GUID): 61D8174B-0FF2-4E23-94E2-4CD8C887FEF9
Problem reading disk in BasicMBRData::ReadMBRData()!
Warning! Read error 22; strange behavior now likely!
Warning! Read error 22; strange behavior now likely!
Disk identifier (GUID): 47F93EC9-EAFD-4349-B82D-040B1C15517B
Disk identifier (GUID): C33B4D83-7D0E-45E1-B2EB-68EDE2BEBB7A
Disk identifier (GUID): 82B84F3A-0538-4ADB-9467-699E17E87DB9
А также при этом это не UUID раздела созданного на GPT диске ploop:
for i in `find /dev/ploop*|egrep -v 'p1$'`;do blkid ${i}p1;done
/dev/ploop10267p1: UUID="bc34c9db-04f8-4c43-b180-210560e0bf50" TYPE="ext4"
/dev/ploop14204p1: UUID="c3b4888a-22a5-4025-b37f-d61904b16567" TYPE="ext4"
/dev/ploop18546p1: UUID="b2aa615b-8375-4a1f-8bf9-1756696d6718" TYPE="ext4"
/dev/ploop18662p1: UUID="b8ccbf07-85fe-44d3-bbc4-6593a3a0c872" TYPE="ext4"
/dev/ploop22367p1: UUID="88829ca9-e1b5-4499-94fe-46d987055368" TYPE="ext4"
/dev/ploop35145p1: UUID="b9370d59-fbad-4e15-b559-2c4af5f4a254" TYPE="ext4"
/dev/ploop38462p1: UUID="189bbe9e-20a2-4b09-8e61-1bf30a4a89f2" TYPE="ext4"
/dev/ploop41650p1: UUID="cb56f5a8-5e47-4ea4-b9bf-bd8e5b8578ff" TYPE="ext4"
/dev/ploop41997p1: UUID="4f53649c-683e-4a31-baea-87a446834f02" TYPE="ext4"
/dev/ploop57837p1: UUID="23028f1d-60de-4d7d-adf9-8466dbb1ff45" TYPE="ext4"
/dev/ploop57849p1: UUID="4f8bf47b-2259-4e60-9f69-bf4828740ee4" TYPE="ext4"