Записи с Меткой ‘ Xen

Замена сбойного диска в Софтовом рейде

========================================================
Замена диска
1. Выключить компьютер и заменить диск
2. Включить компьютер и определить имеющиеся на обоих дисках разделы:
# fdisk /dev/sd -l
3. С помощью fdisk создать на новом диске разделы, идентичные оригиналу
Необходимо пометить нужный раздел нового диска (sda1 или sdb1) как загрузочный до включения в зеркало.
Swap-разделы не подлежат зеркалированию в программном RAID
4.Мониторинг состояния
Информация о всех RAID-массивах:
# more /proc/mdstat
или
# cat /proc/mdstat
Информация о конкретном дисковом разделе:
# mdadm -E /dev/sd<1-10>
например:
# mdadm -E /dev/sdb2
5.Восстановление функционирования
# mdadm -a /dev/md<0-6> /dev/sd<1-10>
например:
# mdadm -a /dev/md0 /dev/sdb1
Нужно быть аккуратным с номерами разделов
В случае ошибки, удалить компонент из RAID командой:
# mdadm -r /dev/md0 /dev/sdb1
получается не всегда — устройство может быть занято
========================================================

Добавление диска как storage в xen

fdisk -l(THIS WILL LIST THE DISKS IN THE SYSTEM)

You will see the following information:

Disk /dev/sda: 128.0 GB, 128035676160 bytes
255 heads, 63 sectors/track, 15566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 523 4194304 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 523 1045 4194304 83 Linux
/dev/sda3 1045 15566 116645255+ 8e Linux LVM

Disk /dev/sdb: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn’t contain a valid partition table

Assuming that /dev/sdb is the drive you want to use

Type the following

[root@system]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF 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.

The number of cylinders for this disk is set to 4865.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-4865, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-4865, default 4865): 4865

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 83
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Now what you want to do is to make a SR so you can use it to store virtual machines on.

ls -l /dev/disk/by-id/ (you should see the following)

total 0
lrwxrwxrwx 1 root root 9 May 26 14:50 scsi-SATA_C300-CTFDDAC1280000000010510303CFAA -> ../../sda
lrwxrwxrwx 1 root root 10 May 26 14:50 scsi-SATA_C300-CTFDDAC1280000000010510303CFAA-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 May 26 14:50 scsi-SATA_C300-CTFDDAC1280000000010510303CFAA-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 May 26 14:50 scsi-SATA_C300-CTFDDAC1280000000010510303CFAA-part3 -> ../../sda3
lrwxrwxrwx 1 root root 9 May 26 14:50 scsi-SATA_ST31500341AS_9VS4N7W5 -> ../../sdb
lrwxrwxrwx 1 root root 10 May 26 14:50 scsi-SATA_ST31500341AS_9VS4N7W5-part1 -> ../../sdb1

Assuming that sdb is the one to use type the following

xe sr-create type=lvm content-type=user device-config:device=/dev/disk/by-id/scsi-SATA_ST31500341AS_9VS4N7W5 name-label=»LOCAL SR»

Удаление Storage Xen

1. First, you have to determine the Storage-Repository-UUID:

xe sr-list

-> write down / take note of SR-UUID of the SR to delete

2. Find the corresponding Physical Block Device (PBD):

xe pbd-list sr-uuid=your-SR-uuid

-> write down / take note of PBD-UUID of the PBD to unplug and delete

3. Unplug the PBD:

xe pbd-unplug uuid=your-PBD-uuid

4. Delete PBD:

xe pbd-destroy uuid=your-PBD-uuid

5. Delete the association of your SR and the PBD:

xe sr-forget uuid=your-SR-uuid

Коротко:

xe sr-list name-label=Local\ storage | head -1
uuid ( RO)                : 75264965-f981-749e-0f9a-e32856c46361
# xe pbd-list sr-uuid=75264965-f981-749e-0f9a-e32856c46361 | head -1
uuid ( RO)                  : ff7e9656-c27c-1889-7a6d-687a561f0ad0
# xe pbd-unplug uuid=ff7e9656-c27c-1889-7a6d-687a561f0ad0 
# xe sr-destroy uuid=75264965-f981-749e-0f9a-e32856c46361

 

xcp zabbix agent

сначала переводим в статус enabled=1 все нужные репозитории в /etc/yum.repo.d/

потом
wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
sudo rpm -Uvh epel-release-5*.rpm
ls -1 /etc/yum.repos.d/epel*

sudo rpm -Uvh http://repo.zabbix.com/zabbix/2.2/rhel/5/i386/zabbix-release-2.2-1.el5.noarch.rpm
(Можно посмотреть тут http://www.alsigned.ru/?p=2463)

yum install zabbix vim

vi /etc/zabbix/zabbix_agentd.conf

diff centos & deb config

[root@srv-vm2 ~]# diff /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf_deb 
23c23
< LogFile=/var/log/zabbix/zabbix_agentd.log
---
> LogFile=/var/log/zabbix-agent/zabbix_agentd.log
34c34
< LogFileSize=0
---
> LogFileSize=10
85c85
< Server=127.0.0.1
---
> Server=192.168.x.x
110c110
< # StartAgents=3
---
> StartAgents=5
137c137
< Hostname=Zabbix server
---
> Hostname=srv-vm2
240c240
< #	Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time.
---
> #	Installing Zabbix will create include directory in /etc/zabbix, unless modified during the compile time.
246,249c246,248
< Include=/etc/zabbix/zabbix_agentd.d/
< 
< # Include=/usr/local/etc/zabbix_agentd.userparams.conf
< # Include=/usr/local/etc/zabbix_agentd.conf.d/
---
> # Include=/etc/zabbix/zabbix_agentd.userparams.conf
> # Include=/etc/zabbix/zabbix_agentd.conf.d/
> Include=/etc/zabbix/zabbix_agentd.conf.d/

 

Xen Autostart VM

First approach is to set auto_poweron parameter to true at the pool and VM level.

Setting the XenServer to allow Auto-Start
1. Gather the UUID’s of the pools you wish to auto-start.
To get the list of the pool’s on your XenServer type

xe pool-list

2. Copy the UUID of the pool. If you have just one server, it will still have a pool UUID as bellow:
uuid ( RO) : d170d718-e0de-92fc-b920-f4c59cc62e91
name-label ( RW):
name-description ( RW):
master ( RO): 755d4ea3-373b-44b9-8ae3-3cd6f77a7f33
default-SR ( RW): 51218f44-6ac6-4893-98fb-f924b08f7af9
3. Set the pool or server to allow auto-start:

xe pool-param-set uuid=UUID other-config:auto_poweron=true

Note: *Replacing UUID with the UUID of the XenServer or pool.
Setting the Virtual Machines to Auto-Start
1. Gather the UUID’s of the Virtual Machine you want to auto-start by typing:
xe vm-list
Note: This generates a list of Virtual Machines in your pool or server and their associated UUID’s.

2. Copy the UUID of the Virtual Machines you want to auto-start, and type the following command for each Virtual Machine to auto-start:
xe vm-param-set uuid=UUID other-config:auto_poweron=true
Note: *Replace UUID with the UUID of the Virtual Machine to auto-start.*

For this second part (enabling auto-start for the VMs) we can use a little one-line script, which would enable autostart for ALL vms:

for i in `xe vm-list is-control-domain=false –minimal | tr , ‘ ’`; do xe vm-param-set uuid=$i other-config:auto_poweron=true; done
Edit rc.local file to start all vms with «auto_poweron» in their other-config

Add the following lines at the end of /etc/rc.local file:

[ -e /proc/xen ] || exit 0

XAPI_START_TIMEOUT_SECONDS=240

# wait for xapi to complete initialisation for a max of XAPI_START_TIMEOUT_SECONDS
/opt/xensource/bin/xapi-wait-init-complete ${XAPI_START_TIMEOUT_SECONDS}

if [ $? -eq 0 ]; then

pool=$(xe pool-list params=uuid —minimal 2> /dev/null)

auto_poweron=$(xe pool-param-get uuid=${pool} param-name=other-config param-key=auto_poweron 2> /dev/null)
if [ $? -eq 0 ] && [ «${auto_poweron}» = «true» ]; then
logger «$0 auto_poweron is enabled on the pool— this is an unsupported configuration.»

# if xapi init completed then start vms (best effort, don’t report errors)
xe vm-start other-config:auto_poweron=true power-state=halted —multiple >/dev/null 2>/dev/null || true
fi
fi

Second approach is to use vApp

1. Create vApp
2. Choose vms to vApp
3. Choose boot order and delays between starts
4. To get uuid of vApp use:

xe appliance-list name-label=»name-vapp»
5. Edit rc.local file to start vApp:

echo «sleep 40» >> /etc/rc.local
echo «xe appliance-start uuid=uuid-vapp» >> /etc/rc.local

7. Save file, reboot XenServer

Tkns, http://sysadmin.compxtreme.ro/autostart-vm-in-free-version-of-xenserver-6-x/

Xen 6.5

Проброс PCie:
http://support.citrix.com/article/CTX125574
http://habrahabr.ru/post/137327/
http://habrahabr.ru/post/151661/
http://ursus-mellifera.livejournal.com/6432.html

Делаем xe vm-list и находим uuid нашей виртуалки, у меня uuid=d103a91d-5c38-844f-14d5-64b3c495eb08
Выполняем команду lspci и находим в выводе нашу карту, например 02:00.0 VGA compatible …, 02:00.1 Audio… (двойка удивительным образом соответствует номеру слота, куда воткнута карта).
Записываем однострочный скрипт вида
xe vm-param-set other-config:pci=0/0000:02:00.0,0/0000:02:00.1 uuid=d103a91d-5c38-844f-14d5-64b3c495eb08

В итоге проброс локального видеонаблюдения devline из двух карт:
xe vm-param-set other-config:pci=0/0000:05:00.0,0/0000:06:00.0 uuid=85842063-12b5-ca59-60d7-fe2e7e55980

XenConvert & Xen Center — Windows
http://www.citrix.com/go/products/xenserver/xenserver-additional-resources-free.html

Xo — Xen Orchestra
admin@admin.net — admin

OpenXenManager — Linux
http://sourceforge.net/projects/openxenmanager/
http://www.linuxreaders.com/2010/08/openxenmanager-xencenter-alternative.html

Vt-d Xen
http://xgu.ru/wiki/%C8%F1%EF%EE%EB%FC%E7%EE%E2%E0%ED%E8%E5_VT-d_%E2_Xen

Управление локальными хранилищами:
Вообще все жесткие по умолчанию можно сложить в LVM и из него брать место
http://habrahabr.ru/post/86769/
http://mtaalamu.ru/blog/admining/2429.html

RAID1:
http://discussions.citrix.com/topic/360943-software-raid-mdadm-on-xenserver-65-unexpected-failure/
http://wysotsky.info/?p=106&lang=ru
http://alex-bug.livejournal.com/97570.html
http://sfattic.blogspot.ru/2011/10/xenserver-linuxraid-level-1.html

Скрипт на буржуйском «заменяет нормальный на бразильский бекграунд /usr/share/splash/background.png», но все шуршит Xen 6.5:
xen-6.5.x-mdadm_raid1.sh
Можно сразу забрать: wget http://office.edeg.com.br/reserved/xen/xen-6.5.x-mdadm_raid1.sh

после sh ./xen-6.5.x-mdadm_raid1.sh part1

После перезагружаемся и на загрузку в биосе ставим второй hdd

после sh ./xen-6.5.x-mdadm_raid1.sh part2

Raid5:
http://citrix.pp.ru/articles-2/2105-ustanovka-citrix-xenserver-na-programnyj-raid.html

Plugins — Распаковать в XenCenter:
XS_Console_Plugins_v4

Создадим Local Storage
# xe sr-create content-type=user type=lvm device-config:device=/dev/md2 shared=false name-label=»Local storage»

Обновление системы на RAID1:
http://wysotsky.info/?p=145

Создание локального стораджа через NFS нужно для HA POOL.
https://www.citrix.com/blogs/2009/01/26/how-to-configure-an-nfs-based-iso-sr-using-local-storage-on-a-xenserver5-host/