Posts

Showing posts from June, 2017

SQL Joins

Image
Joins are used to combine rows from two or more tables based on related columns between them. Joins allow you to retrieve data from multiple tables simultaneously, enabling you to create complex queries that fetch data from different sources. There are different types of joins in SQL, including: INNER JOIN Returns only the rows that have matching values in both tables based on the specified join condition. It discards non-matching rows from both tables. Example:           create table t1(x int); insert into t1 values(1); insert into t1 values(1); insert into t1 values(0); create table t2(y int); insert into t2 values(0); insert into t2 values(1); insert into t2 values(1);           select * from t1 inner join t2 on t1.x = t2.y Output: 2. LEFT JOIN (or) LEFT OUTER JOIN Returns all the rows from the left (or first) table and the matching rows from the right (or second) table. If there is no match, NULL values are

Permission denied while connecting Amazon EC2 with GITLAB through SSH

Image
ubuntu@ip:~/folder$ git clone git@gitlab.com:name/repo.git Cloning into 'folder'... Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. You are getting this error because EC2 instance have dosen't enough permission to access this git repo. You can solve this issue by adding the EC2 instance ssh key to gitlab. The following are the step to generate ssh in EC2 and add that to gitlab, ubuntu@ip-:~$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa):  Enter passphrase (empty for no passphrase):  Enter same passphrase again:  Your identification has been saved in /home/ubuntu/.ssh/id_rsa. Your public key has been saved in /home/ubuntu/.ssh/id_rsa.pub. The key fingerprint is: SHA256:/f+sdfsdfasdfxHdfa7uliBQviGGidshezsLI ubuntu@ip The key's randomart image is: +---[RSA 204

Postgresql Master/Slave Steaming Replication with Docker Container in Ubuntu 14

Install docker Download Official Postgresql docker image from   https://hub.docker.com/_/postgres/ > docker pull postgres Create folder docker_postgres and create a new file docker-compose.yml and paste the below information in it. my-docker:  image: postgres Run the following command to create two docker containers with the name master and slave. > docker run -d --name master postgres > docker run -d --name slave postgres To list the running docker containers > sudo docker ps -a To connect the running docker container. > docker exec -ti master bash Execute the following commands in both master and slave containers Set the password for postgres user > passwd postgres Install openssh and vim > apt-get update > apt-get install openssh-server > service ssh start > apt-get install vim To set default language locale > dpkg-reconfigure locales Locales to be generated: 146 Default locale for the