Centos 7用官方YUM源安装Mariadb Galera集群
- 安装Mariadb数据库前的准备工作
1、安装CentOS7,三台虚拟机(IP分别为192.168.28.7,192.168.28.8,192.168.28.9)
配置yum国内源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# 下载阿里云的base源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# 如果没有wget程序则使用curl下载
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# 快速生成缓存
yum makecache fast
# 生成完整缓存
yum clean all

yum makecache

# 查看yum源是否添加成功
yum repolist
更新系统:
yum update -y


yum install wget -y

yum install vim -y

yum install bash-completion -y

vim ~/.bash_profile 加入

source ~/.bash_profile
2、添加Mariadb官方YUM源,下面以Mariadb 11.5.2为例
使用以下命令快速添加YUM源
# tee /etc/yum.repos.d/mariadb.repo <<-\’EOF\’
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/11.5/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF
3、由于Mariadb服务器是在国外,速度较慢,可以使用国内镜像源替代,以USTC镜像源为例
sed -i \’s#yum\\.mariadb\\.org#mirrors.ustc.edu.cn/mariadb/yum#\’ /etc/yum.repos.d/mariadb.repo
4、刷新YUM缓存
yum makecache

5、查看Mariadb相关的安装包,注意软件包版本和对应的YUM源名字
yum list MariaDB* galera

6、关闭firewalld防火墙
systemctl disable firewalld –now
![]()
7、设置主机名(设置三台虚拟机主机名分别为db1,db2,db3)
# hostnamectl set-hostname db1
# hostnamectl set-hostname db2
# hostnamectl set-hostname db3
8、编辑/etc/hosts文件,加入
# vim /etc/hosts






