在 Debian 6 上安装 GroundWork

GroundWork 是很漂亮的 Nagios 前端, 并增加了很多易用的功能(单纯的配置 Nagios 很头疼对吧). 而且根据目前 GW 的销售方式, 管理50台设备以下的情况可以免费试用, 提供 Email 即可:

http://www.gwos.com/downloads/core/

在 Debian 6 上安装 GW 时还是有些小问题, 就是 PostgreSQL 提示SHMMAX (最大共享内存?)值不够大. 按照如下方式调整一下, 即可安装:

sysctl -w kernel.shmmax=2147483648
sysctl -w kernel.shmall=524288
sysctl -p

第一次运行会提示要求输入 License, 如果之前提交了 Email 地址的话应该已经收到了, 抄过来就可以了.

另外 check_icmp 这个命令有时候会出现”setuid or root”一类的问题导致误报. 按照如下方法可修复.

chown root:nagios check_icmp
chmod 4750 check_icmp

尚未没发现其它问题. 😀

To Duplicate/Backup a Xen VM in a Logical Volume

技术笔记. 请忽略 🙂

0, If you are to duplicate, create VMs on destination server, just to create conf files and logical volumes for VMs and hold the place for source VMs.

#xen-create-image –hostname [HOSTNAME] –ip [IP] –vcpus 2 –pygrub –dist squeeze

1, Create an LVM snapshot for the VM’s logical volume.

#lvcreate -L[SIZE] -s -n [SNAPSHOTNAME] /dev/[VOLUMEGROUP]/[LOGICALVOLUME]

2, Shutdown the VM if optional. Login the VM and shut down or:

#xm shutdown [VM]

3, Copy the snapshot over to destination server. Login to the source server and do

#dd bs=4M if=/dev/[VOLUMEGROUP]/[SNAPSHOTNAME] | gzip -1 – | ssh [USER]@[DESTINATION] dd bs=4M of=[/PATH]/tmp.gz

3.1, If step 3 is successful, you can remove the snapshot optionally.

#lvremove /dev/[VOLUMEGROUP]/[SNAPSHOTNAME]

4, Restore the volume image to the target logical volume on destination server. Better make the target volume bigger than the source volume.

#dd bs=4M if=[/PATH]/tmp.gz | gunzip -1 – | dd bs=4M of=/dev/[TARGETVOLUMEGROUP]/[TARGETLOGICALVOLUME]

4.1, If the target volume is bigger than the source volume(which is recommended), check and resize:

#e2fsck -f /dev/[TARGETVOLUMEGROUP]/[TARGETLOGICALVOLUME]
#resize2fs /dev/[TARGETVOLUMEGROUP]/[TARGETLOGICALVOLUME]

5, Mount target volume for modifications such as IP, etc. And un-mount after this.

#mount /dev/[TARGETVOLUMEGROUP]/[TARGETLOGICALVOLUME] /[MOUNTPATH]
#umount /dev/[TARGETVOLUMEGROUP]/[TARGETLOGICALVOLUME]

6, Compare both source and destination VM configuration files if there’s different booting methods.

7, Boot up the cloned VMs and test.

#xm create [HOSTNAME].cfg
#xm top

🙂

Xen 4.0 Hypervisor with LVM on Debian 6 Squeeze

这篇用不用中文都是差不多了, 索性用英文了. Xen 是VM(虚拟机)的一种, 现在很多商用 VPS 服务商就是使用基于 Xen, 或者 OpenVZ 技术在一台物理上的服务器上同时运行多个VM的.

1, Install Debian 6 Squeeze

This step will be the easiest. Just to remember to use LVM when partitioning and leave enough unused(un-partitioned) disk space for later use. If your system has >= 4GB of memory, choose AMD64 architecture.

Reference to LVM: http://www.debian-administration.org/articles/410

2, Install Xen

Guess all commands below require root privilege, so don’t bother using “sudo” but log in with root or “su”.

 apt-get install xen-linux-system xen-qemu-dm xen-tools

“xen-linux-system” is not a actual package, it will match something like “xen-linux-system-2.6.32-5-xen-686”, which is a meta package.

3, Modify grub to boot Xen by default

Open and edit “/etc/default/grub”, change

GRUB_DEFAULT = 0

to

GRUB_DEFAULT = 4

Number 4 means the 5th item in grub boot menu.

To prevent further change to the boot menu, also add the following to “/etc/default/grub”:

GRUB_DISABLE_OS_PROBER = true

And then update grub with

update-grub

Reference: http://wiki.debian.org/Xen

4, Build your own Debian network bridge. First, take down your eth0:

ifdown eth0

Open and edit “/etc/network/interfaces”, change TO

auto lo
iface lo inet loopback

auto br0
iface br0 inet static
address x.x.x.x
netmask x.x.x.x
network x.x.x.x
broadcast x.x.x.x
gateway x.x.x.x
bridge_ports eth0
bridge_stp on
bridge_maxwait 0

Then “br0” will be your new network bridge, and eth0 is your physical Ethernet interface.You can now try bring your bridge online:

ifup br0

Now load some settings to “/etc/sysctl.conf”

net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0

To make these effective, run the command:

sysctl -p /etc/sysctl.conf

Reference: http://wiki.libvirt.org/page/Networking

5, Default settings for new VM images, to change, open and edit “/etc/xen-tools/xen-tools.conf” and revise the following lines:

lvm = VOLUME GROUP NAME
size = 8GB #disk size
memory = 512MB
swap = 512MB

gateway = x.x.x.x
netmask = x.x.x.x

passwd = 1

pygrub = 1

6, Create VM images with xen-create-image

xen-create-image –hostname HOSTNAME –ip IP –vcpus 2 –pygrub –dist squeeze

Note, by default, debootstrap method, an Internet connection is required to download from Debian mirrors. After success, 2 new logical volume2(LV 🙂 ) will be created along with a configuration file called /etc/xen/HOSTNAME.cfg

7, Run VM images

xm create /etc/xen/HOSTNAME.cfg

8, Make VM images auto-start when system boots

mkdir /etc/xen/auto
ln -s /etc/xen/HOSTNAME.cfg /etc/xen/auto

Reference: http://www.howtoforge.com/using-xen-with-lvm-based-vms-instead-of-image-based-vms-debian-etch

At this point, you should be able to log in to VM via 2 ways:

xm console HOSTNAME

or

ssh [email protected]