用APT安装

对于Debian和Ubuntu,我们强烈建议用命令apt-get, aptitude或其它的包管理工具从软化仓库中安装MariaDB。

安装最便捷的方法是用在线软件源配置工具来安装。

导入GnuPG签钥Import the GnuPG signing key

首先导入用于软件仓库签证的签钥,对每个服务器只要操作一次。签钥用于验证一apt下载时进行验证。

签钥ID是0xcbcb082a1bb943db,完全的指纹为:

1993 69E5 404B D5FC 7D2F E43B CBCB 082A 1BB9 43DB

apt-key程序可轻松地导入签钥于apt中:

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db

在Debian和Ubuntu系统中,导入签钥的命令是一样的。

例子:
localhost:~# apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /tmp/tmp.ASyOPV87XC --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
gpg: requesting key 1BB943DB from hkp server keyserver.ubuntu.com
gpg: key 1BB943DB: public key "Daniel Bartholomew (Monty Program signing key) <dbart@askmonty.org>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1

签钥导入后,你要做的就是添加相应的软件仓库了。

添加MariaDB软件源到你的sources.list中:

请用我们的在线工具软件源配置工具来产生相应的源(APT行)。

#华中科技大学启明学院
# MariaDB 5.5 repository list - created 2014-02-07 03:25 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.hustunique.com/mariadb/repo/5.5/debian wheezy main
deb-src http://mirrors.hustunique.com/mariadb/repo/5.5/debian wheezy main
#电子科技大学, 成都
# MariaDB 5.5 repository list - created 2014-02-07 03:28 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/debian wheezy main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/debian wheezy main

在工具中,请根据你使用的系统选择"debian"或"ubuntu",再选择你要使用发行版本,最后选择要安装的MariaDB版本。

你可以用下面的命令来检查你正在使用的发行版本。

lsb_release -a

在有了sources.list入口后,把它添加到: /etc/apt/sources.list (如: "sudo gedit /etc/apt/sources.list " 或使用sources.list.d/文件下的分立文件 (如: with "sudo gedit /etc/apt/sources.list.d/mariadb.list ")。

你可以使用软件源管理工具添加APT行,这个工具可以在Ubuntu软件中心的“编辑”菜单中。在新立得软件包管理器中,这个工作叫做“软件仓库(Respositories),它位于”设置“菜单中。在启动了工具后,点击”添加……“按钮,将APT行(源)一行一行地粘贴进去。

备添加GPG签钥一样,这个工作一台服务器只要做一次。

用apt-get安装MariaDB:

添加了签钥和APT源后,你可以进行:

sudo apt-get update

来下载安装MariaDB的相关信息。

MariaDB现在可以用你惯用的工具来安装了,例如:

sudo apt-get install mariadb-server

Installing MariaDB Galera Cluster with apt-get

The instructions for installing MariaDB Galera Cluster are virtually the same as for installing MariaDB. The setup of importing the signing key and creating the sources.list entry are both the same. The only difference is in the install step. Instead of installing the mariadb-server package, you install the mariadb-galera-server and galera packages, like so:

sudo apt-get install mariadb-galera-server galera

If the server already has the mariadb-server package installed, it will be automatically removed prior to installing mariadb-galera-server.

See the Galera section of the Knowledgebase for more information on MariaDB Galera Cluster.

Installation Issues

MariaDB starting with 5.5

Upgrading mariadb-server and mariadb-client packages

As noted in MDEV-4266, the mariadb-server and mariadb-client packages have a minor upgrade issue if you use 'apt-get install mariadb-server' or 'apt-get install mariadb-client' to upgrade them instead of the more common 'apt-get upgrade'. This is because those two packages depend on mariadb-server-5.5 and mariadb-client-5.5 with no specific version of those packages. For example, if you have the mariadb-server package installed, version 5.5.29 and you install version 5.5.30 of that package it will not automatically upgrade the mariadb-server-5.5 package to verstion 5.5.30 like you would expect because the 5.5.29 version of that package satisfies the dependency.

The mariadb-server and mariadb-client packages are virtual packages, they only exist to require the installation of the mariadb-server-5.5 and mariadb-client-5.5 packages, respectively. MariaDB will function normally with a, for example, version 5.5.30 version of the mariadb-server package and a version 5.5.29 version of the mariadb-server-5.5 package. No data is at risk. However, expected behavior is for 'apt-get install mariadb-server' to upgrade everything to the latest version (if a new version is available), so this is definitely a bug.

A fix is planned for this bug in a future version of MariaDB. In the mean time, when upgrading MariaDB, use 'apt-get upgrade' or 'apt-get install mariadb-server-5.5'.

MariaDB starting with 5.1

Version Mismatch Between MariaDB and Ubuntu/Debian Repositories

As mentioned here (and in MDEV-4080 and MDEV-3882) sometimes APT will refuse to install MariaDB. Or, if MariaDB is already installed, suggest the removal of MariaDB to apply an upgrade to the mysql-common or libmysqlclient packages. This happens whenever the version number of those two packages is higher in the distribution repositories than the versions in the MariaDB repositories. Most MariaDB packages have different names than their MySQL counterparts, but in order for upgrades from MySQL to MariaDB to be successful in APT, those two packages must be named the same. Because they have the same names, APT just checks the version numbers and tries to install what it considers to be the most recent.

It is rare for the version numbers of mysql-common or libmysqlclient to be higher in the official Ubuntu or Debian repositories than they are in the MariaDB repositories, but it has happened. Whenever it has it has been because of critical bug fix releases for bugs that existed in the version of MySQL in the distribution repositories but which had already been fixed in the version of MariaDB in the MariaDB repositories.

If a situation as described above exists when you try to install MariaDB you will get an error like this:

The following packages have unmet dependencies:
 mariadb-server : Depends: mariadb-server-5.5 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

There are three primary ways of fixing this issue:

  1. Specifying Specific Versions to Install
  2. Holding Packages
  3. Pinning the MariaDB Repository

Click on the links above to jump to directions for each (or simply scroll down).

Specifying Specific Versions to Install

A way to fix this is to specify the exact version of the two packages that you want to install. To do this, first determine the full version numbers of the affected packages. An easy way to do so is with 'apt-cache show':

apt-cache show mysql-common | grep Version
apt-cache show libmysqlclient18 | grep Version

For each of the above you will be given a list of versions. The ones in the MariaDB repositories will have "mariadb" in the version strings and are the ones you want. With the version numbers in hand you will be able to install MariaDB by explicitly specifying the version numbers like so:

apt-get install mariadb-server-5.5 mariadb-client-5.5 \
  libmysqlclient18=<version-number> \
  mysql-common=<version-number>

Replace the two instances of <version-number> in the example above with the actual version number of MariaDB that you want to install.

Holding Packages

After MariaDB is installed, and as long as the version number issue exists, an 'apt-get dist-upgrade' will try to remove MariaDB in order to install the "upgraded" libmysqlclient and mysql-common packages. To prevent this from happening you can hold them so that apt doesn't try to upgrade them. To do so, open a terminal, become root with 'sudo -s', and then enter the following:

echo libmysqlclient18 hold | dpkg --set-selections
echo mysql-common hold | dpkg --set-selections

The holds will prevent you from upgrading MariaDB, so when you want to remove the holds, open a terminal, become root with 'sudo -s', and then enter the following:

echo libmysqlclient18 install | dpkg --set-selections
echo mysql-common install | dpkg --set-selections

You will then be able to upgrade MariaDB as normal (e.g. with 'sudo apt-get update; sudo apt-get upgrade').

Pinning the MariaDB Repository

Another thing you can do is to pin the MariaDB repository that you use. This is done by creating a file under '/etc/apt/preferences.d/' with the following contents:

Package: *
Pin: origin <mirror-domain>
Pin-Priority: 1000

Replace '<mirror-domain>' with the domain name of the MariaDB mirror you use. For example, 'ftp.osuosl.org'. With the pin file in place, packages from your MariaDB repository will have priority over packages from the system repositories.

手工安装.deb文件

虽然不推荐这个方法,但MariaDB也是可以下载手工安装的(不使用如:apt-get等软件包管理器)。请在你最近的镜像的“repo/”目录下,“.deb”就在debian/pool/ubuntu/pool/的相应目录中。

下面是在Debian 5 amd64中安装MariaDB 5.1.42(其他系统也差不多):

sudo apt-get update
sudo apt-get install libdbi-perl libdbd-mysql-perl psmisc
sudo dpkg --install mysql-common_5.1.42-mariadb73_all.deb
sudo dpkg --install libmariadbclient16_5.1.42-mariadb73_amd64.deb libmysqlclient16_5.1.42-mariadb73_amd64.deb \
mariadb-client_5.1.42-mariadb73_all.deb mariadb-client-5.1_5.1.42-mariadb73_amd64.deb mariadb-server_5.1.42-mariadb73_all.deb \
mariadb-server-5.1_5.1.42-mariadb73_amd64.deb

Comments

Comments loading...