Tokyo tyrant (ttserver) series-Backup Recovery and addition of slave Database

Source: Internet
Author: User

Tokyo tyrant (ttserver) series-Backup Recovery and addition of slave Database

[ ArticleAuthor:Sun Li
Link: Http://www.cnblogs.com/sunli/ Update Time: 2009-08-25]

Part 1: Tokyo tyrant (ttserver) series-high availability and high reliability + nginx

As we mentioned earlierThe use of ttserver and how to configure Master/Slave at the beginning. It is very efficient and reliable in use, so if our service runs for a period of time, we need to add a slave database (ttserver) to share the pressure or for load balancing and HA, because it is an online system, there should be no downtime. How should we back up and copy data and start a slave database?

1. How to back up and restore

Log on to the ttserver and run the following command:

] #Tcrmgr copy-port 11211 localhost/data/backup. Tch

Localhost: ttserver Host Name

/Data/backup. Tch indicates the path where the backup file is saved. Note that this refers to the path of the machine where the ttserver is located.

You can also back up remote machines,

 ] #Tcrmgr copy-port 11211 remotehost/data/backup. Tch

    The backup file will be stored in/data/backup. Tch of remotehost.

    Next, it is relatively simple to restore the data. simply replace the data file of the original ttserver and start it.

    This method is suitable for regular data backup and can be recovered to a certain time point in the event of a disaster failure. It is not suitable for adding database files required when the slave database is used.

    2. How to add slave databases without stopping services

    If the slave database needs to be synchronized, a time version of the file is required to prevent data conflicts.

    First, create a script file named "backup. Sh" and grant the execution permission (chmod 755 backup. Sh ). For example:

    /Data/backup/path.

    # ! /Bin/sh
    Srcpath = " $1 "
    Destpath = " $1. $2 "
    Rm -F   " $ Destpath "
    CP -F   " $ Srcpath "   " $ Destpath "

    Next, run the following command. The execution time depends on your disk performance and data size.

    Tcrmgr copy - Port 11211 Masterhost' @/ Data / Backup / Backup. Sh'

    materthost: Master Database Host Name. Note: Backup. SH is stored in materthost machine.

    '@/Data/Backup/Backup. Sh': IfIn the tcrmgr COPY Command, the parameter starts with @, and the subsequent string is executed as the command line.

     

    After the execution is complete, go to the ttserver data directory and execute LS-lH to find a file name similar to the following,

    - RW - R -- R -- 1 Root 9 . 2g Aug 25   14 : 31 Casket. Tch. 1251181588942889

    Make sure to generate casket. Tch.XXXXXSimilar file name, XXXXX represents the timestamp.

    Next, run ttserver with the backup file on the database salve, and mistakenly write the time into a timestamp file.Ttserver. Rts.

     

    ] $ Ls
    ] $ CP casket. Tch. XXXXX casket. Tch
    ] $ Echo XXXXX > Ttserver. Rts
    ] $ Mkdir ulog
    ] $ Ttserver-mhost masterhost-mport - Port 11211 - Ulog - Sid 2   - RTS ttserver. Rts casket. Tch

    After running, ttserver synchronizes data with this timestamp.

    Masterhost: Master Database Host Name

    Mport: Master database port number

    Now we have added a salve slave database ttserver.

    3. Summary

    We recommend that you use the method used in 2 for backup. The timestamp is included above to precisely know the data version time.

    In addition, please note: when using this method for backup, ttserver will keep synchronization blocking and no data modification during the backup process. Therefore, the version backed up is consistent with the timestamp.

     


      Contact Us

      The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

      If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

      A Free Trial That Lets You Build Big!

      Start building with 50+ products and up to 12 months usage for Elastic Compute Service

      • Sales Support

        1 on 1 presale consultation

      • After-Sales Support

        24/7 Technical Support 6 Free Tickets per Quarter Faster Response

      • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.