Arch Linux VPS

提供: ArchWiki
2014年12月23日 (火) 19:26時点におけるKusakata (トーク | 投稿記録)による版 (Created page with "Category:Arch の入手とインストール Category:Virtualization en:Virtual Private Server {{Related articles start}} {{Related2|Co...")
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
ナビゲーションに移動 検索に移動

関連記事

Wikipedia:ja:バーチャル・プライベート・サーバ より:

バーチャルプライベートサーバ (VPS) はホスティングサーバ事業者によって使われている言葉で仮想マシンのことを指す。他の仮想マシンと同じ物理コンピュータ上のソフトウェアで動作しながらも、一つの独立した物理コンピュータとほとんど同じように使えるということを強調するために使われます。個々の顧客のニーズにあわせてカスタマイズすることができ、独立したコンピュータとしてのプライバシーを持ちながら、サーバーソフトウェアが動作するように設定することが可能です。

この記事では仮想専用サーバーにおける Arch Linux の利用について検討して、VPS 固有のインストール手順・フィックスなども述べます。

警告: Linux 2.6.32 は systemd バージョン 205 からサポートされていません (そして systemd 212 以降では動作しません)。コンテナによる仮想化環境は多くが古いカーネルを使っており、そのような環境では Arch Linux を最新状態に保つことができない可能性があります。ただし、OpenVZ は、カーネルビルド 042stab094.7 から、CLOCK_BOOTTIME 機能をバックポートしているため最新の systemd でも動作します。

Arch Linux を提供しているプロバイダ

警告: プロバイダの品質について保証はできません。発注する前に自分で確認してください。
ノート: 以下のプロバイダでは便利な Arch Linux イメージが用意されています。他のプロバイダで Arch を使うこともできますが、必要な作業が増えます。カスタムディスクイメージをロードしたり (ハードウェア仮想化が必須)、chroot 下でインストールしたり、他のディストリビューション上で rsync を使って Arch を同期するなどの方法があります。
プロバイダ Arch リリース 仮想化 場所 注記
A MilesWeb VPS 2013.10.14 OpenVZ ヨーロッパ, インド, US OpenVZ プラットフォームで最新の Arch Linux が使えます。クイックセットアップ、24時間365日のライブチャット・メール・電話サポート。VPS は月20ドルから。
123 Systems 2010.05.xx OpenVZ ダラス, US-TX 再インストール時に Arch が選択できます。カーネルはとても古い (2.6.18-308) ので OpenVZ のトラブルシューティングを見て下さい。購入する前に見られる情報は限られており、購入しないと Arch Linux のバージョンも確認できません。
AUSWEB 最新リリースのみ (clarify?) VMware ESXi シドニー, AU Latest ISO (clarify?) of Arch Available. Enterprise Service.
affinity.net.nz 2013.08.01 KVM オークランド, ニュージーランド (NZ) IRC チャンネルは ircs.kiwicon.org の #affinity
Afterburst 2012.12.01 OpenVZ マイアミ, US-FL; ニュルンベルク, DE 旧名 FanaticalVPS。カーネルバージョンは VPS が存在するノードによります。マイアミのノードは問題ありません (2.6.32-042stab072.10) がドイツのノードの場合カスタム glibc が必要になることがあります。
BuyVM 2013.07.01 KVM LA, バッファロー NY 登録時には別の OS を選択しなくてはなりません。アクセスできるようになったら、最新の Arch ISO をマウントして再起動を選択して手動でインストールします。
Edis 2013.03.01 vServer, KVM, OpenVZ 世界中に多数所在 専用サーバや、マン島 (IM) にある"オフショア"な場所も選べます。
DirectVPS 2014.01.xx OpenVZ アムステルダム, NL; ロッテルダム, NL オランダ語のサイト。https://www.directvps.nl/try-1.plp?p=31 からバージョンが確認できます。
Gandi 2013.10.27 Xen パリ, FR; ボルチモア, MD, US; ビッセン, LU Very granular scaling of system resources (e.g. RAM, disk space); IPv6-only option available; you can supply your own install image, version based on keyring package version
GigaTux 2013.06.01 Xen シカゴ, US-IL; フランクフルト, DE; ロンドン, GB; サンノゼ, US-CA
Host Virtual 2011.08.19 KVM 世界中に多数所在 Appears to use KVM virtualization. Site lists "Xen based virtualization" and features lists ability to install from ISO.
Hostigation 2010.05 i686 OpenVZ, KVM シャーロット, US-NC; ロサンジェルス, US-CA x86_64 に移行することが可能
IntoVPS 2012.09.xx OpenVZ アムステルダム, NL; ブカレスト, RO; ダラス, US-TX; フレモント, US-CA; ロンドン, GB Blog has not been updated since September, 2012 which included the Arch Linux update.
Leapswitch Networks [2013.10.xx] OpenVZ/KVM USA, インド, ポルトガル, スペイン, ウクライナ, ドイツ 現在 ArchLinux はコントロールパネルから再インストールするときだけ選べます。申し込みフォームにはありません。
Linode.com 2013.06.xx Xen 東京, JP; US 複数; ロンドン, GB カスタムカーネルを実行するために、linux-linodeAUR をインストールしてください (linux では32ビットの Linode 上で動作しません)。
LYLIX 2014.01.xx OpenVZ US 複数; ヨーロッパ 32ビットと64ビットが利用可能。
Node Deploy 2014.10.01 OpenVZ, KVM ドイツ (DE); ロサンジェルス, US-CA; アトランタ, US-GA; フェニックス, US-AZ "NodeDeploy では事実上すべての linux ディストリビューションをサポートしています"。Arch Linux もオペレーティングシステムのリストに記載されています。バージョン情報はなし。
Netcup 2012.11.xx KVM ドイツ (DE) ドイツ語のサイト。
OnePoundWebHosting 2013.05.xx Xen PV, Xen HVM イギリス (UK) レジストラでもあります。サーバーの場所は特定できません。
proPlay.de 2012.12.xx OpenVZ, KVM ドイツ (DE) ドイツ語のサイト。
QuickVZ 2013.10 OpenVZ, Xen アムステルダム, オランダ (NL); ストックホルム, スウェーデン (SE) Provide hardened Arch Linux images along with Enterprise services (e,g. VPN, Virtual Private LAN Service (VPLS) and Virtual Routers.
Rackspace Cloud 2013.6 Xen 世界中に多数所在 料金は時間単位。"next gen" の VPS を使って下さい (mycloud.rackspace.com パネルを使用); 第1世代の Rackspace VPS の Arch イメージは古くなっています。
RamHost.us 2013.05.01 OpenVZ, KVM ロサンジェルス, US-CA; グレートブリテン (GB); アトランタ, US-GA; ドイツ (DE) RamHost の IRC ネットワークで最新 ISO をリクエストできます。
RamNode 2013.07.01 SSD and SSD Cached: OpenVZ, KVM シアトル, WA USA, アトランタ, GA USA You can request Host/CPU passthrough with KVM service. Customer service has been prompt and professional. Regular discount codes can be found (15-35% off). Modern hardware. Competitive pricing (before discounts).
Tilaa 2014.10.01 KVM アムステルダム, NL 英語またはオランダ語のサイト。
TransIP 2013.05.01 KVM アムステルダム, NL 英語のサイト。レジストラ。
XenVZ 2009.12.07 OpenVZ, Xen イギリス (UK), アメリカ (US) ハードウェア
Virpus 2014.11.07 Xen カンザスシティ, US-KS; ロサンジェルス, US-CA Wow Technologies, Inc の子会社。ライブチャット、メール、電話、チケットシステムによる24時間365日サポート。費用は月5ドルから。
Vmline 2013.09.01 KVM, OpenVZ クラクフ, PL S-Net の再販売。完全仮想化。ポーランド語のサイト。
VPSBG.eu 2013.10 OpenVZ ソフィア, ブルガリア ブルガリアのオフショア VPS - 匿名の登録と Bitcoin による支払いが可能。
VPS6.NET 2013.01.xx OpenVZ, Xen, HVM-ISO US 複数; フランクフルト, DE; ブカレスト, RO; イスタンブール, TR レジストラ。
VPS.NET 2014.01.xx OpenVZ, Xen, HVM-ISO US, カナダ, UK, ブラジル, オランダ, フランス, ドイツ, 日本, シンガポール, インド, オーストラリア; その他複数 Managed & Un managed VPS service provider, multiple OS and configurations..

インストール

KVM

QEMU#(Arch) Linux ゲストを用意するを見て下さい。

OpenVZ

OpenVZ プロバイダで最新の Arch Linux をインストール

It's possible to directly copy an installation of Arch Linux over the top of a working OpenVZ VPS. This tutorial explains how to create a basic installation of Arch Linux with pacstrap (as used in a standard install) and then replace the contents of a target VPS with it using rsync.

This process (with minor modification) also works to migrate existing Arch installations between various environments and has been confirmed to work in migrating from OpenVZ to Xen and from Xen to OpenVZ. For an install to Xen, other hardware-virtualized platforms, or probably even to physical hardware (unconfirmed), extra steps (basically running mkinitcpio and installing a bootloader) are needed.

必須要件
  • A working Arch Linux installation
    • To keep things simple, it should match the architecture you want to install on your VPS (x86_64 or i686).
    • To build from other distributions, arch-bootstrap.sh can be used in place of pacstrap.
  • The arch-install-scripts, rsync, and openssh packages from the official repositories
    • SSH isn't strictly required, but rsync over SSH is the method used here.
  • A VPS running any distribution, with rsync and a working SSH server
    • Its architecture (x86_64 or i686) doesn't matter as long as the OpenVZ installation can support your target architecture.
  • OpenVZ's serial console feature (usually accessible via your provider's control panel)
    • Without this, any network configuration for the target VPS will have to be done immediately after the "Build" step below.
クリーンな Arch Linux 環境を作成

As root, build the installation (optionally replacing build with your preferred target directory):

# mkdir build
# pacstrap -cdGM build
ノート: By default, the pacstrap script will build the installation according to your system's pacman.conf. Its Architecture setting (auto by default) will determine if an i686 or x86_64 installation is created. Alternatively, you could add the -C option (like -C custom-pacman-config.conf) if you'd like to change the architecture, use custom mirrors, etc.
VPS にあるものを全て Arch 環境と置き換える

Replace all files, directories, etc. on your target VPS with the contents of your build directory (replacing "YOUR.VPS.IP.ADDRESS" below):

警告: Be careful with the following command. By design, rsync is very destructive, especially with the --delete option.
# rsync -ax --delete -e ssh --stats -P build/ YOUR.VPS.IP.ADDRESS:/
ノート: At minimum, only the -a (preserve timestamps, permissions, etc.), -x (don't cross filesystem boundaries), and --delete (delete anything in the target that doesn't exist in the source) options are required. -e ssh (use rsync over SSH) is recommended and makes things simple.
設定
  1. Reboot the VPS externally (using your provider's control panel, for example).
  2. Using OpenVZ's serial console feature, configure the network and basic system settings, as in a normal installation.
    • If you don't have access to the serial console feature, you'll need to preconfigure your network settings before synchronizing Arch to the VPS.

2010.05 インストールイメージの更新

These instructions assume you have a 2010.05 image from your VPS provider and you would like to get it updated. The biggest work involves preparing /lib for the symlink upgrade (glibc 2.16, and later filesystem 2013.01).

警告: If you are on a older kernel than 2.6.32, please refer further down the page to get the glibc-vps repository working (just add the repository and you can follow these steps).

To start, grab the latest BusyBox from http://busybox.net/downloads/binaries/latest/. This allows you to force glibc (losing /lib temporarily) without losing your OS (BusyBox comes with its own GNU tools which are statically linked).

# wget http://busybox.net/downloads/binaries/latest/busybox-i686
# chmod +x busybox-i686

First, you can get a list of packages that own files in /lib with the following command:

$ pacman -Qo /lib/* | cut -d' ' -f 5 | egrep -v 'glibc' | uniq | xargs

For the current 2010.05 that comes from ibiru's page, these are the packages that were required to be removed for me:

pacman -S acl attr util-linux-ng bzip2 libcap e2fsprogs libgcrypt libgpg-error udev readline ncurses pam pcre popt procps readline shadow e2fsprogs sysfsutils udev util-linux-ng sysvinit coreutils

You may have to remove /lib/udev/devices/loop0 (a simple rm works).

After the upgrade finishes, you must remove any extra empty directories in /lib (/lib/modules is the common offender):

# rm -rf /lib/modules

Install tzdata to fix some dependencies, and remove /etc/profile.d/locale.sh:

# pacman -S tzdata
# rm /etc/profile.d/locale.sh

Remove /var/run (you should have nothing running that matters):

# rm -rf /var/run

Force glibc, which will pull in the latest filesystem package, but will BREAK everything (other than BusyBox):

# pacman -S --force glibc

Now, you will have a broken system, so symlink /usr/lib to /lib with BusyBox's ln program:

# ./busybox-i686 ln -s /usr/lib /lib

And you should have a fully functional system where you can now update pacman.

# pacman -S pacman
# pacman-key --init
# pacman-key --populate archlinux
# pacman-db-upgrade
# pacman -Syy

Now, update initscripts to get the iproute2 package:

# pacman -S initscripts

Install the makedev package:

pacman -S makedev

Add the following to your /etc/rc.local:

/usr/sbin/MAKEDEV tty
/usr/sbin/MAKEDEV pty

Comment the following lines in /etc/inittab:

#c1:2345:respawn:/sbin/agetty -8 -s 38400 tty1 linux
#c2:2345:respawn:/sbin/agetty -8 -s 38400 tty2 linux
#c3:2345:respawn:/sbin/agetty -8 -s 38400 tty3 linux
#c4:2345:respawn:/sbin/agetty -8 -s 38400 tty4 linux
#c5:2345:respawn:/sbin/agetty -8 -s 38400 tty5 linux
#c6:2345:respawn:/sbin/agetty -8 -s 38400 tty6 linux

Finally, you should be able to upgrade the whole system:

# pacman -Syu

You may run into some issues with krb5 and heimdal, as krb5 no longer provides+conflicts+replaces heimdal (https://projects.archlinux.org/svntogit/packages.git/commit/trunk/PKGBUILD?h=packages/krb5&id=f5e6d77fd14ced15ebf5b6a78a7c76e0db0625f7). The old openssh depends on heimdal (and the new openssh depends on krb5), so force install krb5, then upgrade openssh, then remove heimdal and reinstall krb5.

# pacman -S --force krb5
# pacman -S openssh openssl
# pacman -R heimdal
# pacman -S krb5

Fix syslog-ng. Set the src to unix-dgram("/dev/log") and add --no-caps to both check and run args in /etc/conf.d/syslog-ng.

Make sure your /etc/rc.conf is not messed up with broken network definitions, or else be sure serial access works on your VPS before you reboot.

VPS のネットワーク設定を rc.conf から netcfg に移行 (OpenVZ でテスト済み)

1) Install netcfg

pacman -S netcfg

2) Create a netcfg configuration file /etc/network.d/venet

CONNECTION='ethernet'
DESCRIPTION='VPS venet connection'
INTERFACE='venet0'
IP='static'
IPCFG=(
#default
'addr add 127.0.0.1/32 broadcast 0.0.0.0 dev venet0'
#IPv4 address
'addr add xxx.xxx.xxx.xxx/32 broadcast 0.0.0.0 dev venet0'
#IPv4 route
'route add default dev venet0'
#IPv6 address
'addr add xxxx:xx:xx::x/128 dev venet0'
#IPv6 route
'-6 route add default dev venet0'
)
DNS=('xxx.xxx.xxx.xxx' 'xxx.xxx.xxx.xxx')

3) Edit your netcfg main conf file /etc/conf.d/netcfg

NETWORKS=(venet)
WIRED_INTERFACE="venet0"

4) Try your new setup

rc.d stop network && ip addr flush venet0 && netcfg venet

Your VPS should still be connected and have its IP addresses set correctly. (Check with ip a)

DO NOT proceed to next step if this isn't the case.

5) Make your new setup survive reboots

In the DAEMONS array in /etc/rc.conf, replace network with net-profiles.

Remove all networking information that is in /etc/rc.conf.

reboot

VPS で initscripts から systemd に移行

警告: This has been known to work with OpenVZ on the 2.6.32 kernel, but systemd may not work on older kernels.

This is very similar to a regular arch system, except you probably don't have access to your kernel line.

1) Move from network in rc.conf to netcfg (see above).

2) Install systemd

pacman -S systemd

2 bonus for OpenVZ) Remove kernel core dump pattern since this is blocked by OpenVZ and causes errors

Edit /usr/lib/sysctl.d/coredump.conf, comment out the following line:

#kernel.core_pattern=|/usr/lib/systemd/systemd-coredump %p %u %g %s %t %e

3) Move all configuration from /etc/rc.conf (except the DAEMONS array) to its appropriate location.

See Native configuration and rc.conf for details.

Now your /etc/rc.conf should only contain the DAEMONS array.

4) Install systemd-sysvcompat

pacman -S systemd-sysvcompat

It will ask to replace sysvinit, say yes.

reboot

5) Move daemons from the DAEMONS array in /etc/rc.conf to systemd

See the guide and the daemons list.

If your DAEMONS array is now empty, skip next step.

6) Moving rc.d daemons with no systemd support, example: vzquota

Create a custom systemd service file for vzquota: /etc/systemd/system/newvzquota.service:

[Unit]
Description=Setup vzquota on VPS
ConditionFileIsExecutable=/etc/rc.d/vzquota

[Service]
Type=oneshot
ExecStart=/etc/rc.d/vzquota start
ExecStop=/etc/rc.d/vzquota stop
TimeoutSec=0
StandardInput=tty
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
ノート: It is recommended to choose a .service file name that is different from the name of the daemon, because systemd might try to call the LEGACY scripts with the old name.

Enable this service:

systemctl enable newvzquota.service

Remove vzquota from the DAEMONS array in /etc/rc.conf

Repeat this step to remove all daemons from /etc/rc.conf.

7) Removing /etc/rc.local and /etc/rc.local.shutdown

Write custom .service files to replace functionality in /etc/rc.local and /etc/rc.local.shutdown. You can take a look at /usr/lib/systemd/system/rc-local.service and /usr/lib/systemd/system/rc-local-shutdown.service for inspiration.

8) Removing initscripts

Your /etc/rc.conf file must look like this:

DAEMONS=()

and /etc/rc.local and /etc/rc.local.shutdown must now be empty.

Uninstall initscripts

pacman -R initscripts
reboot

Xen

Xen#ハードウェア仮想化 (HVM) Arch domU の設定Xen#準仮想化 (PV) Arch domU の設定 を見て下さい。

OpenStack と Xen のコンポーネントを sysmted に変換

Rackspace NextGen Cloud などの、OpenStack/Xen による VPS を使う場合、systemd で有効にする必要がある3つのコンポーネントがあります。そのうちの2つは現行バージョンの xe-guest-utilities に含まれています: xe-linux-distribution と xe-daemon。

OpenStack の nova-agent については、現行バージョンの 0.0.1.37 には sysvinit のスタートアップスクリプトしか含まれていないので、カスタムサービスファイルを作成する必要があります。

/etc/systemd/system/nova-agent.service
[Unit]
Description=nova-agent service
After=xe-daemon.service

[Service]
Environment=LD_LIBRARY_PATH=/usr/share/nova-agent/0.0.1.37/lib
ExecStart=usr/bin/nova-agent -n -l info /usr/share/nova-agent/nova-agent.py

[Install]
WantedBy=multi-user.target

Once these steps are done, you can continue with converting the server from sysvinit to systemd.

以下のサービスを有効にするようにしてください:

# systemctl enable xe-linux-distribution
# systemctl enable xe-daemon
# systemctl enable nova-agent

トラブルシューティング

OpenVZ: kernel too old for glibc

Are you on a virtual private server (VPS) with an old kernel & broke your system? Are you using OpenVZ?

Check your kernel version with:

uname -r

If your kernel is older than 2.6.32, you will need a custom version of glibc (because of dependencies in glibc).

Arch Template Used: https://dev.archlinux.org/~ibiru/openvz/2010.05/arch-2010.05-i686-minimal.tar.gz

ノート: For installs that have not been updated to glibc-2.16, it will save you lots of time and prevent major breakage to do:
pacman -U https://dev.archlinux.org/~ibiru/openvz/glibc-vps/i686/glibc-2.16.0-101-i686.pkg.tar.xz

or

pacman -U https://dev.archlinux.org/~ibiru/openvz/glibc-vps/x86_64/glibc-2.16.0-101-x86_64.pkg.tar.xz

Add a single -d if needed. The instructions below assume that this has been done.

Following similar instructions from DeveloperWiki:usrlib.

Try doing the following to fix it:

1) Edit /etc/pacman.conf and add the following repository ABOVE [core]:

For 32-bit:

[glibc-vps]
Server = https://dev.archlinux.org/~ibiru/openvz/glibc-vps/i686

For 64-bit:

[glibc-vps]
Server = https://dev.archlinux.org/~ibiru/openvz/glibc-vps/x86_64

2) Then run pacman -Syy followed by pacman -Syu. You will be notified to upgrade pacman first.

3) Upgrade the pacman database by running pacman-db-upgrade as root.

4) Edit /etc/pacman.conf.pacnew (new pacman config file) and add the following repository ABOVE [core]:

[glibc-vps]
Server = https://dev.archlinux.org/~ibiru/openvz/glibc-vps/$arch

5) Replace /etc/pacman.conf with /etc/pacman.conf.pacnew (run as root):

# mv /etc/pacman.conf.pacnew /etc/pacman.conf

6) Upgrade your whole system with new packages again pacman -Syu

If you get the following error or a similar error:

initscripts: /etc/profile.d/locale.sh exists in filesystem

Simply delete that file (e.g., rm -f /etc/profile.d/locale.sh), then run pacman -Syu again.

If you get the following error or a similar error:

filesystem: /etc/mtab exists in filesystem

Run pacman -S filesystem --force

If you get the following error or a similar error:

libusb-compat: /usr/bin/libusb-config exists in filesystem

Run pacman -S libusb and then pacman -S libusb-compat

7) Before rebooting, you need to install the makedev package from the official repositories by running pacman -S makedev.

8) Add MAKEDEV to /etc/rc.local:

/usr/sbin/MAKEDEV tty
/usr/sbin/MAKEDEV pty

9) Edit /etc/inittab, comment out the following lines; otherwise, you will see errors in /var/log/errors.log):

#c1:2345:respawn:/sbin/agetty -8 -s 38400 tty1 linux
#c2:2345:respawn:/sbin/agetty -8 -s 38400 tty2 linux
#c3:2345:respawn:/sbin/agetty -8 -s 38400 tty3 linux
#c4:2345:respawn:/sbin/agetty -8 -s 38400 tty4 linux
#c5:2345:respawn:/sbin/agetty -8 -s 38400 tty5 linux
#c6:2345:respawn:/sbin/agetty -8 -s 38400 tty6 linux

10) To enable use of the hostname command, install the package inetutils from the official repositories.

11) Remove disabling of the SysRq key and setup of core dump pattern because this is blocked by OpenVZ and causes errors.

Because sysctl does not use /etc/sysctl.conf any more[1], you must transfer all settings to /etc/sysctl.d/99-sysctl.conf (or any other file in /etc/sysctl.d/; however, do not transfer the following line:

kernel.sysrq = 0

Edit /usr/lib/sysctl.d/coredump.conf and comment out the following line:

#kernel.core_pattern=|/usr/lib/systemd/systemd-coredump %p %u %g %s %t %e

12) Save and reboot.

Enjoy & thank ioni if you happen to be in #archlinux

SSH fails: PTY allocation request failed on channel 0

Some VPSes have an outdated /etc/rc.sysinit. You may be able to log in via serial console or with the following command:

$ ssh root@broken.server '/bin/bash -i'

Then run the following:

# mv /etc/rc.sysinit.pacnew /etc/rc.sysinit
# reboot

Once it is working, you should be able to comment out the udevd_modprobe line in /etc/rc.sysinit to save a bit of RAM the next time you reboot.

If the above does not work, take a look at this guide.