Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Compilation, installation and configuration of MariaDB Galera Cluster Cluster Enterprise Edition

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Installation environment

System: CentOS 6.8 x8664

Software: MariaDB 10.1.16

Node 1: 192.168.11.132 4C 8GB

Node 2: 192.168.11.133 4C 8GB

Software acquisition

Visit the MariaDB Enterprise Edition download address https://mariadb.com/my_portal/download/mariadb-enterprise login account and select the 10.1.16GA version source code package to download.

Starting with MariaDB Enterprise version 10.1, the Enterprise Edition package is integrated with clustering capabilities, so there is only one download package.

Download the source code package to the / usr/src directory of the CentOS system

Visit the http://galeracluster.com/ download page of galeracluster's official website

Select the latest version of Galera 3 wsrep source code package and download it to the / usr/src directory of the CentOS system.

After the download is complete, copy the two packages to the / usr/src directory of each node

Installation process

1. Add a yum source for epel

Rpm-vih http://mirrors.ustc.edu.cn/epel/epel-release-latest-6.noarch.rpm

two。 Regenerate the yum source cache

Yum clean all;yum makecache

3. Use yum to install the necessary software 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

4. Use the file CRC check code to determine that if / etc/localtime and / usr/share/zoneinfo/Asia/Shanghai are not the same file, the system time zone is not Asia and Shanghai, and you need to copy or link / usr/share/zoneinfo/Asia/Shanghai file to / etc/localtime file to overwrite it.

5. Synchronize with ntp server to update system time

Ntpdate 0.centos.pool.ntp.org

Hwclock-w

/ etc/init.d/ntpd start

Chkconfig ntpd on

Chkconfig ntpdate on

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

7. Extract the galera package, copy it to / usr/local and rename it

Tar zxf galera-3-25.3.17.tar.gz

Mv galera-3-25.3.17 / usr/local/galera

8. Use the scons command to compile and install galera

9. / usr/local/galera/libgalera_smm.so module will be generated when the installation is complete

10. Change 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

11. Compiling simultaneously with the 4 cores of cpu

Make-j 4

twelve。 Installation

Make install

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

14. If the / etc/my.cnf file exists, delete or rename it. And create a new profile

Mv / etc/my.cnf / etc/my.cnf.bak

Cp support-files/my-large.cnf.sh / usr/local/mariadb/etc/my.cnf

15. Edit / usr/local/mariadb/etc/my.cnf modify port and socket parameters and add them in [mysqld]

Pid-file = / usr/local/mariadb/run/mariadb.pid

Log-error = / usr/local/mariadb/log/mariadb.log

16. Modify the mariadb directory owner

Chown-R mariadb:mariadb / usr/local/mariadb/

17. Initialize the mariadb database

/ usr/local/mariadb/scripts/mysql_install_db-user=mariadb-basedir=/usr/local/mariadb/-datadir=/usr/local/mariadb/data/

18. Modify / usr/local/mariadb/bin/mysqld_safe file parameters

User='mariadb'

19. Start the mariadb database

/ usr/local/mariadb/bin/mysqld_safe &

20. View process and port status

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

twenty-two。 Modify the following parameters in the / etc/init.d/mariadb file

Basedir=/usr/local/mariadb

Datadir=/usr/local/mariadb/data

Mysqld_pid_file_path=/usr/local/mariadb/run/mariadb.pid

23. Add chkconfig Management

Chkconfig-add mariadb

24. Test startup function

25. Configure the login password for the root account of the mariadb database and configure security.

/ usr/local/mariadb/bin/mysql_secure_installation

twenty-six。 Log in to the database with a password

/ usr/local/mariadb/bin/mysql-upright root'-p'D5) Galli3'

twenty-seven。 Create a sst account to synchronize the database

GRANT USAGE ON *. * to sst@'%' IDENTIFIED BY 'gurds0Gl'

GRANT ALL PRIVILEGES on *. * to sst@'%'

FLUSH PRIVILEGES

twenty-eight。 Stop the database

/ etc/init.d/mariadb stop

Modify the configuration file / usr/local/mariadb/etc/my.cnf to add at the end

! includedir / usr/local/mariadb/etc/my.cnf.d/

twenty-nine。 Create / usr/local/mariadb/etc/my.cnf.d/ directory and 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/

Perform steps 1 through 29 above to install the configuration database at Node 2 (if there is more than one node, at each other node).

At node one, execute:

Modify the parameters below / usr/local/mariadb/etc/my.cnf.d/wsrep.cnf 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.132192.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

Check the log / usr/local/mariadb/log/mariadb.log with WSREP: Synchronized with group, and the ready for connections message indicates that the cluster service started successfully.

Tail / usr/local/mariadb/log/mariadb.log

Execute on Node 2:

Modify the parameters below / usr/local/mariadb/etc/my.cnf.d/wsrep.cnf 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.132192.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

Log details

If there are multiple nodes, please refer to Node 2 configuration.

Log in to the mariadb database at any node

Check whether the cluster function is enabled

Show status like 'wsrep_ready'

Initialize the database display

Show variables like 'wsrep_cluster_address'

View cluster-related parameters

Show status like 'wsrep%'

Number of wsrep_cluster_size cluster size nodes

Wsrep_cluster_state_uuid Cluster uuid

Wsrep_connected connection status

Wsrep_ready startup status

Check whether the database system time of each node is the same.

Select now ()

Test in a create database and data table

Create database base

Use base

Create table pet (name varchar (20), owner varchar (20), species varchar (20), sex char (1), birth date, death date)

Check on another node that the synchronization has been successful

Insert a record into the data table in another node

Insert into pet values ('Puffball','Diane','hamster','f','1999-03-30 zero zero)

Check on other nodes that the records have been synchronized

Select * from pet

Delete database

Drop database base

So far, the MariaDB Galera Cluster cluster has been successfully deployed.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report