Posts

How Replication transfer events from Master to Slave in MySQL

Image
In MySQL the events (write operations) are transferred from master to slave with the help of threads. Thread Name Runs On Binlog Dump Master IO Slave SQL Slave and in the following chronological order. The slave connects to the master (as a client) using the credentials that were given during setup. This credentials are set by executing CHANGE MASTER TO at slave side. It might be possible that MySQL is storing the credentials in a plain form. Hence it is advisable to create a separate user in Master with privileges that grant it the power of serving the purpose of replication only. IO thread from the slave asks for new events in the master if any. Binlog Dump thread from master checks this and send contents to IO thread if new events are do present. IO thread then writes the new events to the relay logs on slave. SQL thread on the slave then reads these events from relay logs and apply them to the dat...

How to set the proxy for APT on Ubuntu

This post is regarding: How to set the proxy for APT on Ubuntu 18.04 , as I have set up that version of Ubuntu in my test machine. You can see if that works for other versions also. APT a.k.a Aptitude will not use the HTTP Proxy environment variables. Instead, it has its own configuration file where you can set your proxy. This tutorial will show you how to set the proxy so that you may be able to install and update packages from remote repos. If you filled in your proxy information during installation, the Apt configuration file would have been automatically updated. However, if you did not, then you must follow the following instructions. Creating an Apt Proxy Conf File Apt loads all configuration files under /etc/apt/apt.conf.d. We can create a configuration specifically for our proxy there, keeping it separate from all other configurations. 1. Create a new configuration file named proxy.conf. sudo touch /etc/apt/apt.conf.d/proxy.conf 2. Open the proxy.conf ...

What are the components of a sharded cluster in MongoDB

Image
Sharded Cluster Components A MongoDB sharded cluster consists of the following components: shard : Each shard contains a subset of the sharded data. As of MongoDB 3.6, shards must be deployed as a replica set . mongos : The mongos acts as a query router, providing an interface between client applications and the sharded cluster. Starting in MongoDB 4.4, mongos can support hedged reads to minimize latencies. config servers : Config servers store metadata and configuration settings for the cluster. As of MongoDB 3.4, config servers must be deployed as a replica set (CSRS).  Image courtesy by :  diagrams.net Production Configuration In a production cluster, ensure that data is redundant and that your systems are highly available. Consider the following for a production sharded cluster deployment: Deploy Config Servers as a 3 member replica set Deploy each Shard as a 3 member replica set Deploy one or more mongos routers Replica Set Distribution Where possible, consider deployi...

What is CAP Theorem

Image
In theoretical computer science, the CAP theorem, also named as Brewer's theorem after computer scientist Eric Brewer, states that it is impossible for a distributed data store or distributed system to simultaneously provide more than two out of the following three guarantees: C onsistency : Every read receives the most recent write or an error. A guarantee that every node in a distributed cluster returns the same, most recent, successful write. Consistency refers to every client having the same view of the data. For this to happen, whenever data is written to one node, it must be instantly forwarded or replicated to all the other nodes in the system before the write is deemed successful to client. Consistency in CAP refers to sequential consistency, a very strong form of consistency. There are various types of consistency models like eventual consistency and strong consistency.  A vailability : Every request receives a (non-error) response, without the guarantee that it conta...

What is idempotent operation

Idempotent, in programming and mathematics, is a property of some operations such that no matter how many times you execute them, you achieve the same result. In programming, idempotent can be a property of many different code elements, including functions, methods, requests and statements. Idempotent is a language-agnostic property: It means the same thing in any programming context. Here’s a simple demonstration of idempotent in HTTP requests: HTTP GET requests are a method of retrieving specified data from a source, such as getting a bank account balance. GET requests are idempotent: Accessing the same data should always be consistent. On the other hand, POST requests are designed to change the target, such as adding a sum to a bank account. As such, a POST request should change the result and that means it’s not idempotent. In computing, an idempotent operation is one that has no additional effect if it is called more than once with the same input parameters. For example, removing ...

How to truncate the Slow Query Log on AWS RDS MySQL

I was in need to empty the slow_log table in MySQL database inside a Amazon Relational Database System to look into a performance issue. But I got the below error. I was surprised because I had login with the master user of the RDS. mysql> use mysql mysql> truncate table slow_log Error Code: 1044. Access denied for user 'dbroot'@'%' to database 'mysql' On surfing the internet I got this and it resolved my problem. "Amazon RDS will not give you SSH access to its database server. That means you don’t have the opportunity to view any of the log files, even the slow query log, for the database. But RDS provides a way to play with the slow queries. If your slow queries are many then this table will hold too many queries to handle. You cannot truncate the table or delete any row from there. There is only a way to move all the data from this table to another table named ‘slow_log_backup’, making the slow_log table empty. To do so you have to run a stored pro...

what is character encoding and decoding

Characters are abstract entities that can be represented in many different ways. A character encoding is a system that pairs each character in a supported character set with some value that represents that character. For example, Morse code is a character encoding that pairs each character in the Roman alphabet with a pattern of dots and dashes that are suitable for transmission over telegraph lines. A character encoding for computers pairs each character in a supported character set with a numeric value (also known as code point) that represents that character. A character encoding has two distinct components:   An encoder, which translates a sequence of characters into a sequence of numeric values (bytes). A decoder, which translates a sequence of bytes into a sequence of characters.    A computer can only work with 0s and 1s. It does not understand human languages like English, Hindi etc. Hence you need to mention the correct character set while either rendering ...
Back To Top