docker centos7.2 mysql5.7

原创
2016/11/03 15:21
阅读数 246

wget http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-common-5.7.16-1.el7.x86_64.rpm
wget http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-libs-5.7.16-1.el7.x86_64.rpm
wget http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-client-5.7.16-1.el7.x86_64.rpm
wget http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-server-5.7.16-1.el7.x86_64.rpm

yum install -y perl
yum install -y numactl-libs
yum install -y net-tools
rpm -i mysql-community-common-5.7.16-1.el6.x86_64.rpm
rpm -i mysql-community-libs-5.7.16-1.el6.x86_64.rpm
rpm -i mysql-community-client-5.7.16-1.el6.x86_64.rpm
rpm -i mysql-community-server-5.7.16-1.el7.x86_64.rpm

groupadd mysql
useradd -r -g mysql mysql -s /sbin/nologin
chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql /mnt/docker/mysql
rm -rf /mnt/docker/mysql/datadir/*

mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql/ --datadir=/mnt/docker/mysql/datadir/

systemctl enable mysqld.service

exit

docker commit -m="mysql5.7.16 centos7 systemd启动" 7ea468e9b950 loowj/centosmd/mysql5.6.16:0.0.1

docker -d 后台运行cmd /usr/sbin/init 运行

docker run -it -d --privileged=true -v /sys/fs/cgroup:/sys/fs/cgroup -v ~/loowj/docker.mnt/mysql:/mnt/docker/mysql -p 3306:3306 e0c2096791c2 /usr/sbin/init

进入容器

nsenter --mount --uts --ipc --net --pid --target $(docker inspect --format "{{.State.Pid}}" "2a94313424f3fa")

新建一个可以远程的Mysql用户

create user loowj IDENTIFIED by '123456';

grant ALL PRIVILEGES ON *.* to loowj@"%" identified by "123456" WITH GRANT OPTION;

FLUSH PRIVILEGES; 

简单启动centosmd

docker run -it -d --privileged=true -v /sys/fs/cgroup:/sys/fs/cgroup -v ~/loowj/docker.mnt:/mnt/docker 10e35aa8b9cc

 

docker centos 源

mysql 运行
docker pull docker.io/centos/systemd 
docker run -it --privileged=true -v /sys/fs/cgroup:/sys/fs/cgroup ~/loowj/docker.mnt/mysql:/mnt/docker/mysql -p 3306:3306 docker.io/centos/systemd /bin/bash

注:loowj/centos7-mysql:0.0.2  可以是官方纯净版

docker centos7安装mysql
wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
tar -zxvf mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
mkdir /usr/local/mysql
mv mysql-5.7.16-linux-glibc2.5-x86_64/* /usr/local/mysql/

rm -rf mysql-5.7.16-linux-glibc2.5-x86_64*

groupadd mysql
useradd -r -g mysql mysql -s /sbin/nologin
chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql /mnt/docker/mysql

yum install -y libaio
rm -rf /mnt/docker/mysql/datadir/*

/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql/ --datadir=/mnt/docker/mysql/datadir/

exit 退出镜像

 

dockerfile

镜像尺寸调优:

http://www.broadview.com.cn/article/12

yum clean all

展开阅读全文
打赏
0
1 收藏
分享
加载中
更多评论
打赏
0 评论
1 收藏
0
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部