diff --git a/Galera/LB.conf b/Galera/LB.conf new file mode 100644 index 0000000..5f45e8a --- /dev/null +++ b/Galera/LB.conf @@ -0,0 +1,24 @@ +stream { + + # Define all gluster nodes + upstream gluster_nodes { + # least_conn; + hash $remote_addr consistent; + server :3306; # fail_timeout=5s + server :3306; # fail_timeout=5s + server :3306; # fail_timeout=5s + server :3306; # fail_timeout=5s + } + + # TCP traffic to gluster nodes + server { + listen 3306; + proxy_pass gluster_nodes; + proxy_bind transparent; + # proxy_bind $remote_addr transparent; + # proxy_protocol on; + # set_real_ip_from $proxy_protocol_addr; + } + + +} \ No newline at end of file diff --git a/Galera/README b/Galera/README new file mode 100644 index 0000000..df722e3 --- /dev/null +++ b/Galera/README @@ -0,0 +1,20 @@ +user for running script: +keepaliveddd + + +sudo adduser keepaliveddd + + + +#Galera nodes +''' +sudo apt install galera-4 mariadb-server +''' + +#Load balancers +''' +sudo apt install keepalived nginx +''' + + +Of course change what needs to be changed in config files. \ No newline at end of file diff --git a/Galera/chck_nginx.sh b/Galera/chck_nginx.sh new file mode 100644 index 0000000..2a9f370 --- /dev/null +++ b/Galera/chck_nginx.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +check=$(pidof nginx) + +if [ -z $check ]; then + exit 1 + +else : + exit 0 + +fi \ No newline at end of file diff --git a/Galera/keepalived/GLUSTER-LB-NODE-1.conf b/Galera/keepalived/GLUSTER-LB-NODE-1.conf new file mode 100644 index 0000000..065f947 --- /dev/null +++ b/Galera/keepalived/GLUSTER-LB-NODE-1.conf @@ -0,0 +1,36 @@ +global_defs { + enable_script_security + script_user keepaliveddd +} + +vrrp_script track_nginx { + script "/etc/keepalived/chck_nginx.sh" + interval 10 +} + +vrrp_instance GLUSTER-LB { + state MASTER + interface eth1 + virtual_router_id 30 + priority 100 + advert_int 1 + + unicast_src_ip + unicast_peer { + + } + + authentication { + auth_type PASS + auth_pass + } + + track_script { + track_nginx + } + + virtual_ipaddress { + / dev + } + +} diff --git a/Galera/keepalived/GLUSTER-LB-NODE-2.conf b/Galera/keepalived/GLUSTER-LB-NODE-2.conf new file mode 100644 index 0000000..72b4cbd --- /dev/null +++ b/Galera/keepalived/GLUSTER-LB-NODE-2.conf @@ -0,0 +1,38 @@ +global_defs { + enable_script_security + script_user keepaliveddd +} + +vrrp_script track_nginx { + script "/etc/keepalived/chck_nginx.sh" + interval 10 +} + +vrrp_instance GLUSTER-LB { + state BACKUP + interface + virtual_router_id 10 + priority 95 + advert_int 1 + + unicast_src_ip + unicast_peer { + + } + + authentication { + auth_type PASS + auth_pass + } + + + track_script { + track_nginx + } + + virtual_ipaddress { + / dev + } + +} + diff --git a/Galera/keepalived/GLUSTER-LB-NODE-3.conf b/Galera/keepalived/GLUSTER-LB-NODE-3.conf new file mode 100644 index 0000000..381f220 --- /dev/null +++ b/Galera/keepalived/GLUSTER-LB-NODE-3.conf @@ -0,0 +1,36 @@ +global_defs { + enable_script_security + script_user keepaliveddd +} + +vrrp_script track_nginx { + script "/etc/keepalived/chck_nginx.sh" + interval 10 +} + +vrrp_instance GLUSTER-LB { + state BACKUP + interface + virtual_router_id 10 + priority 90 + advert_int 1 + + unicast_src_ip + unicast_peer { + + } + + authentication { + auth_type PASS + auth_pass + } + + track_script { + track_nginx + } + + virtual_ipaddress { + / dev + } + +} diff --git a/Galera/mariadb_conf/GLUSTER-NODE-1.cnf b/Galera/mariadb_conf/GLUSTER-NODE-1.cnf new file mode 100644 index 0000000..1166075 --- /dev/null +++ b/Galera/mariadb_conf/GLUSTER-NODE-1.cnf @@ -0,0 +1,22 @@ +# vim /etc/mysql/conf.d/galera.cnf + +[mysqld] +binlog_format=ROW +default-storage-engine=innodb +innodb_autoinc_lock_mode=2 +bind-address=0.0.0.0 + +# Galera Provider Configuration +wsrep_on=ON +wsrep_provider=/usr/lib/galera/libgalera_smm.so + +# Galera Cluster Configuration +wsrep_cluster_name="GLUSTER-NPM" +wsrep_cluster_address="gcomm://ADDRESSES,SEPARATED,WITH,COMA" + +# Galera Synchronization Configuration +wsrep_sst_method=rsync + +# Galera Node Configuration +wsrep_node_address="" +wsrep_node_name="GLUSTER-NODE-1" diff --git a/Galera/mariadb_conf/GLUSTER-NODE-2.cnf b/Galera/mariadb_conf/GLUSTER-NODE-2.cnf new file mode 100644 index 0000000..fdad870 --- /dev/null +++ b/Galera/mariadb_conf/GLUSTER-NODE-2.cnf @@ -0,0 +1,22 @@ +# vim /etc/mysql/conf.d/galera.cnf + +[mysqld] +binlog_format=ROW +default-storage-engine=innodb +innodb_autoinc_lock_mode=2 +bind-address=0.0.0.0 + +# Galera Provider Configuration +wsrep_on=ON +wsrep_provider=/usr/lib/galera/libgalera_smm.so + +# Galera Cluster Configuration +wsrep_cluster_name="GLUSTER-NPM" +wsrep_cluster_address="gcomm://ADDRESSES,SEPARATED,WITH,COMA" + +# Galera Synchronization Configuration +wsrep_sst_method=rsync + +# Galera Node Configuration +wsrep_node_address="" +wsrep_node_name="GLUSTER-NODE-2" diff --git a/Galera/mariadb_conf/GLUSTER-NODE-3.cnf b/Galera/mariadb_conf/GLUSTER-NODE-3.cnf new file mode 100644 index 0000000..3d3eb4a --- /dev/null +++ b/Galera/mariadb_conf/GLUSTER-NODE-3.cnf @@ -0,0 +1,22 @@ +# vim /etc/mysql/conf.d/galera.cnf + +[mysqld] +binlog_format=ROW +default-storage-engine=innodb +innodb_autoinc_lock_mode=2 +bind-address=0.0.0.0 + +# Galera Provider Configuration +wsrep_on=ON +wsrep_provider=/usr/lib/galera/libgalera_smm.so + +# Galera Cluster Configuration +wsrep_cluster_name="GLUSTER-NPM" +wsrep_cluster_address="gcomm://ADDRESSES,SEPARATED,WITH,COMA" + +# Galera Synchronization Configuration +wsrep_sst_method=rsync + +# Galera Node Configuration +wsrep_node_address="" +wsrep_node_name="GLUSTER-NODE-3" diff --git a/Galera/mariadb_conf/GLUSTER-NODE-4.cnf b/Galera/mariadb_conf/GLUSTER-NODE-4.cnf new file mode 100644 index 0000000..df34dff --- /dev/null +++ b/Galera/mariadb_conf/GLUSTER-NODE-4.cnf @@ -0,0 +1,22 @@ +# vim /etc/mysql/conf.d/galera.cnf + +[mysqld] +binlog_format=ROW +default-storage-engine=innodb +innodb_autoinc_lock_mode=2 +bind-address=0.0.0.0 + +# Galera Provider Configuration +wsrep_on=ON +wsrep_provider=/usr/lib/galera/libgalera_smm.so + +# Galera Cluster Configuration +wsrep_cluster_name="GLUSTER-NPM" +wsrep_cluster_address="gcomm://ADDRESSES,SEPARATED,WITH,COMA" + +# Galera Synchronization Configuration +wsrep_sst_method=rsync + +# Galera Node Configuration +wsrep_node_address="" +wsrep_node_name="GLUSTER-NODE-4"