忍者ブログ
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

VEを1つ作成する

# vzctl create 101 --ostemplate centos-6-x86

IPアドレスをつける(ネットマスク /24 を忘れないように)
# vzctl set 101 --ipadd 192.168.5.10/24 --save

nameserverを設定する
# vzctl set 101 --nameserver 192.168.5.1 --save

VE101を起動させる
# vzctl start 101

VE101に入る
# vzctl enter 101

rootパスワードを変更、ユーザを1人作成
sshdが起動していること、pingで外に出られることを確認したらWindows端末からsshでログイン。
これで仮想環境ができあがった。

VE101の現状はこんな感じ
# free
                     total             used           free     shared    buffers     cached
Mem:       262144         136004     126140              0             0     110172
-/+ buffers/cache:            25832     236312
Swap:       524288                  0      524288

# df
Filesystem           1K-blocks      Used   Available  Use%  Mounted on
/dev/simfs             2097152    615896   1481256    30%    /
none                       131072              4      131068     1%    /dev

メモリーサイズを設定する場合は二つのパラメーターを設定する

例えば
・保障されるサイズ:128メガ
・最大サイズ:256メガ

とするなら

それぞれの数値に*256します。(サイズに関わらず*256でいいです)
128*256=32768
256*256=65536

そして

# vzctl set 101 --vmguarpages 32768 --save  保障されるサイズ
# vzctl set 101 --privvmpages 65536 --save  最大サイズ

その後VEをリスタート。
# vzctl restart 101

これでメモリの設定が反映。
# free
                     total         used          free     shared    buffers     cached
Mem:        262144      21136     241008             0             0      10420
-/+ buffers/cache:       10716     251428
Swap:       524288              0     524288

設定値は・etc/vz/conf/101.confに書き込まれている
#cat /etc/vz/conf/101.conf

PRIVVMPAGES="65536:65536"
VMGUARPAGES="32768:32768"

ディスク容量(クォータ)の変更

現在の容量を確認
#vzctl exec 101 df -h

# df
Filesystem           1K-blocks      Used   Available   Use%  Mounted on
/dev/simfs             2097152    610112   1487040     30%   /
none                       131072              4     131068       1%   /dev

ディスククォータの書式は

vzctl set CTID --diskspace $SoftLimit$:$HardLimit$ --save

なので

softlimitを8G
hardlimitを10G
とするなら

#vzctl set 101 --diskspace 8G:10G --save

これはVEリブートしなくても設定が反映されるようだ。
# df
Filesystem           1K-blocks      Used    Available  Use%  Mounted on
/dev/simfs             8388608    610112   7778496      8%    /
none                       131072              4     131068      1%    /dev

CPUリソースの割り当て

CPU使用率を以下二つのパラメーターで定義する。
cpuunits:最低保障されるリソース
cpulimit:最大リソース

現在の使用率を確認
# vzcpucheck
Current CPU utilization: 2000
Power of the node: 182865

cpuunitsを5%
cpulimitを10%としたい場合は
182865*0.05=9143.25 なので
9000を割り当てる。

# vzctl set 101 --cpuunits 9000 --cpulimit 10 --save
Setting CPU limit: 10
Setting CPU units: 9000
CT configuration saved to /etc/vz/conf/101.conf


ここまでの101.confはこんな感じ。

# cat /etc/vz/conf/101.conf

#  Copyright (C) 2000-2011, Parallels, Inc. All rights reserved.
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

# This config is only valid for decent VSwap-enabled kernel
# (version 042stab042 or later).

# RAM
PHYSPAGES="0:256M"

# Swap
SWAPPAGES="0:512M"

# Disk quota parameters (in form of softlimit:hardlimit)
DISKSPACE="8388608:10485760"
DISKINODES="200000:220000"
QUOTATIME="0"

# CPU fair scheduler parameter
CPUUNITS="9000"
VE_ROOT="/vz/root/$VEID"
VE_PRIVATE="/vz/private/$VEID"
OSTEMPLATE="centos-6-x86"
ORIGIN_SAMPLE="vswap-256m"
IP_ADDRESS="192.168.1.41/24"
NAMESERVER="192.168.1.1"
VMGUARPAGES="32768"
PRIVVMPAGES="65536"
CPULIMIT="10"

 

PR
この記事にコメントする
お名前
タイトル
文字色
メールアドレス
URL
コメント
パスワード   Vodafone絵文字 i-mode絵文字 Ezweb絵文字
カレンダー
08 2024/09 10
S M T W T F S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
ブログ内検索
checkinstallをインストール  HOME  OpenVZのインストールと設定

material:web*citron  template:ゆずろぐ

忍者ブログ [PR]