Posts

Setting Up PostgreSQL Logical Replication with Docker Compose

Hi everyone 😀, Sorry😅 for not posting any blogs; I was stuck in other work. In the previous post, we saw that we enabled MySQL Replication using GTID . Today, we see how to allow Postgres Logical Replication in our local setup using docker-compose.  Environment Setup We have two PostgreSQL instances configured using Docker Compose: Publisher (postgres-1): The source server where changes are captured. Subscriber (postgres-2): The destination server that receives replicated data. Docker Compose Configuration Publisher (docker-compose.yml) version: '3.8' services: postgres-1: build: ./ container_name: postgres-1 environment: POSTGRES_USER: postgresadmin POSTGRES_PASSWORD: admin123 POSTGRES_DB: postgresdb PGDATA: "/data" volumes: - ./postgres-1/pgdata:/data - ./postgres-1/config:/config - ./postgres-1/archive:/mnt/server/archive ports: - "5000:5432" networks: - custom_network ...

MySQL Multi Source Master Slave Replication using GTID

Image
We are using GTID-based master-slave replication. In this replication, both master and slave should have the same GTID. This blog post aims to provide a step-by-step guide to help you set up MySQL Replication using GTIDs and help you replicate your MySQL data with ease. Prerequisite Master Source 1 Channel name:  DEVELOPMENT Database: mydb1 Enable Replication For Tables testing1 testing2 testing3 Mysql Server Running: 192.168.0.201:3307 Master Source 2 Channel name:  PRODUCTION Database: mydb1 Enable Replication For Tables testing4 testing5 testing6 Mysql Server Running: 192.168.0.201:3308 Slave Mysql Server Running: 192.168.0.209:3306 Configuration of  masters(192.168.0.201:3307/192.168.0.201:3308) and slave (192.168.0.209:3306) my.cnf config for master (192.168.0.201:3307) my.cnf config for master (192.168.0.201:3308) my.cnf config for slave (192.168.0.209:3306) Steps for taking a dump and restoring it Run the following commands in both masters 192.168.0.201:3307 and 1...

Dockerfile

Hey everyone, This article is about the Dockerfile that we use in building container images. It is nothing but a simple text file with instructions to build a custom image. Docker file helps us to provide instructions on what needs to be pulled, what arguments need to be run after building the image, and providing some configurations. FROM : Specifies the base image to use for the build. It is typically the first instruction in a Dockerfile. Example: FROM ubuntu:latest RUN : Executes commands in the shell of the container. These commands are run during the build process to install packages, configure the environment, etc. Example: RUN apt-get update && apt-get install -y python3 COPY or ADD : Copies files or directories from the host machine into the image. COPY is preferred for simple file copying, while ADD has additional features like extracting tar files and downloading files from URLs. Example: COPY app.py /app/ WORKDIR : Sets the working directory for any RUN, CMD, ENTRY...

Regex 101: An Introduction to Regular Expressions for Developers

Regular expressions (regex) are a powerful tool for searching and manipulating text. They allow you to describe patterns of characters that you want to match, rather than specifying every possible combination of characters. In this blog, we will go over some common regex operations and provide examples for each one. Matching a literal string: regex: hello will match the string "hello". Matching any character: regex: . will match any single character. Matching a set of characters: regex: [aeiou] will match any single vowel. Matching a range of characters: regex: [a-z] will match any single lowercase letter. Matching a negated set of characters: regex: [^aeiou] will match any single non-vowel character. Matching zero or one occurrence: regex: a? will match either the string "a" or an empty string. Matching zero or more occurrences: regex: a* will match any string that contains zero or more "a" characters. Matching one or more occurrences: regex: a+ will matc...

Helm Commands Cheatsheet

Hi everyone😎, Sharing helm commands that I use day to day. helm create: This command creates a chart directory along with the common files and directories used in a chart. Create a new chart with the given name:-  helm create [CHART]

Minimum Bracket Reversal

For a given expression in the form of a string, find the minimum number of brackets that can be reversed in order to make the expression balanced. The expression will only contain curly brackets. If the expression can't be balanced, return -1. Example : Expression : {{{{ If we reverse the second and the fourth opening brackets, the whole expression will get balanced. Since we have to reverse two brackets to make the expression balanced, the expected output will be 2. Expression : {{{ In this example, even if we reverse the last opening bracket, we would be left with the first opening bracket and hence will not be able to make the expression balanced and the output will be -1. Input Format : The first and the only line of input contains a string expression, without any spaces in between.   Output Format : The only line of output will print the number of reversals required to balance the whole expression. Prints -1, otherwise. Note :You don't have to print anything. It has alrea...

Stock Span

Afzal has been working with an organization called 'Money Traders' for the past few years. The organization is into the money trading business. His manager assigned him a task. For a given array/list of stock's prices for N days, find the stock's span for each day. The span of the stock's price today is defined as the maximum number of consecutive days(starting from today and going backwards) for which the price of the stock was less than today's price. For example, if the price of a stock over a period of 7 days are [100, 80, 60, 70, 60, 75, 85], then the stock spans will be [1, 1, 1, 2, 1, 4, 6]. Explanation: On the sixth day when the price of the stock was 75, the span came out to be 4, because the last 4 prices(including the current price of 75) were less than the current or the sixth day's price. Similarly, we can deduce the remaining results. Afzal has to return an array/list of spans corresponding to each day's stock's price. Help him to achi...

Popular posts from this blog

MySQL Multi Source Master Slave Replication using GTID

Access and modify all the resources of our Wiki.js using WikiJS API

How to setup an Nginx reverse proxy with a SSL certificate in XWIKI