I. Quản lý Container: Tạo mới Container với OS template là fedora-core-
86 sử dụng cấu hình lấy từ file ct-basic.conf-sample
Code:
# vzctl create 101 --ostemplate fedora-core-8-x86 -–config basic
Thiết đặt thông số mạng cho Container Code:
# vzctl set 101 --hostname test101.swsoft.com --save --> đặt Hostname cho Container
Code:
# vzctl set 101 --ipadd 10.0.186.1 --save --> đặt địa chỉ IP cho Container
Code:
# vzctl set 101 --nameserver 192.168.1.165 --save --> đặt DNS cho Container
Code:
# vzctl exec 101 service sshd status --> Kiểm tra trạng thái của dịch vụ SSH
Đặt password cho tài khoản root của container
Code:
# vzctl start 101 --> Khởi động Container 101
[This command starts Container 101, if it is not started yet]
# vzctl set 101 --userpasswd root:test --> đặt password là "test" cho root
Khởi động, tắt, khởi động lại và kiểm tra tình trạng container Code:
# vzctl start 101 --> Khởi động Container 101
Starting Container ...
Setup slm memory limit
Setup slm subgroup (default)
Setting devperms 20002 dev 0x7d0
Adding port redirection to Conta
Adding IP address(es) to pool:
Adding IP address(es): 10.14.14.
Hostname for Container set: loca
Container start in progress...
Code:
# vzctl status 101 --> Xem tình trạng hiện tại của Container 101
CTID 101 exists mounted running
Code:
# vzlist 101 --> liệt kê thông tin về Container 101
CTID NPROC STATUS IP_ADDR HOSTNAME
101 20 running 10.0.186.101 test.swsoft.com
Code:
# vzctl stop 101 --> tạm dừng Container 101
Stopping Container ...
Container was stopped
Container is unmounted
Code:
# vzctl restart 101 --> khởi động lại Container 101
Stopping Container ...
Container was stopped
Container is unmounted
Starting Container ...
...
Container start in progress...
Liệt kê danh sách các Container Code:
# vzlist -a --> Liệt kê danh sách các container hiện có trên hệ thống
CTID NPROC STATUS IP_ADDR HOSTNAME
1 35 running 10.101.60.79 localhost
101 8 running 10.101.66.1 ct101.swsoft.com
102 7 running 10.101.66.159 ct102.swsoft.com
103 - stopped 10.101.66.103 ct103.swsoft.com
Xóa Container Code:
# vzctl stop 101 --> tắt Container 101
Stopping Container ...
Container was stopped
Container is unmounted
# vzctl delete 101 --> xóa Container 101
Deleting Container private area: /vz/private/101
Container private area was deleted
II/ Quản lý Application Cài đặt Application Template trên Harware Node Code:
# vzpkg install template mysql-fedora-core-8-x86-tmpl-4.0.0-2.swsoft.rpm --> cài đặt template MySQL cho Hardware Node
Preparing... ############################# [100%]
1:mysql-fedora-core-8-x86 ############################# [100%]
Thêm Application cho Container Code:
# vzpkg install 101 mysql --> Cài MySQL cho container 101
...
Installed:
mysql i386 0:4.1.12-3.FC8.1
mysql-bench i386 0:4.1.12-3.FC8.1
mysql-devel i386 0:4.1.12-3.FC8.1
Xem danh sách các template đã được cài đặt trên Hardware Node Code:
# vzpkg list
fedora-core-6-x86
fedora-core-6-x86 mysql
Xem danh sách các template đã được cài đặt trên Container Code:
# vzpkg list 101
fedora-core-8-x86 2007-05-21 02:21:56
fedora-core-8-x86 mysql 2007-05-21 05:36:42
Gỡ bỏ ứng dụng khỏi Container Code:
# vzpkg remove 101 mysql --with -> Gỡ bỏ MySQL khỏi Container 101
vzpkg remove 101 mysql
Removed:
mysql
mysql-server
mysql-devel
mysql-bench
perl-DBD-MySQL
Bài viết cùng chủ đề: