# Set up a slave with copy of another slave

**URL:** <https://forums.percona.com/t/set-up-a-slave-with-copy-of-another-slave/3224>\
**Category:** Other MySQL® Questions\
**Created:** [January 24, 2014, 8:07am UTC](https://forums.percona.com/t/set-up-a-slave-with-copy-of-another-slave/3224 "2014-01-24T08:07:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DenisM](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@DenisM](https://forums.percona.com/u/DenisM)\
**Post date:** [January 24, 2014, 8:07am UTC](https://forums.percona.com/t/set-up-a-slave-with-copy-of-another-slave/3224/1 "2014-01-24T08:07:52Z")

</div>

Hi,  
I’ve got a master-slave pair, now I need to duplicate the slave.  
Is it possible to stop slave MySQL, copy all datadir files, and then simply run the new slave?

---

<div class="post-metadata">

**Author:** ![carshann](https://avatars.discourse-cdn.com/v4/letter/c/8e8cbc/32.png) [@carshann](https://forums.percona.com/u/carshann)\
**Post date:** [January 25, 2014, 3:12am UTC](https://forums.percona.com/t/set-up-a-slave-with-copy-of-another-slave/3224/2 "2014-01-25T03:12:36Z")

</div>

You can absolutely copy a slave, as a rule of thumb I’d usually lock the tables completely (or shut down the slave whilst copying the files) whilst copying the files though: [INDENT]STOP SLAVE;  
FLUSH TABLES WITH READ LOCK;

rsync newslave:\<new\_mysql\_datadir\>

UNLOCK TABLES;  
START SLAVE;[/INDENT]  
^^ should do it, make sure to keep the MySQL client window open whilst the tables are locked (usually easier to keep that session open in a screen session)

Note: If the servers are all MySQL/Percona 5.6 remember to remove/rename the auto.cnf file before starting up the new server. The auto.cnf file defines the servers UUID (a bit like server\_id used to be in /etc/my.cnf, but globally unique and it’s stored in the data\_directory now), and thus needs to be unique (auto-generated) for each and every slave. The Percona guys wrote about this recently, check ([URL=“[Beware of MySQL 5.6 server UUID when cloning slaves](http://www.mysqlperformanceblog.com/2014/01/21/beware-mysql-5-6-server-uuid-cloning-slaves/)”][http://www.mysqlperformanceblog.com/...loning-slaves/[/URL]](http://www.mysqlperformanceblog.com/...loning-slaves/%5B/URL%5D)) for more info.

---

<div class="post-metadata">

**Author:** ![DenisM](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@DenisM](https://forums.percona.com/u/DenisM)\
**Post date:** [January 27, 2014, 8:29am UTC](https://forums.percona.com/t/set-up-a-slave-with-copy-of-another-slave/3224/3 "2014-01-27T08:29:25Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![DenisM](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@DenisM](https://forums.percona.com/u/DenisM)\
**Post date:** [May 26, 2014, 9:44am UTC](https://forums.percona.com/t/set-up-a-slave-with-copy-of-another-slave/3224/4 "2014-05-26T09:44:57Z")

</div>

I’ve rsync’ed the datadir w/ MySQL stopped, but the copy failed to start:  
[HR][/HR]140526 18:43:35 mysqld\_safe Starting mysqld daemon with databases from /srv/mysql  
140526 18:43:35 [Note] Flashcache bypass: disabled  
140526 18:43:35 [Note] Flashcache setup error is : ioctl failed

140526 18:43:35 [Note] Plugin ‘FEDERATED’ is disabled.  
140526 18:43:35 InnoDB: The InnoDB memory heap is disabled  
140526 18:43:35 InnoDB: Mutexes and rw\_locks use GCC atomic builtins  
140526 18:43:35 InnoDB: Compressed tables use zlib 1.2.3  
140526 18:43:35 InnoDB: Using Linux native AIO  
140526 18:43:36 InnoDB: Initializing buffer pool, size = 40.0G  
140526 18:43:38 InnoDB: Completed initialization of buffer pool  
140526 18:43:38 InnoDB: highest supported file format is Barracuda.  
InnoDB: Error: tried to read 512 bytes at offset 0 512.  
InnoDB: Was only able to read 0.  
140526 18:43:38 InnoDB: Operating system error number 22 in a file operation.  
InnoDB: Error number 22 means ‘Invalid argument’.  
InnoDB: Some operating system error numbers are described at  
InnoDB: [url][http://dev.mysql.com/doc/refman/5.5/en/operating-system-error-codes.html[/url]](http://dev.mysql.com/doc/refman/5.5/en/operating-system-error-codes.html%5B/url%5D)  
InnoDB: File operation call: ‘read’.  
InnoDB: Cannot continue operation.  
140526 18:43:38 mysqld\_safe mysqld from pid file /srv/mysql/idb03.pid ended [HR][/HR]  
Then I deleted ib\_logfile{0|1} and got the following:  
[HR][/HR]140526 18:54:56 mysqld\_safe Starting mysqld daemon with databases from /srv/mysql  
140526 18:54:56 [Note] Flashcache bypass: disabled  
140526 18:54:56 [Note] Flashcache setup error is : ioctl failed

140526 18:54:56 [Note] Plugin ‘FEDERATED’ is disabled.  
140526 18:54:56 InnoDB: The InnoDB memory heap is disabled  
140526 18:54:56 InnoDB: Mutexes and rw\_locks use GCC atomic builtins  
140526 18:54:56 InnoDB: Compressed tables use zlib 1.2.3  
140526 18:54:56 InnoDB: Using Linux native AIO  
140526 18:54:56 InnoDB: Initializing buffer pool, size = 40.0G  
140526 18:54:58 InnoDB: Completed initialization of buffer pool  
140526 18:54:58 InnoDB: Log file /srv/mysql/ib\_logfile0 did not exist: new to be created  
InnoDB: Setting log file /srv/mysql/ib\_logfile0 size to 1900 MB  
InnoDB: Database physically writes the file full: wait…  
InnoDB: Progress in MB: 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900  
140526 18:55:00 InnoDB: Log file /srv/mysql/ib\_logfile1 did not exist: new to be created  
InnoDB: Setting log file /srv/mysql/ib\_logfile1 size to 1900 MB  
InnoDB: Database physically writes the file full: wait…  
InnoDB: Progress in MB: 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900  
140526 18:55:01 InnoDB: Error: Write to file /srv/mysql/ib\_logfile0 failed at offset 0 0.  
InnoDB: 512 bytes should have been written, only 0 were written.  
InnoDB: Operating system error number 22.  
InnoDB: Check that your OS and file system support files of this size.  
InnoDB: Check also that the disk is not full or a disk quota exceeded.  
InnoDB: Error number 22 means ‘Invalid argument’.  
InnoDB: Some operating system error numbers are described at  
InnoDB: [URL][http://dev.mysql.com/doc/refman/5.5/en/operating-system-error-codes.html[/URL]](http://dev.mysql.com/doc/refman/5.5/en/operating-system-error-codes.html%5B/URL%5D)  
140526 18:55:01 InnoDB: Assertion failure in thread 140044504708864 in file fil0fil.c line 5378  
InnoDB: Failing assertion: ret  
InnoDB: We intentionally generate a memory trap.  
InnoDB: Submit a detailed bug report to [http://bugs.mysql.com](http://bugs.mysql.com).  
InnoDB: If you get repeated assertion failures or crashes, even  
InnoDB: immediately after the mysqld startup, there may be  
InnoDB: corruption in the InnoDB tablespace. Please refer to  
InnoDB: [URL][http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html[/URL]](http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html%5B/URL%5D)  
InnoDB: about forcing recovery.  
140526 18:55:01 - mysqld got signal 6 ;  
This could be because you hit a bug. It is also possible that this binary  
or one of the libraries it was linked against is corrupt, improperly built,  
or misconfigured. This error can also be caused by malfunctioning hardware.  
We will try our best to scrape up some info that will hopefully help diagnose  
the problem, but since we have already crashed, something is definitely wrong  
and this may fail.

key\_buffer\_size=6442450944  
read\_buffer\_size=131072  
max\_used\_connections=0  
max\_threads=200  
thread\_count=0  
connection\_count=0  
It is possible that mysqld could use up to  
key\_buffer\_size + (read\_buffer\_size + sort\_buffer\_size)\*max\_threads = 6729048 K  
bytes of memory  
Hope that’s ok; if not, decrease some variables in the equation.

Thread pointer: 0x0  
Attempting backtrace. You can use the following information to find out  
where mysqld died. If you see no messages after this, something went  
terribly wrong…  
stack\_bottom = (nil) thread\_stack 0x31000  
/usr/sbin/mysqld(my\_print\_stacktrace+0x39)[0x7a0799]  
/usr/sbin/mysqld(handle\_segfault+0x464)[0x510224]  
/lib64/libpthread.so.0(+0xf710)[0x7f5ea6b27710]  
/lib64/libc.so.6(gsignal+0x35)[0x7f5ea5cee925]  
/lib64/libc.so.6(abort+0x175)[0x7f5ea5cf0105]  
/usr/sbin/mysqld[0x8cbc4b]  
/usr/sbin/mysqld[0x8fe6ed]  
/usr/sbin/mysqld[0x9009b9]  
/usr/sbin/mysqld[0x90137d]  
/usr/sbin/mysqld[0x90209f]  
/usr/sbin/mysqld[0x9040e8]  
/usr/sbin/mysqld[0x84dc5d]  
/usr/sbin/mysqld[0x810299]  
/usr/sbin/mysqld(\_Z24ha\_initialize\_handlertonP13st\_plugin\_int+0x48)[0x680218]  
/usr/sbin/mysqld[0x58feda]  
/usr/sbin/mysqld(\_Z11plugin\_initPiPPci+0xa1c)[0x5941dc]  
/usr/sbin/mysqld[0x51573b]  
/usr/sbin/mysqld(\_Z11mysqld\_mainiPPc+0x5bd)[0x51919d]  
/lib64/libc.so.6(\_\_libc\_start\_main+0xfd)[0x7f5ea5cdad1d]  
/usr/sbin/mysqld[0x50e7f1]  
The manual page at [URL][http://dev.mysql.com/doc/mysql/en/crashing.html[/URL]](http://dev.mysql.com/doc/mysql/en/crashing.html%5B/URL%5D) contains  
information that should help you find out what is causing the crash.  
140526 18:55:01 mysqld\_safe mysqld from pid file /srv/mysql/idb03.pid ended [HR][/HR]  
​What am I missing?

---

<div class="post-metadata">

**Author:** ![psong](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/psong/32/16894_2.png) [@psong](https://forums.percona.com/u/psong)\
**Post date:** [June 5, 2014, 2:19am UTC](https://forums.percona.com/t/set-up-a-slave-with-copy-of-another-slave/3224/5 "2014-06-05T02:19:40Z")

</div>

Hi there,

Are you running mysqld as “mysql” user? You can run “ps aux | grep mysqld” to verify.

Then check the file permission in your datadir, run “ls -l data\_dir”. Make sure files are owned by “mysql”.

Is the new slave of the same server version as the existing slave?

---

<div class="post-metadata">

**Author:** ![yogesh777](https://avatars.discourse-cdn.com/v4/letter/y/87869e/32.png) [@yogesh777](https://forums.percona.com/u/yogesh777)\
**Post date:** [June 12, 2014, 12:58am UTC](https://forums.percona.com/t/set-up-a-slave-with-copy-of-another-slave/3224/6 "2014-06-12T00:58:54Z")

</div>

also verify configuration file my.cnf values on new slave should be same specially innodb\_log\_file\_size
