hnakamur’s blog

ものすごい勢いで忘れる私のために未整理でもいいからとりあえずメモ

ラベル OpenVZ の投稿を表示しています。 すべての投稿を表示
ラベル OpenVZ の投稿を表示しています。 すべての投稿を表示

2008-12-17

OpenVZでCentOS5をゲストOSとしてセットアップの続き



昨日の記事の続きです。


検索してみると



というページを発見。


まねしてやってみる。



# vi /vz/template/centos/5/x86_64/config/install-post
===================================================================
--- /vz/template/centos/5/x86_64/config/install-post 2008/12/17 15:14:07 1.1
+++ /vz/template/centos/5/x86_64/config/install-post 2008/12/17 15:25:17 1.4
@@ -35,10 +35,10 @@
$VZCTL exec2 $VEID sed -i -e '/getty/d' /etc/inittab

# Disable klogd
-$VZCTL exec2 $VEID \
- "sed -i -e 's/daemon\\ klogd/passed\\ klogd\\ skipped/' \
- -e 's/killproc\\ klogd/passed\\ klogd\\ skipped/' \
- /etc/init.d/syslog"
+#$VZCTL exec2 $VEID \
+# "sed -i -e 's/daemon\\ klogd/passed\\ klogd\\ skipped/' \
+# -e 's/killproc\\ klogd/passed\\ klogd\\ skipped/' \
+# /etc/init.d/syslog"
# FIXME: fix '/etc/init.d/syslog status' to return 0
# even if klogd is not running

@@ -55,7 +55,7 @@
# Disable fsync() in syslog
$VZCTL exec2 $VEID \
'sed -i -e s@\\\([[:space:]]\\\)\\\(/var/log/\\\)@\\\1-\\\2@' \
- /etc/syslog.conf
+ /etc/rsyslog.conf

# Disable X11Forwarding by default
$VZCTL exec2 $VEID \
@@ -85,3 +85,5 @@
#echo "Rebuilding RPM DB ..."
#$RPM --root $VE_ROOT --rebuilddb
#rm -f $VE_ROOT/var/lib/rpm/__db.0*
+
+mkdir -p $VE_ROOT/var/lib/yum || abort "Can't create /var/lib/yum"
===================================================================
# vzpkgcache -f centos-5-x86_64-minimal
...


しかし、やはり



could not open ts_done file: [Errno 2] No such file or directory: '/vz/root/100001/var/lib/yum/transaction-done.2008-12-18.00:31.05'


のようなエラーが連発しているので、別の端末から手動で



# mkdir -p /vz/root/100001/var/lib/yum


として作成。


その後



...
Complete!
chmod: cannot access `/etc/cron.daily/slocate.cron': No such file or directory
chmod: cannot access `/etc/cron.daily/makewhatis.cron': No such file or directory
Packing cache file centos-5-x86_64-minimal.tar.gz ...
Cache file centos-5-x86_64-minimal.tar.gz [129M] created.
#


となって一応終了。cron.dailyでエラーが出てますがInstall OpenVZ on a x86 64 system Centos-Fedora - OpenVZ Wikiにも



It finishes with complaints about cron.daily, but don't worry about it.



と書いてあるので気にしないことにします。


で、そのページの続きに従って実行。あとBasic operations in OpenVZ environment - OpenVZ Wikiも見つつ。



# vzpkgls -c
centos-5-x86_64-minimal
# vzctl create 200 --ostemplate centos-5-x86_64-minimal
Creating container private area (centos-5-x86_64-minimal)
Performing postcreate actions
Container private area was created



# vzctl create 200 --ostemplate centos-5-x86_64-minimal
# vzctl start 200


パッケージインストールのテスト。fastestmirrorが効いてなくて遅いミラーを選んでしまったようで1分程度かかったが成功。



# vzyum 200 install nano
# vzrpm 200 -qa



# vzctl set 200 --ipadd 192.168.1.101 --save
# vzctl set 200 --nameserver 192.168.1.1.1 --save
# vzctl stop 200
# vzctl start 200
# vzctl exec 200 ps ax
PID TTY STAT TIME COMMAND
1 ? Ss 0:00 init [3]
9513 ? Ss 0:00 /usr/sbin/sshd
9524 ? Rs 0:00 ps ax
# vzctl enter 200
# ps ax
PID TTY STAT TIME COMMAND
1 ? Ss 0:00 init [3]
9513 ? Ss 0:00 /usr/sbin/sshd
9526 ? Ss 0:00 vzctl: pts/0
9527 pts/0 Ss 0:00 -bash
9542 pts/0 R+ 0:00 ps ax
# exit
# vzctl stop 200


てなわけでとりあえず動きました!





2008-12-16

OpenVZを試す、が、まだうまくいかない



Linux-VServerはバニラカーネルへのパッチとして提供されていて、パッチあたりまくりのCentOSだとうまく当たらないし、そうかといってバニラカーネル+Linux-VServerにしてしまうとCentOSとは別物になってしまってCentOSの検証環境としては使えないなあと悩んでいて以下のページを見つけました。



そうかOpenVZならCentOSのカーネルにも対応していたのか(もっと早く気付けよ>私)。ということでトライしてみました。



# cd /etc/yum.repos.d/
# wget http://download.openvz.org/openvz.repo
# rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ
# yum search ovzkernel
# yum install ovzkernel.x86_64
# vi /etc/sysctl.conf
===================================================================
RCS file: /etc/sysctl.conf,v
retrieving revision 1.1
diff -u -r1.1 /etc/sysctl.conf
--- /etc/sysctl.conf 2008/12/16 16:13:56 1.1
+++ /etc/sysctl.conf 2008/12/16 16:15:34
@@ -4,15 +4,19 @@
# sysctl.conf(5) for more details.

# Controls IP packet forwarding
-net.ipv4.ip_forward = 0
+net.ipv4.ip_forward = 1
+net.ipv4.conf.default.proxy_arp = 0

# Controls source route verification
+net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
+net.ipv4.conf.default.send_redirects = 1
+net.ipv4.conf.all.send_redirects = 0

# Do not accept source routing

# Controls the System Request debugging functionality of the kernel
-kernel.sysrq = 0
+kernel.sysrq = 1

# Controls whether core dumps will append the PID to the core filename
# Useful for debugging multi-threaded applications
===================================================================
# sysctl -p
net.ipv4.ip_forward = 1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
kernel.sysrq = 1
kernel.core_uses_pid = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
net.ipv4.tcp_syncookies = 1
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.eth0.accept_redirects = 0
net.ipv4.conf.lo.accept_redirects = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.eth0.accept_source_route = 0
net.ipv4.conf.lo.accept_source_route = 0

# reboot
uname -r
2.6.18-92.1.13.el5.028stab059.6
# yum install vzctl vzctl-lib vzpkg vzquota vzyum vzrpm43 vzrpm43-python vzrpm44 vzrpm44-python
oading "fastestmirror" plugin
Loading mirror speeds from cached hostfile
* addons: ftp2.riken.jp
* extras: ftp2.riken.jp
* base: ftp2.riken.jp
* openvz-kernel-rhel5: ftp.iij.ad.jp
* openvz-utils: ftp.iij.ad.jp
* updates: ftp2.riken.jp
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package vzctl.i386 0:3.0.23-1 set to be updated
---> Package vzpkg.noarch 0:2.7.0-18 set to be updated
---> Package vzrpm44-python.i386 0:4.4.1-22.5 set to be updated
---> Package vzquota.i386 0:3.0.12-1 set to be updated
---> Package vzyum.noarch 0:2.4.0-11 set to be updated
--> Processing Dependency: cElementTree.so for package: vzyum
---> Package vzrpm43-python.i386 0:4.3.3-7_nonptl.6 set to be updated
---> Package vzrpm44.i386 0:4.4.1-22.5 set to be updated
---> Package vzctl.x86_64 0:3.0.23-1 set to be updated
---> Package vzquota.x86_64 0:3.0.12-1 set to be updated
---> Package vzrpm43.i386 0:4.3.3-7_nonptl.6 set to be updated
---> Package vzctl-lib.i386 0:3.0.23-1 set to be updated
---> Package vzctl-lib.x86_64 0:3.0.23-1 set to be updated
--> Finished Dependency Resolution
Error: Missing Dependency: cElementTree.so is needed by package vzyum


おおっとなんかエラーが。


で、検索したら本家のドキュメントに行き着く(最初からこちらを見ようね>私)。



というわけで続き。



# yum install vzctl vzquota
# /sbin/service vz start
# /sbin/chkconfig --list vz
# wget http://linux.carreira.com.pt/ovzutils/setx86_64-0.3.tar.gz
# tar zxf setx86_64-0.3.tar.gz
# sh setx86_64
# vi /vz/template/centos/5/x86_64/config/.rpmmacros
===================================================================
RCS file: /vz/template/centos/5/x86_64/config/.rpmmacros,v
retrieving revision 1.1
diff -u -r1.1 /vz/template/centos/5/x86_64/config/.rpmmacros
--- /vz/template/centos/5/x86_64/config/.rpmmacros 2008/12/16 16:34:18 1.1
+++ /vz/template/centos/5/x86_64/config/.rpmmacros 2008/12/16 16:34:35
@@ -1 +1 @@
-%_install_langs C
+%_install_langs C:ja_JP.UTF-8
===================================================================

# vzpkgls | grep x86_64
fedora-7-x86_64-small
fedora-7-x86_64-default
fedora-7-x86_64-minimal
fedora-core-5-x86_64-default
fedora-core-5-x86_64-minimal
fedora-core-3-x86_64-default
fedora-core-3-x86_64-minimal
fedora-core-6-x86_64-default
fedora-core-6-x86_64-minimal
fedora-core-4-x86_64-default
fedora-core-4-x86_64-minimal
centos-5-x86_64-default
centos-5-x86_64-minimal
centos-4-x86_64-default
centos-4-x86_64-minimal
# vzpkgcache -f centos-5-x86_64-minimal
...
Installing: libgcc ####################### [ 1/87]
could not open ts_done file: [Errno 2] No such file or directory: '/vz/root/100001/var/lib/yum/transaction-done.2008-12-17.01:43.38'
Installing: setup ####################### [ 2/87]
could not open ts_done file: [Errno 2] No such file or directory: '/vz/root/100001/var/lib/yum/transaction-done.2008-12-17.01:43.38'
...
Complete!
sed: can't read /etc/init.d/syslog: No such file or directory
ERROR: Script install-post failed


途中で/vz/root/100001/var/lib/yum/というディレクトリが無いっぽいエラー連発。最後にもエラーが。なんか間違えたかな。


調べてみると/vz/root/まではあるがその下はないようだ。/etc/init.d/syslogのほうはあるんだけどな。続きはまた今度。





2008-11-24

coLinux入りカーネルソースにOpenVZのカーネルパッチ当てを試みるも失敗



参考URL



作業環境はcoLinux 0.7.3、kernel 2.6.22.18。


まず、coLinuxのSnapshotsのページから0.7.3の最新のカーネルstable-colinux-20080524.tar.gzを取得。まずビルド環境が整っているかの確認も兼ねて、coLinuxのメモ - カーネルのコンパイルに従ってmake kernelまでやってみた。



# cd /usr/src
# wget http://www.colinux.org/snapshots/stable-colinux-20080524.tar.gz
# tar zxf stable-colinux-20080524.tar.gz
# cd stable-colinux-20080524
# ./configure
# make kernel


次にOpenVZのカーネルパッチを組み込もうと思い、Compiling the OpenVZ kernel (the Debian way) - OpenVZ Wikiではdebian etchに含まれるカーネル2.6.18が前提になっているのでこれは使えないと判断し、自前でパッチを当ててビルドしようと思った。


探して見つけたpatch-ovz005.1-combined.gzをとってきて解凍して、パッチ当てを試みたがぜんぜんあたらなくて*.rejファイルが大量にできてしまった。記憶があやふやだけどこんな感じで実行した。



# cd /usr/src/download
# wget http://download.openvz.org/kernel/branches/2.6.22/2.6.22-ovz005.1/patches/patch-ovz005.1-combined.gz
# gunzip patch-ovz005.1-combined.gz
# cd /usr/src/build/stable-colinux-20080524
# patch -p1 < /usr/src/download/patch-ovz005.1-combined


http://download.openvz.org/kernel/branches/debian/etch/ とかを見てもバージョンが飛び飛びだし、OpenVZではdebianはメインターゲットではないのかもという印象を受けた。





ブログ アーカイブ