Back up MySQL databases in a Linux heterogeneous network

Source: Internet
Author: User

The following articles mainly describe how to correctly back up MySQL databases in a Linux heterogeneous network (Figure). They are mainly divided into local backup and data backup to a DVD disk, the following describes the specific content of the article, hoping to help you in this regard.

I am the administrator of a small and medium-sized Linux website. The system architecture is RHEL 4.0 + PHP 4.3 + MySQL (the best combination with PHP) 4.03 + apache (the most popular WEB server platform on Unix) 1.23. The average daily IP Access volume is 200, a typical small Linux website. Because it is a small website, there is no cost to use a tape drive for system backup, using a DVD Disc recorder + network hard disk.

As Linux is widely used, especially in network applications, a large number of network servers use Linux operating systems. Because there are still some differences between Linux desktop applications and Windows, in enterprise applications, Linux and Windows operating systems often coexist to form a heterogeneous network. Most servers use Linux and Unix, while Windows 9X/2000/XP is used on PC. Next we will talk about backing up MySQL on a Linux heterogeneous network (the best combination with PHP ).

I. local backup

A common backup method for MySQL databases is to use the utility MySQL (the best combination with PHP) dump. The command format is as follows:

# MySQL (the best combination with PHP) dump [options] database [tables]

The parameter description is as follows:

Options: represents the dump option of MySQL (the best combination with PHP), which can be found through MySQL (the best combination with PHP) dump-help.

Database: indicates the database to be backed up.

Tables: indicates the table to be backed up. If no table is specified, the entire database is backed up.

Using MySQL (the best combination with PHP) dump for backup is very simple. To back up MySQL Database "phpbb_db_backup", run the following command:

# MySQL (the best combination with PHP) dump-u-p phpbb_db_backup>/usr/backups/MySQL (the best combination with PHP)/phpbb_db_backup.2005.5.6

You can also use the gzip command to compress the backup file:

# MySQL (the best combination with PHP) dump phpbb_db_backup | gzip>/usr/backups/MySQL (the best combination with PHP)/phpbb_db_backup.2005.5.6. Gz

Run the following command to restore data:

# MySQL (best combination with PHP)-u-p phpbb_db_backup

Ii. Back up data to a DVD Disk

With the increase of MySQL (the best combination with PHP) data size, the use of traditional CD-R to back up the hard disk is not realistic, the use of CD-RW volume production is too troublesome, tape drive for small and medium-sized enterprises and too expensive. In addition, the complexity of each application is increasing daily and dramatically, and the amount of data processed is also quite large. Linux users often encounter the problem of: Is there any way to back up and store data economically and quickly. As the prices of the DVD recorder and disc quickly decrease, it is wise to use the DVD recorder to back up the Linux operating system.

1. Installation

The following describes how to use a DVD recorder in a Linux environment by taking the built-in burning device of the IDE interface as an example. In Linux, You need to virtualize the burning device of the IDE interface to a SCSI device to burn a DVD. Linux Versions later than 2.4 contain SCSI simulation compiled into the kernel, so you only need to make some minor changes to the Startup File; USB or 1394 (FireWire) the external recorder of the interface is much simpler.

Connect the DVD burner device to dev/hdc, the second IDE interface of the computer, and turn on the power. Assume that the system starts with Grub and opens/boot/grub in a text editor. conf, locate the line starting with "kernel" and add "hdc = ide-scsi" to the end of the line, for example: "kernel/vmlinuz-2.4.20-8ro root = LABEL =/hdc = ide-scsi ".

2. Install the recording software

DVD + RW-Tools: a software toolkit containing a DVD and an image, including Growisofs and dvd + rw-format. Official station: http://fy.chalmers.se /~ Appro/linux/DVD + RW /,

CDRDAO: DAO is Disk-At-Once (Real-time recording), which is a two-second buffering method without audio tracks during the burning process. It can completely control the disk layout and track. This function is quite helpful in burning multiple source disks.

Cdrtools: includes a set of tools for CD and DVD burning. Growisofs uses the mkisofs tool in this package when creating an image. You can use readcd to create an ISO image from an existing DVD. In addition, the Cdrecord application can be used to scan the CD/DVD recorder connected to the system and burn an ISO image to a CD-R (W) disc. Generally, most Linux versions include this software. You can also download and use http: // freshmeat.net/redir/cdrecord/35795/url_homepage/cdrecord.html.

Dvdrecord: Specifies the DVD recording software under the command line. The DVD burning in the command line can be used in many cases. For example, when we remotely access the host, the GUI on the machine cannot be started, or the machine cannot start the GUI for some reason. In addition, you also need to use the command line tool to complete automatic backup and other repeated functions.

The above describes the necessary software and related download URLs. The installation process is relatively simple and will not be repeated here.

3. command line burning

Use a DVD + RW-Tools to burn data

Growisofs is a DVD + RW-Tools tool. Growlsofs uses different methods to access its burning devices. It uses the Unix path under/dev to connect to the recorder. Different systems and releases use different paths for the recorder, so the best way is to view the help in the release. In some systems, a soft link named/dev/dvd is set to point to an available DVD recorder. In this article, use/dev/dvd to specify the recorder, if the path settings in the system are different, replace them with the appropriate path.

1) format a DVD disc that can be read and written

You can use the DVD 10 RW-format Command provided in the dvd + rw-Tools toolkit. There are two ways to format a DVD: Quick Mode and full mode. Quick Mode:

# Dvd + rw-format-blank/dev/dvd

Full mode:

# Dvd + rw-format-blank = full/dev/dvd

(2) store files on a DVD dial:

Similar to a general CD, a DVD uses an ISO file system and the same general extensions (Joliet and RockRidge ). Growlsofs provides a simple method to store files or directories to a DVD dial. Use the mkisofs tool to create an image without burning the image before it is stored on the hard disk. The basic command format is as follows:

# Growisofs-dvd-compat-Z/dev/dvd-J-R/path/to/home/cao

This command is used to create an image and burn the file in the/path/to/home/cao directory to a DVD.

Ii. Network Backup

It is insecure to store MySQL (the best combination with PHP) data on one computer. Therefore, you should back up the data to other computers in the LAN. Assume that the IP address of the MySQL server (the best combination with PHP) is 192.168.1.3. The IP address of the remote computer in Linux is 192.168.1.17, And the IP address of the remote computer in Windows is 192.168.1.18. The network topology is shown in Figure 1.

(Best combination with PHP) MySQL database (figure) "/>
1. Back up data through the NFS Network

Similar to windows Network Sharing, UNIX (Linux) systems also have their own network sharing, that is, NFS (Network File System), before linux client mounting (mount) NFS disk sharing, you must configure the NFS server first. The NFS server configuration in linux is as follows:

(1) Modify/etc/exports to add a shared directory.

 
 
  1. /export/home/sunky 192.168.1.17(rw)  
  2. /export/home/sunky1 *(rw)  
  3. /export/home/sunky2 linux-client(rw)  

Note: sunky, sunky1, and sunky2 under the/export/home/directory are the shared directories, 10.140.133.23, *, and linux-client are IP addresses or host names allowed to connect to the shared linux client. If you want to use the host name linux-client, you must add the linux-client host ip definition in the server host/etc/hosts file. The format is as follows:

192.168.1.17 linux-client

If a new share is added to the/etc/export file, stop the NFS service and then start the NFS service to make the new share take effect. The command exportfs-rv can also achieve the same effect. Mount the NFS share of other linux or UNIX systems on the linux client. Here we suppose 192.168.1.17 is the ip address of the NFS server host. Of course, the host name can also be used here, but the Server ip definition must be added to the local/etc/hosts file. /Export/home/sunky is the directory shared by the server. In this way, you can use/mnt/nfs on the linux client to access files shared by NFS on other linux or UNIX systems.

To back up MySQL (the best combination with PHP) data to a Linux Remote Computer, you must install the NFS NetworkFile System on both ends ), after the NFS protocol is installed on a remote NFS computer, modify the configuration file:/etc/exports and add a line:

/Usr/backups/MySQL (best combination with PHP)/192.168.1.17 (rw, no_root_squash)

Share/usr/backups/MySQL (the best combination with PHP)/directory. This directory has the read and write permissions of the remote root user. Save the NFS configuration file and run the following command:

# Exportfs-a-r

Then restart the NFS service:

# Service nfsd start

After the remote computer is set, create a backup_share directory under the MySQL (best combination with PHP) server/mnt directory:

# Mkdir/mnt/backup_share

Mount the/usr/backups/MySQL (the best combination with PHP)/directory of the remote Linux computer to MySQL (the best combination with PHP) under the/mnt/backup_share directory of the server:

# Mount-t nfs 192.168.1.17:/usr/backups/MySQL (the best combination with PHP)/mnt/backup_share

After mounting the directory, you only need to enter the/mnt/backup_share Directory, which is equal to/usr/backups/MySQL (the best combination with PHP) of the NFS computer whose IP address is 192.168.1.7) directory. The following uses MySQL (the best combination with PHP) dump to back up "phpbb_db_backup" to a remote computer:

# MySQL (best combination with PHP) dump phpbb_db_backup>/mnt/backup_share/phpbb_db_backup.2005-5-6

2. network backup through Samba

The core of Windows Network Sharing is SMB/CIFS. To mount windows disk sharing in linux, you must install and use the samba software package. Currently, most popular linux distributions already contain samba packages. If samba is not installed on linux, install samba first. You can also download the samba package at www.samba.org. The latest version is 3.0.10. Then create a directory/arc on a Windows computer and share it with them to grant them read and write permissions. Similarly, create a backup_share1 directory under the MySQL (best combination with PHP) server/mnt directory and mount it:

# Mount-t smbfs-o username = csung, password = XXXX // 192.168.1.18/arc/mnt/backup_share

Run the following command to back up the data:

# MySQL (best combination with PHP) dump phpbb_db_backup>/mnt/backup_share/phpbb_db_backup.2005-5-6

MySQL (the best combination with PHP) is a powerful MySQL database that requires more practice in practice. This article introduces MySQL (the best combination with PHP) network backup method. Hope to help you.

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.