In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "how to use UNIX pipeline and redirection function in system backup". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The UNIX command has three valid data streams: standard input, standard output, and standard error.
A pipeline is a technology that transmits information one way from one program process to another. Unlike other forms of inter-process communication, such as IPC, MESSAGE PASSING, SOCKET, etc., the pipeline is one-way. Typically, pipes pass the output of one process to another as input. The system temporarily retains the pipeline information before the receiving process receives the information.
In UNIX shell, pipes are represented by a vertical bar (|) on the command line. The standard output of the command on the left side of the pipe serves as the standard input of the command on the right side of the pipe.
The input and output redirection of UNIX can transfer the standard input and output of commands from keyboards and terminals to other device files.
We can use the pipeline and input and output redirection function to skillfully implement some functions in the UNIX system, to give the following three examples (assuming that the user has the corresponding permissions).
i. The host tom does not have a tape drive, while the host jerry has a tape drive.
Our task is to back up the tom data to tape via jerry.
Suppose we use the tar command to back up the / dir directory to tape.
First, modify the file / etc/hosts on tom and add the IP address of jerry:
192.0.0.2 jerry
Then, ping jerry, see if the network is open.
Modify the .rhosts of tom and add the following line:
Jerry
Make jerry a trusted host for tom.
Now, on jerry, rlogin tom, normally, does not need a password and should be able to log in to the tommachine.
On jerry, run:
Rsh tom "" tar cvf-/ dir "" > / dev/rmt0h
Where tar cvf-/ dir copies the / dir to standard output and then to the tape drive that is redirected to the host jerry to complete the backup.
ii. How to realize the simultaneous backup of tape drives of multiple hosts and speed up the backup speed.
With the acceleration of the information process, many enterprises have developed from manual operation to the use of information technology to improve productivity, and enterprises have also accumulated a lot of data, many of which require 7x24 to run on an hourly basis.
The backup process of the database will degrade the performance of the server even without downtime, and the benefit of shortening the backup time window as much as possible is obvious.
However, a UNIX host is generally configured with only one tape drive. Assuming that we have another UNIX host with tape drives available, we can use two tape drives to work at the same time to speed up backup time.
Suppose you have an ORACLE database running on the host tom, and the database has four data files each for 2GB:
/ dev/volume1
/ dev/volume2
/ dev/volume3
/ dev/volume4
It takes 15 minutes for each data file to be backed up to tape, and an hour for backup using tom's own tape drive.
We have a jerry mainframe with a tape drive and are free. The following operations take advantage of plumbing technology to shorten backup time.
* step: make jerry a trusted host for tom, using the same method as above.
The second step is to divide the backup task into two groups, volume1,volume2 backed up on tom and volume3,volume4 backed up on jerry.
Run on tom:
Dd if=/dev/volume1 of=/dev/rmt0
Dd if=/dev/volume2 of=/dev/rmt0
Run on jerry:
Rsh tom "" dd if=/dev/volume3 "" | dd of=/dev/rmt0
Rsh tom "" dd if=/dev/volume4 "" | dd of=/dev/rmt0
Through the above method, the backup time can be reduced by half. If more hosts join the backup work, the effect will be more significant in the case of making full use of network bandwidth.
iii. To solve the problem of insufficient disk space, how to make the application generate data and generate compressed files directly without going through the intermediate process.
Take exp/imp, an ORACLE database logical backup tool, as an example.
The data backed up by exp in ORACLE database can save about half of the disk space after compression, such as compress compression. However, to go through the intermediate process, about half the buffer space of the original file size is required in compression. Using the pipeline, the final compressed file can be generated directly, omitting the intermediate process.
The regular exp command runs as follows:
Exp system/manager@testdb file=expdat.dmpfull=y
Use the pipeline as follows:
Mknod exp_pipe p / * generate named pipes * /
Exp system/manager@testdb file=./exp_pipefull=y / * send backup data to the pipeline * /
Compress exp_pipe > expfull.dmp.Z / * generate compressed backup files * /
The recovery operation can also use the pipeline to skip the process of unzipping the file and generating the original file, as follows:
Mknod imp_pipe p / * generate the corresponding named pipe * /
Uncompress-c expfull.dmp.Z > imp_pipe/* sends the decompressed data into the pipeline * /
Imp system/manager@testdb file=./imp_pipefromuser=scott
Touser=scott / * Import pipeline data into database testdb*/
This is the end of the content of "how to use UNIX pipes and redirects in system backup". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.