docker安装MySQL8.0及初始化错误处理
Preface
Several days ago,I've implement a docker environmnet,I'm gonna Install a MySQL 8.0 version on it.Let's see the detail of it.
Procedure
Check and run docker container again.
1 [root@docker vagrant]# docker images
2 REPOSITORY TAG IMAGE ID CREATED SIZE
3 centos7 latest 7d0b68af5a06 10 days ago 694MB
4 [root@docker vagrant]# docker run -d -v /vagrant/mysql_soft:/opt/mysql -v /vagrant/data1:/data -v /etc/hosts:/etc/hosts -p2222:22 --cap-add=NET_ADMIN --name c1 -h docker centos7
mysql下载后的初次使用5 fbf17e3f6aa8324b8d494aa0211122f5d735bf6f648a99b6632ae2be5be996da
6 [root@docker vagrant]# docker ps -a
7 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8 fbf17e3f6aa8 centos7 "/usr/bin/supervisor…"5 seconds ago Up 3 seconds (healthy) 0.0.0.0:2222->22/tcp c1
9 103f318448c9 centos7 "/usr/bin/supervisor…"25 minutes ago Exited (0) 3 minutes ago node1
10 [root@docker vagrant]# docker rm container 103f318448c9
11 103f318448c9
12 Error: No such container: container
13 [root@docker vagrant]# docker ps
14 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
15 fbf17e3f6aa8 centos7 "/usr/bin/supervisor…"32 seconds ago Up 30 seconds (healthy) 0.0.0.0:2222->22/tcp c1
16 [root@docker vagrant]# ssh root@172.17.0.2
17 root@172.17.0.2's password:
18 Last login: Wed Jun 1300:18:112018 from 172.17.0.1
19 [root@docker ~]# df -h
20 Filesystem Size Used Avail Use% Mounted on
21 /dev/mapper/docker-253:0-16777839-60de86a769f75e2e96c849e76f1b3de10ac8c8d9985597ff3f758070edada54d 10G 682M 9.4G 7% /
22 tmpfs 64M 0 64M 0% /dev
23 tmpfs 497M 0 497M 0% /sys/fs/cgroup
24 none 612G 242G 370G 40% /data
25 /dev/mapper/centos-root 8.4G 2.1G 6.3G 26% /etc/hosts
26 shm 64M 0 64M 0% /dev/shm
27 tmpfs 497M 0 497M 0% /proc/scsi
28 tmpfs 497M 0 497M 0% /sys/firmware
Download and extract MySQL software.
1 [root@docker ~]# cd /vagrant/mysql_soft
2 [root@docker mysql_soft]# wget sql/get/Downloads/MySQL-8.0/mysql-8.0.11-linux-glibc2.12-x86_
3 [root@docker mysql_soft]# cd /opt/mysql
4 [root@docker mysql]# ls -l
5 total 1215644
6 -rwxrwxrwx 110001000641798603 Mar 1821:32 mysql-5.7.21-linux-glibc2.12-x86_
7 -rwxrwxrwx 110001000603019898 Jun 1900:42 mysql-8.0.11-linux-glibc2.12-x86_
8 [root@docker mysql]# tar -zxf mysql-8.0.11-linux-glibc2.12-x86_
9tar: mysql-8.0.11-linux-glibc2.12-x86_64/lib/libcrypto.so: Cannot create symlink to `libcrypto.so.1.0.0': Protocol error
10tar: mysql-8.0.11-linux-glibc2.12-x86_64/lib/libmysqlclient.so: Cannot create symlink to `libmysqlclient.so.21': Protocol error
11tar: mysql-8.0.11-linux-glibc2.12-x86_64/lib/libmysqlclient.so.21: Cannot create symlink to `libmysqlclient.so.21.0.11': Protocol error
12tar: mysql-8.0.11-linux-glibc2.12-x86_64/lib/libssl.so: Cannot create symlink to `libssl.so.1.0.0': Protocol error
13tar: mysql-8.0.11-linux-glibc2.12-x86_64/lib/plugin/libssl.so.1.0.0: Cannot create symlink to `../../lib/libssl.so.1.0.0': Protocol error
14tar: mysql-8.0.11-linux-glibc2.12-x86_64/lib/plugin/libcrypto.so.1.0.0: Cannot create symlink to `../../lib/libcrypto.so.1.0.0': Protocol error
15tar: mysql-8.0.11-linux-glibc2.12-x86_64/lib/plugin/debug/libssl.so.1.0.0: Cannot create symlink to `../../../lib/libssl.so.1.0.0': Protocol error
16tar: mysql-8.0.11-linux-glibc2.12-x86_64/lib/plugin/debug/libcrypto.so.1.0.0: Cannot create symlink to `../../../lib/libcrypto.so.1.0.0': Protocol error
17tar: mysql-8.0.11-linux-glibc2.12-x86_64/bin/libssl.so.1.0.0: Cannot create symlink to `../lib/libssl.so.1.0.0': Protocol error
18tar: mysql-8.0.11-linux-glibc2.12-x86_64/bin/libcrypto.so.1.0.0: Cannot create symlink to `../lib/libcrypto.so.1.0.0': Protocol error
19tar: Exiting with failure status due to previous errors
Check absent "libxxx.so" then install them untill there're no "not found" results.
1 [root@docker mysql]# ldd /usr/local/mysql/bin/mysqld.sh
2 ldd: /usr/local/mysql/bin/mysqld.sh: No such file or directory
3 [root@docker mysql]# ldd /usr/local/mysql/bin/mysqld
4 linux-vdso.so.1 => (0x00007fff57cca000)
5 libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f57bc85d000)
6 libaio.so.1 => not found
7 libnuma.so.1 => not found
8 libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f57bc625000)
9 libssl.so.1.0.0 => not found
10 libcrypto.so.1.0.0 => not found
11 libdl.so.2 => /lib64/libdl.so.2 (0x00007f57bc420000)
12 librt.so.1 => /lib64/librt.so.1 (0x00007f57bc217000)
13 libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f57bbf10000)
14 libm.so.6 => /lib64/libm.so.6 (0x00007f57bbc0e000)
15 libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f57bb9f7000)
16 libc.so.6 => /lib64/libc.so.6 (0x00007f57bb62a000)
17 /lib64/ld-linux-x86-64.so.2 (0x00007f57bca7f000)
18 libfreebl3.so => /lib64/libfreebl3.so (0x00007f57bb427000)
19 [root@docker mysql]# yum install -y libaio numactl libssl libcrypto
20 -- Omitted
21 [root@docker mysql]# ldd /usr/local/mysql/bin/mysqld
22 linux-vdso.so.1 => (0x00007fff05f82000)
23 libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc18aca3000)
24 libaio.so.1 => /lib64/libaio.so.1 (0x00007fc18aaa0000)
25 libnuma.so.1 => /lib64/libnuma.so.1 (0x00007fc18a894000)
26 libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007fc18a65d000)
27 libssl.so.1.0.0 => not found
28 libcrypto.so.1.0.0 => not found
29 libdl.so.2 => /lib64/libdl.so.2 (0x00007fc18a458000)
30 librt.so.1 => /lib64/librt.so.1 (0x00007fc18a24f000)
31 libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fc189f48000)
32 libm.so.6 => /lib64/libm.so.6 (0x00007fc189c46000)
33 libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fc189a2f000)
34 libc.so.6 => /lib64/libc.so.6 (0x00007fc189662000)
35 /lib64/ld-linux-x86-64.so.2 (0x00007fc18aec5000)
36 libfreebl3.so => /lib64/libfreebl3.so (0x00007fc18945f000)
37 [root@docker mysql]# find / -name libssl.so.1.0.0
38 /opt/mysql/mysql-8.0.11-linux-glibc2.12-x86_64/lib/libssl.so.1.0.0
39 [root@docker mysql]# cp /opt/mysql/mysql-8.0.11-linux-glibc2.12-x86_64/lib/libssl.so.1.0.0 /usr/lib64
40 [root@docker mysql]# find / -name libcrypto.so.1.0.0
41 /opt/mysql/mysql-8.0.11-linux-glibc2.12-x86_64/lib/libcrypto.so.1.0.0
42 [root@docker mysql]# cp /opt/mysql/mysql-8.0.11-linux-glibc2.12-x86_64/lib/libcrypto.so.1.0.0 /usr/lib64
43 [root@docker mysql]# ldd /usr/local/mysql/bin/mysqld
44 linux-vdso.so.1 => (0x00007fff13ffe000)
45 libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f156dbc3000)
46 libaio.so.1 => /lib64/libaio.so.1 (0x00007f156d9c0000)
47 libnuma.so.1 => /lib64/libnuma.so.1 (0x00007f156d7b4000)
48 libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f156d57d000)
49 libssl.so.1.0.0 => /lib64/libssl.so.1.0.0 (0x00007f156d30d000)
50 libcrypto.so.1.0.0 => /lib64/libcrypto.so.1.0.0 (0x00007f156cf25000)
51 libdl.so.2 => /lib64/libdl.so.2 (0x00007f156cd21000)
52 librt.so.1 => /lib64/librt.so.1 (0x00007f156cb18000)
53 libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f156c811000)
54 libm.so.6 => /lib64/libm.so.6 (0x00007f156c50f000)
55 libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f156c2f8000)
56 libc.so.6 => /lib64/libc.so.6 (0x00007f156bf2b000)
57 /lib64/ld-linux-x86-64.so.2 (0x00007f156dde5000)
58 libfreebl3.so => /lib64/libfreebl3.so (0x00007f156bd28000)
Make required directory and create soft link.
1 [root@docker mysql]# mkdir -p /data/mysql/mysql3306/{data,logs,tmp}
2 [root@docker mysql]# ln -sv /opt/mysql/mysql-8.0.11-linux-glibc2.12-x86_64 /usr/local/mysql
3 ‘/usr/local/mysql’ -> ‘/opt/mysql/mysql-8.0.11-linux-glibc2.12-x86_64’
Create mysql group & user.
1 [root@docker mysql]# userdel mysql
2 [root@docker mysql]# groupadd mysql
3 [root@docker mysql]# useradd -g mysql -s /sbin/nologin -d /usr/local/mysql -MN mysql
Modify directory privilege.
1 [root@docker mysql]# cd /usr/local
2 [root@docker local]# chown -sql mysql
Modify environment variable.
1 [root@docker local]# echo"export PATH=$PATH:/usr/local/mysql/bin" >> ~/.bash_profile
2 [root@docker local]# source ~/.bash_profile
3 [root@docker local]# echo $PATH
4 /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin
Prepare a suitable myf in docker and then copy it to specific path.
1 [root@docker local]# cp /opt/mysql/myf /data/mysql/mysql3306/my3306f
Initialize MySQL db.
[root@docker local]# mysqld --defaults-file=/data/mysql/mysql3306/my3306f --initialize
mysqld: [Warning] World-writable config file'/data/mysql/mysql3306/my3306f' is ignored.
2018-06-23T16:26:39.446641Z 0 [System] [MY-013169] [Server] mysqld (mysqld 8.0.11) initializing of server in progress as process 20451
2018-06-23T16:26:39.528638Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file '/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2018-06-23T16:26:39.804315Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2018-06-23T16:26:39.804363Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-06-23T16:26:40.010408Z 0 [System] [MY-010910] [Server] mysqld: Shutdown complete (mysqld 8.0.11) MySQL Community Server - GPL.
[root@docker ~]# cd /data/mysql/mysql3306/data -- There're no files in the directory,why does it show the existent error?Let's see below.
[root@docker data]# ls -la
total 4
drwxrwxrwx 1 mysql mysql 0 Jun 1903:24 .
drwxrwxrwx 1 mysql mysql 4096 Jun 2400:38 ..
I change the way of initialization.
1 [root@docker data]# mysqld --basedir=/usr/local/mysql --datadir=/data/mysql/mysql3306/data --user=mysql --initialize
22018-06-23T17:04:01.792594Z 0 [System] [MY-013169] [Server] mysqld (mysqld 8.0.11) initializing of server in progress as process 12261
32018-06-23T17:04:01.887954Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /data/mysql/mysql3306/data/ is case insensitive
4 mbind: Operation not permitted
52018-06-23T17:04:12.669761Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: o/>k*hqxn1T=
62018-06-23T17:04:16.807974Z 0 [System] [MY-013170] [Server] mysqld (mysqld 8.0.11) initializing of server has completed
7 [root@docker etc]# ps aux | grep mysqld
8 root 137120.00.010692976 pts/1 SN+ 01:060:00grep --color=auto mysqld
Start mysqld but failed.
1 [root@docker etc]# mysqld --defaults-file=/data/mysql/mysql3306/my3306f &
2 [1] 14145
3 [root@docker etc]# mysqld: [Warning] World-writable config file'/data/mysql/mysql3306/my3306f' is ignored.
42018-06-23T17:06:54.345108Z 0 [System] [MY-010116] [Server] mysqld (mysqld 8.0.11) starting as process 14145
52018-06-23T17:06:54.346090Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file '/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
62018-06-23T17:06:54.357718Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /data/ is case insensitive
72018-06-23T17:06:54.358228Z 0 [ERROR] [MY-010123] [Server] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
82018-06-23T17:06:54.358263Z 0 [ERROR] [MY-010119] [Server] Aborting
92018-06-23T17:06:54.362713Z 0 [System] [MY-010910] [Server] mysqld: Shutdown complete (mysqld 8.0.11) MySQL Community Server - GPL.
10 ^C
11 [1]+ Exit 1 mysqld --defaults-file=/data/mysql/mysql3306/my3306f
The my3306f cannot be world-writable,so I copy it to "/tmp" and start mysqld again.
1 [root@docker etc]# cp /data/mysql/mysql3306/my3306f /tmp
2 [root@docker etc]# cd /tmp
3 [root@docker tmp]# ls -l | grep my3306f
4 -rwxr-xr-x 1 root root 9672 Jun 2401:10 my3306f
5 [root@docker tmp]# mysqld --defaults-file=/tmp/my3306f &
6 [1] 16816
7 [root@docker tmp]# ps aux | grep mysqld
8 root 169260.00.010692976 pts/1 SN+ 01:110:00grep --color=auto mysqld
9 [1]+ Exit 1 mysqld --defaults-file=/tmp/my3306f
10 [root@docker etc]# tail /data/mysql/mysql3306/data/error.log
112018-06-24T01:11:03.732865+08:000 [Warning] [MY-010086] [Server] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 122018-06-24T01:11:03.735145+08:000 [Warning] [MY-010097] [Server] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
132018-06-24T01:11:03.736465+08:000 [System] [MY-010116] [Server] mysqld (mysqld 8.0.11) starting as process 16816
14 mbind: Operation not permitted
152018-06-24T01:11:04.184074+08:001 [ERROR] [MY-012263] [InnoDB] InnoDB: The Auto-extending innodb_system data file'./ibdata1' is of a different size 768 pages (rounded down to MB) than specified in the f file: initial 6400 162018-06-24T01:11:04.184868+08:001 [ERROR] [MY-012930] [InnoDB] InnoDB: Plugin initialization aborted with error Generic error.
172018-06-24T01:11:04.810086+08:001 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
182018-06-24T01:11:04.810840+08:000 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
192018-06-24T01:11:04.810961+08:000 [ERROR] [MY-010119] [Server] Aborting
202018-06-24T01:11:04.828841+08:000 [System] [MY-010910] [Server] mysqld: Shutdown complete (mysqld 8.0.11) MySQL Community Server - GPL.
It still has problem 'cause size of "./ibdata1" is incompatible with the parameter in "my3306f".
1 [root@docker data]# ls -l ibdata1
2 -rwxrwxrwx 1 mysql mysql 12582912 Jun 2401:04 ibdata1
3 [root@docker data]# cat /tmp/my3306f | grep innodb_data_file_path
4 innodb_data_file_path =ibdata1:100M:autoextend # ibdata1:12M:autoextend
5 [root@docker data]# vim /tmp/my3306f | grep innodb_data_file_path
6 [root@docker data]# cat /tmp/my3306f | grep innodb_data_file_path
7 innodb_data_file_path =ibdata1:12M:autoextend # ibdata1:12M:autoextend
After I started mysqld several seconds later,the process down again at once.
1 [root@docker etc]# mysqld --defaults-file=/tmp/my3306f &
2 [1] 4761
3 [root@docker etc]# ps aux|grep mysqld
4 mysql 476138.03.147490832152 pts/1 SNl 01:420:01 mysqld --defaults-file=/tmp/my3306f
5 root 48080.00.010692972 pts/1 SN+ 01:420:00grep --color=auto mysqld
6 [root@docker etc]# ps aux|grep mysqld
7 root 69640.00.010692972 pts/1 SN+ 01:450:00grep --color=auto mysqld
8 [root@docker etc]#
9 [root@docker data]# tail -10 error.log
102018-06-24T01:42:30.177384+08:000 [Warning] [MY-010097] [Server] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path. 112018-06-24T01:42:30.179005+08:000 [System] [MY-010116] [Server] mysqld (mysqld 8.0.11) starting as process 4761
12 mbind: Operation not permitted
13100
14100
15100
162018-06-24T01:42:33.215591+08:001 [ERROR] [MY-011087] [Server] Different lower_case_table_names settings for server ('1') and data dictionary ('2').
172018-06-24T01:42:33.216211+08:000 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
182018-06-24T01:42:33.216289+08:000 [ERROR] [MY-010119] [Server] Aborting
192018-06-24T01:42:34.839683+08:000 [System] [MY-010910] [Server] mysqld: Shutdown complete (mysqld 8.0.11) MySQL Community Server - GPL.
The error shows that the value is not equal between "lower_case_table_names" and dictionary.
1 [root@docker data]# cat /opt/mysql/myf|grep lower_case_table_names
2 lower_case_table_names =1 # 0
3 [root@docker data]# cat /tmp/my3306f | grep lower_case_table_names
4 lower_case_table_names =1 # 0
5 [root@docker data]# vim /tmp/my3306f
6 [root@docker data]# cat /tmp/my3306f | grep lower_case_table_names
7 lower_case_table_names =2 # 0
After I've modified my3306f,it seems no error occurs now.
1 [root@docker data]# tail -10 error.log
22018-06-24T01:53:20.035831+08:000 [Warning] [MY-010315] [Server] 'user' entry 'mysql.infoschema@localhost' ignored in --skip-name-resolve mode.
32018-06-24T01:53:20.035971+08:000 [Warning] [MY-010315] [Server] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
42018-06-24T01:53:20.036064+08:000 [Warning] [MY-010315] [Server] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
52018-06-24T01:53:20.036160+08:000 [Warning] [MY-010315] [Server] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
62018-06-24T01:53:20.036898+08:000 [Warning] [MY-010323] [Server] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
72018-06-24T01:53:20.037083+08:000 [Warning] [MY-010323] [Server] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
82018-06-24T01:53:20.037268+08:000 [Warning] [MY-010311] [Server] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
92018-06-24T01:53:20.042517+08:000 [Warning] [MY-010330] [Server] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
102018-06-24T01:53:20.042646+08:000 [Warning] [MY-010330] [Server] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
112018-06-24T01:53:20.099046+08:000 [System] [MY-010931] [Server] mysqld: ready for connections. Version: '8.0.11' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server - GPL.
12 [root@docker etc]# ps aux|grep mysqld
13 mysql 118122.09.3114868895244 pts/1 SNl 01:530:01 mysqld --defaults-file=/tmp/my3306f
14 root 125140.00.010692972 pts/1 SN+ 01:540:00grep --color=auto mysqld
Start mysql client and modify the password generated by initialization.
1 [root@docker etc]# mysql
2 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
3 [root@docker etc]# mysql -p
4 Enter password: -- Use the password which generated by initialization(here is "o/>k*hqxn1T=")
5 Welcome to the MySQL monitor. Commands end with ; or \g.
6 Your MySQL connection id is 9
7 Server version: 8.0.11
8
9 Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
10
11 Oracle is a registered trademark of Oracle Corporation and/or its
12 affiliates. Other names may be trademarks of their respective
13 owners.
14
15 Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
16
17 mysql> show databases;
18 ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
19 mysql> alter user root@localhost identified by 'Passw0rd';
20 Query OK, 0 rows affected (0.11 sec)
21
22 mysql> show databases;
23 +--------------------+
24 | Database |
25 +--------------------+
26 | information_schema |
27 | mysql |
28 | performance_schema |
29 | sys |
30 +--------------------+
314 rows in set (0.20 sec)
32
33 mysql>
Summary
ldd can be used to check if mysqld is missing "libxxx.so" file.Then you can install or copy directly into "/usr/lib64" directory.
There're many errors in my installation procedure due to inappropriate parameters.
Because of the vagrant,all the shared directories in docker contains also has the 777 privilege what cause the world-writable issue.
Since MySQL 5.7,password of root@localhost must be changed while first login.Otherwise,you can do nothing at all.
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论