.. _Managing Datastores:

Managing Datastores
-------------------

To keep your virtual machines and containers in Virtuozzo Storage, you can place them in datastores. A datastore is a directory in a Virtuozzo Storage cluster with a number of parameters set for it, namely tier, redundancy, and failure domain.

.. warning:: If you delete a datastore, all VMs, containers, or backups in it will be deleted!

.. _Creating Datastores:

Creating Datastores
~~~~~~~~~~~~~~~~~~~

To create a datastore, do the following:

#. On the **SERVICES** > **COMPUTE** screen, click **ADD DATASTORES**.

   .. image:: ../../../images/stor_image46_2.png
      :align: center
      :class: align-center

#. On the **Add Datastore** panel, specify a name.

#. In **Tier**, select the `storage tier <http://docs.virtuozzo.com/virtuozzo_7_installation_guide/preparing-for-installation/planning-storage-gui.html#understanding-storage-tiers>`__ that will be used for the object storage.

#. In **Failure domain**, choose a `placement policy for replicas <http://docs.virtuozzo.com/virtuozzo_7_installation_guide/preparing-for-installation/planning-storage-gui.html#understanding-failure-domains>`__.

#. In **Data redundancy**, select the `redundancy mode <http://docs.virtuozzo.com/virtuozzo_7_installation_guide/preparing-for-installation/planning-storage-gui.html#understanding-data-redundancy>`__ that the object storage will use.

#. Click **Done**.

To change the datastore settings later, select it and click **Configure**.

.. _Placing Virtual Environments and Backups in Datastores:

Placing Virtual Environments and Backups in Datastores
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

After creating a datastore, you can set it to store your virtual environments and their backups

-  via Virtuozzo Automator (for instructions, refer to the `Virtuozzo Automator Administrator's Guide <http://docs.virtuozzo.com/virtuozzo_automator_7_administrators_guide/managing-physical-servers/configuring-virtual-environments-host-settings.html>`__) or

-  by creating symbolic links from the virtual environments and backups default location to this datastore as follows:

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

   #. Check the default location of:

      #. container private area in the ``/etc/vz/vz.conf`` file:

         ::

             VE_PRIVATE=/vz/private/$VEID 

      #. virtual machine files by running:

         ::

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

      #. backup files by running:

         ::

              # prlsrvctl info | grep "Backup path"
              Backup path: /vz/vmprivate/backups

   #. If the ``/vz/private``, ``/vz/vmprivate``, and ``/vz/vmprivate/backups`` directories exist on the server, remove them.

   #. Make symbolic links from the containers, virtual machines and backups default locations to the desired datastores. For example, to store your virtual machines in the ``vmprivate`` datastore, containers in the ``private`` datastore, and their backups in the ``backups`` datastore, execute the following commands:

      ::

           # ln -s /mnt/vstorage/vols/datastores/vmprivate /vz/vmprivate
           # ln -s /mnt/vstorage/vols/datastores/private /vz/private
           # ln -s /mnt/vstorage/vols/datastores/backups /vz/vmprivate/backups

The newly created virtual environments and backups will be placed and stored in their respective datastores.
