CREATE AND MANAGE VPS:
-------------------------------------------
Before creating VPS you need to download desired pre-created templates (those are in .tar.gz format) and store it under "/vz/template/cache". But don't untar/extract them. You can download templates here - http://download.openvz.org/template/precreated.
DOWNLOAD TEMPLATES
]# cd /vz/template/cache
]# wget http://download.openvz.org/template/precreated/ubuntu-9.04-x86.tar.gz
]# wget http://download.openvz.org/template/precreated/centos-6-x86.tar.gz
CHECK AVAILABLE PRECREATED OSTEMPLATES:
]# vzpkgls
ubuntu-9.04-x86
centos-6-x86
NOTE: It will get this information from /vz/template/cache directory. Lists all templates without .tar.gz extension.
DETERMINE VPS ID:
VPS is managed by only ID, hence you need to follow simple guidliness regarding this.The ID is a 32-bit integer number beginning with zero and unique for a given Hardware Node. OpenVZ reserves the IDs ranging from 0 to 100. Though OpenVZ uses only ID 0, different versions might use additional Virtual Private Servers IDs for internal needs.
The only strict requirement for a VPS ID is to be unique for a particular Hardware Node.For example, on Hardware Node 1 you create
Virtual Private Servers within the range of IDs from 101 to 1000; on Hardware Node 2 you use the range from 1001 to 2000, and so on. This approach makes it easier to remember on which Hardware Node a Virtual Private Server has been created, and eliminates the possibility of VPS
ID conflicts when a Virtual Private Server migrates from one Hardware Node to another.
Note, Before determining VPS ID make sure that there is no VPS exists having same ID. You may use command -
]# vzlist -a 101
Container(s) Not Found
CREATE VPS AND SET PARAMETERS:
]# vzctl create 101 --ostemplate centos-6-x86 --config basic
Structure of container is, The private area is the directory containing the actual files of the given Container; it is usually residing in /vz/private/CTID/. The private area is mounted to the /vz/root/CTID directory on the Hardware Node and provides Container users with a complete Linux file system tree.
The option --config sets parameters for VPS from sample configuration files located under "/etc/sysconfig/vz-scripts/". These file names are like, ve-basic.conf-sample, ve-unlimited.conf-sample. You need to specify the file name portion between '-' and '.' with --config option. You can create and use sample configuration files according to your need.
If you don't specify --ostemplate and --config options, then it will use default settings from globle configuration file "/etc/sysconfig/vz". You may customize this file by editing options CONFIGFILE="basic" and DEF_OSTEMPLATE="centos-5".
]# vzctl set 101 --onboot yes --save OR ]# vzctl set 101 --onboot no --save
]# vzctl set 101 --ipadd 202.52.134.143 --save
]# vzctl set 101 --hostname test.rootuser.in --save
]# vzctl set 101 --nameserver 202.52.134.254 --nameserver 8.8.8.8 --save
MEMORY(RAM)LIMIT:
]# vzctl set 101 --ram 1G --save AND ]# vzctl set 101 --swap 1G --save (--ram <bytes>[KMG] | --swap <bytes>[KMG])
OR
]# vzctl set 101 --vmguarpages 1536M --save (Dedicated)
]# vzctl set 101 --oomguarpages 1536M --save
]# vzctl set 101 --privvmpages 1536M:2048M --save (Burstable)
HDD(Disk)LIMIT:
]# vzctl set 101 --diskspace 45G:50G --save
]# vzctl set 101 --diskinodes 471859:524288 --save
Disk inodes must be at least 1% of actual disk space. Eg, Firstly convert disk space from GB/MB to KB.
Here, 45 GB = 47185920 KB & 50 GB = 52428800 KB. So disk inodes will be 471859:524288.
CPU/CPU UNITS & CPU LIMIT (CPU OR cupunits+cpulimit)
Example:
If you have a 1 Quad Core CPU at 2.0 ghz
The Max CPU Limit (%) would be 400
The Max Number of CPU's would 4
ie. 1 core is max 100% and 4 cores is max 400%
Case:
CPU Units = 4
CPU Limit (%) = 200
The customer will see 4 cores at 1.0ghz each.
OR simple use below trick.
As we have a 1 Quad Core CPU at 2.0 ghz, We can calculate CPU power into Percentage (100%) as below,
]# vzcpucheck
Current CPU utilization: 5000 <-- CPU utilized by HW node including all VPS.
Power of the node: 479997 <-- HW nodes' max CPU power.
If I want to assign 25% of my Quad Core CPU to VPS ID 101, then 1% of actual CPU will be [(479997*1)/100] = 4799.97. So 1 cpuunits will be 4799.97. Simillarly 25% of CPU would be around 119999. In the following example, Container 101 is guaranteed to receive about 25% of the CPU time even if the Hardware Node is fully used. Besides, CT 101 will not receive more than 30% of the CPU time even if the CPU is not fully loaded.
]# vzctl set 101 --cpuunits 119999 --cpulimit 30 --save
In other words, 25% = 1 CPU core. Hence we can also use below command -
]# vzctl set 101 --cpus 1 --save
In above example, We configuring 1 CPU inside container. Option --cpus sets number of CPUs available in the container.
]# vzctl start 101
]# vzctl set 101 --userpasswd root:CentOS_06 OR ]# vzctl exec 101 passwd
]# vzctl set 101 --name computer1 --save (Its an alternate name for CID.)
]# vzlist -o name 101
]# vzctl set 101 --description "Owner - L Johnson ; Purpose - Email ; Providers - Hostin Services" --save
]# vzlist -o description 101
MANAGE CONTAINER STATUS:
]# vzctl start 101
]# vzctl stop 101
]# vzctl restart 101
]# vzctl status 101
VIEW CONTAINERS:
]# vzlist -a <CID>
]# vzlist [Display live/running/online containers]
]# vzlist -a [Display all online/offline containers]
RUN A COMMAND FOR VPS FROM HARDWARE NODE:
]# vzctl exec 101 service sshd start
]# vzctl exec 101 chkconfig sshd on
]# vzctl exec 101 date
]# vzctl exec 101 hostname
]# vzctl exec 101 ifconfig
ACCESSING VPS FROM HARDWARE NODE:
]# vzctl enter 101
vps~]# exit
You can access VPS remotely from Linux or windows machine. You may use ssh from Linux and Putty 3rd party tool from windows machine.
DELETE VPS:
]# vzctl stop 101
]# vzctl destroy 101
]# cd /etc/sysconfig/vz-scripts/
]# ls 101.* [You will find files 101.conf.destroyed, 101.mount.destroyed and 101.umount.destroyed]
]# rm -rf 101.*
DETERMINE VPS ID FROM PROCESS:
]# top OR ]# ps -auxf
]# vzpid <PID>
VALIDATING VIRTUAL PRIVATE SERVER CONFIGURATION:
[Manual Method]
]# vzcfgvalidate /etc/sysconfig/vz-scripts/101.conf
Error: kmemsize.bar should be > 1835008 (currently, 25000)
Recommendation: dgramrcvbuf.bar should be > 132096 (currently, 65536)
Recommendation: othersockbuf.bar should be > 132096 (currently,122880)
]# vzctl set 101 --kmemsize 2211840:2359296 --save
]# vzcfgvalidate /etc/sysconfig/vz-scripts/101.conf
Recommendation: kmemsize.lim-kmemsize.bar should be > 163840 (currently, 147456)
Recommendation: dgramrcvbuf.bar should be > 132096 (currently, 65536)
Recommendation: othersockbuf.bar should ba > 132096 (currently,122880)
Validation completed: success
[Auto validate Method]
]# vzcfgvalidate -r|-i
DISABLE CONTAINER:
There may appear situations when you wish to forbid Container owners to use their Containers. For example, it may happen in case the Container owner uses it for unallowed purposes: intruding into computers of other users, participating in DoS attacks, etc. In such cases, the OpenVZ software allows you to disable a Container, thus, making it impossible to start the Container once it was stopped. For example, you can execute the following command to disable Container 101 residing on your Hardware Node:
]# vzctl set 101 --disabled yes --save OR ]# vzctl set 101 --disabled no --save
After the Container stopping, the Container user will not be able to start it again until you enable this Container again by passing the --disabled no option to vzctl set. You can also use the --force option to start any disabled Container. For example:
]# vzctl start 101 --force
NOTE: I make use of --disabled option, when I migrated vps from one node to another. but one copy of migrated vps was on the source node, so another admin's (or after hw reboot they) can't start automatically.
SUSPEND CONTAINER:
OpenVZ allows you to suspend any running Container on the Hardware Node by saving its current state to a special dump file. Later on, you can resume the Container and get it in the same state the Container was at the time of its suspending. During the command execution, the /vz/dump/Dump.101 file containing the entire state of Container 101 is created and the Container itself is stopped.
]# vzctl chkpnt 101
At any time, you can resume Container 101 by executing the following command -
]# vzctl restore 101
The Container state is restored from the /vz/dump/Dump.101 file on the Node. Upon the restoration completion, any applications that were running inside Container 101 at the time of its suspending will be running and the information content will be the same as it was when the Container was suspended.
REMOVE VPS IP ADDRESS:
]# vzctl set 101 –ipdel 202.52.134.123 --save
IMP FILES:
/var/log/vzctl.log
/etc/sysconfig/vz
/etc/sysconfig/vz-scripts/vpsid.conf
/etc/sysconfig/vz-scripts/ve-name.conf-sample
/etc/sysctl.conf
/etc/cron.d/vpsreboot
/vz/dump/
/vz/templates/cache
OTHER IMP PARAMETERS (Remaning to learn):
avnumproc : The average number of processes and threads.
numproc : The maximal number of processes and threads the VPS may create.
numtcpsock : The max number of TCP sockets.
numothersock: The max number of sockets other than TCP ones. Like UDP, etc.
thats it...
1 comment:
Borgata Hotel Casino & Spa - Mapyro
The Borgata 진주 출장안마 Hotel Casino & Spa 김해 출장마사지 is a popular American-style 아산 출장샵 resort 1xbet korean located in Atlantic City, New Jersey. The resort 전라남도 출장샵 features 1,002 rooms, with 69 suites
Post a Comment