High Availability (HA) Aplikasi ke Database via Load Balancer

High Availability (HA) Aplikasi ke Database via Load Balancer

High Availability (HA) adalah konsep penting dalam menjaga ketersediaan aplikasi dan database pada saat terjadi kegagalan sistem atau lonjakan beban. Load Balancer (LB) adalah komponen kunci dalam arsitektur HA yang mendistribusikan lalu lintas ke berbagai server database untuk memastikan ketersediaan dan performa optimal.

Best Practices

Beberapa praktik terbaik yang perlu diperhatikan:

  1. Load Balancer Setup:
    • Load Balancer Type: Use a load balancer that supports the distribution of traffic to the database with algorithms such as round-robin, least-connections, or IP hashes. Examples: HAProxy, NGINX, or AWS ELB.
    • Health Checks: Implement health checks on load balancers to monitor the health status of database nodes. If a node fails, the load balancer should automatically redirect traffic to healthy nodes.
  2. Database Replication:
    • Master-Slave Replication: Configure master-slave replication where the master receives all write operations and the slave is used for read operations. This can reduce the load on the master server and increase HA.
    • Multi-Master Replication: For systems that require high write availability in multiple locations, multi-master replication may be considered. Make sure to handle conflicts effectively.
  3. Automatic Failover:
    • Failover Mechanism: Use tools like Pacemaker or Patroni to detect failures on the primary database server and automatically failover to the secondary node without manual intervention.
    • DNS-based Failover: Use DNS-based failover to redirect traffic to another data center or region if the entire infrastructure goes down.
  4. Data Consistency & Split-Brain Scenarios:
    • Quorum-based Systems: In a multi-node configuration, ensure that the system has a quorum mechanism in place to prevent split-brain scenarios, where two independent nodes consider themselves masters.

Menggunakan Oracle Connection Manager sebagai Load Balancer

Langkah 1: Instalasi Oracle Connection Manager

Oracle Connection Manager (CMAN) is a proxy server that can be used to distribute client connections to Oracle databases.

  1. CMAN Installation:Instalasi Oracle Connection Manager dilakukan melalui Oracle Universal Installer (OUI) yang tersedia dalam instalasi Oracle Database Client.
  2. Connection Manager Configuration:After installation, the configuration file cman.ora which is usually in $ORACLE_HOME/network/admin/cman.ora.

Step 2: Using CMAN as a Load Balancer

On clients accessing the database, use the following configuration on the tnsnames.ora

Database Replication: Master-Slave Setup

Oracle provides the Data Guard feature for Master-Slave Replication implementations, which provides data replication from the primary database to the backup database.

Step 1: Configure the Primary Database

  1. Enable Force Logging:To ensure all changes are logged in the redo logs.ALTER DATABASE FORCE LOGGING;
  2. Enable Archivelog Mode:Make sure the database is running in archivelog mode.SHUTDOWN IMMEDIATE; STARTUP MOUNT; ALTER DATABASE ARCHIVELOG; ALTER DATABASE OPEN;
  3. Create Standby Redo Logs:Standby redo logs are required for Data Guard configuration.ALTER DATABASE ADD STANDBY LOGFILE ('/u01/app/oracle/oradata/orcl/stdby01.log') SIZE 500M;
  4. Create a TNS Entry for Standby:Add entries to the tnsnames.ora on the primary server that leads to standby.STDBY = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.11)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl_stdby) ) )
  5. Backup Primary Database and Send to Standby:Use RMAN to create backups and send them to standby.
    RMAN> BACKUP DATABASE PLUS ARCHIVELOG;
    Then restore on standby.

Step 2: Configure Database Standby

  1. Restore Backup on Standby:Restore Backup on Standby:RMAN> RESTORE DATABASE; RMAN> RECOVER DATABASE;
  2. Start Standby Database:Start the database in standby mode.ALTER DATABASE MOUNT STANDBY DATABASE;
  3. Enable Managed Recovery:Enable managed recovery for standby.ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

Conclusion

  • Load Balancer: Use Oracle Connection Manager to distribute the connection load evenly among database nodes.
  • Master-Slave Replication: Use Oracle Data Guard to ensure real-time replication of data from primary to standby database.
  • Multi-Master Replication: Using Oracle GoldenGate to implement bi-directional replication between multiple database masters, allowing each node to perform write operations and stay in sync with other nodes.
  • Automatic Failover: Pacemaker and Corosync along with Oracle Data Guard provide an automated failover mechanism that can be installed in a self-managed VPS environment.
  • DNS-based Failover: Bind9 can be used to manage DNS failover automatically by redirecting traffic to the standby node when the primary node fails.
  • Data Consistency & Split-Brain Scenarios: Quorum-based systems configurations with STONITH protect databases from split-brains, maintaining data consistency across clusters.

Dengan konfigurasi ini, sistem database Oracle Anda akan memiliki tingkat ketersediaan tinggi dan perlindungan terhadap berbagai skenario kegagalan tanpa menggunakan layanan cloud eksternal.

Referensi External


Butuh Solusi High Availability Database untuk Bisnis Anda?

PT Neuronworks Indonesia is present as a trusted partner in the implementation of reliable and scalable information technology solutions. With more than 10 years of experience in the IT industry, we are ready to help optimize your business database infrastructure with High Availability solutions that are customized as needed.

Layanan Kami Meliputi:

  • Konsultasi Arsitektur Database
  • Implementasi High Availability Solution
  • Database Performance Optimization
  • 24/7 Monitoring & Support
  • Security Assessment & Implementation

Hubungi Tim Ahli Kami Sekarang untuk konsultasi GRATIS mengenai solusi High Availability Database yang tepat untuk bisnis Anda!

Berita Rekomendasi

Solusi Rekruitasi Karyawan Anda

30/09/2024

Your Employee Recruitment Solution

Rekruitasi merupakan serangkaian proses penarikan sekelompok kandidat berdasarkan kualifikasi dan kriteria yang diajukan oleh perusahaan. Proses ini dilakukan dengan harapan mendapatkan calon karyawan yang kompeten di bidangnya. Tahap rekruitasi setiap…

View
New Relic & Sentry: Monitoring Performa Sistem

11/11/2024

New Relic & Sentry: System Performance Monitoring

Pada saat Training Programmer Intermediate saya baru mengetahui teknologi yang bernama New Relic ini. New Relic adalah platform observabilitas yang membantu Anda membangun perangkat lunak yang lebih baik. Anda dapat…

View
SSDL: Membangun Perangkat Lunak Aman

12/11/2024

SSDL: Membangun Perangkat Lunak Aman

Secure Software Development Lifecycle (SSDL) adalah proses pengembangan perangkat lunak yang dirancang untuk membangun perangkat lunak yang aman dan andal. SSDL mengintegrasikan praktik keamanan ke dalam semua tahap pengembangan perangkat…

View