Showing posts with label CentOS. Show all posts
Showing posts with label CentOS. Show all posts

Friday, November 8, 2019

How to fix "Could not get lock" Error while apt install


Sometimes we are having below error while trying to install a package using apt install in linux.

sudo apt install default-jre
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

Reason: some other process is using /var/lib/dpkg/lock

Resolution: 

1. Check whether any other apt install process is running or not. If any process is running wait for that process

2. Reboot OS and try again

3. If above [1] and [2] are not working, the worst option will be removing /var/lib/dpkg/lock file.
     sudo rm /var/lib/dpkg/lock

Friday, April 5, 2019

Mysql Load Balancing with Nginx (Ubuntu)


Environment setup:

Mysql master server : 192.168.1.10
Mysql slave server : 192.168.1.12

Nginx server : 192.168.1.14

1. Add Nginx configurations

Add below configuration to nginx main configuration file (/etc/nginx/nginx.conf) just after the http block     
stream {
    upstream mysql_cluster {
        server 192.168.1.10:3306; # node1
        server 192.168.1.12:3306 backup; # node2
    }
    server {
        listen 3306; 
        proxy_pass mysql_cluster;
    }
}
2. Open 3306 port in Nginx server

Since we are using 3306 port, we need to use SELinux and open port privileges
Try below command in Nginx server
sudo semanage port -l | grep http_port_t
check port 3306 is there, if not we can add it by using below command
sudo semanage port -a -t http_port_t  -p tcp 3306 
3. Enable firewall

 If you are using CentOS, you may use below command to enable firewall rules in Nginx server

firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload

File Sharing using NFS in GKE Cluster

 File Sharing using NFS in GKE Cluster There was a requirement to create common file sharing location which should be accessible by specific...