Difference between revisions of "util-vserver:Useful commands"

From Linux-VServer

Jump to: navigation, search
(Putting a virtual server in a spefified directory)
(Copying a virtual server and changing its address IP (deprecated): Add new versions of the commands)
Line 33: Line 33:
 
== Copying a virtual server and changing its address IP ==
 
== Copying a virtual server and changing its address IP ==
 
You should visit this section: [[Building Guest Systems]]
 
You should visit this section: [[Building Guest Systems]]
== Copying a virtual server and changing its address IP (deprecated)==
+
== Copying a virtual server and changing its address IP ==
 +
Copying a virtual server is done just like building a new vserver, but by using the <tt>clone</tt> method (for local copies) or <tt>rsync</tt> method (for remote copies).
 +
 
 +
For example, to create a new vserver <tt>web01</tt> that is a clone of the <tt>template</tt> vserver, run:
 +
 
 +
<pre>vserver web01 build -m clone --hostname web01.domain.com --interface dummy0:10.0.0.1/24 -- --source template</pre>
 +
 
 +
For copying <tt>web01</tt> from otherhost.domain.com, run:
 +
<pre>vserver web01 build -m clone --hostname web01.domain.com --interface dummy0:10.0.0.1/24 -- --source otherhost.domain.com:/var/lib/vservers/web01</pre>
 +
This rsync command is untested, but from looking at the script it should work like this.
 +
 
 +
These commands do not start or stop any running vservers, so you should do that manually before copying to ensure integrity.
 +
 
 +
 
 +
For reference, this used to be done with the <pre>vserver-copy</pre> command, which is now deprecated.
 
<pre>
 
<pre>
 
# vserver-copy --stopstart --ip newIP --domain newDomain nameOldServer nameNewServer
 
# vserver-copy --stopstart --ip newIP --domain newDomain nameOldServer nameNewServer

Revision as of 22:20, 7 August 2008

Contents

Starting a virtual server

You can start a virtual server with the following command:

# vserver <name> start

Where <name> is the name of the virtual server.

Coming into a virtual server

To enter into a virtual server execute this command:

# vserver <name> enter

To exit from a virtual server

To exit from a virtual server you only need to finish the Shell. For example typing:

# exit

or pressing "Ctrl + d"

In this way you can finish the virtual server Shell.

Stopping a virtual server

Use the following command:

# vserver <name> stop

Showing what virtual servers are running and some information about them

run this command:

$ vserver-stat

Copying a virtual server and changing its address IP

You should visit this section: Building Guest Systems

Copying a virtual server and changing its address IP

Copying a virtual server is done just like building a new vserver, but by using the clone method (for local copies) or rsync method (for remote copies).

For example, to create a new vserver web01 that is a clone of the template vserver, run:

vserver web01 build -m clone --hostname web01.domain.com --interface dummy0:10.0.0.1/24 -- --source template

For copying web01 from otherhost.domain.com, run:

vserver web01 build -m clone --hostname web01.domain.com --interface dummy0:10.0.0.1/24 -- --source otherhost.domain.com:/var/lib/vservers/web01

This rsync command is untested, but from looking at the script it should work like this.

These commands do not start or stop any running vservers, so you should do that manually before copying to ensure integrity.


For reference, this used to be done with the
vserver-copy
command, which is now deprecated.
# vserver-copy --stopstart --ip newIP --domain newDomain nameOldServer nameNewServer

where:

-s,--stopstart: stops  the virtual server before copying and start the new vserver afterwards.
                This really only makes sense if you are copying across root hosts and not changing
                names or IP addresses.

-i,--ip address: the new IP address when changing name. Overwrites /etc/hosts. Must be used with -d

-d,--domain domain: the new DNS domain when changing name. Overwrites /etc/hosts. Must be used with -i

You can see more information in "man vserver-copy"

Deleting a virtual server

# vserver <name> delete

Where <name> should be replaced by the name of virtual server.

Putting a virtual server in a specified directory

vserver <name> build ... --rootdir /path/to/vserver ...

Other useful commands

vserver-info: gives info about the vserver program itself

vtop: a top command that shows the top of *all* vservers

vpstree: a tree ps view of processes of all vservers

vps: a ps that shows processes of all vservers

Personal tools