ស្វែងយល់ពី OpenVZ Container

OpenVZ Container ជាប្រភេទ Virtualization ដែលអាចអោយយើងបង្កើត Container ជាច្រើនប្រើប្រាស់ដោយពឹងផ្អែកលើ Kernel របស់ Host Server។ អ្នកអាច Restart Container, update, install update និងប្រើប្រាស់ root user របស់ container បានដោយមិនប៉ះពាល់ដល់ Host Server នោះទេ។

ខាងក្រោមនេះជាការតម្លើងនិងប្រើប្រាស់ OpenVZ នៅលើ លីនុច CentOS 6

ដំបូងអ្នកត្រូវដោនឡូត Repository file យកមកដាក់នៅក្នុងលីនុចរបស់អ្នកសិន

wget -P /etc/yum.repos.d/ http://ftp.openvz.org/openvz.repo

បន្ទាប់មកទៀតអ្នកអាច import key ពី OpenVZ Repository បានដោយធ្វើដូចខាងក្រោមនេះ

rpm –import http://ftp.openvz.org/RPM-GPG-Key-OpenVZ

បន្ទាប់មកអ្នកត្រូវដោនឡូត OpenVZ Kernel មកប្រើប្រាស់

yum  install  vzkernel

installvzkernel

បន្ទាប់មកទៀតអ្នកត្រូវ ចូលទៅកែ file /etc/sysctl.conf និងសរសេរបន្ថែមដូចខាងក្រោមនេះ

net.ipv4.ip_forward = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1
net.ipv4.conf.default.proxy_arp = 0

net.ipv4.conf.all.rp_filter = 1

kernel.sysrq = 1

net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0

បន្ទាប់មកទៀតអ្នកត្រូវតម្លើង Package OpenVZ ដូចខាងក្រោមនេះ 
yum install vzctl vzquota ploop

បន្ទាប់ពីតម្លើងរួចហើយអ្នកអាច Reboot Server របស់អ្នក ដែលពេលនេះលីនុច Server របស់អ្នកប្រើប្រាស់ Kernel របស់ OpenVZ ជំនួសKernel ចាស់
បន្ទាប់មកទៀតអ្នកអាចចូលទៅកែ file /etc/vz/vz.conf 
neighbordev
បន្ទាប់មកអ្នកអាចប្រើប្រាស់ Command ដើម្បីដោនឡូត Template យកមកប្រើប្រាស់បានហើយ
openvz-template

ចុងក្រោយអ្នកអាចប្រើប្រាស់ Template ដើម្បីបង្កើត ជា Container ប្រើប្រាស់
Container ID: 120
OS: Centos 6
Hostname: myvps.techfree.info
IP Address: 192.168.153.133
Nameserver: 8.8.8.8 
Total CPUs: 1
RAM: 1GB
Disk space: 6GB
SWAP (vswap): 1GB

ដើម្បីបាន Container ដូចខាងលើនេះអ្នកត្រូវសរសេរ Command ដូចខាងក្រោមនេះ Server និងដោនឡូត Template មកដោយខ្លួនឯង
# vzctl create 120 --ostemplate centos-6-x86_64
# vzctl set 120 --onboot yes --save
# vzctl set 120 --hostname myvps.techfree.info --save
# vzctl set 120 --ipadd 192.168.153.133 --save
# vzctl set 120 --nameserver 8.8.8.8  --save
# vzctl set 120 --cpus 1 --save
# vzctl set 120 --ram 1G --save
# vzctl set 120 --diskspace 6G --save
# vzctl set 120 --swap 1G --save
# vzctl start 120
vzctl

បន្ទាប់មកទៀតអ្នកត្រូវដាក់ password root សម្រាប់ Container ថ្មី លេខ ១២០នេះដោយប្រើប្រាស់ Command ដូចខាងក្រោមនេះ 
vzctl exec 110 passwd

បន្ទាប់មកអ្នកអាចចូលទៅប្រើប្រាស់ container បានដោយគ្រាន់តែប្រើប្រាស់ command 
vzctl enter 120 
បន្ទាប់មកអ្នកអាចចាត់ចែង update package ផ្សេងៗក្នុង container បានហើយ 
vzctltest