Docker

安装 Docker:

sudo yum install -y yum-utils device-mapper-persistent-data lvm2
wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
sudo sed -i 's+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo
sudo yum makecache fast
sudo yum install docker-ce
systemctl start docker
systemctl enable docker

安装 docker-compose:

yum install python2-pip
pip install docker-compose

编写 docker-compose.yaml

mkdir mariadb
vim mariadb/docker-compose.yaml
version: '2'
services:
  db:
    image: mariadb
    container_name: mariadb
    ports:
      - "3306:3306"
    volumes:
      - database:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=123456
volumes:
  database:
    driver: local

开始吧:

docker-compose up -d

连接:

mysql -uroot -h127.0.0.1 -p

yum

开端口:

firewall-cmd --add-service=mysql --permanent
firewall-cmd --reload

配置清华大学源:

vim /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.1 CentOS repository list - created 2016-12-31 08:44 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/10.1/centos7-amd64
gpgkey = https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum//RPM-GPG-KEY-MariaDB
gpgcheck = 1

安装:

yum install MariaDB-server MariaDB-client

启动:

systemctl start mariadb
systemctl enable mariadb
systemctl status mariadb

初始化:

mysql_secure_installation

编译安装

安装编译环境以及依赖:

yum update -y
yum-builddep mariadb-server

下载源码编译

git clone --branch 10.3 https://github.com/MariaDB/server.git
cmake -DRPM=centos7 server/
make package

创建用户:

chown -R mysql /usr/local/mysql/
cd /usr/local/mysql/
scripts/mysql_install_db --user=mysql
/usr/local/mysql/bin/mysqld_safe --user=mysql &