Home | Mirror | Search

第 31 章 OpenVZ

目錄

1. 安裝OpenVZ
2. 使用OpenVZ & 建立VPS
2.1. 安裝操作系統模板
2.2. 創建OpenVZ操作系統節點(VPS)
3. 設置VPS參數

1. 安裝OpenVZ

過程 31.1. OpenVZ 安裝步驟

  1. 獲得OpenVZ yum安裝源

    # cd /etc/yum.repos.d
    # wget http://download.openvz.org/openvz.repo
    # rpm --import  http://download.openvz.org/RPM-GPG-Key-OpenVZ
    				
  2. 安裝OpenVZ核心以及標頭檔

    # yum install ovzkernel[-flavor]
    				
  3. 修改啟動所使用的內核為OpenVZ內核,使OpenVZ內核為預設啟動內核

    # vim /etc/grub.conf
    				

    將類似下面的內容

    title Fedora Core (2.6.8-022stab029.1)
           root (hd0,0)
           kernel /vmlinuz-2.6.8-022stab029.1 ro root=/dev/sda5 quiet rhgb vga=0x31B
           initrd /initrd-2.6.8-022stab029.1.img
    				

    修改為類似這樣

    title OpenVZ (2.6.8-022stab029.1)
            root (hd0,0)
            kernel /vmlinuz-2.6.8-022stab029.1 ro root=/dev/sda5
            initrd /initrd-2.6.8-022stab029.1.img
    				

    或直接在裡面尋找類似開頭為

    title CentOS (2.6.18-194.3.1.el5.028stab069.6)
    
    				

    的項目,並且把default改為他的下標,下標從0開始

  4. 修改LINUX網絡配置檔案

    /etc/sysctl.conf
    # On Hardware Node we generally need
    # packet forwarding enabled and proxy arp disabled
    net.ipv4.ip_forward = 1 #修改
    
    net.ipv6.conf.default.forwarding = 1 #添加
    net.ipv6.conf.all.forwarding = 1 #添加
    net.ipv4.conf.default.proxy_arp = 0 #添加
    
    # Enables source route verification
    net.ipv4.conf.all.rp_filter = 1 #修改
    
    # Enables the magic-sysrq key
    kernel.sysrq = 1 #修改
    
    # We do not want all our interfaces to send redirects
    net.ipv4.conf.default.send_redirects = 1 #添加
    net.ipv4.conf.all.send_redirects = 0 #添加
    				
  5. 關閉SELinux

    # lokkit --selinux=disabled
    				
    SELINUX=disabled
    				
  6. 重啟LINUX

    # reboot
    				
  7. 安裝OpenVZ管理工具

    # yum install vzctl
    # yum install vzquota
    # yum install vzyum
    				

    用到什麼工具就安裝什麼工具,具體可以使用# yum search vz*搜索一下

  8. 啟動OpenVZ服務

    # /sbin/service vz start
    				
comments powered by Disqus