Was this page helpful?

OpenVZ 管理

專有名詞定義

  • Hardware Node(HN):實際運行 openvz 服務的作業系統。
  • Container(CT)/Virtual Environment(VE)/Virtual Private Server (VPS):虛擬機環境。

HN指令集

  • 登入 container(無密碼,以 root 身份)
vzctl enter <CTID>
  • 啟動/關閉/重啟 container
vzctl start <CTID>
vzctl stop <CTID>
vzctl restart <CTID> 
  • 設定 container 參數
vzvtl set <CTID> --privvmpages 131072:135168 --save
或
vzvtl set <CTID> --privvmpages 512M:528M --save 
  • 列出所有 containers
vzlist -a

安裝 pre-created template

官方有提供一些已經做好的的作業系統(operating system template),包含有 centos, ubuntu, debian 等等。
下載位址:http://wiki.openvz.org/Download/template/precreated

cd /vz/template/cache/
wget http://download.openvz.org/template/precreated/centos-5-x86.tar.gz 

注意:

template 檔不用解壓縮。

新增&啟動 Container

WebVZ Admin > Containers > New Container

  • Owner of the container:Administrator <或者,新增新的用戶>
  • Operating system template:<選擇要安裝的作業系統 template>
  • Configuration file name:<選擇已經定義的系統設定檔>
  • Container ID:102 <自訂一組數字>
  • Name:ast16 <自訂 container 名稱>
  • IP Address:<IP 位址>
  • Hostname:<主機名稱>
  • Nameserver(DNS):<DNS 主機位址>
  • Enable booting on startup:no <是否在 openvz 服務啟動後自動開啟這 container>
  • Sart up the container after creating it:yes <是否在新增後,自動啟動 container>
  • Root password:<設定 root 密碼>

注意:

- owner of the container:之後可以修改。
- operating system template:之後不可修改
- configuration file name:之後不可更改,但仍可以修改個別的參數,例如 disk space, kernel memory size, etc..。
- container ID:之後不可修改
- name:之後可以修改。
- IP address, hostname, DNS, root password:之後可以修改。

- 建立新的 container 時,系統需要一段時間進行處理,約需 15-17 分。

Q&A

Q: 切換到 container 時發生錯誤:Unable to fork: Cannot allocate memory

A: 在 HN 執行指令檢查這個 container 是否需要調整參數

[root@openvz ~]# cat /proc/user_beancounters
Version: 2.5
       uid  resource           held    maxheld    barrier      limit    failcnt
      102:  kmemsize        2264829    4732901   14372700   14790164          0
            lockedpages           0          0       2048       2048          0
            privvmpages       65949      66587      65536      69632        548 <== 注意這行
            shmpages             16         16      21504      21504          0
            dummy                 0          0          0          0          0
            numproc              53        119        240        240          0
...
... 

- 檢查哪些參數有發生 failcnt,並且持需增加中,這表示需要調整該參數值。

- 執行指令調整時,只會修改 barrier 及 limit 的值。

- memory page size 為 4KB,包含 32/64 bit。

Was this page helpful?
標籤 (Edit tags)
  • No tags
您必須 登入 才能發佈評論。
Powered by MindTouch Core