<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Foyez Ahmed Rony on Medium]]></title>
        <description><![CDATA[Stories by Foyez Ahmed Rony on Medium]]></description>
        <link>https://medium.com/@far.rony?source=rss-aa3e989b098e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rnH9m-eOhiaNh_IkuBO-PQ.jpeg</url>
            <title>Stories by Foyez Ahmed Rony on Medium</title>
            <link>https://medium.com/@far.rony?source=rss-aa3e989b098e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 00:42:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@far.rony/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a Highly Available PostgreSQL Cluster with Patroni, etcd, and HAProxy (Oracle Linux 8 &…]]></title>
            <link>https://medium.com/@far.rony/building-a-highly-available-postgresql-cluster-with-patroni-etcd-and-haproxy-oracle-linux-8-eaad426859fd?source=rss-aa3e989b098e------2</link>
            <guid isPermaLink="false">https://medium.com/p/eaad426859fd</guid>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[high-availability]]></category>
            <category><![CDATA[replication]]></category>
            <category><![CDATA[patroni]]></category>
            <category><![CDATA[postgresql-database]]></category>
            <dc:creator><![CDATA[Foyez Ahmed Rony]]></dc:creator>
            <pubDate>Mon, 14 Sep 2026 09:23:58 GMT</pubDate>
            <atom:updated>2026-09-15T05:29:21.445Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a Highly Available PostgreSQL Cluster with Patroni, etcd, and HAProxy (Oracle Linux 8 &amp; PostgreSQL Release 16)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EVo5-hI0uxF1-O87x4Dk0g.png" /></figure><p>Here’s the actual setup we built and tested:</p><ul><li><strong>node1 (192.168.5.4)</strong> — Runs etcd (cluster member), HAProxy (load balancer), and PostgreSQL with Patroni. Currently the <strong>Leader</strong> — serves as PostgreSQL primary.</li><li><strong>node2 (192.168.5.5)</strong> — Runs etcd (cluster member), HAProxy (load balancer), and PostgreSQL with Patroni. Streaming <strong>Replica</strong>.</li><li><strong>node3 (192.168.5.7)</strong> — Runs etcd (cluster member), HAProxy (load balancer), and PostgreSQL with Patroni. Streaming <strong>Replica</strong>.</li></ul><p>Every node runs the full stack — that’s the “stacked” topology. etcd forms a proper 3-member quorum (tolerates 1 node failure), Patroni on each node watches etcd to know who’s leader, and HAProxy on each node routes port 5000 (writes) to whichever node is currently primary and port 5001 (reads) to the replicas.</p><p>Run the OS-prep, PostgreSQL, etcd, and Patroni steps <strong>on all 3 nodes</strong> unless noted otherwise.</p><h3>Step 1 — OS prep (all 3 nodes)</h3><pre>sudo hostnamectl set-hostname node1   # node2, node3 respectively<br>sudo tee -a /etc/hosts &lt;&lt;EOF<br>192.168.5.4 node1<br>192.168.5.5 node2<br>192.168.5.7 node3<br>EOF<br><br>sudo systemctl disable --now firewalld   # or open the specific ports below<br>sudo setenforce 0                         # or configure proper SELinux policies</pre><p>Ports needed: 5432 (postgres), 8008 (Patroni REST API), 2379/2380 (etcd), 5000/5001 (HAProxy, defined below).</p><h3>Step 2 — Install PostgreSQL (all 3 nodes)</h3><pre>sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm<br>sudo dnf -qy module disable postgresql<br>sudo dnf install -y postgresql16-server postgresql16-contrib</pre><pre># Do NOT run initdb manually — Patroni will bootstrap the data directory<br>sudo mkdir -p /var/lib/pgsql/16/data<br>sudo chown postgres:postgres /var/lib/pgsql/16/data<br>sudo chmod 700 /var/lib/pgsql/16/data</pre><h3>Step 3 — Install etcd from binary (all 3 nodes)</h3><pre>ETCD_VER=v3.5.17<br>cd /tmp<br>curl -L https://github.com/etcd-io/etcd/releases/download/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o etcd.tar.gz<br>tar xzf etcd.tar.gz<br>sudo mv etcd-${ETCD_VER}-linux-amd64/etcd /usr/local/bin/<br>sudo mv etcd-${ETCD_VER}-linux-amd64/etcdctl /usr/local/bin/<br>sudo mv etcd-${ETCD_VER}-linux-amd64/etcdutl /usr/local/bin/<br><br>sudo useradd -r -s /sbin/nologin etcd<br>sudo mkdir -p /var/lib/etcd<br>sudo chown etcd:etcd /var/lib/etcd</pre><p>Write the config — use these exact commands, adjusting only name/IP per node</p><p>Confirm your 3 real IPs first —</p><p>On node1 (192.168.5.4):</p><pre>name: etcd1<br>data-dir: /var/lib/etcd<br>listen-peer-urls: http://192.168.5.4:2380<br>listen-client-urls: http://192.168.5.4:2379,http://127.0.0.1:2379<br>initial-advertise-peer-urls: http://192.168.5.4:2380<br>advertise-client-urls: http://192.168.5.4:2379<br>initial-cluster: etcd1=http://192.168.5.4:2380,etcd2=http://192.168.5.5:2380,etcd3=http://192.168.5.7:2380<br>initial-cluster-token: patroni-etcd-cluster<br>initial-cluster-state: new<br>EOF</pre><p>On node2 (192.168.5.5):</p><pre>cat &gt; /etc/etcd/etcd.conf.yml &lt;&lt;&#39;EOF&#39;<br>name: etcd2<br>data-dir: /var/lib/etcd<br>listen-peer-urls: http://192.168.5.5:2380<br>listen-client-urls: http://192.168.5.5:2379,http://127.0.0.1:2379<br>initial-advertise-peer-urls: http://192.168.5.5:2380<br>advertise-client-urls: http://192.168.5.5:2379<br>initial-cluster: etcd1=http://192.168.5.4:2380,etcd2=http://192.168.5.5:2380,etcd3=http://192.168.5.7:2380<br>initial-cluster-token: patroni-etcd-cluster<br>initial-cluster-state: new<br>EOF</pre><p>On node3 (192.168.5.7):</p><pre>cat &gt; /etc/etcd/etcd.conf.yml &lt;&lt;&#39;EOF&#39;<br>name: etcd3<br>data-dir: /var/lib/etcd<br>listen-peer-urls: http://192.168.5.7:2380<br>listen-client-urls: http://192.168.5.7:2379,http://127.0.0.1:2379<br>initial-advertise-peer-urls: http://192.168.5.7:2380<br>advertise-client-urls: http://192.168.5.7:2379<br>initial-cluster: etcd1=http://192.168.5.4:2380,etcd2=http://192.168.5.5:2380,etcd3=http://192.168.5.7:2380<br>initial-cluster-token: patroni-etcd-cluster<br>initial-cluster-state: new<br>EOF</pre><p>Create the systemd unit — identical on all 3 nodes</p><pre>cat &gt; /etc/systemd/system/etcd.service &lt;&lt;&#39;EOF&#39;<br>[Unit]<br>Description=etcd distributed key-value store<br>After=network.target<br><br>[Service]<br>Type=notify<br>User=etcd<br>ExecStart=/usr/local/bin/etcd --config-file=/etc/etcd/etcd.conf.yml<br>Restart=on-failure<br>RestartSec=5<br>LimitNOFILE=65536<br><br>[Install]<br>WantedBy=multi-user.target<br>EOF</pre><p>Fix permissions and start — on all 3 nodes, ideally within a few seconds of each other</p><pre>chown etcd:etcd /etc/etcd/etcd.conf.yml<br>systemctl daemon-reload<br>systemctl enable --now etcd<br><br>#Verify<br>systemctl status etcd --no-pager<br>ss -tlnp | grep etcd<br><br>#Once all 3 are up, test from any node:<br>etcdctl --endpoints=http://192.168.5.4:2379,http://192.168.5.5:2379,http://192.168.5.7:2379 member list<br>etcdctl --endpoints=http://192.168.5.4:2379,http://192.168.5.5:2379,http://192.168.5.7:2379 endpoint health --c</pre><h3>Step 3 — Install Patroni (all 3 nodes)</h3><pre>dnf install -y python3 python3-pip python3-devel gcc<br>pip3 install --upgrade pip<br>pip3 install patroni[etcd3] psycopg2-binary<br><br>#Confirm it installed and find where patroni landed:<br>which patroni<br>patroni --version</pre><p>Write /etc/patroni.yml — per node, matching name/IP to your etcd naming<br>On node1 (192.168.5.4):</p><pre>cat &gt; /etc/patroni.yml &lt;&lt;&#39;EOF&#39;<br>scope: postgres-cluster<br>namespace: /db/<br>name: node1<br><br>restapi:<br>  listen: 192.168.5.4:8008<br>  connect_address: 192.168.5.4:8008<br><br>etcd3:<br>  hosts: 192.168.5.4:2379,192.168.5.5:2379,192.168.5.7:2379<br><br>bootstrap:<br>  dcs:<br>    ttl: 30<br>    loop_wait: 10<br>    retry_timeout: 10<br>    maximum_lag_on_failover: 1048576<br>    postgresql:<br>      use_pg_rewind: true<br>      use_slots: true<br>      parameters:<br>        wal_level: replica<br>        hot_standby: &quot;on&quot;<br>        max_wal_senders: 10<br>        max_replication_slots: 10<br>        wal_keep_size: 128MB<br><br>  initdb:<br>    - encoding: UTF8<br>    - data-checksums<br><br>  pg_hba:<br>    - host replication replicator 192.168.5.0/24 md5<br>    - host all all 192.168.5.0/24 md5<br>    - host all all 127.0.0.1/32 trust<br><br>postgresql:<br>  listen: 192.168.5.4:5432<br>  connect_address: 192.168.5.4:5432<br>  data_dir: /var/lib/pgsql/16/data<br>  bin_dir: /usr/pgsql-16/bin<br>  pgpass: /tmp/pgpass<br>  authentication:<br>    replication:<br>      username: replicator<br>      password: &quot;ReplPass123&quot;<br>    superuser:<br>      username: postgres<br>      password: &quot;SuperPass123&quot;<br>  parameters:<br>    unix_socket_directories: &#39;/var/run/postgresql&#39;<br><br>tags:<br>  nofailover: false<br>  noloadbalance: false<br>  clonefrom: false<br>  nosync: false<br>EOF</pre><p>#<strong>On node2</strong> — same file, change only name: node2, and both 192.168.5.4 → 192.168.5.5 occurrences under restapi and postgresql.listen &amp; connect_address.(restapi.listen,restapi.connect_address,postgresql.listen,postgresql.connect_address)</p><p>#<strong>On node3</strong> — same, name: node3, IP → 192.168.5.7.</p><p>(Keep the etcd3.hosts line identical — all 3 endpoints — on every node.)Use whatever real passwords you want instead of the placeholders, but use the same values on all 3 nodes for replicator and postgres.</p><p><strong>systemd unit — identical on all 3 nodes</strong></p><pre>cat &gt; /etc/systemd/system/patroni.service &lt;&lt;EOF<br>[Unit]<br>Description=Patroni PostgreSQL HA<br>After=syslog.target network.target etcd.service<br><br>[Service]<br>Type=simple<br>User=postgres<br>Group=postgres<br>ExecStart=$(which patroni) /etc/patroni.yml<br>KillMode=process<br>TimeoutSec=30<br>Restart=on-failure<br><br>[Install]<br>WantedBy=multi-user.target<br>EOF</pre><blockquote>Permissions check<br>mkdir -p /var/run/postgresql<br>chown postgres:postgres /var/run/postgresql<br>chown postgres:postgres /etc/patroni.yml</blockquote><p><strong>Start Patroni on node1 first</strong>, wait for it to bootstrap, then start node2 and node3 (they’ll clone from the leader):</p><pre>sudo systemctl daemon-reload<br>sudo systemctl enable --now patroni    # on node1, wait ~30s<br>sudo systemctl enable --now patroni    # on node2<br>sudo systemctl enable --now patroni    # on node3</pre><p>Check cluster state from any node:</p><pre>[root@node1 ~]# patronictl -c /etc/patroni.yml list<br>+ Cluster: postgres-cluster (7685278097854917530) +-------------+-----+------------+-----+<br>| Member | Host        | Role    | State     | TL | Receive LSN | Lag | Replay LSN | Lag |<br>+--------+-------------+---------+-----------+----+-------------+-----+------------+-----+<br>| node1  | 192.168.5.4 | Leader  | running   |  1 |             |     |            |     |<br>| node2  | 192.168.5.5 | Replica | streaming |  1 |   0/7000148 |   0 |  0/7000148 |   0 |<br>| node3  | 192.168.5.7 | Replica | streaming |  1 |   0/7000148 |   0 |  0/7000148 |   0 |<br>+--------+-------------+---------+-----------+----+-------------+-----+------------+-----+</pre><h3>Step 5<strong>—</strong> HAProxy for client-facing routing (all 3 nodes, or a 4th if you get one later)</h3><p>HAProxy uses Patroni’s REST API (8008) to detect who&#39;s currently primary — /master returns 200 only on the leader, /replica returns 200 only on replicas.</p><pre>sudo dnf install -y haproxy</pre><p>Write /etc/haproxy/haproxy.cfg — identical on all 3 nodes</p><pre>cat &gt; /etc/haproxy/haproxy.cfg &lt;&lt;&#39;EOF&#39;<br>global<br>    maxconn 100<br><br>defaults<br>    log global<br>    mode tcp<br>    retries 2<br>    timeout client 30m<br>    timeout connect 4s<br>    timeout server 30m<br>    timeout check 5s<br><br>listen stats<br>    mode http<br>    bind *:7000<br>    stats enable<br>    stats uri /<br><br>listen postgres_write<br>    bind *:5000<br>    option httpchk OPTIONS /master<br>    http-check expect status 200<br>    default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions<br>    server node1 192.168.5.4:5432 maxconn 100 check port 8008<br>    server node2 192.168.5.5:5432 maxconn 100 check port 8008<br>    server node3 192.168.5.7:5432 maxconn 100 check port 8008<br><br>listen postgres_read<br>    bind *:5001<br>    option httpchk OPTIONS /replica<br>    http-check expect status 200<br>    default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions<br>    server node1 192.168.5.4:5432 maxconn 100 check port 8008<br>    server node2 192.168.5.5:5432 maxconn 100 check port 8008<br>    server node3 192.168.5.7:5432 maxconn 100 check port 8008<br>EOF</pre><p>SELinux — allow HAProxy to make network connections<br>Since you disabled SELinux earlier (setenforce 0), this likely isn’t an issue, but if it’s enforcing on any node:</p><blockquote>[root@node1 ~]# getenforce<br>Permissive</blockquote><p>If it shows Enforcing:<br>setsebool -P haproxy_connect_any 1</p><p><strong>Start HAProxy</strong></p><pre>systemctl enable - now haproxy<br>systemctl status haproxy - no-pager</pre><p>Verify routing works correctly<br>From any node, test the write port — it should always reach the current leader:</p><pre>[root@node1 ~]# PGPASSWORD=&#39;SuperPass123&#39; psql -h 127.0.0.1 -p 5000 -U postgres -c &quot;SELECT pg_is_in_recovery();&quot;<br> pg_is_in_recovery<br>-------------------<br> f<br>(1 row)</pre><p>Should return f (false — meaning this is the primary, since port 5000 only routes to /master).</p><p>Test the read port — it should reach a replica:</p><pre>[root@node1 ~]# PGPASSWORD=&#39;SuperPass123&#39; psql -h 127.0.0.1 -p 5001 -U postgres -c &quot;SELECT pg_is_in_recovery();&quot;<br> pg_is_in_recovery<br>-------------------<br> t<br>(1 row)</pre><p>Should return t (true — this is a replica).</p><p>Check the stats page too, in a browser or via curl:</p><pre>curl http://192.168.5.4:7000/</pre><p>You should see postgres_write showing node1 as UP (green) and node2/node3 as DOWN (since they don’t match /master), and postgres_write — wait, correct: postgres_read should show node2/node3 UP and node1 DOWN.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*57Z2zvKC5DLh0swqFlUmDQ.png" /></figure><p>each of the 3 nodes runs the same stack — HAProxy on top routing by health check, Patroni managing PostgreSQL underneath, and etcd tying all three together for leader election. Right now node1 is primary, node2/node3 are streaming replicas, and etcd is healthy across all three.</p><p>Since each node runs its own HAProxy independently (no shared VIP yet), application currently needs to know all 3 HAProxy IPs and try them in order — that’s the gap keepalived would close by giving you one floating IP instead.</p><p>Right now your app has to know all 3 HAProxy IPs and handle “try the next one if this fails” logic itself. keepalived removes that: it gives you <strong>one virtual IP (VIP)</strong> that always points to whichever node is currently healthy, using VRRP (Virtual Router Redundancy Protocol) to move the IP between nodes automatically if one goes down.</p><h3>How it works</h3><ul><li>All 3 nodes run keepalived alongside HAProxy.</li><li>They elect a <strong>MASTER</strong> via VRRP priority — the master claims the VIP (e.g. 192.168.5.10) on its network interface.</li><li>The other 2 nodes are <strong>BACKUP</strong> — they watch for VRRP heartbeats from the master.</li><li>If the master node or its HAProxy dies, keepalived detects it within ~1–3 seconds and moves the VIP to the next-highest-priority healthy node.</li><li>Your application only ever connects to 192.168.5.10:5000 (write) and :5001 (read) — it never needs to know which physical node is behind it.</li></ul><p>Crucially, keepalived should <strong>check that HAProxy is actually running</strong> on each node — not just that the node is up — otherwise the VIP could sit on a node whose HAProxy crashed while Postgres is fine. That’s what the vrrp_script block does below.</p><h3>Install and configure — on all 3 nodes</h3><p>Install and configure — on all 3 nodes</p><pre>dnf install -y keepalived</pre><p><strong>On node1</strong> (/etc/keepalived/keepalived.conf):</p><pre>vrrp_script chk_haproxy {<br>    script &quot;killall -0 haproxy&quot;<br>    interval 2<br>    weight 2<br>    fall 3<br>    rise 2<br>}<br><br>vrrp_instance VI_1 {<br>    state MASTER<br>    interface eth0<br>    virtual_router_id 51<br>    priority 150<br>    advert_int 1<br>    authentication {<br>        auth_type PASS<br>        auth_pass patroni_vip<br>    }<br>    virtual_ipaddress {<br>        192.168.5.10/24<br>    }<br>    track_script {<br>        chk_haproxy<br>    }<br>}</pre><p><strong>On node2</strong> —<strong>node2</strong> — same file, change state MASTER → state BACKUP and priority 150 → priority 140.<br><strong>On node3</strong> — identical, but state BACKUP and priority 130.</p><p>(Replace eth0 with your actual interface name — check with ip a.)</p><p>The priority values just determine who wins the initial election (node1 wins as it has the highest); after that, whichever healthy node has the highest priority holds the VIP at any given time — including automatically promoting node2 if node1 goes down.</p><p><strong>Start it</strong></p><pre>systemctl enable --now keepalived<br>systemctl status keepalived --no-pager</pre><p>Then check which node is currently holding the VIP:</p><pre>ip a | grep 192.168.5.10</pre><h3>Update application</h3><p>Instead of connecting to individual node IPs, point everything at:</p><pre>Host: 192.168.5.10<br>Write port: 5000<br>Read port: 5001</pre><h3>Test failover</h3><pre>systemctl stop keepalived   # or stop haproxy on node1<br>ip a | grep 192.168.5.10    # should now disappear from node1<br># on node2:<br>ip a | grep 192.168.5.10    # should now appear here</pre><p>Two kinds of failover here — planned (you choose it) and automatic (Patroni detects failure). Here’s both.</p><h3>1. Planned switchover (safe, use this for real maintenance)</h3><p>Run this on any node — you don’t have to be on the current leader:</p><pre>[root@node1 ~]# patronictl -c /etc/patroni.yml switchover<br>Current cluster topology<br>+ Cluster: postgres-cluster (7685278097854917530) +-------------+-----+------------+-----+<br>| Member | Host        | Role    | State     | TL | Receive LSN | Lag | Replay LSN | Lag |<br>+--------+-------------+---------+-----------+----+-------------+-----+------------+-----+<br>| node1  | 192.168.5.4 | Leader  | running   |  4 |             |     |            |     |<br>| node2  | 192.168.5.5 | Replica | streaming |  4 |   0/7000630 |   0 |  0/7000630 |   0 |<br>| node3  | 192.168.5.7 | Replica | streaming |  4 |   0/7000630 |   0 |  0/7000630 |   0 |<br>+--------+-------------+---------+-----------+----+-------------+-----+------------+-----+<br>Primary [node1]:<br>Candidate [&#39;node2&#39;, &#39;node3&#39;] []:<br>When should the switchover take place (e.g. 2026-09-15T12:22 )  [now]:<br>Are you sure you want to switchover cluster postgres-cluster, demoting current leader node1? [y/N]: y<br>2026-09-15 11:23:03.74045 Successfully switched over to &quot;node3&quot;<br><br>[root@node1 ~]# patronictl -c /etc/patroni.yml list<br>+ Cluster: postgres-cluster (7685278097854917530) +-------------+-----+------------+-----+<br>| Member | Host        | Role    | State     | TL | Receive LSN | Lag | Replay LSN | Lag |<br>+--------+-------------+---------+-----------+----+-------------+-----+------------+-----+<br>| node1  | 192.168.5.4 | Replica | streaming |  5 |   0/7000870 |   0 |  0/7000870 |   0 |<br>| node2  | 192.168.5.5 | Replica | streaming |  5 |   0/7000870 |   0 |  0/7000870 |   0 |<br>| node3  | 192.168.5.7 | Leader  | running   |  5 |             |     |            |     |<br>+--------+-------------+---------+-----------+----+-------------+-----+------------+-----+</pre><h3>2. Automatic failover (simulating a real crash)</h3><p>This is what your chaos_test.sh kill-leader already does — worth running for real now that the stack is stable:</p><pre># find current leader<br>patronictl -c /etc/patroni.yml list<br><br># SSH to that node, then:<br>sudo systemctl stop patroni</pre><p>Watch from another node:</p><pre>journalctl -u patroni -f</pre><p>You’ll see the survivors notice the leader’s etcd lease expire (~30s TTL, tunable), hold an election, and promote whichever replica has the least lag. Confirm:</p><pre>patronictl -c /etc/patroni.yml list</pre><p>To bring the old node back as a replica (it won’t rejoin as primary automatically — Patroni won’t create split-brain):</p><pre>sudo systemctl start patroni</pre><p>It’ll rejoin as a replica and sync via pg_rewind if needed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eaad426859fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Oracle 26ai-Converting a Physical Standby to a Snapshot Standby using DGMGRL Utility]]></title>
            <link>https://medium.com/@far.rony/oracle-26ai-converting-a-physical-standby-to-a-snapshot-standby-using-dgmgrl-utility-3d3e60632f5f?source=rss-aa3e989b098e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d3e60632f5f</guid>
            <category><![CDATA[oracle-database-23ai]]></category>
            <category><![CDATA[data-guard-broker]]></category>
            <category><![CDATA[oracle]]></category>
            <category><![CDATA[oracle-data-guard]]></category>
            <dc:creator><![CDATA[Foyez Ahmed Rony]]></dc:creator>
            <pubDate>Tue, 08 Sep 2026 03:33:48 GMT</pubDate>
            <atom:updated>2026-09-08T03:33:48.404Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WwEU_GslKXpBu6fTf9aNzQ.png" /></figure><p><strong>Step1:-Show the Configuration</strong></p><pre>[oracle@primarydb]$ dgmgrl sys/pass@prod<br>DGMGRL&gt; SHOW CONFIGURATION;<br><br>Configuration - DGConfig<br><br>  Protection Mode: MaxPerformance<br>  Members:<br>  prod - Primary database<br>    sec  - Physical standby database<br><br>Fast-Start Failover:  Disabled<br><br>Configuration Status:<br>SUCCESS   (status updated 54 seconds ago)</pre><p>Step2:-<strong>Issue the convert Command</strong></p><pre>DGMGRL&gt; convert database sec to snapshot standby;<br>2026-09-07T11:02:35.457+06:00<br>Converting database &quot;sec&quot; to a Snapshot Standby database, please wait...<br><br>2026-09-07T11:03:06.934+06:00<br>Database &quot;sec&quot; converted successfully<br><br>2026-09-07T11:03:06.939+06:00<br>DGMGRL&gt;</pre><p><strong>Step3:-Show the Configuration</strong></p><pre>DGMGRL&gt; SHOW CONFIGURATION;<br><br>Configuration - DGConfig<br><br>  Protection Mode: MaxPerformance<br>  Members:<br>  prod - Primary database<br>    sec  - Snapshot standby database<br><br>Fast-Start Failover:  Disabled<br><br>Configuration Status:<br>SUCCESS   (status updated 26 seconds ago)</pre><p><strong>Step4:- Convert backup to Physical standby database</strong></p><pre>DGMGRL&gt; convert database sec to PHYSICAL STANDBY;<br>2026-09-07T15:29:18.642+06:00<br>Converting database &quot;sec&quot; to a Physical Standby database, please wait...<br><br>2026-09-07T15:29:19.326+06:00<br>Operation requires shut down of instance &quot;sec&quot; on database &quot;sec&quot;<br>Shutting down instance &quot;sec&quot;...<br>Connected to &quot;sec&quot;<br>Database closed.<br>Database dismounted.<br>ORACLE instance shut down.<br><br>2026-09-07T15:30:04.526+06:00<br>Operation requires start up of instance &quot;sec&quot; on database &quot;sec&quot;<br>Starting instance &quot;sec&quot;...<br>Connected to an idle instance.<br>ORACLE instance started.<br>Connected to &quot;sec&quot;<br>Database mounted.<br><br>2026-09-07T15:31:16.349+06:00<br>Continuing to convert database &quot;sec&quot; ...<br><br>2026-09-07T15:31:48.358+06:00<br>Database &quot;sec&quot; converted successfully<br><br>2026-09-07T15:31:48.359+06:00</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d3e60632f5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Oracle APEX 22.2, ORDS & Tomcat Installation Guide]]></title>
            <link>https://medium.com/@far.rony/oracle-apex-22-2-ords-tomcat-installation-guide-74761132e389?source=rss-aa3e989b098e------2</link>
            <guid isPermaLink="false">https://medium.com/p/74761132e389</guid>
            <category><![CDATA[oracle-apex]]></category>
            <category><![CDATA[ord]]></category>
            <category><![CDATA[oracle]]></category>
            <dc:creator><![CDATA[Foyez Ahmed Rony]]></dc:creator>
            <pubDate>Wed, 02 Sep 2026 03:52:44 GMT</pubDate>
            <atom:updated>2026-09-02T04:08:39.410Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WN-TYL9bzbucpdFxLYzNtw.png" /></figure><h3>1. Environment Prerequisites &amp; Setup</h3><h4>Environment Variables</h4><p>Add the following configuration to your /home/oracle/.bash_profile</p><pre># Oracle &amp; Java Settings<br>export JAVA_HOME=/u01/jdk-11.0.9<br>export PATH=$JAVA_HOME/bin:$PATH<br><br># Tomcat Settings<br>export CATALINA_HOME=/u01/apache-tomcat-9.0.45<br>export CATALINA_BASE=$CATALINA_HOME<br>export CATALINA_OPTS=&quot;$CATALINA_OPTS -Duser.timezone=UTC&quot;<br><br># ORDS Settings<br>export ORDS_HOME=/u01/ords<br>export ORDS_CONFIG=/u01/ords/config<br>export ORDS_LOGS=${ORDS_CONFIG}/logs<br>export PATH=$ORDS_HOME/bin:$PATH<br><br># ORDS Deployment Parameters<br>export DB_PORT=1521<br>export DB_SERVICE=orclpdb<br>export SYSDBA_USER=SYS<br>export SYSDBA_PASSWORD=SysPassword1<br>export ORDS_PASSWORD=Password1<br><br># Tomcat Java Options for ORDS<br>export JAVA_OPTS=&quot;-Dconfig.url=${ORDS_CONFIG} -Xms1024M -Xmx1024M&quot;</pre><p>Apply the profile changes:</p><pre>source ~/.bash_profile</pre><h3>2. Oracle APEX Installation</h3><h4>Step 1: Create Tablespace</h4><p>Log into your target Pluggable Database (PDB) as SYSDBA:</p><pre>sqlplus / as sysdba<br>ALTER SESSION SET CONTAINER = orclpdb;<br><br>CREATE TABLESPACE apex <br>  DATAFILE &#39;/u01/app/oracle/oradata/orcl/apex01.dbf&#39; <br>  SIZE 100M AUTOEXTEND ON NEXT 1M;</pre><h3>Step 2: Extract &amp; Install APEX</h3><p>Extract the APEX package and run the installation script:</p><pre>cd /u01<br>unzip apex_22.2.zip<br>cd apex<br>sqlplus / as sysdba<br>ALTER SESSION SET CONTAINER = orclpdb;<br><br>-- Syntax: @apexins.sql tablespace_apex tablespace_files tablespace_temp images<br>@apexins.sql APEX APEX TEMP /i/</pre><h3>Step 3: Configure APEX Instance &amp; Users</h3><p>Set the Instance Administrator password:</p><pre>@apxchpwd.sql</pre><p>Configure RESTful Services:</p><pre>@apex_rest_config.sql</pre><p>Unlock and update APEX schema accounts:</p><pre>ALTER USER APEX_220200 IDENTIFIED BY &quot;Pass&quot; ACCOUNT UNLOCK;<br>ALTER USER APEX_PUBLIC_USER IDENTIFIED BY &quot;Pass&quot; ACCOUNT UNLOCK;<br>ALTER USER ANONYMOUS IDENTIFIED BY &quot;Pass&quot; ACCOUNT UNLOCK;</pre><h3>3. ORDS Installation &amp; Configuration</h3><blockquote>Step 1: Prepare ORDS Directory</blockquote><pre>mkdir -p /u01/ords/config/logs<br>cd /u01/ords<br>unzip /path/to/ords-22.x.zip</pre><h3>Step 2: Silent ORDS Installation (ORDS 22.x+)</h3><p>Run the unattended installation against your PDB:</p><pre>ords --config ${ORDS_CONFIG} install \<br>     --log-folder ${ORDS_LOGS} \<br>     --admin-user ${SYSDBA_USER} \<br>     --db-hostname localhost \<br>     --db-port ${DB_PORT} \<br>     --db-servicename ${DB_SERVICE} \<br>     --feature-db-api true \<br>     --feature-rest-enabled-sql true \<br>     --feature-sdw true \<br>     --gateway-mode proxied \<br>     --gateway-user APEX_PUBLIC_USER \<br>     --password-stdin &lt;&lt;EOF<br>${SYSDBA_PASSWORD}<br>${ORDS_PASSWORD}<br>EOF</pre><p>Unlock ORDSYS schema if locked:</p><pre>sqlplus / as sysdba<br>ALTER SESSION SET CONTAINER = orclpdb;<br>ALTER USER ORDSYS IDENTIFIED BY &quot;Pass&quot; ACCOUNT UNLOCK;</pre><h3>4. Apache Tomcat Integration &amp; Deployment</h3><h4>Step 1: Deploy APEX Static Images</h4><p>Copy APEX static assets to Tomcat’s web root:</p><pre>[oracle@oracledb u01]$ tar -xzf jdk-11.0.9_linux-x64_bin.tar.gz<br>[oracle@oracledb u01]$ tar -xzf apache-tomcat-9.0.45.tar.gz<br><br>#Copy the APEX images to the Tomcat &quot;webapps&quot; directory.<br>mkdir -p $CATALINA_HOME/webapps/i/<br>cp -R /u01/apex/images/* $CATALINA_HOME/webapps/i/</pre><h4>Step 2: Deploy ORDS WAR File</h4><p>Copy the ORDS application archive to Tomcat:</p><pre>cp /u01/ords/ords.war $CATALINA_HOME/webapps/</pre><h4>Step 3: Manage Tomcat Service</h4><p>Start or restart Tomcat to deploy ords.war:</p><pre># Stop Tomcat<br>$CATALINA_HOME/bin/shutdown.sh<br># Start Tomcat<br>$CATALINA_HOME/bin/startup.sh<br><br>#Verify Tomcat is running:<br>ps -ef | grep tomcat</pre><p>To verify and unlock the actual ORDS-managed schema accounts, run:</p><pre>-- Check the status of actual ORDS runtime accounts<br>SELECT username, account_status <br>FROM dba_users <br>WHERE username LIKE &#39;ORDS_%&#39;;</pre><pre>-- Unlock and set passwords for the generated ORDS users<br>ALTER USER ORDS_METADATA IDENTIFIED BY &quot;Pass&quot; ACCOUNT UNLOCK;<br>ALTER USER ORDS_PUBLIC_USER IDENTIFIED BY &quot;Pass&quot; ACCOUNT UNLOCK;</pre><h4>5. Verification</h4><p>Access APEX through your browser using your Tomcat host and port (default 8080):</p><ul><li><strong>APEX Administration Services:</strong> http://&lt;hostname&gt;:8080/ords/apex_admin</li><li><strong>APEX Workspace Login:</strong> http://&lt;hostname&gt;:8080/ords</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74761132e389" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Grant SELECT Object Privilege on One or More Objects to a User/Role]]></title>
            <link>https://medium.com/@far.rony/how-to-grant-select-object-privilege-on-one-or-more-objects-to-a-user-role-c02ffe51caa1?source=rss-aa3e989b098e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c02ffe51caa1</guid>
            <category><![CDATA[grant-permisson]]></category>
            <category><![CDATA[create-user]]></category>
            <category><![CDATA[grant-role]]></category>
            <category><![CDATA[oracle-database]]></category>
            <dc:creator><![CDATA[Foyez Ahmed Rony]]></dc:creator>
            <pubDate>Tue, 05 May 2026 06:39:14 GMT</pubDate>
            <atom:updated>2026-05-05T06:39:14.918Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dXg78I9KNYF-R-zDvYsiLg.png" /></figure><h3>1. Create User</h3><pre>CREATE USER report_user IDENTIFIED BY &quot;strong_password&quot;;<br>GRANT CREATE SESSION TO report_user;</pre><h3>2. Create Role</h3><pre>CREATE ROLE PGMS_ACCESS_ROLE;<br>GRANT PGMS_ACCESS_ROLE TO report_user;</pre><h3>3. Grant SELECT on all existing objects in a schema</h3><p>Let’s say your schema is APP_SCHEMA.</p><pre>BEGIN<br>  FOR t IN (<br>    SELECT owner, table_name <br>    FROM all_tables <br>    WHERE owner = &#39;APP_SCHEMA&#39;<br>  )<br>  LOOP<br>    EXECUTE IMMEDIATE <br>      &#39;GRANT SELECT ON &#39; || t.owner || &#39;.&#39; || t.table_name || &#39; TO PGMS_ACCESS_ROLE&#39;;<br>  END LOOP;<br>END;<br>/</pre><p>Or</p><pre>SELECT &#39;GRANT SELECT ON &#39;||OWNER||&#39;.&#39;||TABLE_NAME||&#39; TO PGMS_ACCESS_ROLE;&#39; FROM DBA_TABLES WHERE OWNER=&#39;APP_SCHEMA&#39;;</pre><p>Also include <strong>views</strong>:</p><pre>BEGIN<br>  FOR v IN (<br>    SELECT owner, view_name <br>    FROM all_views <br>    WHERE owner = &#39;APP_SCHEMA&#39;<br>  )<br>  LOOP<br>    EXECUTE IMMEDIATE <br>      &#39;GRANT SELECT ON &#39; || v.owner || &#39;.&#39; || v.view_name || &#39; TO PGMS_ACCESS_ROLE&#39;;<br>  END LOOP;<br>END;<br>/</pre><p>Or</p><pre>select &#39;GRANT select ON &#39;||owner||&#39;.&#39;||object_name||&#39; TO PGMS_ACCESS_ROLE;&#39;<br>from all_objects<br>where owner = &#39;APP_SCHEMA&#39;<br>and object_type=&#39;VIEW&#39;;</pre><h3>4. Grant EXECUTE on procedures and functions</h3><pre>BEGIN<br>  FOR p IN (<br>    SELECT owner, object_name <br>    FROM all_procedures <br>    WHERE owner = &#39;APP_SCHEMA&#39;<br>  )<br>  LOOP<br>    EXECUTE IMMEDIATE <br>      &#39;GRANT EXECUTE ON &#39; || p.owner || &#39;.&#39; || p.object_name || &#39; TO PGMS_ACCESS_ROLE&#39;;<br>  END LOOP;<br>END;<br>/</pre><p>Or</p><pre>select &#39;GRANT EXECUTE ON &#39;||owner||&#39;.&#39;||object_name||&#39; TO PGMS_ACCESS_ROLE;&#39;<br>from all_objects<br>where owner = &#39;APP_SCHEMA&#39;<br>and object_type=&#39;FUNCTION&#39;;</pre><h3>5. Handle future objects (VERY IMPORTANT)</h3><p>The above only covers existing objects. For new ones, you need a trigger:</p><pre>CREATE OR REPLACE TRIGGER grant_select_execute<br>AFTER CREATE ON APP_SCHEMA.SCHEMA<br>BEGIN<br>  IF ORA_DICT_OBJ_TYPE IN (&#39;TABLE&#39;,&#39;VIEW&#39;) THEN<br>    EXECUTE IMMEDIATE <br>      &#39;GRANT SELECT ON APP_SCHEMA.&#39; || ORA_DICT_OBJ_NAME || &#39; TO PGMS_ACCESS_ROLE&#39;;<br>  ELSIF ORA_DICT_OBJ_TYPE IN (&#39;PROCEDURE&#39;,&#39;FUNCTION&#39;,&#39;PACKAGE&#39;) THEN<br>    EXECUTE IMMEDIATE <br>      &#39;GRANT EXECUTE ON APP_SCHEMA.&#39; || ORA_DICT_OBJ_NAME || &#39; TO PGMS_ACCESS_ROLE&#39;;<br>  END IF;<br>END;<br>/</pre><h3>⚠ Notes (Important DBA insight)</h3><ul><li>Oracle <strong>does NOT have a single “GRANT SELECT ON SCHEMA”</strong> (unlike PostgreSQL)</li><li>You must loop or automate</li><li>If using packages, EXECUTE on package is enough (no need per procedure)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c02ffe51caa1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Inside Oracle RAC: How SCAN and VIP Keep Your Database Always Available]]></title>
            <link>https://medium.com/@far.rony/inside-oracle-rac-how-scan-and-vip-keep-your-database-always-available-e0d02e7b09cc?source=rss-aa3e989b098e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0d02e7b09cc</guid>
            <dc:creator><![CDATA[Foyez Ahmed Rony]]></dc:creator>
            <pubDate>Tue, 25 Nov 2025 10:56:00 GMT</pubDate>
            <atom:updated>2025-11-25T11:14:30.847Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*TPjjUYGW69PWVBG80bdnjg.png" /></figure><p><strong>SCAN basics</strong></p><ul><li>SCAN = <strong>Single Client Access Name</strong></li><li>Introduced in Oracle 11gR2</li><li>Resolves to <strong>3 SCAN IPs</strong> (via DNS or GNS)</li><li>Each SCAN IP runs a <strong>SCAN listener</strong></li></ul><p><strong>Private IP:</strong> This IP address is used for interconnecting nodes. Systems can’t be accessed using this IP from the outside world.<br><strong>Public IP:</strong> This IP is used for accessing the system for day-to-day tasks, monitoring, etc.</p><p><strong>What is VIP?</strong></p><ul><li><strong>VIP = Virtual IP Address</strong></li><li>It is <strong>not tied permanently to a physical server</strong>; it can <strong>move (float) to another node</strong> in the RAC cluster.</li><li>VIP is <strong>used by the node listener</strong> to serve client connections.</li></ul><h3><strong>Why VIP exists in RAC</strong></h3><ol><li><strong>Fast failover</strong></li></ol><ul><li>If a node fails, its VIP moves to a surviving node.</li><li>Clients trying to connect to the failed node get redirected to the new VIP automatically.</li></ul><p><strong>2. Detect failed nodes quickly</strong></p><ul><li>When a client cannot reach a VIP, it immediately knows the node is down.</li><li>Without VIP, client connections would hang until TCP timeout.</li></ul><p><strong>3. Separate from public IP</strong></p><ul><li>Public IP = node’s real physical address</li></ul><h4>VIP = logical address for clients, can float to other node</h4><h3><strong>Key point: SCAN itself does not “magically know” VIPs</strong></h3><ul><li>SCAN is <strong>just a DNS name</strong> that resolves to 3 SCAN IPs.</li><li>Each SCAN IP runs a <strong>SCAN listener</strong> (LISTENER process).</li><li>The SCAN listener <strong>does not have the database itself</strong>, nor the VIP by default.</li></ul><p>So the question is: <strong>how does the SCAN listener know which node VIP to send the client to?</strong></p><p><strong>2️⃣ Cluster Registry (CRS / Oracle Clusterware)</strong></p><ul><li>Every RAC node runs <strong>CRS (Cluster Ready Services)</strong></li><li>CRS maintains <strong>all cluster metadata</strong>, including:</li></ul><ol><li>Which nodes are alive</li><li>Which services are running on which node</li><li>Which VIPs are active on which node</li></ol><ul><li>When a database service starts, its <strong>PMON process</strong> registers the service with:</li></ul><ol><li>Node listener (on the VIP)</li><li>SCAN listeners (on the SCAN IPs)</li></ol><p>This registration is <strong>dynamic</strong>.</p><p><strong>3️⃣ Service registration process</strong></p><ol><li>The database instance starts on Node1</li><li>PMON registers Service1 with:</li><li>Node listener: LISTENER@Node1 VIP (192.168.0.59)</li><li>SCAN listeners: LISTENER@SCAN1, LISTENER@SCAN2, LISTENER@SCAN3</li><li>SCAN listeners now know <strong>“Service1 is currently on Node1 VIP 192.168.0.59”</strong></li></ol><p>This is the key: <strong>SCAN listener queries CRS metadata/registration table</strong> to find where the service is currently running.</p><p><strong>4️⃣ Client connection flow</strong></p><p>Suppose:</p><ul><li>SCAN NAME: rac-scan.mydomain.com → 192.168.0.101 / 102 / 103</li><li>Node1 VIP: 192.168.0.59</li><li>Node2 VIP: 192.168.0.60</li><li>Service: Service1</li></ul><p><strong>Steps:</strong></p><ol><li>Client resolves <strong>rac-scan.mydomain.com </strong>→ chooses 192.168.0.101</li><li>Client connects → SCAN listener on 192.168.0.101</li><li>SCAN listener <strong>looks in CRS</strong> → finds:</li><li>Service1 is currently registered on Node1 <strong>VIP 192.168.0.59</strong></li><li>SCAN listener sends <strong>redirect</strong> → tells client:</li><li>Connect to 192.168.0.59:1521</li><li>Client disconnects from SCAN → reconnects to Node1 VIP → Service1</li></ol><p><strong>5️⃣ Failover scenario</strong></p><ul><li>Node1 fails → VIP 192.168.0.59 moves to Node2</li><li>CRS is updated → SCAN listeners now know:</li><li>Service1 is now on Node2 VIP 192.168.0.59</li><li>Next client connection to SCAN → redirected to <strong>new node VIP automatically</strong></li></ul><p>SCAN itself never moves or changes, it just <strong>queries cluster metadata to see where the service lives</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*HHA5OkmfjVevVFaNNYzAkg.png" /></figure><p><strong>Client connect (TNS)</strong></p><p><strong>tnsnames.ora</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*a1djh8kBond4s6WVo2rbDA.png" /></figure><p><strong>Node1 listener.ora</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Oq4544nT4sBk0_olxYMlWA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0d02e7b09cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When Oracle Picks the Wrong Execution Plan — Take Back Control]]></title>
            <link>https://medium.com/@far.rony/when-oracle-picks-the-wrong-execution-plan-take-back-control-b559ef758b6e?source=rss-aa3e989b098e------2</link>
            <guid isPermaLink="false">https://medium.com/p/b559ef758b6e</guid>
            <category><![CDATA[oracle-database]]></category>
            <category><![CDATA[performance-tuning]]></category>
            <category><![CDATA[database-performance]]></category>
            <category><![CDATA[execution-plan]]></category>
            <dc:creator><![CDATA[Foyez Ahmed Rony]]></dc:creator>
            <pubDate>Wed, 13 Aug 2025 06:15:28 GMT</pubDate>
            <atom:updated>2025-08-13T06:15:28.980Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>When Oracle Picks the Wrong Execution Plan — Take Back Control</strong></h3><p>You’ve seen it happen.</p><p>A query runs like lightning in QA ✅<br> Then in production… it crawls ❌</p><p>No code changes. No database upgrades. Just… slow.</p><p><strong>The culprit?</strong><br> The Oracle Optimizer decided to pick a different execution plan.</p><p>When this happens in a business-critical query, you don’t always have the luxury of rewriting code, adding hints, or restarting the application. You need a <strong>quick, non-invasive fix</strong>.</p><p>That’s where coe_xfr_sql_profile.sql from <strong>SQLT</strong> (SQLTXPLAIN) comes in. It lets you <em>lock in</em> a known-good execution plan instantly — without touching application code.</p><p><strong>🎯 What We’ll Do</strong></p><p>We’ll:</p><ol><li>Identify the SQL statement</li><li>Find its fastest plan in history</li><li>Create a SQL Profile to force that plan in production</li></ol><p><strong>🛠 Requirements</strong></p><p>Before you start, make sure you have:</p><ul><li><strong>DBA privileges</strong> (SYSDBA access)</li><li><strong>SQLT installed</strong> on the target database</li><li><strong>SQL_ID</strong> of the query in both environments (good and bad plans)</li></ul><p><strong>🔍 Step-by-Step Process</strong></p><p><strong>Step 1: Identify the SQL</strong></p><p>Find the query by text:</p><pre>SELECT sql_id, sql_text<br>FROM v$sql<br>WHERE sql_text LIKE &#39;%your_query%&#39;;</pre><p><strong>Step 2: Find the Best Plan</strong></p><p>Check past execution times to locate the fastest plan_hash_value:</p><pre>SELECT sql_id, plan_hash_value, executions, elapsed_time<br>FROM v$sql<br>WHERE sql_id = &#39;your_sql_id&#39;<br>ORDER BY elapsed_time;</pre><p>Pick the <strong>plan_hash_value</strong> with the best performance.</p><p><strong>Step 3: Run coe_xfr_sql_profile.sql</strong></p><p>From $ORACLE_HOME/rdbms/admin:</p><pre>sqlplus / as sysdba<br>@coe_xfr_sql_profile.sql</pre><p>When prompted, enter:</p><ul><li>SQL_ID</li><li>PLAN_HASH_VALUE of the good plan</li></ul><p>This generates a .sql file named:</p><pre>coe_xfr_sql_profile_&lt;sql_id&gt;_&lt;plan_hash_value&gt;.sql</pre><p><strong>Step 4: Apply the SQL Profile</strong></p><pre>@coe_xfr_sql_profile_&lt;sql_id&gt;_&lt;plan_hash_value&gt;.sql</pre><p>You should see:</p><p>SQL Profile “COE_&lt;sql_id&gt;_&lt;plan_hash_value&gt;” created.</p><p><strong>Step 5: Validate</strong></p><p>Confirm that the profile is active:</p><pre>SELECT sql_id, sql_profile<br>FROM dba_sql_profiles<br>WHERE sql_id = &#39;your_sql_id&#39;;</pre><p><strong>✅ Why This Method Works</strong></p><ul><li><strong>No code changes</strong> — Safe for production</li><li><strong>Reversible</strong> — Drop the profile anytime</li><li><strong>Immediate impact</strong> — No restart needed</li><li><strong>Stability</strong> — Critical queries stay on the good plan</li></ul><p>💡 <strong>Pro Tip:</strong><br> This method works best when the execution plan’s performance difference is due to optimizer choices (e.g., different join methods, missing histograms). If the plan difference is due to outdated statistics or missing indexes, fix those root causes too.</p><p>In many cases you <strong>can</strong> simply run DBMS_STATS.GATHER_TABLE_STATS and fix the problem — <strong>if</strong> the root cause is just <strong>stale or missing statistics</strong>.</p><p>Example quick fix:</p><pre>BEGIN<br>    DBMS_STATS.GATHER_TABLE_STATS(<br>        ownname =&gt; &#39;YOUR_SCHEMA&#39;,<br>        tabname =&gt; &#39;YOUR_TABLE&#39;,<br>        cascade =&gt; TRUE -- also gathers index stats<br>    );<br>END;<br>/</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b559ef758b6e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing and Configuring MariaDB Galera Cluster on CentOS 8/9]]></title>
            <link>https://medium.com/@far.rony/installing-and-configuring-mariadb-galera-cluster-on-centos-8-b2145b127ce8?source=rss-aa3e989b098e------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2145b127ce8</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[mariadb]]></category>
            <category><![CDATA[galera-cluster]]></category>
            <dc:creator><![CDATA[Foyez Ahmed Rony]]></dc:creator>
            <pubDate>Sun, 13 Jul 2025 09:21:41 GMT</pubDate>
            <atom:updated>2025-07-26T05:12:42.885Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*vlfmbKbQ9aN1Ky4aBR6I-A.png" /></figure><p>In this guide, I’ll walk you through setting up a MariaDB Galera Cluster on CentOS 8. Galera Cluster provides synchronous multi-master replication for MariaDB, offering high availability and scalability for your database infrastructure.</p><h3>Prerequisites</h3><ul><li>Three servers running CentOS 8 (192.168.5.67, 192.168.5.68, 192.168.5.69 in this example)</li><li>Root or sudo privileges on all servers</li><li>Network connectivity between nodes</li></ul><h3>Step 1: Disable Firewall (for testing environments only)</h3><p>For lab environments, we’ll disable the firewall. In production, you should configure proper firewall rules instead.</p><pre>systemctl stop firewalld<br>systemctl disable firewalld</pre><h3>Step 2: Set Up MariaDB Repository</h3><p>Install the official MariaDB repository:</p><pre>wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup<br>chmod +x mariadb_repo_setup # Assign executable permissions<br>./mariadb_repo_setup --mariadb-server-version=&quot;mariadb-10.11.6&quot;</pre><h3>Step 3: Install MariaDB Packages</h3><p>Install MariaDB packages:</p><pre>sudo yum install mariadb -y<br>sudo yum install MariaDB -y</pre><h3>Step 4: Start and Secure MariaDB</h3><p>Start the MariaDB service and run the security script:</p><pre>sudo systemctl start mariadb<br>sudo systemctl enable mariadb<br>sudo mariadb-secure-installation</pre><p>Follow the prompts to set a root password and secure your installation.</p><h3>Step 5: Configure Galera Cluster</h3><p>Edit the MariaDB configuration file:</p><pre>vi /etc/my.cnf.d/server.cnf</pre><p>Add the Galera configuration section (repeat on all nodes with appropriate IP addresses):</p><pre>[mysqld]<br>log_error = /var/log/mysql/mariadb-error.log<br>general_log = 1<br>general_log_file = /var/log/mysql/mariadb-query.log<br>[galera]<br># Mandatory settings<br>wsrep_on=ON<br>wsrep_provider=/usr/lib64/galera-4/libgalera_smm.so<br>wsrep_cluster_address=&quot;gcomm://192.168.5.67,192.168.5.68,192.168.5.69&quot;<br>wsrep_cluster_name=&quot;my_galera_cluster&quot;<br>wsrep_node_address = 192.168.5.67   # Local node IP<br>binlog_format=row<br>default_storage_engine=InnoDB<br>innodb_autoinc_lock_mode=2</pre><p>Ensure the log directory exists and has the correct permissions:</p><pre>sudo mkdir -p /var/log/mysql<br>sudo chown mysql:mysql /var/log/mysql</pre><h3>Step 6: Bootstrap the Cluster</h3><p>Stop MariaDB on all nodes:</p><pre>systemctl stop mariadb</pre><p>On the first node (192.168.5.67 in this example), bootstrap the new cluster:</p><pre>[root@node1 ~]# galera_new_cluster</pre><p>On the other nodes, simply start MariaDB:</p><pre>systemctl start mariadb</pre><h3>Step 7: Verify Cluster Status</h3><p>Check the cluster size to verify all nodes have joined:</p><pre>mysql -u root -p -e &quot;SHOW STATUS LIKE &#39;wsrep_cluster_size&#39;&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*MubbBrLWDTr1kAzGuDSPnw.png" /></figure><p>You should see output indicating the number of nodes in the cluster.</p><h3>Conclusion</h3><p>You’ve now successfully set up a MariaDB Galera Cluster on CentOS 8. The cluster provides synchronous replication across all nodes, ensuring high availability for your database services.</p><p>For production environments, consider:</p><ul><li>Proper firewall configuration instead of disabling it</li><li>Monitoring solutions to track cluster health</li><li>Regular backups</li><li>Proper security hardening</li></ul><p>The Galera Cluster will automatically handle node failures and rejoins, maintaining data consistency across all nodes.</p><h3>✅ Step-by-Step Recovery When All Nodes Are Down</h3><h3>🔍 Step 1: Choose the Best Node to Bootstrap</h3><p>Look for the node with the <strong>highest transaction </strong><strong>seqno</strong>. Check this file:</p><pre>cat /var/lib/mysql/grastate.dat</pre><p>Look for this line:</p><pre>seqno: 12345   ← choose the node with the highest number</pre><h3>🚀 Step 2: Bootstrap the Cluster on That Node</h3><p>On the selected node (e.g. node1):</p><pre>[root@node1 ~]# galera_new_cluster</pre><h3>✅ Step 3: Verify Cluster Is Running</h3><pre>mysql -u root -e &quot;SHOW STATUS LIKE &#39;wsrep_cluster_size&#39;;&quot;</pre><p>Should return:</p><pre>| wsrep_cluster_size | 1 |</pre><p>Also check:</p><pre>mysql -u root -e &quot;SHOW STATUS LIKE &#39;wsrep_cluster_status&#39;;&quot;</pre><p>Should return:</p><pre>| wsrep_cluster_status | Primary |</pre><h3>🟢 Step 4: Start MariaDB Normally on the Other Nodes</h3><p>On node2 and node3:</p><pre>sudo systemctl start mariadb</pre><p>Then check on each:</p><pre>mysql -u root -e &quot;SHOW STATUS LIKE &#39;wsrep_cluster_size&#39;;&quot;</pre><p>Eventually, all nodes should report:</p><pre>| wsrep_cluster_size | 3 |</pre><p>Having <strong>3 nodes in DC (Data Center)</strong> and <strong>2 nodes in DR (Disaster Recovery)</strong> is a common and smart pattern in Galera clustering, but it comes with trade-offs.</p><h3>✅ Pros of 3 DC + 2 DR Node Setup</h3><h3>1. ✅ Quorum favors DC</h3><ul><li>You have <strong>3 nodes in DC</strong> → they hold <strong>majority (3/5)</strong>.</li><li>In case of <strong>network split</strong>, DC can retain <strong>quorum</strong> and continue accepting writes.</li><li>DR site with only 2 nodes <strong>won’t form quorum</strong>, so it won’t become primary → avoids split-brain.</li></ul><h3>2. ✅ High Availability in DC</h3><ul><li>Even if <strong>1 or 2 nodes fail</strong> in DC, the cluster continues (as long as 3 nodes total are up with majority).</li></ul><h3>3. ✅ DR Redundancy</h3><p>DR site can be used as:</p><ul><li>Read-only replicas (if configured safely)</li><li>Backup/snapshot destination</li><li>SST donor nodes if needed</li><li>They can <strong>join back automatically</strong> if partition heals.</li></ul><h3>4. ✅ Disaster Recovery (DR) Preparedness</h3><ul><li>If DC is completely lost, you can <strong>manually promote DR site</strong> by:</li><li>Bootstrapping 1 DR node using --wsrep-new-cluster</li><li>Letting others join it</li></ul><h3>❌ Cons / Challenges</h3><h3>1. ❌ DR Site Has No Write Capability in Split</h3><ul><li>If DC loses connectivity, DR site (2 nodes) <strong>cannot reach quorum (2/5)</strong> → <strong>no writes allowed</strong>.</li><li>This is by design (CP model), but <strong>may confuse applications</strong>.</li></ul><h3>2. ❌ Manual Intervention Needed in DR-Only Failover</h3><ul><li>If DC is permanently down, you must:</li><li>Choose a DR node</li><li>Bootstrap it with --wsrep-new-cluster</li><li>Rebuild the cluster</li><li>This is <strong>not automatic</strong> (by design, to prevent split-brain).</li></ul><h3>3. ❌ Asymmetric Latency</h3><ul><li>DR nodes may experience <strong>higher latency</strong> to DC.</li></ul><p>This affects:</p><ul><li>Synchronous replication</li><li>Certification process</li><li>Write performance</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2145b127ce8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding AWR Report Metrics -Part02]]></title>
            <link>https://medium.com/@far.rony/understanding-awr-report-metrics-part02-8edbad5f4cc3?source=rss-aa3e989b098e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8edbad5f4cc3</guid>
            <category><![CDATA[oracle-database]]></category>
            <dc:creator><![CDATA[Foyez Ahmed Rony]]></dc:creator>
            <pubDate>Tue, 20 May 2025 10:27:36 GMT</pubDate>
            <atom:updated>2025-05-20T10:27:36.935Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*0EEsHoF1wb79EdONT70Eqg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*ohxMgG09uJANLP3qvwcYMA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*XClNsLf7eSWdU7IEFTf0cQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*mzYymeXzzQ5CbVhn29fBAw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*RSHocZiDXx2Te5tycNxhQQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*JHkySkV47bPU-6KeoZF8WQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*atSDyhi_BiKaCUqZOllxYA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*a764wOtVIV9l5kwaz4RhFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*G-QzstK3Wh8sDcb9dWv2IA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8edbad5f4cc3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding AWR Report Metrics -Part01]]></title>
            <link>https://medium.com/@far.rony/understanding-awr-report-metrics-d36a2bcd83b0?source=rss-aa3e989b098e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d36a2bcd83b0</guid>
            <category><![CDATA[oracle-database]]></category>
            <category><![CDATA[oracle-performance-tuning]]></category>
            <category><![CDATA[performance-tuning]]></category>
            <dc:creator><![CDATA[Foyez Ahmed Rony]]></dc:creator>
            <pubDate>Tue, 20 May 2025 07:29:33 GMT</pubDate>
            <atom:updated>2025-05-20T08:31:12.200Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0IZJtdRLhpfGdh0AA8o6YA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*hnLoMeW01zwwwvYiP4tS9g.png" /></figure><p><strong>🔷 Database Snapshot Metrics</strong></p><p>Snapshot Timeframe</p><ul><li>Begin Snap: ID 14864 at 22-Apr-25 11:00:34</li><li>End Snap: ID 14865 at 22-Apr-25 11:17:04</li><li>Elapsed Time: 16.5 minutes</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*WyHem5Ah-etlMM8PKE6pFQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*S3MRGNWRrOrh-hrQoV9bEA.png" /></figure><p><strong>How to Spot Waits as the Bottleneck</strong></p><p><strong>1. High DB Time + Low CPU Utilization = Wait Suspects</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*xgPUVVk8sSl8a3jktnHUcg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d36a2bcd83b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Time Model]]></title>
            <link>https://medium.com/@far.rony/using-time-model-8ffc6f6925dc?source=rss-aa3e989b098e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ffc6f6925dc</guid>
            <category><![CDATA[oracle-database]]></category>
            <category><![CDATA[oracle-awr]]></category>
            <dc:creator><![CDATA[Foyez Ahmed Rony]]></dc:creator>
            <pubDate>Sun, 18 May 2025 11:32:02 GMT</pubDate>
            <atom:updated>2025-05-18T11:32:02.746Z</atom:updated>
            <content:encoded><![CDATA[<p>DB time: The time the database spends on serving requests by processing them and by waiting is collectively called DB time.</p><p>Perform processing (DB CPU)</p><p>Waiting for a resource (DB waits)</p><pre>DB Time = DB CPU + total DB waits</pre><p>DB time represents the time the database spent on executing the user calls (DB CPU and DB waits)</p><p><strong>Time Model</strong></p><p>Available in: V$SYS_TIME_MODEL and V$SESS_TIME_MODEL</p><p><strong>Database Time Model Query Example</strong></p><pre>SELECT STAT_NAME, TO_CHAR(VALUE/1000000,&#39;999,999&#39;) TIME_S<br>FROM V$SYS_TIME_MODEL<br>WHERE VALUE &lt;&gt;0 AND STAT_NAME NOT IN (&#39;background elapsed time&#39;,<br>&#39;background cpu time&#39;)<br>ORDER BY VALUE DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/0*togl48CXyvnWV6XR" /></figure><p>DB wait time = 86–33 = 53s</p><p><strong>Sessions Time Model Query Example</strong></p><pre>SELECT S.SID, S.USERNAME, T.STAT_NAME,<br>ROUND(T.VALUE/1000000,2) &quot;TIME (SEC)&quot;<br>FROM V$SESS_TIME_MODEL T, V$SESSION S<br>WHERE T.SID = S.SID AND T.STAT_NAME IN (&#39;DB time&#39;,&#39;DB CPU&#39;)<br>AND S.USERNAME IS NOT NULL ORDER BY T.VALUE DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/404/0*EYzoyTwif4Jc-9WF" /></figure><p><strong>Using Time Model to Measure System Scalability</strong></p><pre>SELECT TO_CHAR(DBTIME.VALUE/1000000,&#39;999,999&#39;) DBTIME,<br>TO_CHAR(DBCPU.VALUE/1000000,&#39;999,999&#39;) DBCPU,<br>TO_CHAR((DBTIME.VALUE-DBCPU.VALUE)/1000000,&#39;999,999&#39;) WAIT_TIME,<br>TO_CHAR((DBTIME.VALUE-DBCPU.VALUE)/DBTIME.VALUE*100,&#39;99.99&#39;) || &#39;%&#39;<br>WAIT_PCT,<br>(SELECT COUNT(*) FROM V$SESSION WHERE USERNAME IS NOT NULL) USERS_CNT<br>FROM V$SYS_TIME_MODEL DBTIME, V$SYS_TIME_MODEL DBCPU<br>WHERE DBTIME.STAT_NAME = &#39;DB time&#39; AND DBCPU.STAT_NAME = &#39;DB CPU&#39;;</pre><pre>DBTIME   DBCPU    WAIT_TIME WAIT_PC USERS_CNT<br>-------- -------- --------- ------- ----------<br>1,349   1,103     245       17.10%        10<br>2,419   1,263     1,156     45.11%       50<br>5,590   1,503     4,087     75.15%       100</pre><p>Wait_Pct increases and It will be a sluggish system if the user count increases to 100.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ffc6f6925dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>