跳到主要内容

1、实战:MariaDB部署(yum方式)-2024.3.28(测试成功)

更新于:2024年3月29日

实战:MariaDB部署(yum方式)-2024.3.28(测试成功)

image-20240328154157777

目录

[toc]

环境

centos7.9 2001
mariadb-server 10.5.24

无实验软件

须知

centos6:默认仓库有mysql-server v5.1.73版本包

yum info mariadb-server

centos7:默认仓库有mariadb-server v5.5.65版本包 yum info mariadb-server

centos8上默认仓库有mysql 8.0.17,mariadb 10.3.17版本包

部署

(1)默认版本

默认yum直接部署会安装centos仓库自带的mariadb-server v5.5.65版本包:

yum install mariadb-server -y
[root@linux ~]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 5 *:8730 *:*
LISTEN 0 128 *:443 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 5 [::]:8730 [::]:*
LISTEN 0 128 [::]:443 [::]:*
[root@linux ~]# systemctl enable --now mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@linux ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2024-03-28 14:30:23 CST; 16s ago
Process: 24929 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
Process: 24844 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Main PID: 24927 (mysqld_safe)
Tasks: 20
Memory: 102.9M
CGroup: /system.slice/mariadb.service
├─24927 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─25093 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var...

Mar 28 14:30:21 linux mariadb-prepare-db-dir[24844]: MySQL manual for more instructions.
Mar 28 14:30:21 linux mariadb-prepare-db-dir[24844]: Please report any problems at http://mariadb.org/jira
Mar 28 14:30:21 linux mariadb-prepare-db-dir[24844]: The latest information about MariaDB is available at http://mariadb.org/.
Mar 28 14:30:21 linux mariadb-prepare-db-dir[24844]: You can find additional information about the MySQL part at:
Mar 28 14:30:21 linux mariadb-prepare-db-dir[24844]: http://dev.mysql.com
Mar 28 14:30:21 linux mariadb-prepare-db-dir[24844]: Consider joining MariaDB's strong and vibrant community:
Mar 28 14:30:21 linux mariadb-prepare-db-dir[24844]: https://mariadb.org/get-involved/
Mar 28 14:30:21 linux mysqld_safe[24927]: 240328 14:30:21 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Mar 28 14:30:21 linux mysqld_safe[24927]: 240328 14:30:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Mar 28 14:30:23 linux systemd[1]: Started MariaDB database server.
[root@linux ~]#
[root@linux ~]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 5 *:8730 *:*
LISTEN 0 128 *:443 *:*
LISTEN 0 50 *:3306 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 5 [::]:8730 [::]:*
LISTEN 0 128 [::]:443 [::]:*
[root@linux ~]#
#*:3306 这里的*代表任意地址的3306都可以访问。

[root@linux ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

(2)配置mariadb官方镜像仓库

老版本:

image-20240328145650715

image-20240328145916234

image-20240328145932386

# MariaDB 10.5 CentOS repository list - created 2024-03-28 06:37 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
# rpm.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# baseurl = https://rpm.mariadb.org/10.5/centos/$releasever/$basearch
baseurl = https://download.nus.edu.sg/mirror/mariadb/yum/10.5/centos/$releasever/$basearch
module_hotfixes = 1
# gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgkey = https://download.nus.edu.sg/mirror/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1

使用清华源:

https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/

https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/10.5.24/centos7-amd64/

image-20240328145953956

image-20240328150012168

这里把gpgcheck=0设置为0就好。

# vim /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/10.5.24/centos7-amd64/
gpgcheck = 0




#2024年5月27日 更新
# vim /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/10.5.25/centos7-amd64/
gpgcheck = 0


#2024年6月13日 更新
# vim /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/10.5.25/centos8-amd64/
gpgcheck = 0

清理缓存,查看仓库:

[root@linux ~]# yum clean all
[root@linux ~]# yum repolist mariadb
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.cloud.aliyuncs.com
* extras: mirrors.cloud.aliyuncs.com
* updates: mirrors.cloud.aliyuncs.com
repo id repo name status
mariadb MariaDB 103
repolist: 103
[root@linux ~]#

(3)安装并验证

安装:

[root@linux ~]# yum install  mariadb-server -y --disableexcludes=MariaDB
……
Installed:
MariaDB-client.x86_64 0:10.5.24-1.el7.centos MariaDB-compat.x86_64 0:10.5.24-1.el7.centos
MariaDB-server.x86_64 0:10.5.24-1.el7.centos

Dependency Installed:
MariaDB-common.x86_64 0:10.5.24-1.el7.centos boost-program-options.x86_64 0:1.53.0-28.el7 galera-4.x86_64 0:26.4.16-1.el7.centos
lsof.x86_64 0:4.87-6.el7 pcre2.x86_64 0:10.23-2.el7 socat.x86_64 0:1.7.3.2-2.el7

Replaced:
mariadb.x86_64 1:5.5.68-1.el7 mariadb-libs.x86_64 1:5.5.68-1.el7 mariadb-server.x86_64 1:5.5.68-1.el7

Complete!

[root@linux ~]# systemctl enable --now mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

验证:

[root@linux ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.5.24-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

一键执行

wget -qO- https://onedayxyy.cn/scripts/mariadb_install/mariadb_install_yum.sh |bash

mariadb_install_yum.sh

##1、配置清华源镜像仓库
cat > /etc/yum.repos.d/mariadb.repo << EOF
[mariadb]
name = MariaDB
baseurl = https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/10.5.25/centos7-amd64/
gpgcheck = 0
EOF

yum clean all
yum makecache
yum repolist all


##2、部署
yum install -y mariadb-server --disableexcludes=MariaDB
systemctl enable --now mariadb

##3、测试
mysql

关于我

我的博客主旨:

  • 排版美观,语言精炼;
  • 文档即手册,步骤明细,拒绝埋坑,提供源码;
  • 本人实战文档都是亲测成功的,各位小伙伴在实际操作过程中如有什么疑问,可随时联系本人帮您解决问题,让我们一起进步!

🍀 微信二维码

x2675263825 (舍得), qq:2675263825。

image-20230107215114763

🍀 微信公众号

《云原生架构师实战》

image-20230107215126971

🍀 个人博客站点

https://onedayxyy.cn/

🍀 语雀

https://www.yuque.com/xyy-onlyone

🍀 csdn

https://blog.csdn.net/weixin_39246554?spm=1010.2135.3001.5421

image-20230107215149885

🍀 知乎

https://www.zhihu.com/people/foryouone

image-20230107215203185

最后

好了,关于本次就到这里了,感谢大家阅读,最后祝大家生活快乐,每天都过的有意义哦,我们下期见!