• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Generate Unique IDs For MySQL Cluster Backups

by admin

Each online MySQL Cluster backup receives a unique identification number. This is to ensure that there is a history of activities in the backup directory. However, this can causes problems. For example, if a system restarts, this ID counter is reset and starts again at number 1, causing problems if you didn’t move earlier backups. This post will discuss how to generate unique backup ids.

The best method is after each online backup operation to move the created backup directory to another location (e.g. a file server). This will ensure that there can never be a problem with duplicate backup IDs on the data nodes themselves. Additionally, you can generate your own backup IDs and pass them to the START BACKUP statement using the ndb_mgm client tool. As of MySQL Cluster versions 6.2.17, 6.3.23, and 7.0.3, this ID has an upper limit of 4294967296 (232). Earlier versions only support a maximum of 2147483648 (231).

One example of how to generate your own backup ID is to use Unix or POSIX time. The advantage of this is that it is already a 32-bit number and each time you run START BACKUP it will be the current time, which is unique unless you tamper with the system clock. You would enter something like the following from the command-line:

$ TS=$(date +%s) && ndb_mgm -e "START BACKUP ${TS}"
Connected to Management Server at: localhost:1186
Waiting for completed, this may take several minutes
Node 1: Backup 1455575258 started from node 49
Node 1: Backup 1455575258 started from node 49 completed
 StartGCP: 2596 StopGCP: 2599
 #Records: 7378 #LogRecords: 0
 Data: 501128 bytes Log: 0 bytes

Another example would be to use the actual date and hour a backup is made. The advantage of this is that it’s easier to read and one can see directly from which day the backup was made. The following example, however, will only work once per hour—it’s entered from the command-line, as well:

$ TS=$(date +%Y%m%d%H) && ndb_mgm -e "START BACKUP ${TS}"
Connected to Management Server at: localhost:1186
Waiting for completed, this may take several minutes
Node 1: Backup 2016021609 started from node 49
Node 1: Backup 2016021609 started from node 49 completed
 StartGCP: 2665 StopGCP: 2668
 #Records: 7378 #LogRecords: 0
 Data: 501128 bytes Log: 0 bytes

There are many possible ways to generate backup IDs and not be restricted to timestamps. You could generate a counter which is stored in a central database running on your backup server. How you generate an ID is up to you.

Filed Under: mysql, MySQL Cluster

Some more articles you might also be interested in …

  1. How to Configure Multiple MySQL Servers On One System Using mysqld_multi
  2. Which Ports are Used by mysqld, ndb_mgmd, and ndbd/ndbmtd in a MySQL Cluster Installation
  3. How to use a Wrapper Script to set Custom Per-Process Attributes for MySQL Server
  4. How to Disable Client Access Control in MySQL
  5. How to take Logical Backups on a MySQL Replication Slave using shell script
  6. mysqldump – How to Restore a Specific Database From a Backup of All Databases
  7. What is the purpose of “system user” in MySQL Replication
  8. How to Add Data Nodes to MySQL Cluster without Restarting the Cluster (version 6.4 and later)
  9. How to Use External Python modules in MySQL Shell
  10. How To Start And Stop MySQL Cluster

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright