将ASM里面的文件copy到文件系统


将ASM里面的文件copy到文件系统

数据文件存放在ASM里面查看不是很直观,有时候需要把文件从ASM里面copy到文件系统。我记录了一下两种方法,还有一种用AMDU,ODU也可以实现

1. 直接在asmcmd里面用cp命令

ASMCMD> ls   
SYSAUX.260.894187589
SYSTEM.259.894187575
UNDOTBS1.261.894187601
UNDOTBS2.263.894187615
USERS.264.894187621
USERS.268.895081225
USERS.269.895582787
USERS.280.898078315


ASMCMD> cp SYSAUX.260.894187589 /home/grid/sysaux.dbf
copying +datadg01/xedb/datafile/SYSAUX.260.894187589 -> /home/grid/sysaux.dbf


[root@rac01test grid]# pwd
/home/grid
You have new mail in /var/spool/mail/root
[root@rac01test grid]# ll
total 1894508
drwxr-xr-x 2 grid oinstall       4096 Oct 23 16:34 Desktop
drwxr-xr-x 2 grid oinstall       4096 Oct 23 16:34 Documents
drwxr-xr-x 2 grid oinstall       4096 Oct 23 16:34 Downloads
-rw-r----- 1 grid oinstall 1939873792 Apr 14 16:18 sysaux.dbf
这里sysaux.dbf就是copy出来的文件

2.用rman copy命令

2.1 rman  copy 归档
copy archivelog '+ARCH_DG/arc1/1_1216_894187568.dbf' to '/tmp/log/1_1216_894187568.dbf';

2.1 rman copy 数据文件

RMAN> copy datafile  '+DATADG01/xedb/datafile/system.259.894187575' to '/home/oracle/system.dbf'

Starting backup at 14-APR-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=152 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=+DATADG01/xedb/datafile/undotbs1.261.894187601
output file name=/home/oracle/system.dbf tag=TAG20160414T171543 RECID=2 STAMP=909162958
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
Finished backup at 14-APR-16


[root@rac01test oracle]# ll
-rw-r----- 1 oracle asmadmin 770711552 Apr 14 16:29 system.dbf
这里的system文件就是copy出来的
 
  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 Linux 内核中,可以使用以下函数来读写文件: 1. `filp_open()` 函数:用于打开文件,返回一个指向打开文件对象的指针。 2. `vfs_read()` 函数:用于从文件中读取数据。 3. `vfs_write()` 函数:用于向文件中写入数据。 4. `filp_close()` 函数:用于关闭文件。 以下是一个简单的示例,展示如何在内核中读取和写入文件: ```c #include <linux/fs.h> #include <asm/uaccess.h> static int read_file(char *filename, char *buffer, int buflen) { struct file *f; loff_t pos = 0; ssize_t ret; f = filp_open(filename, O_RDONLY, 0); if (IS_ERR(f)) return -1; ret = vfs_read(f, buffer, buflen, &pos); filp_close(f, NULL); return ret; } static int write_file(char *filename, char *buffer, int buflen) { struct file *f; loff_t pos = 0; ssize_t ret; f = filp_open(filename, O_WRONLY | O_CREAT, 0644); if (IS_ERR(f)) return -1; ret = vfs_write(f, buffer, buflen, &pos); filp_close(f, NULL); return ret; } ``` 在上面的示例中,`read_file()` 函数使用 `filp_open()` 函数打开指定的文件,然后使用 `vfs_read()` 函数从文件中读取数据。`write_file()` 函数使用 `filp_open()` 函数打开指定的文件,然后使用 `vfs_write()` 函数向文件中写入数据。最后,使用 `filp_close()` 函数关闭文件。 需要注意的是,由于内核空间和用户空间的地址空间是隔离的,因此在内核中读取和写入文件时,需要使用 `copy_from_user()` 和 `copy_to_user()` 函数来进行数据的复制。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值