Saturday, April 17, 2010

VPS admin tasks

vzctl set 10 --onboot yes --save
### Set IP for VPS ###
vzctl set 10 --ipadd 192.168.1.5 --save
### Set Nameservers IP for VPS ###
vzctl set 10 --nameserver 192.168.1.111 --save
vzctl set 10 --nameserver 192.168.1.111 --save
### Set Hostname IP for VPS ###
vzctl set 10 --hostname vps.nixcraft.in --save
### Set Disk quota for VPS (10G min [soft] and 11G max hard limit) ###
vzctl set 10 --diskspace 10G:11G --save
### Okat let start it ###
vzctl start 10
### Set root user password for VPS ###
vzctl exec 10 passwd
vzctl is used to create and set various vps properties such as memory, disk usage and much more. Where,

* create 10 : Your VPS ID.
* --ostemplate ubuntu-9.04-x86_64 : VPS template.
* --config vps.ubuntu: Save configuration.
* set 10 : Set various option for VPS ID # 10.
* --onboot yes : Make sure VPS boots automatically after a reboot.
* --save : Save changes to config file.

Common OpenVZ Admin Tasks

vzctl act as a master tool for various tasks:
How Do I Set VPS Name to vps.cyberciti.biz ?

# vzctl set 10 --hostname vps.cyberciti.biz --save
How Do I Set VPS IP Address?

# vzctl set 10 --ipadd 74.86.48.99 --save
How Do I Set VPS DNS Name Servers?

# vzctl set 10 --nameserver 10.0.1.11 --save
How Do I Set Disk Quota?

# vzctl set 10 --diskspace SoftLimitG:HardLimitG --save
# vzctl set 10 --diskspace 10G:12G --save
How Do I Stop / Start / Restart VPS Servers?

# vzctl start 10
# vzctl restart 10
# vzctl stop 10
How Do I Run a Command For VPS?

You can run command as follows
# vzctl exec 10 w
# vzctl exec 10 df
# vzctl exec 10 date
# vzctl exec 10 ps aux
How Do I Login Into VPS Server (container)?

Type the following command
# vzctl enter 10
To exit, simply type:
# exit
You can remotely login to your VPS using a ssh client itself or using putty:
$ ssh user@your-vps.example.com
How Do I Destroy VPS?

Type the following command to delete VPS:
# vzctl destroy 10
Another Example: Creating a CentOS Linux VPS

Download CentOS 64 bit template:
# cd /vz/template/cache
# wget http://download.openvz.org/template/precreated/centos-5-x86_64.tar.gz
Create a VPS and set various limits (see vzctl man page):
# vzctl create 11 --ostemplate centos-5-x86_64
# vzctl set 11 --quotaugidlimit 150 --numproc 400:400 \
--kmemsize 16384000:18022400 --privvmpages 262144:292912 \
--hostname=forums.nixcraft.com --diskspace 2000000:2000000 \
--shmpages 16384:16384 --ipadd 75.126.168.152 \
--nameserver 10.0.1.11 --nameserver 10.0.1.12 --save
# vzctl set 11 --onboot yes --save
Set the password for vps root user:
# vzctl set 11 --userpasswd root:pass
Start VPS:
# vzctl start 11
Enter into VPS:
# vzctl enter 11
Now you can install additional software and configure your vps:
[vps #] yum update
[vps #] yum install httpd

No comments:

Post a Comment