.. _Setting Up Clients:

Setting Up Clients
------------------

The process of setting up a client includes three stages:

1. Preparing to mount the Virtuozzo Storage cluster to the client.

2. Mounting the cluster.

3. Configuring virtual machines and Containers to be stored in the cluster.

.. _Stage 1\: Preparing to Mount the Cluster:

Stage 1: Preparing to Mount the Cluster
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To prepare for mounting the Virtuozzo Storage cluster to the client:

1. Log in to the server you want to act as a client as root or as a user with root privileges.

2. Download and install the ``vstorage-libs-shared`` and ``vstorage-client`` RPM packages. These packages are available in the Virtuozzo remote repository (this repository is automatically configured for your system when you install Virtuozzo) and can be installed with this command:

   ::

       # yum install vstorage-client

3. Create the directory to mount the Virtuozzo Storage cluster to, for example:

   ::

       # mkdir -p /vstorage/stor1

4. Make sure that cluster discovery is configured in your network. For details, see :ref:`Configuring Cluster Discovery`.

5. Authenticate the server in the cluster. This step is required only if the server where you are setting up the client has never been authenticated in the cluster before. For example, you can skip this step if this is the same server where you set up the first MDS server or some of the chunk servers. Otherwise, run the following command to authenticate the server in the cluster:

   ::

       # vstorage -c stor1 auth-node

   Please enter password for cluster:

   During its execution, the command asks you for the password to validate the server. Type the password you specified when setting up the first MDS server and press Enter. ``vstorage`` then compares the provided password with the one stored on the MDS server, and if the passwords match, successfully authenticates the server.

.. _Stage 2\: Mounting the Cluster:

Stage 2: Mounting the Cluster
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Next, you need to mount the cluster to make it accessible to the client. You can do this with the the ``vstorage-mount`` command. For example, if your Virtuozzo Storage cluster has the name of ``stor1``, you can run this command to mount it to the ``/vstorage/stor1`` directory on the client:

::

    # vstorage-mount -c stor1 /vstorage/stor1

You can also configure the client to automatically mount the cluster to the ``/vstorage/stor1`` directory when the client boots. To do this, add a line like the following to the ``/etc/fstab`` file:

::

    vstorage://stor1 /vstorage/stor1 fuse.vstorage rw,nosuid,nodev 0 0

.. note:: If the cluster is not used for virtualization, you can mount it with the ``--fail-on-nospace`` option. In this case an ``ERR_NO_SPACE`` error will be returned if the cluster runs out of free space.

.. _Stage 3\: Configuring Virtual Machines and Containers:

Stage 3: Configuring Virtual Machines and Containers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To configure a server with Virtuozzo to store its virtual machines and Containers in the cluster, do the following:

1. Log in to the server as ``root``.

2. Configure Containers for use in the cluster:

   1. Check the path to the Container private area in the ``/etc/vz/vz.conf`` file. By default, the path is set to the following:

      ::

           VE_PRIVATE=/vz/private/$VEID

   2. Make a symbolic link from the Container private area to the directory in the Virtuozzo Storage cluster that will store Containers. Assuming that this directory is ``/vstorage/stor1/private``, create this directory and run the following command:

      ::

           # ln -s /vstorage/stor1/private/ /vz/private

      .. note:: If the ``/vz/private`` directory already exists on your server, remove it before running the ``ln -s`` command.

3. Configure virtual machines for use in the cluster:

   1. Check the default location of virtual machine files:

      ::

           # prlsrvctl info | grep "VM home"
           VM home: /vz/vmprivate

   2. Make a symbolic link from the default location to the directory in the Virtuozzo Storage cluster that will store virtual machines. For example, to make a link to the ``/vstorage/stor1/vmprivate`` directory, create this directory and execute the following command:

      ::

           # ln -s /vstorage/stor1/vmprivate/ /vz/vmprivate

      .. note:: If the ``/vz/vmprivate`` directory already exists on your server, remove it before running the ``ln -s`` command.
