650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/87/07/wKioL1fSCLzh4YFiAAA_6rVAeUs190.png "width=" 300 " height= "208" alt= "Wkiol1fsclzh4yfiaaa_6rvaeus190.png"/>
Installation Environment
System: CentOS 6.8 x86_64
Software: MariaDB 10.1.16
Node One: 192.168.11.132 4C 8GB
Node two: 192.168.11.133 4C 8GB
Software acquisition
After accessing the MARIADB Enterprise Edition https://mariadb.com/my_portal/download/mariadb-enterprise login account, select the 10.1.16GA version of the source code package download.
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M01/87/32/wKiom1fXUnDgZ5LXAACVVxts84w862.png-wh_500x0-wm_3 -wmp_4-s_3082334876.png "title=" Qq20160913091115.png "alt=" Wkiom1fxundgz5lxaacvvxts84w862.png-wh_50 "/>
Starting with the MARIADB Enterprise 10.1 release, the corporate package is integrated with the cluster functionality, so the download package is one.
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/87/32/wKiom1fXUxihPnE_AACKxmlt5Pc477.png-wh_500x0-wm_3 -wmp_4-s_1961670661.png "title=" Qq20160913091445.png "alt=" Wkiom1fxuxihpne_aackxmlt5pc477.png-wh_50 "/>
Download the source code package to the/USR/SRC directory of the CentOS system
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/87/2F/wKioL1fXU3WBb1lQAAAXxS6aprA965.png-wh_500x0-wm_3 -wmp_4-s_1256413068.png "title=" Qq20160913091550.png "alt=" Wkiol1fxu3wbb1lqaaaxxs6apra965.png-wh_50 "/>
Visit Galeracluster official website http://galeracluster.com/download page
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/87/32/wKiom1fXYJbB0S1YAAQj4ksOczU161.png-wh_500x0-wm_3 -wmp_4-s_2944881031.png "title=" Qq20160913101202.png "alt=" Wkiom1fxyjbb0s1yaaqj4ksoczu161.png-wh_50 "/>
Select the current latest version of Galera 3 wsrep source code package download to the CentOS system/USR/SRC Directory
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/87/32/wKiom1fXYRejtov9AADpZbqXujM879.png-wh_500x0-wm_3 -wmp_4-s_1782640018.png "title=" Qq20160913101330.png "alt=" Wkiom1fxyrejtov9aadpzbqxujm879.png-wh_50 "/>
Copy two packages to the/USR/SRC directory of each node after the download is complete
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/87/30/wKioL1fXYk7BCOH1AAAL5GwUCPE491.png "title=" Qq20160913101937.png "alt=" Wkiol1fxyk7bcoh1aaal5gwucpe491.png "/>
installation process
1. Add the Epel yum source
RPM-VIH http://mirrors.ustc.edu.cn/epel/epel-release-latest-6.noarch.rpm
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/87/33/wKiom1fXaWWSXGhhAAAWOW976s0583.png "title=" Qq20160913105004.png "alt=" Wkiom1fxawwsxghhaaawow976s0583.png "/>
2. Regenerate the Yum source cache
Yum Clean All;yum Makecache
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/87/30/wKioL1fXafmDuO4QAABNM-DjN_A337.png-wh_500x0-wm_3 -wmp_4-s_438180461.png "title=" Qq20160913105230.png "alt=" Wkiol1fxafmduo4qaabnm-djn_a337.png-wh_50 "/>
3. Use Yum to install the necessary packages
Yum install-y ntp ntpdate libaio jemalloc ncurses-devel make CMake bison zlib zlib-devel OpenSSL openssl-devel gcc gcc-c+ + rsync scons boost Boost-devel check Check-devel
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/87/30/wKioL1fXY1PjZjBIAAA8xRo1CB4477.png-wh_500x0-wm_3 -wmp_4-s_1532167138.png "title=" Qq20160913102400.png "alt=" Wkiol1fxy1pjzjbiaaa8xro1cb4477.png-wh_50 "/>
4. Use file CRC check code to determine if/etc/localtime and/usr/share/zoneinfo/asia/shanghai are not the same file, then the system time zone is not Asia Shanghai, this time need to copy or link/usr/share/ Zoneinfo/asia/shanghai file to/etc/localtime file overwrite.
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/87/30/wKioL1fXZP2DbLWRAAAOtiy7Qa0268.png "title=" Qq20160913103105.png "alt=" Wkiol1fxzp2dblwraaaotiy7qa0268.png "/>
5. Synchronizing with NTP server to update the system time
Ntpdate 0.centos.pool.ntp.org
Hwclock-w
/ETC/INIT.D/NTPD start
Chkconfig ntpd on
Chkconfig ntpdate on
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/87/33/wKiom1fXZKSxvuPYAAAU2PHC2RQ048.png "title=" Qq20160913102938.png "alt=" Wkiom1fxzksxvupyaaau2phc2rq048.png "/>
6. Turn off the system Firewall service and SELinux service
/etc/init.d/iptables stop
/etc/init.d/ip6tables stop
Chkconfig iptables off
Chkconfig Ip6tables off
Setenforce 0
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/87/33/wKiom1fXZk6yvQnXAAA5BFKxZPM909.png "title=" Qq20160913103639.png "alt=" Wkiom1fxzk6yvqnxaaa5bfkxzpm909.png "/>
7. Unzip the Galera package, copy to/usr/local and rename
Tar zxf galera-3-25.3.17.tar.gz
MV Galera-3-25.3.17/usr/local/galera
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/87/30/wKioL1fXZu2xf4I7AAAIjXDvXNA094.png "title=" Qq20160913103930.png "alt=" Wkiol1fxzu2xf4i7aaaijxdvxna094.png "/>
8. Use the scons command to compile the installation Galera
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/87/33/wKiom1fXZ3aBK4h_AAAhn7-mo-w971.png "title=" Qq20160913104136.png "alt=" Wkiom1fxz3abk4h_aaahn7-mo-w971.png "/>
9. The/usr/local/galera/libgalera_smm.so module is generated when the installation is complete
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/87/33/wKiom1fXamSDf7FZAAA5QAxFq9E402.png-wh_500x0-wm_3 -wmp_4-s_2758675591.png "title=" Qq20160913105420.png "alt=" Wkiom1fxamsdf7fzaaa5qaxfq9e402.png-wh_50 "/>
10. Switch to the/USR/SRC directory to extract the Mariadb-enterprise configuration
cd/usr/src/
Tar zxf mariadb-enterprise-10.1.16.tar.gz
CD mariadb-10.1.16/
CMake. -dcmake_install_prefix=/usr/local/mariadb-ddefault_sysconfdir=/usr/local/mariadb/etc-dmysql_datadir=/usr/local /MARIADB/DATA-DMYSQL_TCP_PORT=3306-DMYSQL_UNIX_ADDR=/USR/LOCAL/MARIADB/MARIADB.SOCK-DMYSQL_USER=MARIADB- Denabled_local_infile=1-dextra_charsets=all-ddefault_charset=utf8-ddefault_collation=utf8_general_ci-dwith_ Readline=1-dwith_ssl=system-dwith_zlib=system-dwith_libwrap=0-dwith_wsrep=on-dwith_innodb_disallow_writes=on
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/87/33/wKiom1fXa1uC7FXwAAA8G8HJPSc672.png "title=" Qq20160913105822.png "alt=" Wkiom1fxa1uc7fxwaaa8g8hjpsc672.png "/>
11. Compile simultaneously with the 4 core of the CPU
Make-j 4
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/87/31/wKioL1fXa8jifY37AABTKgaVoWY078.png-wh_500x0-wm_3 -wmp_4-s_3351533691.png "title=" Qq20160913110013.png "alt=" Wkiol1fxa8jify37aabtkgavowy078.png-wh_50 "/>
12. Installation
Make install
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/87/33/wKiom1fXbY2zx1FbAAAdCXfGOFA001.png-wh_500x0-wm_3 -wmp_4-s_1651311991.png "title=" Qq20160913110730.png "alt=" Wkiom1fxby2zx1fbaaadcxfgofa001.png-wh_50 "/>
13. Create MARIADB users and corresponding directories
Useradd-m-s/sbin/nologin mariadb
Mkdir-p/usr/local/mariadb/etc
Mkdir-p/usr/local/mariadb/run
Mkdir-p/usr/local/mariadb/log
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/87/31/wKioL1fXbj2TfpRDAAA5VegMD1E927.png "title=" Qq20160913111033.png "alt=" Wkiol1fxbj2tfprdaaa5vegmd1e927.png "/>
14. If a/etc/my.cnf file exists, delete or rename it. and create a new configuration file
Mv/etc/my.cnf/etc/my.cnf.bak
CP SUPPORT-FILES/MY-LARGE.CNF.SH/USR/LOCAL/MARIADB/ETC/MY.CNF
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/87/31/wKioL1fXbvTz8nNoAAALPX_EnCU209.png "title=" Qq20160913111346.png "alt=" Wkiol1fxbvtz8nnoaaalpx_encu209.png "/>
15. Edit/usr/local/mariadb/etc/my.cnf to modify port and socket parameters and add in [mysqld]
Pid-file =/usr/local/mariadb/run/mariadb.pid
Log-error =/usr/local/mariadb/log/mariadb.log
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/87/31/wKioL1fXb9uBpobjAAAkKPuo224517.png "title=" Qq20160913111730.png "alt=" Wkiol1fxb9ubpobjaaakkpuo224517.png "/>
16. Modify the MARIADB directory owner
Chown-r mariadb:mariadb/usr/local/mariadb/
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/87/33/wKiom1fXcGGgTZ4eAAAIg9SO1Jc624.png "title=" Qq20160913111946.png "alt=" Wkiom1fxcgggtz4eaaaig9so1jc624.png "/>
17. Initializing the MARIADB database
/usr/local/mariadb/scripts/mysql_install_db--user=mariadb--basedir=/usr/local/mariadb/--datadir=/usr/local/ mariadb/data/
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/87/31/wKioL1fXcQiho2p_AAAvWmSi5Gc266.png-wh_500x0-wm_3 -wmp_4-s_2274108133.png "title=" Qq20160913112235.png "alt=" Wkiol1fxcqiho2p_aaavwmsi5gc266.png-wh_50 "/>
18. Modify the/usr/local/mariadb/bin/mysqld_safe file parameters
User= ' mariadb '
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/87/33/wKiom1fXcduSsgSMAAAZUa4yiIo651.png-wh_500x0-wm_3 -wmp_4-s_681091855.png "title=" Qq20160913112607.png "alt=" Wkiom1fxcdussgsmaaazua4yiio651.png-wh_50 "/>
19. Start the MARIADB database
/usr/local/mariadb/bin/mysqld_safe &
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/87/33/wKiom1fXcjzy8WK3AAAUZ0aapMk576.png "title=" Qq20160913112746.png "alt=" Wkiom1fxcjzy8wk3aaauz0aapmk576.png "/>
20. View process and port status
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/87/31/wKioL1fXcpOwWkLfAAApihl-u_k220.png "title=" Qq20160913112901.png "alt=" Wkiol1fxcpowwklfaaapihl-u_k220.png "/>
21. Create a startup script
Cp/usr/src/mariadb-10.1.16/support-files/mysql.server/etc/init.d/mariadb
chmod 755/etc/init.d/mariadb
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/87/33/wKiom1fXc23Aq44BAAAOCbnnZJA762.png "title=" Qq20160913113250.png "alt=" Wkiom1fxc23aq44baaaocbnnzja762.png "/>
22. Modify the/etc/init.d/mariadb file with the following parameters
Basedir=/usr/local/mariadb
Datadir=/usr/local/mariadb/data
Mysqld_pid_file_path=/usr/local/mariadb/run/mariadb.pid
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/87/33/wKiom1fXc_6w1lSKAAAyYiF7JY8630.png-wh_500x0-wm_3 -wmp_4-s_30500691.png "title=" Qq20160913113508.png "alt=" Wkiom1fxc_6w1lskaaayyif7jy8630.png-wh_50 "/>
23. Add Chkconfig Management
Chkconfig--add mariadb
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/87/31/wKioL1fXdEKTv3prAAAM3yIHq3w302.png "title=" Qq20160913113624.png "alt=" Wkiol1fxdektv3praaam3yihq3w302.png "/>
24. Test startup function
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/87/31/wKioL1fXdJbAL7iAAAAhwGbQCxw936.png-wh_500x0-wm_3 -wmp_4-s_3370157297.png "title=" Qq20160913113747.png "alt=" Wkiol1fxdjbal7iaaaahwgbqcxw936.png-wh_50 "/>
25. Configure the login password for the MARIADB database root account and configure it securely.
/usr/local/mariadb/bin/mysql_secure_installation
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/87/34/wKiom1fXeH_AstPSAABTfctwSBU394.png "title=" Qq20160913115422.png "alt=" Wkiom1fxeh_astpsaabtfctwsbu394.png "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/87/31/wKioL1fXehTg-a6lAABBUb-GnqM253.png "title=" Qq20160913120111.png "alt=" Wkiol1fxehtg-a6laabbub-gnqm253.png "/>
26. Log in to the database with a password
/usr/local/mariadb/bin/mysql-u ' root '-P ' D5) ga!3 '
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/87/34/wKiom1fXevbSznpzAABE9svakUU547.png "title=" Qq20160913120451.png "alt=" Wkiom1fxevbsznpzaabe9svakuu547.png "/>
27. Create a SST account for synchronizing the database
GRANT USAGE On * * to [e-mail protected] '% ' identified by ' G#DS0GL ';
GRANT all privileges on * * to [email protected] '% ';
FLUSH privileges;
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/87/34/wKiom1fXkO2QWzFIAAAqP4WC1HI415.png-wh_500x0-wm_3 -wmp_4-s_3439347743.png "title=" Qq20160913133840.png "alt=" Wkiom1fxko2qwzfiaaaqp4wc1hi415.png-wh_50 "/>
28. Stop the database
/etc/init.d/mariadb stop
Modify the configuration file/usr/local/mariadb/etc/my.cnf add at the end
!includedir/usr/local/mariadb/etc/my.cnf.d/
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/87/36/wKiom1fXoinwiH_CAAAZwLrd08U003.png "title=" Qq20160913145212.png "alt=" Wkiom1fxoinwih_caaazwlrd08u003.png "/>
29. Create the/usr/local/mariadb/etc/my.cnf.d/directory with the WSREP.CNF configuration file
mkdir/usr/local/mariadb/etc/my.cnf.d/
Cp/usr/src/mariadb-10.1.16/support-files/wsrep.cnf.sh/usr/local/mariadb/etc/my.cnf.d/wsrep.cnf
Chown-r mariadb.mariadb/usr/local/mariadb/etc/my.cnf.d/
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/87/36/wKiom1fXos-w04eaAAAPNcN7CnE045.png "title=" Qq20160913145458.png "alt=" Wkiom1fxos-w04eaaaapncn7cne045.png "/>
In node two (if there are multiple nodes on each other) perform the above 1 to 29 steps to install the configuration database.
On node one execution:
Modify/USR/LOCAL/MARIADB/ETC/MY.CNF.D/WSREP.CNF The following parameters in the [mysqld] section
Wsrep_on=on
Binlog_format=row
Default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
Wsrep_provider=/usr/local/galera/libgalera_smm.so
Wsrep_cluster_name= "My_wsrep_cluster"
Wsrep_cluster_address= "gcomm://192.168.11.132,192.168.11.133"
Wsrep_node_name=node01
wsrep_node_address=192.168.11.132
Wsrep_sst_method=rsync
Wsrep_sst_auth=sst:g#ds0gl
Start the Cluster service
/ETC/INIT.D/MARIADB Bootstrap
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/87/36/wKiom1fXpimT-N0JAAAJ8Xwmu2g436.png "title=" Qq20160913150917.png "alt=" Wkiom1fxpimt-n0jaaaj8xwmu2g436.png "/>
View Log/usr/local/mariadb/log/mariadb.log with the wsrep:synchronized with group, the Ready for connections information indicates that the Cluster service started successfully.
Tail/usr/local/mariadb/log/mariadb.log
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/87/33/wKioL1fXp9DDk6tcAABCu27EHlI362.png "title=" Qq20160913151620.png "alt=" Wkiol1fxp9ddk6tcaabcu27ehli362.png "/>
In node two execution:
Modify/USR/LOCAL/MARIADB/ETC/MY.CNF.D/WSREP.CNF The following parameters in the [mysqld] section
Wsrep_on=on
Binlog_format=row
Default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
Wsrep_provider=/usr/local/galera/libgalera_smm.so
Wsrep_cluster_name= "My_wsrep_cluster"
Wsrep_cluster_address= "gcomm://192.168.11.132,192.168.11.133"
Wsrep_node_name=node02
wsrep_node_address=192.168.11.133
Wsrep_sst_method=rsync
Wsrep_sst_auth=sst:g#ds0gl
Start the Cluster service
/ETC/INIT.D/MARIADB start
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/87/34/wKioL1fXq_Szdk9HAAALshjj7Wk780.png "title=" Qq20160913153357.png "alt=" Wkiol1fxq_szdk9haaalshjj7wk780.png "/>
Log details
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/87/36/wKiom1fXrCDSeCsdAAA7rP71slw095.png "title=" Qq20160913153437.png "alt=" Wkiom1fxrcdsecsdaaa7rp71slw095.png "/>
If you have more than one node, refer to node two configuration.
Log in to the MARIADB database at any one node
See if the cluster feature is turned on
Show status like ' Wsrep_ready ';
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/87/34/wKioL1fXroGhl8shAAAKLfpliLo127.png "title=" Qq20160913154454.png "alt=" Wkiol1fxroghl8shaaaklfplilo127.png "/>
Initializing the display of the database
Show variables like ' wsrep_cluster_address ';
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/87/37/wKiom1fXrxTSZtcmAAAOfhJGJYg838.png "title=" Qq20160913154716.png "alt=" Wkiom1fxrxtsztcmaaaofhjgjyg838.png "/>
View cluster-related parameters
Show status like ' wsrep% ';
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/87/36/wKiom1fXraTQ32fgAAA5bOMs9Z8239.png "title=" Qq20160913154110.png "alt=" Wkiom1fxratq32fgaaa5boms9z8239.png "/>
Wsrep_cluster_size Cluster scale node points
Wsrep_cluster_state_uuid cluster UUID
wsrep_connected Connection Status
Wsrep_ready Boot Status
See if the database system time is consistent across nodes
Select Now ();
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/87/37/wKiom1fXsKexayvCAAAJ85s0jxY257.png "style=" float: none; "title=" Qq20160913155343.png "alt=" Wkiom1fxskexayvcaaaj85s0jxy257.png "/>650" this.width=650; "src=" http:/ /s1.51cto.com/wyfs02/m02/87/34/wkiol1fxskfxf5voaaajjh8ttqq341.png "title=" qq20160913155358.png "style=" float: none; "alt=" Wkiol1fxskfxf5voaaajjh8ttqq341.png "/>
Testing in a database with data tables
Create DATABASE base;
Use base;
CREATE TABLE Pet (name varchar, owner varchar), species varchar, sex char (1), Birth date, death date);
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/87/34/wKioL1fXsYXwfIPKAAAj8s76rfk830.png "title=" Qq20160913155745.png "alt=" Wkiol1fxsyxwfipkaaaj8s76rfk830.png "/>
View synchronized successfully on another node
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/87/37/wKiom1fXscLTKxTRAAAWQpF7Zdw069.png "title=" Qq20160913155839.png "alt=" Wkiom1fxscltkxtraaawqpf7zdw069.png "/>
Inserts a record into the data table on another node
INSERT into pet values (' Puffball ', ' Diane ', ' hamster ', ' f ', ' 1999-03-30 ', null);
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/87/37/wKiom1fXskmQOCA5AAAKpC3Ieww065.png "title=" Qq20160913160057.png "alt=" Wkiom1fxskmqoca5aaakpc3ieww065.png "/>
Viewing records in other nodes is synchronized
SELECT * from Pet;
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/87/34/wKioL1fXspHxSlREAAAPKoJlDQY716.png "title=" Qq20160913160214.png "alt=" Wkiol1fxsphxslreaaapkojldqy716.png "/>
Deleting a database
drop database base;
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/87/34/wKioL1fXtFXQBwJfAAAHdJPhMUY371.png "title=" Qq20160913160946.png "alt=" Wkiol1fxtfxqbwjfaaahdjphmuy371.png "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/87/34/wKioL1fXtHvCNgm_AAAM6JmUANM104.png "title=" Qq20160913161021.png "alt=" Wkiol1fxthvcngm_aaam6jmuanm104.png "/>
At this point mariadb galera cluster cluster was successfully deployed.
This article from the "Server System Communication" blog, reproduced please contact the author!
MariaDB galera cluster cluster Enterprise Edition installation and configuration