Thursday, December 29, 2022

Mysql Backup Bash Script

 #!/bin/bash

$backup_path='/backup/db_backup/'

date=`date +%m-%d-%Y`

mysql -uroot -p'******' -e "show databases" -ss > /tmp/mysql-database-list

# Remove unwanted database from above list

cat  /tmp/mysql-database-list | grep -v -w information_schema > /tmp/mysql-database-final-list

for i in `cat /tmp/mysql-database-final-list`

do

mysqldump -uroot -p'******'  $i > $backup_path/$i.sql-$date

gzip  $backup_path/$i.sql-$date

done


---------------------------------------


This script create backup of all databases that are available on mysql server.

Tuesday, June 25, 2019

How to install Nginx on CentOS 7 | SecuredHost

About Nginx

Nginx is a high performance web server software. It is a much more flexible and lightweight program than Apache HTTP Server.
This tutorial will teach you how to install and start Nginx on your CentOS 7 server. You can use sudo if  you are login with some different user rather then root or sudo user. "sudo yum install epel-release"
To add the CentOS 7 EPEL repository, open terminal and use the following command:
yum install epel-release
Now that the Nginx repository is installed on your server, install Nginx using the following yum command
yum install nginx
Nginx does not start on its own. To get Nginx running 
systemctl start nginx
If you are running a firewall, run the following commands to allow http(80) and https(443) traffic:
sudo firewall-cmd --permanent --zone=public --add-service=http 
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
Enable Nginx service to start when your  system boots, To do so, enter the following command::
systemctl enable nginx

Tuesday, June 4, 2019

Iptables Limits Connections Per IP in cPanel server

How do I restrict the number of connections used by a single IP address to my server for port 80 and 443 using iptables?
You need to use the connlimit modules which allows you to restrict the number of parallel TCP connections to a server per client IP address.



Firstly we have to delete 443 rule from exiting iptables then add connlimit rule and add 443 rule again. connlimit always comes earlier than cpanel 443 default rule.

How to delete rule and add it again. 

First find the 443 cpanel rule number using below command.

iptables -L --line-numbers

Chain IN_public_allow (1 references)
num  target     prot opt source               destination
10   ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:https ctstate NEW


Find the Chain Rule and number which you want to delete. Then run below command.  Chain rule name IN_public_allow  and 10 is rule which we want to delete.

iptables -D IN_public_allow 10

After that add below both rule. First rule is using for restricting IP (10.10.10.1) for 443 port with 50 connection limit. Another rule for allow 443 port on server. Both rules are necessary. 


iptables -A IN_public_allow -p tcp  --syn -s 10.10.10.1 --dport 443 -m connlimit --connlimit-above 50 --connlimit-mask 32 -j REJECT --reject-with tcp-reset

iptables -A IN_public_allow -p tcp -m tcp --dport 443 -m conntrack --ctstate NEW -j ACCEPT

Thursday, November 29, 2018

Red Hat Gluster Storage

Red Hat Gluster Storage provides a scalable, reliable, and cost-effective data management platform across physical, virtual, and cloud environments.

Monday, September 25, 2017

PERL DBD SYBASE

intsall  DBD/Sybase.pm


mkdir /usr/local/freetds

wget  ftp://ftp.freetds.org/pub/freetds/stable/freetds-patched.tar.gz
tar -xvf freetds-patched.tar.gz
cd freetds-1.00.63/
./configure --prefix=/usr/local/freetds
make
make install


wget  http://search.cpan.org/CPAN/authors/id/M/ME/MEWP/DBD-Sybase-1.15.tar.gz

tar -xvf DBD-Sybase-1.15.tar.gz
cd DBD-Sybase-1.15
export SYBASE=/usr/local/freetds
perl Makefile.PL
cd freetds-1.00.63/
make
make install