How can I slow down a MySQL dump as to not affect current load on the server?

前端 未结 6 1432
野性不改
野性不改 2020-11-30 18:11

While doing a MySQL dump is easy enough, I have a live dedicated MySQL server that I am wanting to setup replication on. To do this, I need dumps of the databases to import

6条回答
  •  长情又很酷
    2020-11-30 18:44

    Besides the already mentioned solution of using --single-transaction and --quick , I would not directly pipe the result in gzip but first dump it as a .sql file, and then gzip it. (Use && instead of | )

    The dump itself will be faster so lower downtime. (for what I tested it was double as fast)

    So I would go for "&& gzip" instead of "| gzip"

    Important: check for free disk space first with df -h! since you will need more then piping | gzip.

    mysqldump --single-transaction --quick -u user -p my_db_name > dump_name.sql && gzip dump_name.sql
    

    -> which will also result in 1 file called dump_name.sql.gz

提交回复
热议问题