Created
March 23, 2018 17:25
-
-
Save jebog/418dbaa8208269a1ebf205bb7a3737e9 to your computer and use it in GitHub Desktop.
Revisions
-
jebog created this gist
Mar 23, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,113 @@ #!/bin/bash SERVER_IP=$(ip address show dev eth1 scope global | awk '/inet / {split($2,var,"/"); print var[1]}') HOSTNAME=`hostname -f` SERVER_IP_LIST="172.28.128.100,172.28.128.101,172.28.128.102" cat <<EOT > /etc/yum.repos.d/Galera.repo # MariaDB 10.2 CentOS repository list - created 2018-03-23 09:16 UTC # http://downloads.mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.2/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1 EOT cat <<EOT > /etc/hosts $SERVER_IP $HOSTNAME 127.0.0.1 localhost EOT #yum -y update yum install -y MariaDB-server MariaDB-client policycoreutils-python MariaDB-common rsync lsof vim cat <<EOT > ~/.my.cnf [client] user=root password= EOT systemctl enable mariadb systemctl enable firewalld systemctl start firewalld firewall-cmd --zone=public --add-service=mysql --permanent firewall-cmd --zone=public --add-port=3306/tcp --permanent firewall-cmd --zone=public --add-port=4444/tcp --permanent firewall-cmd --zone=public --add-port=4567/tcp --permanent firewall-cmd --zone=public --add-port=4567/udp --permanent firewall-cmd --zone=public --add-port=4568/tcp --permanent firewall-cmd --reload semanage port -a -t mysqld_port_t -p tcp 4567 semanage port -a -t mysqld_port_t -p udp 4567 semanage port -a -t mysqld_port_t -p tcp 4568 semanage port -a -t mysqld_port_t -p tcp 4444 semanage permissive -a mysqld_t cp /etc/my.cnf.d/server.cnf /etc/my.cnf.d/server.cnf.bak cat <<EOT > /etc/my.cnf.d/server.cnf # # These groups are read by MariaDB server. # Use it for options that only the server (but not clients) should see # # See the examples of server my.cnf files in /usr/share/mysql/ # # this is read by the standalone daemon and embedded servers [server] # this is only for the mysqld standalone daemon [mysqld] log_error=/var/log/mariadb.log # # * Galera-related settings # [galera] binlog_format=ROW default-storage-engine=innodb innodb_autoinc_lock_mode=2 bind-address=0.0.0.0 wsrep_on=ON wsrep_provider=/usr/lib64/galera/libgalera_smm.so wsrep_cluster_address="gcomm://$SERVER_IP_LIST" ## Galera Cluster Configuration wsrep_cluster_name="cluster1" ## Galera Synchronization Configuration wsrep_sst_method=rsync ## Galera Node Configuration wsrep_node_address="$SERVER_IP" wsrep_node_name="$HOSTNAME" # this is only for embedded server [embedded] # This group is only read by MariaDB servers, not by MySQL. # If you use the same .cnf file for MySQL and MariaDB, # you can put MariaDB-only options here [mariadb] # This group is only read by MariaDB-10.1 servers. # If you use the same .cnf file for MariaDB of different versions, # use this group for options that older servers don't understand [mariadb-10.1] EOT touch /var/log/mysqld.log chown mysql:mysql /var/log/mysqld.log # On First node galera_new_cluster # On Other nodes systemctl start mariadb