In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
At work, sometimes you need to copy files from ASM to the file system or vice versa, and do some maintenance operations. This article introduces four ways to copy files:
Cp command in ASMCMD (11g)
Dbms_file_transfer package
Convert or backup as copy of rman
FTP
These four methods are described below.
1. Cp command in ASMCMD (11g)
The cp command is a new 11g command that makes it easy to copy files from ASM to the file system or vice versa. You can also copy files from ASM to the file systems of other servers on the network.
# copy from ASM to file system [grid@rac1 ~] $asmcmd-pASMCMD [+] > cd dataASMCMD [+ data] > cd orclASMCMD [+ data/orcl] > cd datafileASMCMD [+ data/orcl/datafile] > lsSYSAUX.257.925306091SYSTEM.256.925306089UNDOTBS1.258.925306091UNDOTBS2.264.925306377USERS.259.925306091ASMCMD [+ data/orcl/datafile] > ls-lType Redund Striped Time Sys NameDATAFILE UNPROT COARSE MAY 21 11:00:00 Y SYSAUX.257.925306091DATAFILE UNPROT COARSE MAY 21 11:00:00 Y SYSTEM.256.925306089DATAFILE UNPROT COARSE MAY 21 11:00:00 Y UNDOTBS1.258.925306091DATAFILE UNPROT COARSE MAY 21 11:00:00 Y UNDOTBS2.264.925306377DATAFILE UNPROT COARSE MAY 21 11:00:00 Y USERS.259.925306091ASMCMD [+ data/orcl/datafile] > cp USERS.259.925306091 / home/grid/users.dbfcopying + data/orcl/datafile/USERS.259.925306091-> / home/grid/users.dbfASMCMD [+ data/orcl/datafile] > # View replication results [grid@rac1 ~] $ll / home/grid/users.dbf-rw-r-. 1 grid oinstall 5251072 May 21 15:20 / home/grid/users.dbf# copy from the file system to ASMASMCMD [+ data/orcl/datafile] > cp / home/grid/users.dbf + data/orclcopying / home/grid/users.dbf-> + data/orcl/users.dbf# to view the replication result ASMCMD [+ data/orcl/datafile] > cd + data/orclASMCMD [+ data/orcl] > ls-lType Redund Striped Time Sys Name Y ARCHIVELOG/ Y CONTROLFILE/ Y DATAFILE/ Y ONLINELOG/ Y PARAMETERFILE/ Y TEMPFILE/ N spfileorcl.ora = > + DATA/ORCL/PARAMETERFILE/spfile.268.925423909 N users.dbf = > + DATA/ASM/DATAFILE/users.dbf.271.944580085
Detailed usage of cp can be obtained using the help cp command.
If the version of ASM is prior to 11g, you can use the following three methods to copy files.
2. Dbms_file_transfer package
This package, which is not available in Oracle 9, allows you to transfer files between two locations, either the same computer or two computers on the network. Oracle10g extends the functionality of this package to copy from one ASM Diskgroup to another, from ASM Diskgroup to a normal file system, from a normal file system to ASM Diskgroup, from a file system to a file system, or RAW Device. This package provides three ways to accomplish different tasks.
The function of the method states that copy_file completes copying files from one local directory to another local directory. This method cannot complete remote transfer of get_file. This method completes copying remote files to local directories, similar to downloading put_file, which accomplishes the purpose of transferring local files to remote, similar to uploading.
How to use it:
# create directory SQL > create directory asm_dir as'+ data/ASM/DATAFILE/';Directory created.SQL > create directory os_dir as'/ home/oracle';Directory created.# to execute replication SQL > exec dbms_file_transfer.copy_file ('asm_dir','user2.dbf.272.944581345','os_dir','user.dbf'); PL/SQL procedure successfully completed.# to verify the replication result [oracle@rac1 ~] $ls-l / home/oracle/user.dbf-rw-r-. 1 oracle asmadmin 5251072 May 21 15:49 / home/oracle/user.dbf# reverse copy SQL > exec dbms_file_transfer.copy_file ('os_dir','user.dbf','asm_dir','user2.dbf') PL/SQL procedure successfully completed.# verification ASMCMD [+ data/ASM/DATAFILE] > ls-lType Redund Striped Time Sys Name N user2.dbf = > + DATA/ORCL/DATAFILE/COPY_FILE.273.944581883
3. Convert and backup as copy commands of rman
3.1 convert command
The convert command is used to convert data files into byte formats. Oracle can transfer tablespaces (TTS) between different OS platforms. If the byte formats of the two platforms are not consistent, you need to convert the format of the reference data file, which can be performed in the source database or in the destination database. If executed in the source database, you need to use the convert tablespace command, and if you execute in the destination database, you need to use the convert datafile command.
Although the convert command is mainly used to transfer tablespaces across platforms, it can also copy files between ASM and the local file system, and it is also a very simple method.
# copy from ASM to file system RMAN > convert datafile'+ data/orcl/datafile/USERS.259.925306091' format'/ home/oracle/user3.dbf' using convert datafile Starting conversion at target at 21-MAY-17using channel ORA_DISK_1channel ORA_DISK_1: starting datafile conversioninput file name=+DATA/orcl/datafile/users.259.925306091converted datafile=/home/oracle/user3.dbfchannel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01Finished conversion at target at 21-MAY-17# Verification [oracle@rac1 ~] $ls-1 / home/oracle/user3.dbf-rw-r-. 1 oracle asmadmin 5251072 May 21 16:00 / home/oracle/user3.dbf# uses convert tablespace. You need to set the users tablespace to read-only RMAN > sql 'alter tablespace users read only';using target database control file instead of recovery catalogsql statement: alter tablespace users read onlyRMAN > convert tablespace users format' / home/oracle/users%U.dbf'. Starting conversion at source at 21-MAY-17allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=81 instance=orcl1 device type=DISKchannel ORA_DISK_1: starting datafile conversioninput datafile file number=00004 name=+DATA/orcl/datafile/users.259.925306091converted datafile=/home/oracle/usersdata_D-ORCL_I-1453086940_TS-USERS_FNO-4_0ns4qbtn.dbfchannel ORA_DISK_1: datafile conversion complete Elapsed time: 00:00:01Finished conversion at source at 21-MAY-17# verification [oracle@rac1 ~] $ll / home/oracle/usersdata_D-ORCL_I-1453086940_TS-USERS_FNO-4_0ns4qbtn.dbf-rw-r-. 1 oracle asmadmin 5251072 May 21 16:03 / home/oracle/usersdata_D-ORCL_I-1453086940_TS-USERS_FNO-4_0ns4qbtn.dbf# copy from the file system to ASMRMAN > convert datafile'/ home/oracle/user3.dbf','/home/oracle/usersdata_D-ORCL_I-1453086940_TS-USERS_FNO-4_0ns4qbtn.dbf' format'+ data' Starting conversion at target at 21-MAY-17using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=64 instance=orcl1 device type=DISKchannel ORA_DISK_1: starting datafile conversioninput file name=/home/oracle/user3.dbfconverted datafile=+DATA/orcl/datafile/users.274.944582713channel ORA_DISK_1: datafile conversion complete Elapsed time: 00:00:01channel ORA_DISK_1: starting datafile conversioninput file name=/home/oracle/usersdata_D-ORCL_I-1453086940_TS-USERS_FNO-4_0ns4qbtn.dbfconverted datafile=+DATA/orcl/datafile/users.275.944582713channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01Finished conversion at target at 21-MAY-17# see the converted file name # converted datafile=+DATA/orcl/datafile/users.274.944582713#converted datafile=+DATA/orcl/datafile/users.274.944582713 from the log
3.2 backup as copy command
The backup as copy command backs up files in a mirrored manner, so you can naturally copy files from ASM to the file system. This is also one of the options available when migrating from a file system to ASM.
# copy RMAN > backup as copy datafile'+ DATA/orcl/datafile/users.259.925306091' format'/ home/oracle/user4.dbf' Starting backup at 21-MAY-17using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=69 instance=orcl1 device type=DISKchannel ORA_DISK_1: starting datafile copyinput datafile file number=00004 name=+DATA/orcl/datafile/users.259.925306091output file name=/home/oracle/user4.dbf tag=TAG20170521T161225 RECID=17 STAMP=944583145channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01Finished backup at 21-MAY-17# Verification [oracle@rac1 ~] $ls-1 / home/oracle/user4.dbf-rw-r-. 1 oracle asmadmin 5251072 May 21 16:12 / home/oracle/user4.dbf
4.FTP method
The FTP method can perform operations on ASM files and directories in the same way that a copy in a library uses traditional File transfer Protocol (FTP) to perform regular operations on ordinary files. A typical application of accessing ASM files in this way is to copy ASM files from one database to another. Need XML DB support, configuration is the most troublesome, interested students can refer to the "Oracle Database 11g RAC manual, the second edition of the original book" or the official document: http://docs.oracle.com/cd/E11882_01/server.112/e18951/asmfiles.htm#BABJCCEI
Refer to "lie Oracle RAC"
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.