<?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 Ahmet Yusuf Kışla on Medium]]></title>
        <description><![CDATA[Stories by Ahmet Yusuf Kışla on Medium]]></description>
        <link>https://medium.com/@yusuf.kisla?source=rss-bf0c10ccc774------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PFTJvXw2sdnMSwbQYS5Hfw.jpeg</url>
            <title>Stories by Ahmet Yusuf Kışla on Medium</title>
            <link>https://medium.com/@yusuf.kisla?source=rss-bf0c10ccc774------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 00:24:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yusuf.kisla/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[MongoDB Cluster-to-Cluster Sync]]></title>
            <link>https://medium.com/@yusuf.kisla/mongodb-cluster-to-cluster-sync-44b5b47e36a0?source=rss-bf0c10ccc774------2</link>
            <guid isPermaLink="false">https://medium.com/p/44b5b47e36a0</guid>
            <dc:creator><![CDATA[Ahmet Yusuf Kışla]]></dc:creator>
            <pubDate>Sat, 20 Jan 2024 22:02:38 GMT</pubDate>
            <atom:updated>2024-01-21T08:49:42.917Z</atom:updated>
            <content:encoded><![CDATA[<p>MongoDB Cluster-to-Cluster Sync is a method used for data synchronization between two MongoDB clusters. Two different clusters can be continuously kept in sync, and this synchronization can be stopped and triggered again whenever needed. In this article, I will try to explain how to synchronize MongoDB clusters installed on two different distributions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gf_XcvKMkfwiQLxTVqGiaA.png" /></figure><p>Let’s designate our source and destination clusters as follows:</p><p>Source:</p><ul><li>mongo-test-centos-01</li><li>mongo-test-centos-02</li><li>mongo-test-centos-03</li></ul><p>Destination:</p><ul><li>mongo-test-ubuntu-01</li><li>mongo-test-ubuntu-02</li><li>mongo-test-ubuntu-03</li></ul><p><strong>1. MongoDB Cluster-to-Cluster Sync Download</strong></p><p>You can download mongosync from the link below; it is sufficient to download it to the source server.</p><p><a href="https://www.mongodb.com/try/download/mongosync">Download MongoDB mongosync</a></p><pre>wget https://fastdl.mongodb.org/tools/mongosync/mongosync-rhel70-x86_64-1.7.1.tgz<br>After the download process, you can extract the compressed file.<br>tar -zxvf mongosync-*.tgz<br>To add the mongosync binary file to your Path, you can use one of the following commands.<br>sudo cp /root/mongosync-rhel70-x86_64-1.7.1/bin/mongosync /usr/local/bin/<br>sudo ln -s /root/mongosync-rhel70-x86_64-1.7.1/bin/mongosync /usr/local/bin/mongosync</pre><p><strong>2. Creating a New User</strong></p><p>Root role users must be created for both clusters. These users will facilitate communication and data transfer between the source and destination clusters.</p><p>Source:</p><pre>db.createUser({user: &quot;clusteradmin&quot;, pwd: &quot;password1&quot;, roles: [{role: &quot;root&quot;, db: &quot;admin&quot;}]});</pre><p>Destination:</p><pre>db.createUser({user: &quot;clusteradmin&quot;, pwd: &quot;password2&quot;, roles: [{role: &quot;root&quot;, db: &quot;admin&quot;}]});</pre><p><strong>3. Creating the Mongosync Configuration File</strong></p><p>We can create the configuration file under etc as mongosync.conf. While cluster0 points to the source cluster, cluster1 points to the destination cluster.</p><pre>vi /etc/mongosync.conf</pre><pre>cluster0: &quot;mongodb://clusteradmin:password1@mongo-test-centos-01:27127,mongo-test-centos-02:27127,mongo-test-centos-03:27127&quot;<br>cluster1: &quot;mongodb://clusteradmin:password2@mongo-ubuntu-test-01:27127,mongo-ubuntu-test-02:27127,mongo-ubuntu-test-03:27127&quot;<br>logPath: &quot;/var/log/mongosync&quot;<br>verbosity: &quot;WARN&quot;<br></pre><p>To check if the configuration is successful, you can run the following command.</p><pre>cd /usr/local/bin/ <br>nohup mongosync - config /etc/mongosync.conf &gt;&gt; mongosync1.log &amp;</pre><p><strong>4. Initiating the Synchronization Process</strong></p><p>The following command starts the synchronization, and data flow from the source cluster to the destination cluster begins. Unless manually intervened, synchronization will continue continuously. If needed, data flow can be paused and canceled.</p><pre>curl localhost:27182/api/v1/start -XPOST \<br>--data &#39;<br>   {<br>      &quot;source&quot;: &quot;cluster0&quot;,<br>      &quot;destination&quot;: &quot;cluster1&quot;,<br>      &quot;reversible&quot;: true,<br>      &quot;enableUserWriteBlocking&quot;: true<br>   } &#39;</pre><p><strong>Note: The “enableUserWriteBlocking” parameter being set to true indicates that a user other than the clusteradmin cannot input data into the destination cluster.</strong></p><p>Different situations, such as progress, pause, resume, and commit, are available for use when needed.</p><pre>curl localhost:27182/api/v1/progress -XGET<br>curl localhost:27182/api/v1/pause -XPOST --data &#39;{ }&#39;<br>curl localhost:27182/api/v1/resume -XPOST --data &#39;{ }&#39;<br>curl localhost:27182/api/v1/commit -XPOST --data &#39;{ }&#39;</pre><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44b5b47e36a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Postgresql Replication]]></title>
            <link>https://medium.com/@yusuf.kisla/postgresql-replication-4275dd557715?source=rss-bf0c10ccc774------2</link>
            <guid isPermaLink="false">https://medium.com/p/4275dd557715</guid>
            <category><![CDATA[ahmet-yusuf-kışla]]></category>
            <category><![CDATA[postgresql-database]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[postgresql-replication]]></category>
            <category><![CDATA[postgresql]]></category>
            <dc:creator><![CDATA[Ahmet Yusuf Kışla]]></dc:creator>
            <pubDate>Sat, 21 May 2022 10:23:50 GMT</pubDate>
            <atom:updated>2022-05-21T10:23:50.184Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Replikasyon ile amaçlanan canlı veritabanı üzerinde bulunan yükü hafifletmektir. Başlangıç için bir yedekleme hissi uyandırıyor olsa dahi bu işlem kesinlikle bir yedekleme değildir. Replikaya canlı veritabanının bir kopyası denilebilir ve read-only yapıya sahiptir.</em></p><p><em>Genelde çok fazla rapor çekilen veritabanları için replikasyon çıkılabilir. Bazı kullanıcıların taleplerini replika veritabanı karşılayabilecektir. Bunun getirisi ise canlı veritabanı üzerinde bulunan yoğunluğun replika sayesinde dağıtılmış olması olacaktır.</em></p><p><em>Master ve Replika olmak üzere iki sunucu(ubuntu) üzerine postgresql-14 kurulumu yapıldı.</em></p><p><em>Master sunucu ip : 192.168.3.129</em></p><p><em>Replika sunucu ip: 192.168.3.128</em></p><h4>Master Sunucu Tarafında Yapılacak İşlemler</h4><p><em>Öncelikle replication yetkisine sahip, veritabanına bağlanabilecek bir “replikauser” oluşturalım.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*TzomzX3Gyana3Kxm5F-bDQ.png" /></figure><p><em>Oluşturulan kullanıcının veritabınına erişimini sağlayabilmek için kullanıcı bilgilerini pg_hba.conf içerisinde tanımlamamız gerekmekte . Bu dosya etc/postgresql/14/main/ dizini altında bulunmakta.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*JdRooVLlRJ7m2C1BxlAK9g.png" /></figure><p><em>Replikasyon için postgresql.conf dosyası içerisinde bulunan bir kaç parametreyi aktif duruma getirmeye ihtiyacımız var. Replikasyonu local server üzerinde yapmadığımız için listen_addresses ‘*’ olarak değiştirilmelidir. listen_addresses dışında max_wal_sender, wal_keep_segment, wal_sender_timeout, max_replication_slots, track_commit_timestamp, synchronous_standby_names ve wal_level ihtiyaç duyulan parametrelerdir.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*IRo0WYCxo66ZrZoB5-hO3w.png" /></figure><p><em>Yapılan bu değişikliklerin algılanması için postgresql servisi restart edilmelidir.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*IrB-uBHAUwPTSHsfsncjqg.png" /></figure><h4><strong><em>Replika Sunucu Tarafında Yapılacak İşlemler</em></strong></h4><p><em>Ubuntu dağıtımında postgresql kurulumu yapıldığı zaman initdb işlemine ihtiyaç duymadan postgresql servisi başlıyor. Daha doğrusu initdb sistemin kendisi tarafından yapılıyor. Bu yüzden sistem /var/lib/postgresql/14/main/ dizini içerisini otomatik bir şekilde dolduruyor. Replikasyon için main dizinin içerisinin dolu olması bizim istediğimiz bir durum değildir çünkü master sunucudan bir kopyalama işlemi yapılacaktır. Main dizininin içi boş olmadığı durumda dosyaları oluşturamıyoruz. Şimdi servisi durduralım ve ardından main içerisini sağlıklı bir şekilde silelim.</em></p><p><em>Bu işlemlerin arkasından pg_basebackup komutunu yazalım.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*ywbrYfzXdSKxBpePZeHmYA.png" /></figure><ul><li><em>- Fp sıkıştırmadan al.</em></li><li><em>- R recovery.conf içerisine yaz bunun karşılığı postgresql.auto.conf dosyasıdır.</em></li><li><em>-C -S replica1 replica1 adında replication_slot oluştur.</em></li><li><em>-h master sunucu ip bilgisi.</em></li><li><em>-U replikasyon yetkisine sahip kullanıcı bilgisi. pg_hba.conf içerisinde trust olarak tanımladığımız için komut içerisinde şifre belirtmedik.</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*HYG1SdemqbdqOYCrg_hibA.png" /></figure><p><em>Durdurmuş olduğumuz servisi tekrar başlatalım.</em></p><p><strong>Tekrardan master sunucu tarafına geçelim ve replikasyonu kontrol edelim.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*9wZ0mOGMFKIBynptWxZ2Eg.png" /></figure><p><em>Replikasyon başarılı olduğu için burada replikasyon bilgilerini görüntüleyebildik. Son olarak senkron ve asenkron replikasyondan bahsetmek isterim. Yukarıda kayıt tablosunda sync_state bilgisini kontrol ettiğimiz zaman async olduğunu görmekteyiz. Bu noktada postgresql.conf içerisinde sync olması gerektiğiyle ilgili bilgi verilmediği için default olarak async replikasyon yapısı oluşturdu.</em></p><h4>Replikasyon Nasıl Senkron Olabilir ?</h4><p><em>Master sunucuda postgresql.conf dosyasına gidelim synchronous_standby_name paremetresini düzenleyelim.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*sKA67UewX_doeEjl1j0oZQ.png" /></figure><p><em>Burada * olarak tanımlama yaptık. Bu durumda tüm replika sunucuların senkron olması beklenir. Bir çok replika sunucunuzun olduğunu hayal edelim. Bu noktada application_name ismi ile istediğniz sunucuyu sync yapabilirsiniz kısıtlama sizlere ait.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*cyk3CSZQ1bEyivXtPQxqbA.png" /></figure><p><em>Gördüğünüz gibi artık replikasyon senkron bir hal almış oldu.</em></p><p><em>Zaman ayırdığınız için teşekkür ederim…</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4275dd557715" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>