0

When I run Percona XtraDB Cluster with external data directory (I try to restore from backup made with Percona XtraBackup), I have error:

--initialize specified but the data directory has files in it. Aborting.

How can I fix it?

Docker command:

docker run --name xtradb_from_backup -p 3307:3306 \
-e MYSQL_ROOT_PASSWORD=1 -e XTRABACKUP_PASSWORD=2 \
-e CLUSTER_NAME=xtradb -d -v ~/mysql/:/etc/mysql/conf.d \
-v /db:/var/lib/mysql percona/percona-xtradb-cluster:5.7.16 \
--pxc_strict_mode=PERMISSIVE;

Also I have tried omit MYSQL_ROOT_PASSWORD according to documentation:

docker run --name xtradb_from_backup -p 3307:3306 \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes -e XTRABACKUP_PASSWORD=2 \
-e CLUSTER_NAME=xtradb -d -v ~/mysql/:/etc/mysql/conf.d \
-v /db:/var/lib/mysql percona/percona-xtradb-cluster:5.7.16 \
--pxc_strict_mode=PERMISSIVE;

Error log:

Running --initialize-insecure on /var/lib/mysql/
total 345M
drwxrwxr-x  7 1001 root 4.0K Apr 13 14:53 .
drwxr-xr-x 19 root root 4.0K Dec 15 21:40 ..
-rw-r-----  1 1001 root   56 Apr 13 09:28 auto.cnf
...
-rw-r-----  1 1001 root 3.8M Apr 13 14:27 xb_doublewrite
-rw-r--r--  1 1001 root   23 Apr 13 09:14 xtrabackup_binlog_info
-rw-r--r--  1 1001 root   23 Apr 13 10:23 xtrabackup_binlog_pos_innodb
-rw-rw----  1 1001 root  123 Apr 13 10:23 xtrabackup_checkpoints
-rw-r--r--  1 1001 root   46 Apr 13 09:14 xtrabackup_galera_info
-rw-rw----  1 1001 root  549 Apr 11 00:34 xtrabackup_info
-rw-rw----  1 1001 root 158M Apr 13 09:14 xtrabackup_logfile
2017-04-13T14:53:02.875351Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2017-04-13T14:53:02.875413Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2017-04-13T14:53:02.875473Z 0 [Warning] WSREP: Node is running in bootstrap/initialize mode. Disabling pxc_strict_mode checks
2017-04-13T14:53:02.877589Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2017-04-13T14:53:02.877618Z 0 [ERROR] Aborting
Roman Cherepanov
  • 1,639
  • 2
  • 24
  • 44
  • Just create the container with an empty dir and restore the files later (not replacing the files, but using a dump made with mysqldump, for example). I don't think just using a data dir of other mysql/percona server will work... – Salem Apr 13 '17 at 19:54
  • @Salem but it works with [Percona Server](https://hub.docker.com/r/percona/percona-server/) so I thought that with Percona XtraDB Cluster it will work too. – Roman Cherepanov Apr 13 '17 at 20:01
  • See https://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysqld.html . Again I think the easiest way is to just restore the backup after the container creation. You can try to replace the files after, but make sure the users match. Apart from that, I think the only way is to modify the image itself... – Salem Apr 13 '17 at 20:05
  • From the link you provided, it says to not use `$MYSQL_ROOT_PASSWORD` if the data exists. Have you tried to omit this env var and/or the xtradb one? – Salem Apr 13 '17 at 20:07
  • @Salem yes, I have tried to omit `MYSQL_ROOT_PASSWORD` with no effect. – Roman Cherepanov Apr 15 '17 at 17:29

0 Answers0