mysql镜像制作实验

本文为制作镜像的学习实验,错误之处欢迎留言。

准备基础镜像

docker pull openshift/base-centos7

启动镜像后,在容器中安装软件

yum install mariadb -y

yum install mariadb-server -y

启动mysql出现问题:

bash-4.2# mysqld_safe
181128 10:23:32 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
181128 10:23:32 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

bash-4.2# vi /var/log/mariadb/mariadb.log 

181128 10:23:32 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
181128 10:23:32 [Note] /usr/libexec/mysqld (mysqld 5.5.60-MariaDB) starting as process 230 ...
181128 10:23:32 InnoDB: The InnoDB memory heap is disabled
181128 10:23:32 InnoDB: Mutexes and rw_locks use GCC atomic builtins
181128 10:23:32 InnoDB: Compressed tables use zlib 1.2.7
181128 10:23:32 InnoDB: Using Linux native AIO
181128 10:23:33 InnoDB: Initializing buffer pool, size = 128.0M
181128 10:23:33 InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
181128 10:23:33  InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
181128 10:23:33  InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
181128 10:23:33  InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: 127 rollback segment(s) active.
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
181128 10:23:33  InnoDB: Waiting for the background threads to start
181128 10:23:34 Percona XtraDB (http://www.percona.com) 5.5.59-MariaDB-38.11 started; log sequence number 0
181128 10:23:34 [Note] Plugin 'FEEDBACK' is disabled.
181128 10:23:34 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
181128 10:23:34 [Note] Server socket created on IP: '0.0.0.0'.
181128 10:23:34 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
181128 10:23:34 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended

 mysql_install_db --user=mysql

mysql_install_db 会初始化数据目录,并创建它所包含系统表(如果系统表不存在),它还初始化管理表所需的系统表空间和相关的数据结构,详细介绍如下链接:

https://dev.mysql.com/doc/refman/5.6/en/mysql-install-db.html

启动数据库:mysqld_safe

登录:

bash-4.2# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

至此验证了mysql在容器中安装过程,现在编写dockerfile文件:

FROM openshift/base-centos7:latest
RUN yum install mariadb -y && yum install mariadb-server -y && mysql_install_db --user=mysql
#Auto running  service
CMD ["mysqld_safe"]

docker build -t mysql-test:v1 .

即可生成mysql-test镜像,验证mysql启动正常。

参考链接:

https://blog.csdn.net/superchanon/article/details/8546254/

http://blog.too2.net/?p=308

http://doc.okbase.net/ivictor/archive/179538.html

https://my.oschina.net/nyp/blog/735622

https://docs.docker.com/develop/develop-images/dockerfile_best-practices/

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值