[root@localhost cache]# cd /etc/vz/conf
[root@localhost conf]# ls
0.conf
102.conf
ve-light.conf-sample
ve-vswap-1024m.conf-sample
ve-vswap-256m.conf-sample
ve-vswap-4g.conf-sample
101.conf
ve-basic.conf-sample
ve-unlimited.conf-sample
ve-vswap-1g.conf-sample
ve-vswap-2g.conf-sample
ve-vswap-512m.conf-sample
[root@localhost conf]# vzctl create 103 --ostemplate centos-6-x86_64 --config ve-basic.conf-sample
Sample config /etc/vz/conf/ve-ve-basic.conf-sample.conf-sample not found: No such file or directory
Creation of container private area failed //incorrect systax
[root@localhost conf]# vzctl create 103 --ostemplate centos-6-x86_64 --config basic
Creating container private area (centos-6-x86_64)
Performing postcreate actions
CT configuration saved to /etc/vz/conf/103.conf
Container private area was created
[root@localhost conf]# vzlist -a
CTID NPROC STATUS IP_ADDR HOSTNAME
101 - stopped 192.168.140.10 test-container
102 - stopped 192.168.140.10 test-container
103 - stopped - - ////new container just created
[root@localhost conf]# vzlist -a
CTID NPROC STATUS IP_ADDR HOSTNAME
101 - stopped 192.168.140.10 test-container
102 - stopped 192.168.140.10 test-container
103 - stopped - centos-test-nepal
[root@localhost conf]# ####Setting hostname and ip address
[root@localhost conf]# vzctl set 103 --ipadd 192.168.140.11 --save
CT configuration saved to /etc/vz/conf/103.conf
[root@localhost conf]# vzctl set 103 --nameserver 8.8.8.8 --save
CT configuration saved to /etc/vz/conf/103.conf
To set disk space, run the following commands:
Example:
[root@localhost conf]# ls
0.conf
102.conf
ve-light.conf-sample
ve-vswap-1024m.conf-sample
ve-vswap-256m.conf-sample
ve-vswap-4g.conf-sample
101.conf
ve-basic.conf-sample
ve-unlimited.conf-sample
ve-vswap-1g.conf-sample
ve-vswap-2g.conf-sample
ve-vswap-512m.conf-sample
[root@localhost conf]# vzctl create 103 --ostemplate centos-6-x86_64 --config ve-basic.conf-sample
Sample config /etc/vz/conf/ve-ve-basic.conf-sample.conf-sample not found: No such file or directory
Creation of container private area failed //incorrect systax
[root@localhost conf]# vzctl create 103 --ostemplate centos-6-x86_64 --config basic
Creating container private area (centos-6-x86_64)
Performing postcreate actions
CT configuration saved to /etc/vz/conf/103.conf
Container private area was created
[root@localhost conf]# vzlist -a
CTID NPROC STATUS IP_ADDR HOSTNAME
101 - stopped 192.168.140.10 test-container
102 - stopped 192.168.140.10 test-container
103 - stopped - - ////new container just created
Setting hostname of container
[root@localhost conf]# vzctl set 103 --hostname centos-test-nepal --save
CT configuration saved to /etc/vz/conf/103.conf[root@localhost conf]# vzlist -a
CTID NPROC STATUS IP_ADDR HOSTNAME
101 - stopped 192.168.140.10 test-container
102 - stopped 192.168.140.10 test-container
103 - stopped - centos-test-nepal
[root@localhost conf]# ####Setting hostname and ip address
[root@localhost conf]# vzctl set 103 --ipadd 192.168.140.11 --save
CT configuration saved to /etc/vz/conf/103.conf
[root@localhost conf]# vzctl set 103 --nameserver 8.8.8.8 --save
CT configuration saved to /etc/vz/conf/103.conf
To set disk space, run the following commands:
vzctl set CTID --diskspace $SoftLimit$:$HardLimit$ --save
Example:
[host-node]# vzctl set 101 --diskspace 6G:7G --saveYou could verify the space available with this command (ie : CTID =101)
[host-node]# vzctl exec 101 df -hIf you want remove disk quota:
DISK_QUOTA=noThis is also possible via this option:
DISKSPACE="unlimited"
Listing Containers [root@localhost sysconfig]# vzlist -a
CTID NPROC STATUS IP_ADDR HOSTNAME
101 - stopped 192.168.140.10 test-container
IDs, the
number of
running processes inside VPSs, their status,
IPaddresses, and hostnames. This output maybe
customized asdesired by using vzlistcommand line
switches. For example:
# vzlist -o veid,diskinodes.s -s diskinodes.s
VPSID DQINODES.S
1 400000
101 200000
102 200000
Checking the status of CTID 101
[root@localhost conf]# vzctl destroy 102
Destroying container private area: /vz/private/102
Container private area was destroyed
Container private area was destroyed
A runningVPS cannot be destroyedwiththe vzctl destroycommand.
# vzctl stop 101
Stopping VPS ...
VPS was stopped
VPS is unmounted
# vzctl destroy 101
Destroying VPS private area: /vz/private/101
VPS private area was destroyed
# ls /etc/sysconfig/vz-scripts/101.*
/etc/sysconfig/vz-scripts/101.conf.destroyed
/etc/sysconfig/vz-scripts/101.mount.destroyed
/etc/sysconfig/vz-scripts/101.umount.destroyed
# vzctl status 101
VPS 101 deleted unmounted down
If youdonot need the backup copyofthe VPS configurationfiles (with the .destroyed
suffix), you may delete them manually.
Stopping VPS ...
VPS was stopped
VPS is unmounted
# vzctl destroy 101
Destroying VPS private area: /vz/private/101
VPS private area was destroyed
# ls /etc/sysconfig/vz-scripts/101.*
/etc/sysconfig/vz-scripts/101.conf.destroyed
/etc/sysconfig/vz-scripts/101.mount.destroyed
/etc/sysconfig/vz-scripts/101.umount.destroyed
# vzctl status 101
VPS 101 deleted unmounted down
If youdonot need the backup copyofthe VPS configurationfiles (with the .destroyed
suffix), you may delete them manually.
OpenVZ allows you to execute commands in a Virtual Private Server in these cases.Use the
vzctl exec VPS_IDcommand for running a command insidethe VPS with the given ID.
The session below illustrates the situation when SSH daemon is not started:
# vzctl exec 101 /etc/init.d/sshd status
sshd is stopped
# vzctl exec 101 /etc/init.d/sshd start
Starting sshd:[ OK ]
# vzctl exec 101 /etc/init.d/sshd status
sshd (pid 26187) is running...
Now VPS users can log in to the VPS via SSH.
vzctl exec VPS_IDcommand for running a command insidethe VPS with the given ID.
The session below illustrates the situation when SSH daemon is not started:
# vzctl exec 101 /etc/init.d/sshd status
sshd is stopped
# vzctl exec 101 /etc/init.d/sshd start
Starting sshd:[ OK ]
# vzctl exec 101 /etc/init.d/sshd status
sshd (pid 26187) is running...
Now VPS users can log in to the VPS via SSH.
No comments:
Post a Comment