介绍

Percona Server for MySQL 由领先的数据库 L 咨询公司 Percona 发布。Percona Server for MySQL 是一款独立的数据库产品,其基于 Oracle MySQL 开发并融合业内先进的数据库治理经验。

Percona 团队的最终声明是 “ Percona Server for MySQL 是最接近 Oracle 的 MySQL Enterprise 分支版本”,与其他更改了大量基本核心 MySQL 代码的分支有所区别。Percona Server 的一个缺点是他们自己管理代码,不接受外部开发人员的贡献,以这种方式确保他们对产品中所包含功能的控制。

Percona 不得不提的就是它家的 XtraDB ,Percona XtraDB 是 InnoDB 存储引擎的增强版,被设计用来更好的使用更新计算机硬件系统的性能,同时还包含有一些在高性能环境下的新特性。XtraDB 存储引擎是完全的向下兼容,在 MariaDB 中,XtraDB 存储引擎被标识为 ”ENGINE=InnoDB ”,这个与 InnoDB 是一样的,所以你可以直接用 XtraDB 替换掉 InnoDB 而不会产生任何问题。Percona XtraDB 包含有所有 InnoDB’s 健壮性,可依赖的 ACID 兼容设计和高级 MVCC 架构。XtraDB 在 InnoDB 的坚实基础上构建,使 XtraDB 具有更多的特性,更好调用,更多的参数指标和更多的扩展。从实践的角度来看,XtraDB 被设计用来在多核心的条件下更有效的使用内存和更加方便,更加可用。新的特性被用来降低 InnoDB 的局限性。性能层面,XtraDB 与内置的 MySQL 5.1 InnoDB 引擎相比,它每分钟可处理 2.7 倍的事务。

相对于 MariaDB,Percona 更接近官方版也就是 Oracle MySQL,比 MariaDB 更保守,当然随着 MariaDB 的蓬勃发展,Percona 也在不断吸收 MariaDB 的先进经验。

安装

一、软件添加 Percona 软件源:

RHEL/CentOS:

<code class="language-bash"><span class="pln">yum install http</span><span class="pun">://</span><span class="pln">www</span><span class="pun">.</span><span class="pln">percona</span><span class="pun">.</span><span class="pln">com</span><span class="pun">/</span><span class="pln">downloads</span><span class="pun">/</span><span class="pln">percona</span><span class="pun">-</span><span class="pln">release</span><span class="pun">/</span><span class="pln">redhat</span><span class="pun">/</span><span class="lit">0.1</span><span class="pun">-</span><span class="lit">6</span><span class="pun">/</span><span class="pln">percona</span><span class="pun">-</span><span class="pln">release</span><span class="pun">-</span><span class="lit">0.1</span><span class="pun">-</span><span class="lit">6.noarch</span><span class="pun">.</span><span class="pln">rpm</span></code>

Debian/Ubuntu:

<code class="language-bash"><span class="pln">wget https</span><span class="pun">://</span><span class="pln">repo</span><span class="pun">.</span><span class="pln">percona</span><span class="pun">.</span><span class="pln">com</span><span class="pun">/</span><span class="pln">apt</span><span class="pun">/</span><span class="pln">percona</span><span class="pun">-</span><span class="pln">release_0</span><span class="pun">.</span><span class="lit">1</span><span class="pun">-</span><span class="lit">6.</span><span class="pln">$</span><span class="pun">(</span><span class="pln">lsb_release </span><span class="pun">-</span><span class="pln">sc</span><span class="pun">)</span><span class="pln">_all</span><span class="pun">.</span><span class="pln">deb</span></code>

由于 Percona 的软件源在国内的速度非常非常慢,建议手动修改一下软件源配置文件。

运行如下语句:

RHEL/CentOS:

<code class="language-bash"><span class="pln">sed </span><span class="pun">-</span><span class="pln">i </span><span class="str">"s/http:\/\/repo.percona.com\/release/https:\/\/mirror.tuna.tsinghua.edu.cn\/percona\/release/g"</span> <span class="str">`grep -rl "repo.percona.com" /etc/yum.repos.d/percona-release.repo`</span></code>

Debian/Ubuntu:

<code class="language-bash"><span class="pln">sed </span><span class="pun">-</span><span class="pln">i </span><span class="str">"s/http:\/\/repo.percona.com\/apt/https:\/\/mirror.tuna.tsinghua.edu.cn\/percona\/apt/g"</span> <span class="str">`grep -rl "repo.percona.com" /etc/apt/sources.list.d/percona-release.list`</span></code>

二、安装 Percona-Server

RHEL/CentOS:

<code class="language-bash"><span class="pln">yum install </span><span class="typ">Percona</span><span class="pun">-</span><span class="typ">Server</span><span class="pun">-</span><span class="pln">server</span><span class="pun">-</span><span class="lit">57</span></code>

Debian/Ubuntu:

<code class="language-bash"><span class="pln">apt update
apt install percona</span><span class="pun">-</span><span class="pln">server</span><span class="pun">-</span><span class="pln">server</span><span class="pun">-</span><span class="lit">5.7</span></code>

三、查看密码

<code class="language-bash"><span class="pln">cat </span><span class="pun">/</span><span class="pln">var</span><span class="pun">/</span><span class="pln">log</span><span class="pun">/</span><span class="pln">mysqld</span><span class="pun">.</span><span class="pln">log </span><span class="pun">|</span><span class="pln"> grep </span><span class="str">"temporary password"</span></code>

就可以看到临时密码了,

<code class="language-bash"><span class="pun">[</span><span class="pln">root@MF8</span><span class="pun">.</span><span class="pln">BIZ </span><span class="pun">~]#</span><span class="pln"> cat </span><span class="pun">/</span><span class="pln">var</span><span class="pun">/</span><span class="pln">log</span><span class="pun">/</span><span class="pln">mysqld</span><span class="pun">.</span><span class="pln">log </span><span class="pun">|</span><span class="pln"> grep </span><span class="str">"temporary password"</span>
<span class="lit">2018</span><span class="pun">-</span><span class="lit">09</span><span class="pun">-</span><span class="lit">11T06</span><span class="pun">:</span><span class="lit">44</span><span class="pun">:</span><span class="lit">39.668690Z</span> <span class="lit">1</span> <span class="pun">[</span><span class="typ">Note</span><span class="pun">]</span><span class="pln"> A temporary password is generated </span><span class="kwd">for</span><span class="pln"> root@localhost</span><span class="pun">:</span><span class="pln"> XU0</span><span class="pun">+</span><span class="pln">jSPEgss</span></code>

四、安全初始化

运行如下语句进行安全初始化:

<code class="language-bash"><span class="pln">mysql_secure_installation  </span></code>

首先输入密码,就是咱们刚才的临时密码,然后就可以修改密码了,之后一路 y 就行。

Percona Server 5.7 安装教程-米饭粑

基本介绍: Enter current password for root (enter for none): 解释:输入当前 root 用户密码,默认为空,直接回车。 Set root password? [Y/n] y > > 解释:要设置 root 密码吗?输入 y 表示愿意。 Remove anonymous users? [Y/n] y 解释:要移除掉匿名用户吗?输入 y 表示愿意。 Disallow root login remotely? [Y/n] y 解释:不想让 root 远程登陆吗?输入 y 表示愿意。 Remove test database and access to it? [Y/n] y 解释:要去掉 test 数据库吗?输入 y 表示愿意。 Reload privilege tables now? [Y/n] y 解释:想要重新加载权限吗?输入 y 表示愿意。

管理

<code><span class="pln">systemctl restart mysql </span><span class="com">#重启</span><span class="pln">
systemctl start mysql </span><span class="com">#启动</span><span class="pln">
systemctl stop mysql </span><span class="com">#关闭</span><span class="pln">
systemctl status mysql </span><span class="com">#检查状态</span></code>

更新

运行下面的命令系统就会更新所有可以更新的软件包括 Percona

RHEL/CentOS:

<code class="language-bash"><span class="pln">yum update</span></code>

Debian/Ubuntu:

<code class="language-bash"><span class="pln">apt update
apt upgrade </span><span class="pun">-</span><span class="pln">y</span></code>