http://linux-vserver.org/api.php?action=feedcontributions&user=68.167.189.55&feedformat=atomLinux-VServer - User contributions [en]2024-03-28T11:02:14ZUser contributionsMediaWiki 1.20.2http://linux-vserver.org/Fail-overFail-over2007-03-02T06:58:36Z<p>68.167.189.55: /* Active Vserver Failover */</p>
<hr />
<div>=== Active VServer Failover ===<br />
<br />
To perform active vserver failover without user intervention from one host to another you may use heartbeat. To do this, you must first have a mechanism to actively replicate your veserver filesystem and configuration from one host to another. This mechanism must be able to provide a consistent filesystem view to either host on demand (but not neccessarily at the same time). In other words you may use something like NFS, a clustered filesystem like OCFS2 or GFS, or a network replicated block device like drbd, but you cannot use something like rsync, scp or ftp.<br />
<br />
===== Organizing your VServer Directories =====<br />
<br />
Once you have an active replication method, you will likely need to organize your vserver files to be on the same device/filesystem so that you only need one replicated device/filesystem and do not need a separate one just for your vserver configuration files. One way to do this would be to use a ''/vservers'' mount point and to have a subdirectory for each vserver in there: ''/vservers/<server-name>''. If you want to put both the ''/var'' and ''/etc'' sections of your vserver in the vserver's subdirectory and soft link to them you may be tempted to try this arrangement:<br />
<br />
/vservers/<server-name>/etc<br />
/vservers/<server-name>/var<br />
<br />
/etc/vservers/<server-name> -> /vservers/<server-name>/etc<br />
/var/lib/vservers/<server-name> -> /vservers/<server-name>/var<br />
<br />
But if you do this and you enable the util-vserver init script, you are likely to run into a chroot barrier problem. Since this init script sets a chroot barrier on all vservers' var directory's parent you will see something like this error message:<br />
<br />
vlimit: fstat("/etc/vservers/<server-name>/rlimits"): Permission denied<br />
<br />
One workaround to this is to simply put the vserver's var directory into a subdirectory of the vserver's combined directory like this:<br />
<br />
/vservers/<server-name>/barrier/var<br />
/var/lib/vservers/<server-name> -> /vservers/<server-name>/barrier/var<br />
<br />
With this arrangement you could replicate the entire /vservers directory to all hosts and you will than be able to run the vserver anywhere the /vservers directory is replicated.<br />
<br />
===== FileSystem Fail Over =====<br />
<br />
Finally, you will need a mechanism to start and stop your vservers on the appropriate hosts. This is where heartbeat comes in. If you do not have a permanently mounted filesystem on each node, because maybe you are using a regular filesystem on top of a non-shared block device such as drbd, you will need to configure heartbeat to first provide the ''/vservers'' file system on the node which is going to be the active host.<br />
<br />
===== Multiple Vservers and Devices with DRBD 7 =====<br />
<br />
If you have multiple Vservers which you want to be able to fail over independently from one host to another with drbd 7 you might have a hard time doing this with heartbeat. The drbd agent distributed with heartbeat tends to be focused on drbd 8, if you are using drbd 7 you are expected to be using heartbeat 1 which does not use ocf agents and does provide support for multiple independent drbd devices. Instead, you may try this custom [http://www.theficks.name/bin/lib/ocf/drbd drbd ocf agent]. Here is a sample heartbeat configuration for use with this agent:<br />
<br />
<primitive id="vserver_foo_drbd" class="ocf" provider="bar" type="drbd"><br />
<instance_attributes id="vserver_foo_drbd_ia"><br />
<attributes><br />
<nvpair id="vserver_foo_drbd_resource" name="drbd_resource" value="vs_foo"/><br />
</attributes><br />
</instance_attributes><br />
</primitive><br />
<br />
===== OCF Provider =====<br />
<br />
The ''ocf provider'' is simply a fancy term for the directory name under ''/usr/lib/ocf/resource.d/'' where you place your ocf agent (script). The ocf agents distributed with heartbeat are in the heartbeat subdirectory and therefor the provider for them is heartbeat. If you are adding a custom agent, you can either put it in the same directory (heartbeat) and use the heartbeat provider, or you can create a new ''provider'' (bar in the examples) and a directory for that provider ''/usr/lib/ocf/resource.d/bar''.<br />
<br />
===== VServer Fail Over =====<br />
<br />
Once you have configured your filesystem for failover you can configure the vservers themselves for failover. If you want to control more than one vserver with heartbeat, you may use the following [http://www.theficks.name/bin/lib/ocf/VServer vserver ocf agent] to do so. Be sure to specify a colocation constraint between the filesystem and your vservers. You will also need to specify an oderering constraint to be sure that the filesystem is mounted before the vservers are started. Here is a sample ocf vserver configuration for a vserver named ''foo'' and an ocf provider named ''bar'':<br />
<br />
<primitive id="vserver_foo" class="ocf" type="VServer" provider="bar" restart_type="restart"><br />
<instance_attributes id="vserver_foo_ia"><br />
<attributes><br />
<nvpair id="vserver_foo_name" name="vserver" value="foo"/><br />
</attributes><br />
</instance_attributes><br />
</primitive><br />
<br />
===== Complete VServer DRBD Example Heartbeat Config =====<br />
<br />
The simplest way to combine related resources in heartbeat is to use a group. With a group you do not have to specify colocation and ordering constraints, they are implied. To use the above DRBD and VServer ocf resource agents together in a group, your heartbeat configuration will look something like this:<br />
<br />
<group id="vserver_aaa"><br />
<br />
<primitive id="vserver_foo_drbd" class="ocf" provider="bar" type="drbd"><br />
<instance_attributes id="vserver_foo_drbd_ia"><br />
<attributes><br />
<nvpair id="vserver_foo_drbd_resource" name="drbd_resource" value="vs_foo"/><br />
</attributes><br />
</instance_attributes><br />
</primitive> <br />
<br />
<primitive id="vserver_foo_fs" class="ocf" provider="heartbeat" type="Filesystem"><br />
<instance_attributes id="vserver_foo_fs_ia"><br />
<attributes><br />
<nvpair id="vserver_foo_fs_dev" name="device" value="/dev/drbd/vs_foo"/><br />
<nvpair id="vserver_foo_fs_mount" name="directory" value="/vservers/foo"/><br />
<nvpair id="vserver_foo_fs_type" name="fstype" value="ext3"/><br />
</attributes><br />
</instance_attributes><br />
</primitive><br />
<br />
<primitive id="vserver_foo" class="ocf" type="VServer" provider="bar" restart_type="restart"><br />
<instance_attributes id="vserver_foo_ia"><br />
<attributes><br />
<nvpair id="vserver_foo_name" name="vserver" value="foo"/><br />
</attributes><br />
</instance_attributes><br />
</primitive><br />
<br />
</group><br />
<br />
Note the use of the Filesystem agent to mount your drbd device before starting your vserver.</div>68.167.189.55http://linux-vserver.org/Usage_ScenariosUsage Scenarios2007-02-28T06:08:57Z<p>68.167.189.55: /* Fail-over Scenarios */</p>
<hr />
<div>For many people, virtual server may look like a great toy: Very high geekness factor. It looks cool, but probably not for everyone. '''Wrong!'''<br />
<br />
The primary goal of this project is to create virtual servers sharing the same machine. A virtual server operates like a normal Linux server. It runs normal services such as ssh, mail, web and database servers.<br />
<br />
== Consolidation and Separation ==<br />
<br />
As the hardware evolves, it is tempting to put more and more tasks on a server. Though Linux could reliably handle it, at some point, you will end up with too much stuff and people fiddling in the same box that you worry about updating things. Additionally, separating different or similar services which otherwise would interfere with each other, either because they are poorly designed or because they are simply incapable of peaceful coexistence for whatever reason, may often be complex or even impossible.<br />
<br />
The Linux-VServer project addresses this issue. The same box is able to run multiple virtual servers and each one does the job it is supposed to do. If you need to upgrade to PHP 5 for a given project, you can do so, and only that one project is affected.<br />
<br />
Also, you can give the root password of a virtual server to an administrator for that virtual server and he/she will be able to perform updates, restart services and so on without having to know about every other project hosted on the same server. This allows a clever provider to sell Virtual Private Servers, which uses less resources than other virtualization techniques, which in turn allows to put more units on a single machine. <br />
<br />
The list of providers doing so is relatively long, and so this is rightfully considered the main area of application. See [[VServer Hosting]] for a (probably incomplete) list of companies providing Virtual Private Servers based on the Linux-VServer technology.<br />
<br />
== Enhancing Security ==<br />
<br />
While it can be interesting to run several virtual servers in one box, there is one concept potentially more generally useful. Imagine a physical server running a single virtual server. The goal is isolate the main environment from any service, any network. You boot in the main environment, start very few services and then continue in the virtual server.<br />
<br />
The service in the main environment would be:<br />
<br />
* Unreachable from the network. <br />
* Able to log messages from the virtual server in a secure way. The virtual server would be unable to change/erase the logs. Even a cracked virtual server would not be able the edit the log.<br />
* Able to run intrusion detection facilities, potentially spying the state of the virtual server without being accessible or noticed. For example, tripwire could run there and it would be impossible to circumvent its operation or trick it.<br />
<br />
Another option is to put the firewall in a virtual server, and pull in the DMZ, containing each service in a separate VPS. On proper configuration, this setup can reduce the number of required machines drastically, without impacting performance.<br />
<br />
== Resource Independence ==<br />
<br />
Since virtual servers are only guests on the hardware they are using, they are not aware of the specifics: they do not contain disk configurations, kernels or network configurations.<br />
<br />
One key feature of a virtual server is the independence from the actual hardware. Most hardware issues are irrelevant for a virtual server installation. <br />
<br />
The main server acts as a host and takes care of all the details. The virtual server is just a client and ignores all the details. As such, the client can be moved to another physical server with very few manipulations.<br />
<br />
For example, to move the virtual server from one physical computer to another, it sufficient to do the following:<br />
<br />
* shutdown the running server <br />
* copy it over to the other machine <br />
* copy the configuration <br />
* start the virtual server on the new machine <br />
<br />
No adjustments to user setup, password database or hardware configuration are required, as long as both machines are binary compatible.<br />
<br />
Thus, once you have found that a project is using more resource than expected, you can easily move it to another box without tinkering around in hardware configuration files. A virtual server is just a directory on the filesystem of host system.<br />
<br />
== Fail-over Scenarios ==<br />
<br />
Pushing the limit a little further, replication technology could be used to keep an up-to-the-minute copy of the filesystem of a running virtual server. This would permit a very fast [[fail-over]] if the running server goes offline for whatever reason. <br />
<br />
All the known methods to accomplish this, starting with network replication via rsync, or drbd, via network devices, or shared disk arrays, to distributed filesystems, can be utilized to reduce the down-time and improve overall efficiency.<br />
<br />
== Experimenting and Upgrading ==<br />
<br />
If you intend to upgrade a system to get new features or security updates, you probably first test the new packages on the development machine, before you are ready to update the production server. Having some experience you do it properly:<br />
<br />
* Doing a backup of the server<br />
* Perform all the upgrades and install the new applications<br />
<br />
Two hours later you realise that something does not work as expected. To make it worse, it works fine on the development machine. We have all experienced this.<br />
<br />
Another solution to this problem would be to install the new production server on new hardware, but this is not as easy, as you have to clone the first server (most people are not comfortable doing this) or you do not have the hardware.<br />
<br />
Using virtual servers, all this is very easy:<br />
<br />
* Stop the virtual server in production<br />
* Make a copy of the virtual server<br />
* Perform the upgrades in the new virtual server<br />
<br />
To get back to our example above, two hours later you realise that something does not work as expected and you cannot immediately fix it.<br />
<br />
Again, using virtual servers, the (temporary) solution to this problem is very easy:<br />
<br />
* Stop the new virtual server and assign it a new IP address<br />
* Start both the old and new virtual server<br />
<br />
Now the old one is still online and you can track down the issues on your new virtual server using a different IP address, fix the problem and reassign the old IP address to the new virtual server.<br />
<br />
<br />
<br />
== Distribution Independence ==<br />
<br />
People are often talking about their preferred distribution. Should one use Fedora, Debian or something else? Should one give a spin to the latest and greatest distribution just for the sake of it?<br />
<br />
With virtual servers, the choice of a distribution is less important. When you select a distribution, you expect it will do the following:<br />
<br />
* Good hardware support/detection<br />
* Good package technology/updates<br />
* Good package selection<br />
* Reliable packages<br />
<br />
The choice is important because every service running on a box will be using the same distribution. Most distributions out there are good and reliable. Still each one has its peculiarities and probably flaws. For example, one distribution is doing a great job on security but is not delivering the latest and greatest PHP. Now because you have decided to use this distribution for some projects, using virtual servers does not prevent you from using another distribution for other projects or even a second virtual server for existing projects.<br />
<br />
== Other considerations ==<br />
<br />
* '''Virtual Private Servers are running on the same kernel as the host:''' Unlike other VM solutions, Linux-VServer does not require additional memory or processing power, in fact it may even reduce used memory due to the fact that multiple virtual servers may share the same files.<br />
<br />
* '''There are no special daemons running:''' A VPS running crond, sshd, httpd and sendmail uses the same resources as a normal Linux server running these services.<br />
<br />
* '''No pre-allocated disk space needed:''' A VPS generally shares the disk space with the host system, so there is no need to pre-allocate disk space for each virtual server to find out later that your disk is full, yet each VPS is using only a tiny portion of their allocated space.<br />
<br />
* '''Resource sharing:''' Since virtual servers can share binaries and libraries without interfering, a second VPS generally costs about 40-100MB of disk space only. Most of this space is a copy of the packaging database.<br />
<br />
* '''32-/64-bit independence:''' You can easily run a 32-bit distribution inside a VPS on a 64-bit host system, but faster, sometimes a lot.<br />
<br />
* '''Admin tools work inside a vserver as usual''': A vserver feels like a real server from within and can be used in the same ways.<br />
<br />
== See Also ==<br />
<br />
* [[Overview]]</div>68.167.189.55http://linux-vserver.org/Fail-overFail-over2007-02-28T06:07:59Z<p>68.167.189.55: First draft</p>
<hr />
<div>=== Active Vserver Failover ===<br />
<br />
To perform active vserver failover without user intervention from one host to another you may use heartbeat. To do this, you must first have a mechanism to actively replicate your veserver filesystem and configuration from one host to another. This mechanism must be able to provide a consistent filesystem view to either host on demand (but not neccessarily at the same time). In other words you may use something like NFS, a clustered filesystem like OCFS2 or GFS, or a network replicated block device like drbd, but you cannot use something like rsync, scp or ftp.<br />
<br />
Once you have an active replication method, you will likely need to organize your vserver files to be on the same device/filesystem so that you only need one replicated device/filesystem and do not need a separate one just for your vserver configuration files. One way to do this would be to use a ''/vservers'' mount point and to have a subdirectory for each vserver in there: ''/vservers/<server-name>''. Since you will want to put both the ''/var'' and ''/etc'' sections of your vserver in the vserver's subdirectory and soft link to them, it will probably end up looking something like this:<br />
<br />
/vservers/<server-name>/etc<br />
/vservers/<server-name>/var<br />
<br />
/etc/vservers/<server-name> -> /vservers/<server-name>/etc<br />
/var/lib/vservers/<server-name> -> /vservers/<server-name>/var<br />
<br />
With this arrangement you could replicate the entire /vservers directory to all hosts and you will than be able to run the vserver anywhere the /vservers directory is replicated.<br />
<br />
Finally, you will need a mechanism to start and stop your vservers on the appropriate hosts. This is where heartbeat comes in. If you do not have a permanently mounted filesystem on each node (because you are using a non-shared block device such as drbd 7,) you will need to configure heartbeat to first provide the ''/vservers'' file system on the node which is going to be the active host. Once you have configured your filesystem for failover you can configure the vservers themselves for failover. If you want to control more than one vserver with heartbeat, you may use the following vserver [http://www.theficks.name/bin/lib/ocf/VServer ocf agent] to do so. Be sure to specify a colocation constraint between the filesystem and your vservers. You will also need to specify an oderering constraint to be sure that the filesystem is mounted before the vservers are started. Here is a sample ocf vserver configuration for a vserver named ''foo'' and an ocf provider named ''bar'':<br />
<br />
<primitive id="vserver_foo" class="ocf" type="VServer" provider="bar" restart_type="restart"><br />
<instance_attributes id="vserver_foo_ia"><br />
<attributes><br />
<nvpair id="vserver_foo_name" name="vserver" value="foo"/><br />
</attributes><br />
</instance_attributes><br />
</primitive><br />
<br />
The ''ocf provider'' is simply a fancy term for the directory name under ''/usr/lib/ocf/resource.d/'' where you place your ocf agent. The ocf agents distributed with heartbeat are in the heartbeat subdirectory and therefor the provider for them is heartbeat.</div>68.167.189.55