Документация которая находится на сайте Хетзнера почти подходит, но не совсем, вот какраз недостающие данные я и расскажу, а именно:
1. Запускаем Rescue System командой: #installimage
Разбиваем диски например так:
PART /boot ext3 4G PART lvm pve all # LV pve swap swap swap 8G LV pve root / ext3 40G LV pve vz /var/lib/vz ext3 200G LV pve data /data ext4 all
2. Далее следуем пиведенной ниже вырезке с сайта хетзнера.
3. А вот перед перезагрузкой делаем команду:
# update-grub
4. Ниже приведен старый мануал для ядра 6.24 однако из него можно взять настройку сети для виртуальных машин с локальными IP адресами.
5. А так можно пробросить нужный порт на виртуалку:
iptables -t nat -A PREROUTING -d 111.111.111.76 -p tcp -m tcp --dport 122 -j DNAT --to-destination 10.10.0.111:22
Proxmox VE
Proxmox VE это платформа виртуализации на базе OpenVZ и KVM.
Установка в целом считается несложной, так как OpenVZ настраивает всё корректно.
Установка
1. Сначала должна быть установлена операционная система Debian Lenny.
- Просто загрузите сервер в Rescue System
- Запустите installimage и выберите «Debian Lenny 64bit minimal»
- Сконфигурируйте как вам необходимо уровень RAID, разбиение диска и имя сервера
- Сохраните конфигурацию и, после завершения установки, перезагрузите сервер
2. Настройте источники установки для APT
nano /etc/apt/sources.list
Добавьте следующую строку:
deb http://download.proxmox.com/debian lenny pve
Добавьте ключ:
wget -O- "http://download.proxmox.com/debian/key.asc" | apt-key add - apt-get update
3. Установите Proxmox
apt-get install proxmox-ve-2.6.32
Эта версия поддерживает OpenVZ. Обзор можно найти здесь:
http://pve.proxmox.com/wiki/Proxmox_VE_Kernel
Наконец, перезапустите сервер и проверьте ядро с помощью «uname -r»
Настройка сети
Очень важно, чтобы vmbr0 не был соединён с физическим интерфейсом. Только тогда возможна маршрутизация.
Должно быть активировано перенаправление IP (IP forwarding). Это может быть сделано автоматически через /etc/sysctl.conf во время загрузки.
echo 1 > /proc/sys/net/ipv4/ip_forward echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf
Для IPv6 должна быть активирована proxy_ndp.
echo 1 > /proc/sys/net/ipv6/conf/all/proxy_ndp echo 'net.ipv6.conf.all.proxy_ndp=1' >> /etc/sysctl.conf'
Настройка сети с OpenVZ
# /etc/network/interfaces ### Hetzner Online AG - installimage # Loopback device: auto lo iface lo inet loopback # # device: eth0 auto eth0 iface eth0 inet static address 192.168.1.10 broadcast 192.168.1.63 netmask 255.255.255.255 pointopoint 192.168.1.1 gateway 192.168.1.1 # auto vmbr0 iface vmbr0 inet static address 192.168.1.10 broadcast 192.168.1.63 netmask 255.255.255.255 bridge_ports none bridge_stp off bridge_fd 0
Администрирование
Виртуальными машинами можно управлять только из http://Server-IP. Шаблоны можно найти здесьwiki.openvz.org/Download/template/precreated.
Виртуальная сеть «venet» используется для виртуальных машин, которым можно присвоить дополнительные IP адреса.
Для того, чтобы виртуальные машины были доступны по IPv6 адресам, IPv6 адрес машины должен быть добавлен как соседний:
ip -6 neigh add proxy 2a01:4f8:100:92a1::42 dev venet0
Настройка сети с KVM
Чтобы использование KVM необходимо вручную добавить маршруты до виртуальных машин. Например:
# /etc/network/interfaces ### Hetzner Online AG - installimage # Loopback device: auto lo iface lo inet loopback # # device: eth0 auto eth0 iface eth0 inet static address 192.168.1.10 broadcast 192.168.1.63 netmask 255.255.255.255 pointopoint 192.168.1.1 gateway 192.168.1.1 # auto vmbr0 iface vmbr0 inet static address 192.168.1.10 broadcast 192.168.1.63 netmask 255.255.255.255 bridge_ports none bridge_stp off bridge_fd 0 up ip route add 192.168.1.50/32 dev vmbr0
Безопасность
Веб-интерфейс защищён паролем. Однако, рекомендуется дополнительно защитить его через .htaccess для того, чтобы скрыть интерфейс и для защиты от использования уязвимостей.
Для этого создайте файлы .htaccess и .htpasswd в директории:
/usr/share/pve-manager
(не в директории /usr/share/pve-manager/root, это приведёт к ошибке). Генератор htaccess найдёте здесь:http://www.webmaster-toolkit.com/htaccess-generator.shtml
Единственное неудобство заключено в том, что вход в систему должен быть осуществлён множество раз.
Proxmox VE
This guide was written by orphans in a forum post
Installation
1. Boot into rescue mode and type ‘installimage’ to start installation. Make sure to save the password given to you by Hetzner Robot when activating rescue mode. This will be used to log into your new install later, and saves some fiddling having to reset it.
installimage
2. Select ‘Debian 64bit Minimal’ as the OS type.
3. At the partitioning setup enter the following (tweak this for your own needs).
PART /boot ext3 4G PART lvm vg0 424G PART lvm vg1 all # LV vg0 root / ext3 100G LV vg0 swap swap swap 24G LV vg0 backup /backup ext3 300G # LV vg1 vz /var/lib/vz ext3 all
4. Once installed, type reboot to boot into your newly installed OS.
reboot
5. Now you’re booted into your new OS. We’ll perform some routine updates, there shouldn’t be too many.
apt-get update apt-get upgrade
6. Next we need to install the required proxmox files.
nano /etc/apt/sources.list
7. Add the PVE Sources:
# PVE packages provided by proxmox.com deb http://download.proxmox.com/debian lenny pve
8. Add the signing key:
wget -O- "http://download.proxmox.com/debian/key.asc" | apt-key add - apt-get update
9. Install the proxmox kernel, this will install all the required kernel modules. We’re not actually going to be using this kernel, so don’t reboot. None of these kernels worked for me, they all caused kernel panics. (Maybe someone cleverer than I could correct this).
apt-get install pve-kernel-2.6.24-11-pve pve-headers-2.6.24-11-pve
10. Install the actual proxmox package:
apt-get install proxmox-ve-2.6.24
11. Time to fetch the actual OpenVZ kernel we’re going to use.
apt-get install alien fakeroot wget http://download.openvz.org/kernel/branches/2.6.32/2.6.32-belyayev.1/kernel-2.6.32-belyayev.1.x86_64.rpm fakeroot alien -k kernel-2.6.32-budarin.1.x86_64.rpm dpkg -i kernel-2.6.32-budarin.1.x86_64.rpm update-initramfs -c 2.6.32-budarin.1 update-grub
12. Edit your menu.lst file and make sure that the default is the new 2.6.32-budarin.1 kernel.
nano /boot/grub/menu.lst
Either move the entries for the 2.6.32-budarin.1 kernel to the top. Or change default 0 to the required index.
I.E. If the required kernel is the 3rd one in the list, you would change the default line to default 2.
13. Reboot
reboot
Hopefully your box comes back up without any issues 😉
Networking
Next we need to configure networking on the host.
1. Update the interfaces file.
nano /etc/network/interfaces
The following setup depends on what subnets Hetzner has given you, you may need to change some values.
### Hetzner Online AG - installimage # Loopback device: auto lo iface lo inet loopback # # device: eth0 auto eth0 iface eth0 inet static address 192.168.50.18 # Main Hetzner IP broadcast 192.168.50.63 netmask 255.255.255.255 gateway 192.168.50.1 # Gateway IP pointopoint 192.168.50.1 # Gateway IP up echo 1 > /proc/sys/net/ipv4/ip_forward # post-up iptables-restore < /etc/iptables.up.rules # Use this to restore your IP tables rules if you have any # auto vmbr0 iface vmbr0 inet static address 192.168.50.18 # Main Hetzner IP netmask 255.255.255.255 broadcast 192.168.50.63 bridge_ports none bridge_stp off bridge_fd 0 # # # This section is totally optional. It allows us to create extra internal VMs without dedicated IPs that still have connectivity. # auto vmbr1 iface vmbr1 inet static address 10.10.0.1 netmask 255.255.255.0 bridge_ports none bridge_stp off bridge_fd 0 post-up iptables -t nat -A POSTROUTING -s '10.10.0.0/24' -o eth0 -j MASQUERADE post-down iptables -t nat -D POSTROUTING -s '10.10.0.0/24' -o eth0 -j MASQUERADE
2. Change some local network settings to allow ip forwarding.
nano /etc/sysctl.conf
Set these values as needed:
net.ipv4.ip_forward = 1 net.ipv6.conf.all.forwarding = 1 net.ipv4.conf.default.proxy_arp = 1 net.ipv4.conf.all.rp_filter = 1 kernel.sysrq = 1 net.ipv4.conf.default.send_redirects = 1 net.ipv4.conf.all.send_redirects = 0
3. Check we’ve not broken anything:
systcl -p
4. Restart networking to activate config
/etc/init.d/networking restart
5. Grab yourself some up-to-date templates from [1].
cd /var/lib/vz/templates/cache wget http://download.openvz.org/template/precreated/contrib/ubuntu-10.04-minimal_10.04_amd64.tar.gz
6. Browse to your proxmox setup at https://<Main IP>/ and create yourself a new VM with one of your new templates.
7. Select venet as the network type. Enter one of your secondary IPs given to you by Hetzner as the IP.
8. Start your VM and you should have networking. If you don’t then there’s a couple of things to check:
- Are your IP routes present?
You may need to manually add the ip routes to the host. On the HOST run:
ip route list
My server gives the output:
192.168.50.40 dev venet0 scope link 10.10.0.2 dev venet0 scope link 192.168.50.0/26 dev eth0 proto kernel scope link src 192.168.50.18 10.10.0.0/24 dev vmbr1 proto kernel scope link src 10.10.0.1 default via 192.168.50.1 dev eth0
You should have a line like 192.168.50.40 dev venet0 scope link for each of your secondary IPs. If any are missing you can add them manually:
ip route add 192.168.50.40/32 dev venet0
To save these on reboot, you can add them to /etc/network/interfaces
up ip route add 192.168.50.40/32 dev venet0