--- title: "Getting started with Galera or Percona for Kea" slug: "getting-started-with-galera-or-percona-for-kea" description: "This document provides instructions for setting up a working database cluster for use as a Kea lease backend, or any other type of Kea backend." tags: ["high availability", "mysql", "postgresql", "kea configuration", "kea design", "database", "kea dhcp"] updated: 2023-09-22T20:53:40Z published: 2023-09-22T20:53:40Z canonical: "kb.isc.org/getting-started-with-galera-or-percona-for-kea" --- > ## Documentation Index > Fetch the complete documentation index at: https://kb.isc.org/llms.txt > Use this file to discover all available pages before exploring further. # Getting started with Galera or Percona for Kea This document provides instructions for setting up a working database cluster for use as a Kea lease backend, or any other type of backend. The database can be a single point of failure Be aware that currently Kea can connect to a single database host, making it a single point of failure. Follow the progress of the [multiple contact points issue](https://gitlab.isc.org/isc-projects/kea/-/issues/1746) that will mitigate this issue. Interested in Anycast? Many of the points discussed in the Kea development wiki article on [Anycast HA considerations](https://gitlab.isc.org/isc-projects/kea/-/wikis/designs/anycast-ha-considerations) apply to cluster backend setups as well. ## Cluster solutions The clustered backend will have to replace two built-in features of the Kea solution: lease updates and lease syncing. MySQL has two popular extensions for clustering: Galera and Percona XtraDB, which is a fork of Galera. Both of them have a number of features that make them work with Kea: - **active-active failover** All participating nodes respond to requests, similar to Kea HA load-balancing, as opposed to active-passive which is more similar to Kea HA hot-standby. - **multi-master replication** Data is replicated to all client-facing nodes; each of these nodes is sufficient in coordinating data consistency across the cluster and does not need secondary nodes to achieve this. - **virtually synchronous replication** Uses row logging to quickly log writes, but on read they get flushed to persistent storage such that all writes are totally ordered between the nodes and all reads see the same consistent view of the data. - **replication factor == node count** All nodes are self-sufficient to answer any request and they contain data received through all the nodes. - **quorum** During operation, the cluster keeps track of the responsive nodes which form `the primary component`. When one of the nodes unexpectedly goes down, if the nodes that remain form a majority quorum relative to the initial cluster size, then they keep functioning. If not, the primary component is disbanded and no nodes will operate until a majority is formed again. If there is a network partition, the same majority quorum principle applies. If the partition splits the cluster in exactly half, to avoid split-brain, neither of the halves will be operational since they don't satisfy quorum. - **effortless node opt-out** If a node leaves the cluster unexpectedly, it could mean that a network partition occurred. In this case some nodes may still offer service leading to a split-brain scenario. This is why a quorum needs to be instituted. When a node leaves the cluster gracefully, this is a guarantee that the node is offline and not receiving statements. So instead of only the primary component becoming smaller as was the case for unexpected communication cut-offs, the entire cluster size decreases. This increases the tolerance to subsequent node failures since a smaller cluster size requires fewer nodes to be online as part of the quorum. It's also convenient for maintenance or upgrades. To upgrade a drive you can simply stop the node, swap the drives, start the node. - **automatic recovery** When a node comes back up, it replicates data from the functioning nodes and then becomes available itself. Data conflicts are not expected in this scenario. ### Additional Percona features In addition to the features above, Percona has these additional features. - **XtraBackup** XtraBackup is an SST tool that is aware of database entities like tables and rows (as opposed to rsync which is byte by byte replication). It can be useful in reconstructing damaged databases. It needs to be [explicitly configured](https://docs.percona.com/percona-xtrabackup/8.0/index.html). - **Specific threading model** To improve scalability, Percona uses different threads for different purposes. [According to the Percona documentation](https://docs.percona.com/percona-xtradb-cluster/8.0/threading-model.html) these include worker threads (`wsrep_slave_threads`), the rollback thread, the service thread, `gcs_recv_thread`, the gcomm connection thread, donor/joiner/pagestore threads and others. - **More monitoring** Instruments are [exposed in the `PERFORMANCE_SCHEMA`](https://www.percona.com/blog/deep-dive-into-mysqls-performance-schema/) for the user to monitor. - **Better security** If SSL is used, Percona [encrypts the stored data](https://docs.percona.com/percona-server/8.0/security/data-at-rest-encryption.html). --- ## Installing the packages These instructions were verified using the following versions: - Debian 10.8: Galera 25.3.25-2, Percona 8.0.22-13 - Ubuntu 20.04.2 LTS: Galera 25.3.29-1, Percona 8.0.22-13 - Fedora 33: Galera 10.4.18-1, Percona 8.0.22-13 ### For Galera: ``` # deb $ apt install -y galera-3 mariadb-server # RPM $ yum install -y mariadb-server-galera ``` ### For Percona: ``` # deb $ wget https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb $ dpkg -i ./percona-release_latest.$(lsb_release -sc)_all.deb $ apt update $ apt install -y percona-xtradb-cluster-server-5.7 # RPM $ yum install -y https://repo.percona.com/yum/percona-release-latest.noarch.rpm $ yum module disable mysql $ percona-release setup ps80 $ yum install -y Percona-Server-server-57 ``` ## Setting up a cluster Setting up the cluster is done in a similar way for both Galera and Percona. ### Retrieve some values needed in the configuration: #### configuration location ``` # deb $ config=/etc/mysql/mariadb.conf.d/60-cluster.cnf # RPM $ config=/etc/my.cnf.d/cluster.cnf ``` #### outside-facing interface address ``` $ this_node_address=$(ip a s $(ip route | grep -E '^default' | grep -Eo 'dev [a-z0-9]*' | cut -d ' ' -f 2) | grep --color=auto -F ' inet ' | tr -s ' ' | cut -d ' ' -f 3 | cut -d '/' -f 1) $ first_node_address= ... # Chose a first node to act as the cluster initializer and get its address. ``` #### the Galera library For Galera: ``` # deb $ wsrep_provider=$(dpkg-query -L galera-3 | grep -E 'libgalera_smm\.so$' | head -n 1) # RPM $ wsrep_provider=$(yum repoquery --installed -l galera | grep --color=auto --color=auto -E 'libgalera_smm\.so$' | head -n 1) ``` For Percona: ``` # deb $ wsrep_provider=$(dpkg-query -L percona-xtradb-cluster-server-5.7 | grep -E 'libgalera_smm\.so$' | head -n 1) # RPM $ wsrep_provider=$(yum repoquery --installed -l Percona-Server-server-57 | grep --color=auto --color=auto -E 'libgalera_smm\.so$' | head -n 1) ``` ### Create a minimal configuration. For all nodes, run the following command: ``` $ cat > "${config}" < /tmp/percona-xtradb-cluster.conf.d/config/custom.cnf <