Back up a MYSQL database in a Linux heterogeneous network (figure) _ MySQL

Source: Internet
Author: User
I am the administrator of a small and medium-sized Linux website. The system architecture is RHEL4.0 + PHP4.3 + Mysql4.03 + Apache1.23. The average daily IP access volume is 200. The author of a typical Linux small website is 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. Next we will talk about backing up MYSQL on a Linux heterogeneous network.
  
   I. local backup
  
A common backup method for Mysql databases is to use the utility mysqldump. the command format is as follows:
  
# Mysqldump [options] database [tables]
  
The parameter description is as follows:
  
Options: indicates the option of mysqldump. you can find it through mysqldump-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 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_backup
   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 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. For more information about the network topology, see.
  
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 NFS protocol (NetworkFile 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
  
Mysql is a powerful database that requires more practice in practice. This article introduces the network backup method of Mysql. 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.