.. _Configuring Cluster Discovery:

Configuring Cluster Discovery
-----------------------------

Virtuozzo Storage discovery is the process of:

1. Detecting all available cluster names on the network. Each Virtuozzo Storage cluster is identified by a unique name. All cluster tools use this name when performing specific operations on the cluster or monitoring its health and status.

2. Resolving the detected cluster names into the network addresses of MDS servers. MDS servers are the central components of any cluster, so all cluster tools must be able to discover their IP addresses.

To set up cluster discovery in your network, you can use one of the following techniques:

-  (Recommended) DNS records (see :ref:`Using DNS records`),

-  Zeroconf (see :ref:`Setting Up Zeroconf`).

You can also manually specify the information about metadata servers when setting up or configuring the cluster (see :ref:`Specifying MDS Servers Manually`).

.. note:: To verify that the Hardware Node can discover the cluster, use the ``vstorage discover`` command.

.. _Using DNS Records:

Using DNS Records
~~~~~~~~~~~~~~~~~

The recommended way of configuring cluster discovery is to use special DNS records. The process of setting up this type of cluster discovery includes two steps:

1. Announcing the information about running MDS servers in the cluster so that chunk servers, clients, and new MDS servers can automatically obtain this information when necessary. You do this using DNS SRV records.

2. Defining DNS TXT records or enabling DNS zone transfers so that you can discover the unique names of available clusters when necessary.

.. _Announcing the Information About MDS Servers:

Announcing the Information About MDS Servers
********************************************

You can use SRV records to announce the information about running MDS servers in the cluster. The service field of an SRV record pointing to an MDS server must have the following format:

::

    _pstorage._tcp.CLUSTER_NAME

where

- ``_pstorage`` is the symbolic name reserved for Virtuozzo Storage.

- ``_tcp`` denotes that Virtuozzo Storage uses the TCP protocol for communication in the cluster.

-  ``CLUSTER_NAME`` is the name of the Virtuozzo Storage cluster described by the record.

The following example shows a DNS zone file that contains records for three MDS servers listening on the default port 2510 and configured for the ``stor1`` cluster:

::

    $ORIGIN stor.test.
    $TTL    1H
    @       IN SOA ns rname.invalid. (1995032001 5H 10M 1D 3H)
            NS @
            A       192.168.100.1
    s1      A       192.168.100.1
    s2      A       192.168.100.2
    s3      A       192.168.100.3
    ; SERVICE SECTION
    ; MDS for the 'stor1' cluster runs on s1.stor.test and listens on port 2510
    _pstorage._tcp.stor1 SRV 0 1 2510     s1
    ; MDS for the 'stor1' cluster runs on s2.stor.test and listens on port 2510
    _pstorage._tcp.stor1 SRV 0 1 2510     s2
    ; MDS for the 'stor1' cluster runs on s3.stor.test and listens on port 2510
    _pstorage._tcp.stor1 SRV 0 1 2510     s3
    ; eof

Once you configure DNS SRV records for the ``stor1`` cluster, you can list them by issuing the following SRV query:

::

    # host -t SRV _pstorage._tcp.stor1
    _pstorage._tcp.stor1.stor.test has SRV record 0 1 2510 s1.stor.test.
    _pstorage._tcp.stor1.stor.test has SRV record 0 1 2510 s2.stor.test.
    _pstorage._tcp.stor1.stor.test has SRV record 0 1 2510 s3.stor.test.

.. _Discovering Cluster Names:

Discovering Cluster Names
*************************

The easiest and most efficient way of discovering the names of clusters in your network is to specify all cluster names in ``pstorage_clusters`` TXT records of DNS zone files. The following example provides a sample of valid TXT record formats for Virtuozzo Storage clusters:

::

    pstorage_clusters    300    IN     TXT    "cluster1,cluster2" "cluster3,cluster4"
    pstorage_clusters    300    IN     TXT    "cluster5"
    pstorage_clusters    300    IN     TXT    "cluster6" "cluster7"

Another way of discovering cluster names in your network is to use DNS zone transfers. Once DNS zone transfers are enabled, cluster tools will be able to retrieve all DNS SRV records from DNS zone files and extract cluster names from these records.

After you set up cluster discovery via DNS TXT records or DNS zone transfers, you can run the ``vstorage discover`` command on any of the cluster servers to discover the names of all clusters in your network:

::

    # vstorage discover
    02-10-12 13:16:46.233 Discovering using DNS TXT records: OK
    02-10-12 13:16:46.308 Discovering using DNS zone transfer: FAIL
    stor1
    stor2
    stor3

The example ``vstorage`` output shows that:

-  Clusters names are discovered via the DNS TXT records.

-  Three clusters with the names of ``stor1``, ``stor2``, and ``stor3`` are currently set up on the network.

.. _Setting Up Zeroconf:

Setting Up Zeroconf
~~~~~~~~~~~~~~~~~~~

.. warning:: Zeroconf discovery does not work if services are running in Containers or virtual machines.

Zeroconf is another method of discovering cluster names and resolving the discovered names into the IP addresses of running MDS servers. This method does not require any special configuration efforts on your part, except ensuring that multicasts are supported and enabled on your network.

.. note:: To verify that the Hardware Node can discover the cluster, use the ``vstorage discover`` command.

.. _Specifying MDS Servers Manually:

Specifying MDS Servers Manually
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you cannot configure the DNS records in your network, you need to manually specify the IP addresses of all running MDS servers in the cluster each time you do any of the following:

-  Set up a new MDS server in a cluster (except for the first MDS server). For details, see :ref:`Adding MDS Servers`.

-  Set up a new chunk server to a cluster. For details, see :ref:`Setting Up Chunk Servers`.

-  Set up a new client for a cluster. For details, see :ref:`Setting Up Clients`.

To specify the IP address of an MDS server manually, create the ``bs.list`` file in the ``/etc/vstorage/clusters/Cluster_Name`` directory (make this directory if it does not exist) on the server you are configuring for the cluster and specify in it the IP address and port to use for connecting to the MDS server. For example:

::

    # echo "10.30.100.101:2510" >> /etc/vstorage/clusters/stor1/bs.list
    # echo "10.30.100.102:2510" >> /etc/vstorage/clusters/stor1/bs.list

This command:

1. Assumes that you are configuring discovery for the ``stor1`` cluster (thus, the directory name of ``/etc/vstorage/clusters/stor1``).

2. Creates the ``/etc/vstorage/clusters/stor1/bs.list`` file on the server, if it did not exist before.

3. Adds the information on two MDS servers with IP addresses 10.30.100.101 and 10.30.100.102 to the ``bs.list`` file.
