05、以yum的方式部署MySQL
部署MySQL数据库有多种部署方式,常用的部署方式就有三种:yum安装、rpm安装以及编译安装。每一种安装方式都有自己的优势,那么企业当中通常情况下采用的是rpm和二进制安装的方式。
数据库官网下载地址:https://downloads.mysql.com/archives/community/
Linux
企业当中,常用的服务器都是Linux操作系统,少部分是使用Windows操作系统。本次部署采用Mysql 5.7作为实验版本。
Mysql 5.7的主要特性
- 更好的性能:对于多核CPU、固态硬盘、锁有着更好的优化,每秒100W QPS已不再是MySQL的追求,下个版本能否上200W QPS才是吾等用户更关心的
- 更好的InnoDB存储引擎
- 更为健壮的复制功能:复制带来了数据完全不丢失的方案,传统金融客户也可以选择使用MySQL数据库。此外,GTID在线平滑升级也变得可能
- 更好的优化器:优化器代码重构的意义将在这个版本及以后的版本中带来巨大的改进,Oracle官方正在解决MySQL之前最大的难题
- 原生JSON类型的支持
- 更好的地理信息服务支持:InnoDB原生支持地理位置类型,支持GeoJSON,GeoHash特性
- 新增sys库
yum部署方式
从CentOS 7.0发布以来,yum源中开始使用Mariadb来代替MySQL的安装(这里什么是mariadb,和mysql有什么区别,有兴趣的小伙伴可以自行查阅)。即使你输入的是yum install -y mysql , 显示的也是Mariadb的安装内容。如果想安装Mysql就必须使用Mysql官方的yum源。
1、编写yum源配置文件
#配置好yum源,包括epel源
[root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@localhost ~]# yum -y install vim wget
- 使用官方yum仓库
[root@localhost ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
--2021-09-14 06:45:09-- https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm [following]
--2021-09-14 06:45:10-- https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.50.239.110
Connecting to repo.mysql.com (repo.mysql.com)|23.50.239.110|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 26024 (25K) [application/x-redhat-package-manager]
Saving to: ‘mysql80-community-release-el7-3.noarch.rpm’
100%[==============================================================>] 26,024 --.-K/s in 0.04s
2021-09-14 06:45:11 (712 KB/s) - ‘mysql80-community-release-el7-3.noarch.rpm’ saved [26024/26024]
[root@localhost ~]# yum install mysql80-community-release-el7-3.noarch.rpm
Loaded plugins: fastestmirror
Examining mysql80-community-release-el7-3.noarch.rpm: mysql80-community-release-el7-3.noarch
Marking mysql80-community-release-el7-3.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql80-community-release.noarch 0:el7-3 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================