Rebuild GTID based replication using Mysqldump

If you have been working on GTID based replication then you might have faced issues in rebuilding the replication in case the slave throws any error like ‘master has purged the binary logs’ etc. In this post I’ll share the easiest way to rebuild the slave from scratch.   Rebuild GTID based replication using Mysqldump … Read more

Python program to implement N Queens problem

Python program to implement N Queens problem:   def isSafe(board, row, col, n): # check if there is a queen in the same row for i in range(col): if board[row][i] == 1: return False # check if there is a queen in the upper diagonal on the left side for i, j in zip(range(row, -1, … Read more

Upgrade MySQL 5.7 to 8 via Shell script

Here we will write a Shell script to upgrade MySQL 5.7 to 8. #!/bin/bash # Stop MySQL 5.7 server sudo systemctl stop mysql # Backup MySQL 5.7 data sudo mkdir /var/lib/mysql_backup sudo cp -R /var/lib/mysql/* /var/lib/mysql_backup # Remove MySQL 5.7 sudo apt-get remove mysql-server mysql-client mysql-common # Add MySQL 8.0 repository sudo wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb … Read more

Monitor MySQL Error logs from AWS Cloudwatch

Here we will write a Python script that will Monitor MySQL Error logs from AWS Cloudwatch and we’ll notify in case any error is detected. import boto3 import gzip import re import smtplib import os from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart # AWS credentials aws_access_key_id = ‘YOUR_ACCESS_KEY_ID’ aws_secret_access_key = ‘YOUR_SECRET_ACCESS_KEY’ # CloudWatch log … Read more

Python program to monitor disk usage in EC2

Here we will write a Python program to monitor disk usage in AWS EC2 instance, you can use this to on any Linux flavor. import os def get_disk_usage(): total, used, free = os.popen(“df -h /”).readlines()[1].split()[1:4] return { “total”: total, “used”: used, “free”: free } if __name__ == “__main__”: usage = get_disk_usage() print(“Disk usage:”) print(f”Total: {usage[‘total’]}”) … Read more