{"id":20168,"date":"2022-06-21T09:20:05","date_gmt":"2022-06-21T09:20:05","guid":{"rendered":"http:\/\/dev.profelis.net\/?p=20168"},"modified":"2023-02-01T10:57:58","modified_gmt":"2023-02-01T07:57:58","slug":"enterprisedb-failover-manager-nedir-nasil-kurulur-2","status":"publish","type":"post","link":"https:\/\/profelis.com.tr\/en\/2022\/06\/21\/enterprisedb-failover-manager-nedir-nasil-kurulur-2\/","title":{"rendered":"What is EnterpriseDB Failover Manager? How is it Installed?"},"content":{"rendered":"<h2>High Availability Solutions, Part 1<\/h2>\n<p style=\"color: var(--awb-color4); line-height: 1;\" data-fusion-font=\"true\">Authors: Aybars Hallik, Do\u011fan Kemal Cenan<\/p>\n<p>Welcome to our new blog series focusing on High Availability Solutions.<\/p>\n<p>In the first episode of the series <i>\u201cWhat is EnterpriseDB Failover Manager? How to Install It?\u201d <\/i>will focus on the topic, <a href=\"https:\/\/www.enterprisedb.com\/\" target=\"_blank\" rel=\"noopener\">EnterpriseDB<\/a>\u2019s high availability tool <a href=\"https:\/\/www.enterprisedb.com\/docs\/efm\/latest\/\" target=\"_blank\" rel=\"noopener\">EnterpriseDB Failover Manager<\/a> We will explain the integration of pgpool, a tool developed by the Postgres community that offers many features such as load balancing and connection pooling, with (EFM).<\/p>\n<h2><strong>What is replication?<\/strong><\/h2>\n<p>Replication is the process of copying data from a primary database to one or more backup databases. In replication, the primary database is responsible for read-write operations, while the backup database is responsible for read-only operations.<br \/>\nIn this article, we will use the terms \u201cprimary\u201d or \u201cmaster\u201d database as \u201cana veritaban\u0131\u201d, and \u201csecondary\u201d or \u201cstandby\u201d database as \u201cyedek veritaban\u0131\u201d.<\/p>\n<h2><strong style=\"font-size: 25px;\" data-fusion-font=\"true\">What is EnterpriseDB Failover Manager?<\/strong><\/h2>\n<p><span style=\"font-weight: 400;\">The EFM high availability module is a tool developed by EnterpriseDB that automatically makes one of the standby databases the primary database\u2014that is, performs the \u201cPromote\u201d operation\u2014in the event of issues that may arise in the primary database due to software and\/or hardware reasons.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Information we will provide in this document about the function of the EFM tool and how to install it <a href=\"http:\/\/dev.profelis.net\/postgresql\/\" target=\"_blank\" rel=\"noopener\">PostgreSQL<\/a> or <a href=\"http:\/\/dev.profelis.net\/edb-postgres-advanced-server\/\" target=\"_blank\" rel=\"noopener\">EDB Postgres Advanced Server (EPAS)<\/a> Applies to version 9.6 and later of databases.<\/span><\/p>\n<p><strong>Typical EFM cluster elements consist of the components specified below.<\/strong><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Master node: It is the primary database server in the replication structure.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Standby node: A standby node is a database server that uses streaming replication with the primary node.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Witness node: Following a disaster scenario, it witnesses the new role definitions and statuses assigned to two or more nodes. If the cluster contains three or more nodes (provided that the total number of nodes in the cluster is an odd number), a separate witness node is not needed in the cluster, as one of the nodes can fulfill the witness duty. However, if there is no third cluster member node containing a database, a witness node must be added. Furthermore, the cluster may also contain multiple witness nodes (again, provided that the total number of nodes is an odd number).<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Normally, the term cluster describes a single PostgreSQL installation managing multiple databases. However, the term cluster used in this article series will refer to the EFM cluster. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">The EFM cluster can reside on servers in the cloud or in a traditional network. It provides communication via the JGroups library, which is written to enable one-to-one and one-to-many communication. This cluster can consist of a primary EFM agent, one or more backup EFM agents, and optionally a witness EFM agent.<\/span><\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-21659\" src=\"https:\/\/profelis.com.tr\/wp-content\/uploads\/2022\/09\/efmss.png\" alt=\"EFMSS\" width=\"710\" height=\"1108\" title=\"\" srcset=\"https:\/\/profelis.com.tr\/wp-content\/uploads\/2022\/09\/efmss.png 710w, https:\/\/profelis.com.tr\/wp-content\/uploads\/2022\/09\/efmss-192x300.png 192w, https:\/\/profelis.com.tr\/wp-content\/uploads\/2022\/09\/efmss-656x1024.png 656w\" sizes=\"(max-width: 710px) 100vw, 710px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">The above figure shows an EFM cluster using a Virtual IP address. The Virtual IP address ensures that all requests directed to the EFM cluster arrive at a single IP address and are distributed from there. If these changes can be reported to the load balancer as databases are added to or removed from the cluster online, software acting as a load balancer can also assume the virtual IP address function. We will use pgpool as the load balancing tool. We will demonstrate how to perform the pgpool-EFM integration by leaving the task of managing the Virtual IP to pgpool and editing the configuration file provided by EFM to notify EFM as databases are added to or removed from the cluster.<\/span><\/p>\n<p style=\"--fontsize: 22; line-height: 1.5; --minfontsize: 22;\"><span style=\"font-weight: 400;\">When any EFM agent other than the witness is started, the agent connects to the database and checks its status.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">If it cannot reach the database, it starts as IDLE.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">During the database recovery process, the database on the agent's node assumes the role of the standby database. <\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">If the database is not in recovery, the database on the agent node assumes the primary database role.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">In the event of a failover, EFM ensures that the standby server designated as the primary database is the most up-to-date standby server in the cluster. However, if the primary node and the standby node are not in sync, EFM does not automatically perform the promote operation.<\/span><\/p>\n<h2><strong>What are the EnterpriseDB Failover Manager Requirements?<\/strong><\/h2>\n<p><span style=\"font-weight: 400;\">Before configuring the EFM cluster, the system must meet the following requirements.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Java 1.8 (or later) Installation<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Before using EFM, we must have Java installed (version 1.8 or later). <\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">EFM has been tested with OpenJDK, and it is recommended to install the specified version. <\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Instructions for Java installation are platform-specific.<\/span><\/li>\n<\/ul>\n<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">SMTP Server Configuration (Optional)<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">When using EFM, it is possible to choose to receive notifications by user-defined script, email, or both. <\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">If any of these methods are to be used, the SMTP server must be active.<\/span><\/li>\n<\/ul>\n<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Streaming Replication Configuration<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">For EFM, PostgreSQL streaming replication (SR) must be configured between the primary and standby nodes. <\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">EFM does not support other replication types.<\/span><\/li>\n<\/ul>\n<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Editing the pg_hba.conf file<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">The pg_hba.conf files on the primary and standby nodes must be configured to allow communication between all nodes in the cluster. <\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Below is an example of the lines that must be in the pg_hba.conf file on the primary node.<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div class=\"table-1\">\n<table width=\"100%\">\n<thead>\n<tr>\n<th align=\"left\">\n<pre>For access to #\n\nhost database_name efm 127.0.0.1\/32 md5\n\nFor access to the # backup server\n\nhost database_name efm 192.168.1.1\/32 md5\n\nTo access the # witness server\n\nhost database_name efm 192.168.1.2\/32 md5<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<\/div>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">After modifying the pg_hba.conf file, the system needs to be reloaded (using pg_ctl reload or \u201cselect pg_reload_conf();\u201d) for the changes to take effect. <\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Ensuring communication between firewalls<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">If the Linux firewalls on the EFM nodes are enabled, rules granting the necessary permissions must be added to the firewall configurations.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">The following command opens port 7800. EFM establishes the connection using the port number specified in the configuration file. If firewalls are not active, this process is not necessary.<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div class=\"table-1\">\n<table width=\"100%\">\n<thead>\n<tr>\n<th align=\"left\">\n<pre>iptables -I INPUT -p tcp --dport 7800 -j ACCEPT \/sbin\/service iptables save<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<\/div>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The database user having the necessary permissions<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">the database user specified in the db.user parameter in the efm.properties file,\u00a0<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"3\"><span style=\"font-weight: 400;\">pg_current_wal_lsn()<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"3\"><span style=\"font-weight: 400;\">pg_last_wal_replay_lsn()<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"3\"><span style=\"font-weight: 400;\">pg_wal_replay_resume()<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"3\"><span style=\"font-weight: 400;\">pg_wal_replay_pause()<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">must have sufficient database privileges to be able to call its functions.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><b>reconfigure.num.sync<\/b><span style=\"font-weight: 400;\"> or<\/span><b> reconfigure.sync.primary<\/b><span style=\"font-weight: 400;\"> if the parameters are set to \u2018true\u2019:<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"3\"><span style=\"font-weight: 400;\">For version 9.6 <\/span><b>db.user<\/b><span style=\"font-weight: 400;\"> The user specified in the parameter must be a superuser.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"3\"><span style=\"font-weight: 400;\">For versions after 9.6, the specified database user <\/span><b>pg_read_all_stats<\/b><span style=\"font-weight: 400;\"> and to his authority <\/span><b>pg_reload_conf()<\/b><span style=\"font-weight: 400;\">\u2019must have permission to run it.<\/span><\/li>\n<\/ul>\n<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Additionally, the specified user must have the privilege to read the configuration values. The authorized user in the database can grant the necessary permissions to the user using the GRANT command.<\/span><\/li>\n<\/ul>\n<div class=\"table-1\">\n<table width=\"100%\">\n<thead>\n<tr>\n<th align=\"left\">\n<pre>GRANT pg_read_all_settings TO ;<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<\/div>\n<h2><strong>How to Install EnterpriseDB Failover Manager?<\/strong><\/h2>\n<p><span style=\"font-weight: 400;\">EFM installation, <\/span><b>root <\/b><span style=\"font-weight: 400;\">must be performed by the user. During installation, a user named efm is created, which has the authority to monitor the EFM service for databases (clusters) authorized by the enterprisedb (EPAS superuser) or postgres (PostgreSQL superuser) user and has the authority to use the scripts. The installation steps for CentOS 7 are as follows.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">1. To create repo configuration files, superuser privileges are required. Then, the following command is run.<\/span><\/p>\n<div class=\"table-1\">\n<table width=\"100%\">\n<thead>\n<tr>\n<th align=\"left\">\n<pre>yum -y install https:\/\/yum.enterprisedb.com\/edbrepos\/edb-repo-latest.noarch.rpm<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<\/div>\n<p><span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">2. Following the installation in the first step, the edb.repo file will be created under the \/etc\/yum.repos.d directory. The USERNAME and PASSWORD information in this file is replaced with the username and password information obtained from the EnterpriseDB website. This process can be done by opening the file with any editor, or <\/span><\/p>\n<div class=\"table-1\">\n<table width=\"100%\">\n<thead>\n<tr>\n<th align=\"left\">\n<pre>sed -i &quot;s@:@USERNAME:PASSWORD@&quot; \/etc\/yum.repos.d\/edb.repo<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<\/div>\n<p><span style=\"font-weight: 400;\">This can also be done by replacing the USERNAME and PASSWORD parts with the information obtained from EDB and running the command.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">3. The EPEL repository is installed.<\/span><\/p>\n<div class=\"table-1\">\n<table width=\"100%\">\n<thead>\n<tr>\n<th align=\"left\">\n<pre>yum -y install epel-release<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<\/div>\n<p><span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">4. The EFM package is installed. To avoid errors during this installation, the changes specified in step 2 must be made correctly in the edb.repo file.<\/span><\/p>\n<div class=\"table-1\">\n<table width=\"100%\">\n<thead>\n<tr>\n<th align=\"left\">\n<pre>yum -y install edb-efm44<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<\/div>\n<p><span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">5. After installation, the files will be created in the directories specified below.<\/span><\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Executable files<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"3\"><span style=\"font-weight: 400;\">\/usr\/edb\/efm-4.4\/bin<\/span><\/li>\n<\/ul>\n<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Libraries<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"3\"><span style=\"font-weight: 400;\">\/usr\/edb\/efm-4.4\/lib<\/span><\/li>\n<\/ul>\n<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Configuration files<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"3\"><span style=\"font-weight: 400;\">\/etc\/edb\/efm-4.4<\/span><\/li>\n<\/ul>\n<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Logs<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"3\"><span style=\"font-weight: 400;\">\/var\/log\/efm-4.4<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">6. For each node after installation<\/span><\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">The efm.properties file is edited.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">The efm.nodes file is edited.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">If the Virtual IP address and code snippet are defined in the efm.properties file, configuration and testing procedures must be performed.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">EFM agents on each node of the cluster are started.<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><i><span style=\"font-weight: 400;\">Wait for our next blog post to learn the details of these processes.<\/span><\/i><\/p>\n<p>Meanwhile, to get more information about EnterpriseDB <a href=\"\/en\/enterprisedb\/\">Click<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Y\u00fcksek Eri\u015filebilirlik \u00c7\u00f6z\u00fcmleri, B\u00f6l\u00fcm 1 Yazarlar: Aybars Hallik, Do\u011fan Kemal Cenan Y\u00fcksek Eri\u015filebilirlik \u00c7\u00f6z\u00fcmlerine odaklanacak yeni blog serimize ho\u015fgeldiniz. Serinin ilk b\u00f6l\u00fcm\u00fcnde \u201cEnterpriseDB Failover Manager nedir? Nas\u0131l Kurulur?\u201d konusuna odaklanacak, EnterpriseDB\u2019nin y\u00fcksek eri\u015filebilirlik arac\u0131 olan EnterpriseDB Failover Manager (EFM) ile&#8230;<\/p>","protected":false},"author":16,"featured_media":22104,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[76,75,45],"tags":[58,48,61,60,50],"class_list":["post-20168","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-postgresql","category-yazi","tag-acikkaynak","tag-enterprisedb","tag-linux","tag-postgresql","tag-veritabani"],"_links":{"self":[{"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/posts\/20168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/comments?post=20168"}],"version-history":[{"count":0,"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/posts\/20168\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/media\/22104"}],"wp:attachment":[{"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/media?parent=20168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/categories?post=20168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/tags?post=20168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}