Linux network backup MySQL

Source: Internet
Author: User
I am the administrator of a small and medium-sized Linux website. The system architecture is RHEL 4.0 + PhP 4.3 + MySQL 4.03 + Apache 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.

I. local backup

Using mysqldump for backup is very simple. to back up the database "phpbb_db_backup", run the following command:
# Mysqldump-u-p phpbb_db_backup>/usr/backups/MySQL/phpbb_db_backup.2005.5.6
You can also use the gzip command to compress the backup file:
# Mysqldump phpbb_db_backup | gzip>/usr/backups/MySQL/phpbb_db_backup.2005.5.6. GZ
Run the following command to restore data:
# Mysql-u-p phpbb_db_back </usr/backups/MySQL/phpbb_db_backup.2005-5-6

Ii. Back up data to a DVD Disk

With the increase of Mysql Data volume, the use of traditional CD-R to back up the hard disk is not realistic, using CD-RW volume production is too much trouble, tape drive for small and medium 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 recorder device to the second ide interface (DEV/HDC) of the computer and turn on the power. Assume that the system starts with grub and opens/boot/GRUB/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-8 Ro 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 on the connection system and use it to burn an ISO image to a CD-R (w) disc. Usually most Linux versions include this software, you can also download to 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 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 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.

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.
/Export/home/sunky 192.168.1.17 (RW)
/Export/home/sunky1 * (RW)
/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 Data to a remote computer using Linux, you must install the Network File System on both ends. After installing the NFS protocol on the remote NFS computer, you must modify the configuration file:/etc/exports, add a row:
/Usr/backups/MySQL/192.168.1.17 (RW, no_root_squash)
Share the/usr/backups/MySQL/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 server/mnt directory:
# Mkdir/mnt/backup_share
Mount the/usr/backups/MySQL/directory of the remote Linux computer to the/mnt/backup_share directory of the MySQL server:
# Mount-t nfs 192.168.1.17:/usr/backups/MySQL/mnt/backup_share
After mounting the directory, you only need to enter the/mnt/backup_share Directory, which is equal to the/usr/backups/MySQL directory of the NFS computer whose IP address is 192.168.1.7. The following uses mysqldump to back up "phpbb_db_backup" to a remote computer:
# Mysqldump 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. Create a directory (/arc) on a Windows computer and share it with you to grant it read and write permissions. Similarly, create a backup_share1 directory under the MySQL 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:
# Mysqldump phpbb_db_backup>/mnt/backup_share/phpbb_db_backup.2005-5-6

Related Article

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.