精华内容
下载资源
问答
  • cp命令还支持同时复制多个文件,当一次复制多个文件时,目标文件参数必须是一个已经存在的目录,否则将出现错误。 语法 cp(选项)(参数) 选项 -a:此参数的效果和同时指定”-dpR”参数相同; -d:当复制符号连接...
  • ubuntu利用dd命令备份系统

    千次阅读 2014-09-14 12:43:56
    我们使用cp或者tar也可以对系统文件进行备份,但是如果遇到需要把一整个磁盘内容完整复制到另一个partition中,这时候就需要复制bootsector区块,而cp或者tar是不可以复制这个区块的,所以最好使用dd命令啦!...

           虽然一般情况下,我们使用cp或者tar也可以对系统文件进行备份,但是如果遇到需要把一整个磁盘内容完整复制到另一个partition中,这时候就需要复制bootsector区块,而cp或者tar是不可以复制这个区块的,所以最好使用dd命令啦!

    下面就看看dd的用法:

    ddif="input_file" of="output_file" bs="block_size"count="number"

    选顷与参数:

    if:就是 inputfile ~也可以是装置喔!

    of:就是 outputfile ~也可以是装置;

    bs:规划的一个 block的大小,若未指定则预设是512bytes(一个 sector大小)

    count:多少个bs的意思。



    范例:(最好以root权限运行以下指令)

    1、将/etc/passwd备份到 /tmp/passwd.back当中

    ddif=/etc/passwd of=/tmp/passwd.back

    2、将自己磁盘第一个扇区备份/tmp/mbr.back

    ddif=/dev/sda1 of=/tmp/mbr.back bs=512 count=1

    #其中/dev/sda1表示系统的引导分区,每个人的情况不同

    3、每一个硬盘的内容克隆到别一个同大小的硬盘

    ddif=/dev/sda of=/dev/sdb

      把/dev/sda以文件的形式存到U盘里

    ddif=/dev/sda of=/media/disk1/sda-image20121208.img

      对应上面的还原!

    ddif=/dev/sdb of=/dev/sda
    ddif=/media/disk1/sda-image20121208.img of=/dev/sda



    展开全文
  • LinuxC下的复制单一文件与其它语言的没有区别,对于文件操作皆要用到文件流、文件流的缓冲区的概念,可能这就是操作系统中的共性吧!...如下图,用过Linux下的人都知道如何用终端命令复制文件,这里答了等于没答:

    LinuxC下的复制单一文件与其它语言的没有区别,对于文件操作皆要用到文件流、文件流的缓冲区的概念,可能这就是操作系统中的共性吧!网上对于LinuxC如何复制文件,往往直接用到system("cp 源文件 目标文件"),如此“不负责任”的解决方案,要是别人规定不能用shell脚本呢,必须从C语言的根本解决问题呢?

    如下图,用过Linux下的人都知道如何用终端命令复制文件,这里答了等于没答:


    再有一部分关于LinuxC文件流关于复制单一文件的记载写得老长老长,没有抓住问题的本质,用了许许多多没有必要的类库。其实LinuxC复制文件就如下代码,能够极其简短地完成关于文件home/pc/A/a复制到home/pc/A/aaa的任务:

    #include <stdio.h>
    #include <stdlib.h>
    int main(){
    	char buffer[1024];//设置缓冲区大小
    	FILE *in,*out;//定义两个文件流,分别用于文件的读取和写入int len;
    	if((in=fopen("/home/pc/A/a","r"))==NULL){//打开源文件的文件流
    		printf("源文件不存在,请检查路径输入是否存在!\n");
    		exit(1);
    	}
    	if((out=fopen("/home/pc/A/aaa","w"))==NULL){//打开目标文件的文件流
    		printf("创建目标文件流失败!\n");
    		exit(1);
    	}
    	int len;//len为fread读到的字节长
    	while((len=fread(buffer,1,1024,in))>0){//从源文件中读取数据并放到缓冲区中,第二个参数1也可以写成sizeof(char)
    		fwrite(buffer,1,len,out);//将缓冲区的数据写到目标文件中memset(buffer,0,1024);
    	}
    	fclose(out);
    	fclose(in);
    	return 0;
    }

    相信不用多加解释了,都老套路了,搞两个文件流,对应两个文件,一个用于文件的读,一个用于文件的写,读写之间用一个缓冲区来存放,搞完就关闭这两个文件流,运行结果如下:


    展开全文
  • Linux下cp命令模拟

    千次阅读 2010-12-26 20:30:00
    下面利用文件I/O操作来模拟cp命令的单个文件复制与整个目录的复制功能. 用到的函数: 包括文件操作与文件I/O操作   cp命令模拟程序: 例如: 复制/etc/inittab到root目录下,可以用 ./cp /...

    学过Linux的都知道, cp命令是linux系统中的文件复制命令,它有很多的参数,提供了很强的功能。不仅可以进行文件的复制,而且还能复制整个目录。

    下面利用文件I/O操作来模拟cp命令的单个文件复制与整个目录的复制功能.

    用到的函数: 包括文件操作与文件I/O操作

     

    cp命令模拟程序:

    例如: 复制/etc/inittab到root目录下,可以用 ./cp  /etc/inittab /root/

                    ./cp /root/dir  /boot/ 把root下的目录dir复制到boot下

    ./cp是编译生成的exe文件.

     

     

    #include <stdio.h>
    #include <sys/stat.h>
    #include <sys/types.h>
    #include <string.h>
    #include <fcntl.h>

    #include <unistd.h>
    #include <dirent.h>
    #include <stdlib.h>
    #define SIZE 65536*1024
    #define LENGTH 1024
    char buffer[SIZE];//复制用的内存块
    void cpdir( char* argv1,char* argv2);
    int main(int argc,char*argv[]){
    char* argvx=argv[1];
    char str1[100];
    strcpy(str1,argvx);

    FILE* fp;
    struct stat statbuf;
    if(argc==1){
    printf("%s/n", "cp: 缺少了文件操作数请尝试执行“cp --help”来获取更多信息。");
    return 0;
    }



    else if(argc==3){

    lstat(argv[1],&statbuf);//得到源文件的状态和属性信息
    if(statbuf.st_mode&S_IFDIR){//如果是一个目录则进行相应的处理
    //首先建立目标根目录
    char* p1;
    char *p;

    p=strtok(argv[1],"/");
    while(p!=NULL){
    p1=p;
    p=strtok(NULL,"/");
    }

    strcat(argv[2],p1);
    int fdir=mkdir(argv[2],0664);//建立目标目录
    if(fdir==-1){
    perror("建立目标目录失败");
    return 1;
    }



    char str2[100];
    strcpy(str2,argv[2]);
    cpdir(str1,str2);


    }
    //如果只是单个文件
    else{
    char a[10];
    strcpy(a,argv[1]);
    printf("%s/n","sssss");
    char *p;
    char *p1;//p1指向目标文件名
    p=strtok(a,"/");
    while(p!=NULL){
    p1=p;
    p=strtok(NULL,"/");
    }
    printf("%s/n",p1);
    strcat(argv[2],p1);
    printf("%s/n",argv[2]);
    //建立目标文件
    int f=open(argv[2],O_CREAT|O_RDWR,0664);
    if(f==-1){
    perror("建立目标文件");
    return 0;
    }
    //读源文件到缓冲区内,先打开源文件,返回文件流指针
    printf("%s/n",argv[1]);
    fp=fopen(argv[1],"r");//以只读方式打开
    if(fp==NULL){
    perror("打开源文件");
    return 1;
    }

    int realread=fread(buffer,LENGTH,SIZE/LENGTH,fp);//返回实际读文件到缓冲区的次数,每次读入的数据为length
    if(realread<0){
    perror("读源文件失败");
    return 0;
    }
    fclose(fp);//关闭源文件流指针
    //打开目标文件
    fp=fopen(argv[2],"rw+");//以读写的方式打开目标文件
    if(fp==NULL){
    perror("打开目标文件失败");
    return 1;
    }

    int realwrite=fwrite(buffer,LENGTH,SIZE/LENGTH,fp);//将缓冲区的内容读到目标文件中去
    if(realwrite<=0){

    perror("写目标文件失败");
    return 1;
    }

    fflush(fp);//将缓冲区内的数据立即写到文件中去
    fclose(fp);//关闭目标文件流指针




    }

    }




    return 0;


    }
    //如果复制目录
    void cpdir(char* argv1, char* argv2){
    //一个整形参数,另一个是char型指针数组
    //argv1里面存放的是源目录名,argv2里面存放的是目标路径名
    printf("%s/n",argv1);
    printf("%s/n",argv2);
    struct stat statbuf;
    DIR *dp;//定义一个目录流指针
    FILE* fp;

    struct dirent *entry;//定义一个指向目录流指针的下一个目录相关信息的结构体

    if((dp=opendir(argv1))==NULL){
    printf("%s/n","无法打开该目录");
    return;
    }

    chdir(argv1);

    while((entry=readdir(dp))!=NULL){
    stat(entry->d_name,&statbuf);//判断一下子目录流指针所指向的是不是目录
    printf("entry->d_name=%s/n",entry->d_name);

    if(statbuf.st_mode&S_IFDIR){
    printf("%s/n","dirrrrrr");
    if(strcmp(entry->d_name,".")==0||strcmp(entry->d_name,"..")==0){

    continue;//如果是当前目录或者是上一级的目录则不复制
    }


    char s[100];
    strcpy(s,argv2);
    strcat(s,"/");
    strcat(s,entry->d_name);
    int fdir= mkdir(s,0664);

    //建立目录

    if(fdir==-1){
    perror("目标目录建立失败");
    return;
    }
    cpdir(entry->d_name,s);

    }
    //else里面处理的是文件复制
    else{
    printf("%s/n","file=====");
    printf("filename=%s/n",entry->d_name);
    //得用非缓冲区I/O操作,系统调用提供的函数
    char argv22[100];
    strcpy(argv22,argv2);
    strcat(argv22,"/");
    strcat(argv22,entry->d_name);
    // printf("argv2=%s/n",argv2);
    // printf("%s/n",entry->d_name);
    //printf("%s/n",argv22);
    //建立目标文件
    int f1=open(argv22,O_CREAT|O_RDWR,0664);
    if(f1==-1){
    perror("目标文件建立失败");
    return ;
    }
    int f=0;
    f=open(entry->d_name,O_RDONLY);//以只读的方式打开源文件
    if(f==-1){
    perror("源文件打开失败");
    return;
    }

    int realread=read(f,buffer,SIZE);
    if(realread>0){

    int realwrite=write(f1,buffer,SIZE);//写到目标文件中去
    if(realwrite<=0){
    perror("写入失败");
    return ;
    }

    }

    close(f);//关闭源文件
    close(f1);

    }


    }

    chdir("..");
    closedir(dp);//关闭子目录流指针


    }

     

    以上程序用到了文件操作的一些函数,如open,mkdir,unlink,readdir,opendir等 ,还用到了文件I/O操作的一些函数,如read,fread,write,fwrite,flush等。模拟了文件复制命令cp的部分功能。

     

     

    展开全文
  • 在Oracle10g中在操作系统与ASM之间不能使用复制命令(11g有相关复制命令)比如cp操作来复制文件,为了使用ASM来管理已经存在的数据库必须将数据库迁移到ASM中。可以通过RMAN来完成这项操作。假设在文件系统和A...

    在Oracle10g中在操作系统与ASM之间不能使用复制命令(11g有相关复制命令)比如cp操作来复制文件,为了使用ASM来管理已经存在的数据库必须将数据库迁移到ASM中。可以通过RMAN来完成这项操作。假设在文件系统和ASM磁盘组中有足够的空间来存储整个数据库可以将数据库从文件系统中直接迁移到ASM中。如果在ASM和文件系统同时没有足够的空间来存储整个数据库,可以将数据库备份到磁带,使用旧的磁盘来创建ASM磁盘组并使用磁带备份将数据库还原到ASM中。

    如果文件系统和ASM同时有足够的空间来存储整个数据库,可以不使用磁带过渡直接将数据库迁移到ASM中。在这个例子中目标ASM磁盘组为+DISK1。在迁移的过程中所有的闪回日志将会被丢弃,因此,数据库中的任何受保护还原点都将变为无效。在执行迁移之前需要将其删除。

    将数据库从文件系统迁移到ASM的操作步骤如下:
    1.记录数据库迁移之前的数据文件,控制文件,联机重做日志文件的文件名

    SQL> select name,status from v$datafile;
    
    NAME                                                                             STATUS
    -------------------------------------------------------------------------------- -------
    /u01/app/oracle/oradata/test/system01.dbf                                        SYSTEM
    /u01/app/oracle/oradata/test/undotbs01.dbf                                       ONLINE
    /u01/app/oracle/oradata/test/sysaux01.dbf                                        ONLINE
    /u01/app/oracle/oradata/test/users01.dbf                                         ONLINE
    /u01/app/oracle/oradata/test/example01.dbf                                       ONLINE
    /u01/app/oracle/oradata/test/tspitr01.dbf                                        ONLINE
    /u01/app/oracle/oradata/test/test01.dbf                                          ONLINE
    
    7 rows selected
    
    SQL> select member,status from v$logfile;
    
    MEMBER                                                                           STATUS
    -------------------------------------------------------------------------------- -------
    /u01/app/oracle/oradata/test/redo03.log
    /u01/app/oracle/oradata/test/redo02.log
    /u01/app/oracle/oradata/test/redo01.log
    
    SQL> show parameter control_files
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    control_files                        string      /u01/app/oracle/oradata/test/control01.ctl,
                                                     /u01/app/oracle/oradata/test/control02.ctl,
                                                     /u01/app/oracle/oradata/test/control03.ctl
    

    2.将数据库文件作为副本备份到ASM磁盘组

    [oracle@oracle11g ~]$ export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss';
    [oracle@oracle11g ~]$ rman target sys/zzh_2046@test  catalog rman/rman@jy
    
    Recovery Manager: Release 10.2.0.5.0 - Production on Wed Apr 1 16:06:19 2015
    
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    
    connected to target database: TEST (DBID=2168949517)
    connected to recovery catalog database
    
    RMAN> backup as copy incremental level 0 database format '+DISK1' tag 'DB_ASM_MIGRATION';
    
    Starting backup at 2015-04-01 16:06:27
    starting full resync of recovery catalog
    full resync complete
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: sid=151 devtype=DISK
    channel ORA_DISK_1: starting datafile copy
    input datafile fno=00001 name=/u01/app/oracle/oradata/test/system01.dbf
    output filename=+DISK1/test/datafile/system.266.875894803 tag=DB_ASM_MIGRATION recid=17 stamp=875894833
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
    channel ORA_DISK_1: starting datafile copy
    input datafile fno=00003 name=/u01/app/oracle/oradata/test/sysaux01.dbf
    output filename=+DISK1/test/datafile/sysaux.267.875894845 tag=DB_ASM_MIGRATION recid=18 stamp=875894865
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
    channel ORA_DISK_1: starting datafile copy
    input datafile fno=00005 name=/u01/app/oracle/oradata/test/example01.dbf
    output filename=+DISK1/test/datafile/example.265.875894871 tag=DB_ASM_MIGRATION recid=19 stamp=875894883
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
    channel ORA_DISK_1: starting datafile copy
    input datafile fno=00006 name=/u01/app/oracle/oradata/test/tspitr01.dbf
    output filename=+DISK1/test/datafile/tspitr.264.875894885 tag=DB_ASM_MIGRATION recid=20 stamp=875894892
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:16
    channel ORA_DISK_1: starting datafile copy
    input datafile fno=00002 name=/u01/app/oracle/oradata/test/undotbs01.dbf
    output filename=+DISK1/test/datafile/undotbs1.263.875894899 tag=DB_ASM_MIGRATION recid=21 stamp=875894903
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
    channel ORA_DISK_1: starting datafile copy
    input datafile fno=00004 name=/u01/app/oracle/oradata/test/users01.dbf
    output filename=+DISK1/test/datafile/users.262.875894907 tag=DB_ASM_MIGRATION recid=22 stamp=875894907
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
    channel ORA_DISK_1: starting datafile copy
    input datafile fno=00007 name=/u01/app/oracle/oradata/test/test01.dbf
    output filename=+DISK1/test/datafile/test.261.875894909 tag=DB_ASM_MIGRATION recid=23 stamp=875894910
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
    Finished backup at 2015-04-01 16:08:30
    
    Starting Control File and SPFILE Autobackup at 2015-04-01 16:08:30
    piece handle=/u02/c-2168949517-20150401-08 comment=NONE
    Finished Control File and SPFILE Autobackup at 2015-04-01 16:08:35
    
    
    ASMCMD> ls -lrt
    Type      Redund  Striped  Time             Sys  Name
    DATAFILE  UNPROT  COARSE   APR 01 16:00:00  Y    EXAMPLE.265.875894871
    DATAFILE  UNPROT  COARSE   APR 01 16:00:00  Y    SYSAUX.267.875894845
    DATAFILE  UNPROT  COARSE   APR 01 16:00:00  Y    SYSTEM.266.875894803
    DATAFILE  UNPROT  COARSE   APR 01 16:00:00  Y    TEST.261.875894909
    DATAFILE  UNPROT  COARSE   APR 01 16:00:00  Y    TSPITR.264.875894885
    DATAFILE  UNPROT  COARSE   APR 01 16:00:00  Y    UNDOTBS1.263.875894899
    DATAFILE  UNPROT  COARSE   APR 01 16:00:00  Y    USERS.262.875894907
    

    为了确保数据库能执行一致性恢复,归档当前联机重做日

    RMAN> sql 'alter system archive log current';
    
    sql statement: alter system archive log current
    
    

    如果数据库很大在执行上面的备份时可能会要很长时间。如果在执行备份时有大量的数据库活动,可以对数据库生成一个增量备份在迁移之前将0级备份之后的改变刷新到0级备份所创建的副本中。

    RMAN> backup incremental level 1 for recover of copy with tag 'DB_ASM_MIGRATION' database;
    
    Starting backup at 2015-04-01 16:19:52
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting incremental level 1 datafile backupset
    channel ORA_DISK_1: specifying datafile(s) in backupset
    input datafile fno=00001 name=/u01/app/oracle/oradata/test/system01.dbf
    input datafile fno=00003 name=/u01/app/oracle/oradata/test/sysaux01.dbf
    input datafile fno=00005 name=/u01/app/oracle/oradata/test/example01.dbf
    input datafile fno=00006 name=/u01/app/oracle/oradata/test/tspitr01.dbf
    input datafile fno=00002 name=/u01/app/oracle/oradata/test/undotbs01.dbf
    input datafile fno=00004 name=/u01/app/oracle/oradata/test/users01.dbf
    input datafile fno=00007 name=/u01/app/oracle/oradata/test/test01.dbf
    channel ORA_DISK_1: starting piece 1 at 2015-04-01 16:19:53
    channel ORA_DISK_1: finished piece 1 at 2015-04-01 16:20:38
    piece handle=/u02/ora_test875895593_1301 tag=DB_ASM_MIGRATION comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
    Finished backup at 2015-04-01 16:20:39
    
    Starting Control File and SPFILE Autobackup at 2015-04-01 16:20:39
    piece handle=/u02/c-2168949517-20150401-09 comment=NONE
    Finished Control File and SPFILE Autobackup at 2015-04-01 16:20:42
    
    RMAN> recover copy of database with tag 'DB_ASM_MIGRATION';
    
    Starting recover at 2015-04-01 16:21:09
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting incremental datafile backupset restore
    channel ORA_DISK_1: specifying datafile copies to recover
    recovering datafile copy fno=00001 name=+DISK1/test/datafile/system.266.875894803
    recovering datafile copy fno=00002 name=+DISK1/test/datafile/undotbs1.263.875894899
    recovering datafile copy fno=00003 name=+DISK1/test/datafile/sysaux.267.875894845
    recovering datafile copy fno=00004 name=+DISK1/test/datafile/users.262.875894907
    recovering datafile copy fno=00005 name=+DISK1/test/datafile/example.265.875894871
    recovering datafile copy fno=00006 name=+DISK1/test/datafile/tspitr.264.875894885
    recovering datafile copy fno=00007 name=+DISK1/test/datafile/test.261.875894909
    channel ORA_DISK_1: reading from backup piece /u02/ora_test875895593_1301
    channel ORA_DISK_1: restored backup piece 1
    piece handle=/u02/ora_test875895593_1301 tag=DB_ASM_MIGRATION
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:08
    Finished recover at 2015-04-01 16:21:19
    
    Starting Control File and SPFILE Autobackup at 2015-04-01 16:21:19
    piece handle=/u02/c-2168949517-20150401-0a comment=NONE
    Finished Control File and SPFILE Autobackup at 2015-04-01 16:21:23
    
    

    3.在ASM磁盘组中创建一个SPFILE文件副本。将要迁移的数据库SPFILE文件存储为+DISK1/spfile如果数据库是使用的SPFILE启动,就执行以下命令:

    RMAN> run
    2> {
    3> backup as backupset spfile;
    4> restore spfile to '+DISK1/spfile';
    5> }
    
    Starting backup at 2015-04-01 16:24:46
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting full datafile backupset
    channel ORA_DISK_1: specifying datafile(s) in backupset
    including current SPFILE in backupset
    channel ORA_DISK_1: starting piece 1 at 2015-04-01 16:24:48
    channel ORA_DISK_1: finished piece 1 at 2015-04-01 16:24:49
    piece handle=/u02/ora_test875895887_1331 tag=TAG20150401T162446 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
    Finished backup at 2015-04-01 16:24:49
    
    Starting Control File and SPFILE Autobackup at 2015-04-01 16:24:49
    piece handle=/u02/c-2168949517-20150401-0b comment=NONE
    Finished Control File and SPFILE Autobackup at 2015-04-01 16:24:51
    
    Starting restore at 2015-04-01 16:24:52
    using channel ORA_DISK_1
    
    channel ORA_DISK_1: starting datafile backupset restore
    channel ORA_DISK_1: restoring SPFILE
    output filename=+DISK1/spfile
    channel ORA_DISK_1: reading from backup piece /u02/c-2168949517-20150401-0b
    channel ORA_DISK_1: restored backup piece 1
    piece handle=/u02/c-2168949517-20150401-0b tag=TAG20150401T162450
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
    Finished restore at 2015-04-01 16:24:56
    
    
    ASMCMD> ls -lrt
    Type           Redund  Striped  Time             Sys  Name
                                                     Y    DB_UNKNOWN/
                                                     Y    TEST/
                                                     N    spfile => +DISK1/DB_UNKNOWN/PARAMETERFILE/SPFILE.260.875895895
    

    如果数据库是使用PFILE启动,可以在SQL*Plus中执行create spfile命令来创建SPFILE

    SQL>create spfile='+DISK1/spfile' from pfile='$ORACLE_HOME/dbs/inittest.ora'
    
    File created.
    
    

    4.如果被迁移的数据库是备库,需要停止管理恢复模式

    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
    

    执行一致性关闭

    RMAN> SHUTDOWN IMMEDIATE;
    
    
    

    5.在目录/u02/backup中创建一个 pfile参数文件来引用新的SPFILE文件,并重新启动实例到nomount状态

    [oracle@oracle11g backup]$ vi inittest_temp.ora
    spfile='+DISK1/spfile'
    
    RMAN> shutdown immediate
    
    database closed
    database dismounted
    Oracle instance shut down
    
    SQL> startup nomount pfile='/u02/backup/inittest_temp.ora'
    ORACLE instance started.
    
    Total System Global Area  167772160 bytes
    Fixed Size                  1272600 bytes
    Variable Size             109053160 bytes
    Database Buffers           54525952 bytes
    Redo Buffers                2920448 bytes
    

    6.为了下一步将控制文件迁移到ASM中,修改control_files参数:

    SQL> alter system set control_files='+DISK1/control01.ctl' scope=spfile;
    
    System altered.
    

    7.通过设置db_recovery_file_dest和db_recovery_file_dest_size来指定闪回区,这里闪回区大小设置为2G(因为这里只是进行迁移测试实验)

    SQL> alter system set db_recovery_file_dest_size=2G;
    
    System altered.
    
    SQL> alter system set db_recovery_file_dest='+DISK1';
    
    System altered.
    

    8.将实例重新启动到nomount状态,使用RMAN在ASM中创建新的控制文件(使用原来控制文件来创建),切换数据文件,并执执恢复

    SQL> shutdown immediate
    ORA-01507: database not mounted
    
    
    ORACLE instance shut down.
    SQL> startup nomount pfile='/u02/backup/inittest_temp.ora'
    ORACLE instance started.
    
    Total System Global Area  167772160 bytes
    Fixed Size                  1272600 bytes
    Variable Size             109053160 bytes
    Database Buffers           54525952 bytes
    Redo Buffers                2920448 bytes
    
    RMAN> restore controlfile from '/u01/app/oracle/oradata/test/control01.ctl';
    
    Starting restore at 2015-04-01 17:11:20
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: sid=155 devtype=DISK
    
    channel ORA_DISK_1: copied control file copy
    output filename=+DISK1/control01.ctl
    Finished restore at 2015-04-01 17:11:28
    
    
    RMAN> alter database mount;
    
    database mounted
    released channel: ORA_DISK_1
    
    RMAN> switch database to copy;
    
    datafile 1 switched to datafile copy "+DISK1/test/datafile/system.266.875894803"
    datafile 2 switched to datafile copy "+DISK1/test/datafile/undotbs1.263.875894899"
    datafile 3 switched to datafile copy "+DISK1/test/datafile/sysaux.267.875894845"
    datafile 4 switched to datafile copy "+DISK1/test/datafile/users.262.875894907"
    datafile 5 switched to datafile copy "+DISK1/test/datafile/example.265.875894871"
    datafile 6 switched to datafile copy "+DISK1/test/datafile/tspitr.264.875894885"
    datafile 7 switched to datafile copy "+DISK1/test/datafile/test.261.875894909"
    starting full resync of recovery catalog
    full resync complete
    
    RMAN> recover database;
    
    Starting recover at 2015-04-01 17:12:29
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: sid=155 devtype=DISK
    
    starting media recovery
    media recovery complete, elapsed time: 00:00:03
    
    Finished recover at 2015-04-01 17:12:33
    

    9.将临时文件迁移到ASM,必须为每个临时文件执行set newname命令,然后执行switch命令

    RMAN> run
    2> {
    3> set newname for tempfile '/u01/app/oracle/oradata/test/temp01.dbf' to '+DISK1';
    4>switch tempfile all;
    5> }
    
    executing command: SET NEWNAME
    
    renamed temporary file 1 to +DISK1 in control file
    starting full resync of recovery catalog
    full resync complete
    

    10.禁用闪回数据库并重新启动闪回数据库让闪回日志创建在ASM中

    SQL> alter database flashback off;
    
    Database altered.
    
    SQL> alter database flashback on;
    
    Database altered.
    

    11.改变跟踪文件不会被迁移。只能禁用改变跟踪再重新启用改变跟踪,并将改变跟踪文件存储在ASM中

    SQL> alter database disable block change tracking;
    
    Database altered.
    
    SQL> alter database enable block change tracking using file '+DISK1';
    
    Database altered.
    

    12.如果迁移的是主库,打开数据库

    SQL> alter database open;
    
    Database altered.
    

    如果是备库,恢复管理恢复模式

    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE;
    

    13.对于主库,要迁移联机重做日志文件是通过增加新的重做日志文件并存储在ASM中并删除旧的重做日志文件。对于备库,就是删除旧的备重做日志并增加新的备重做日志并存储在ASM中

    SQL> select * from v$log;
    
        GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS            FIRST_CHANGE# FIRST_TIME
    ---------- ---------- ---------- ---------- ---------- --- ----------------  ------------- ------------
             1          1         97   52428800          1 NO  CURRENT            1288360      01-APR-15
             2          1         95   52428800          1 YES INACTIVE           1226685      30-MAR-15
             3          1         96   52428800          1 YES INACTIVE           1268619      31-MAR-15
    
    SQL> alter database drop logfile group 2;
    
    Database altered.
    
    SQL> alter database add logfile group 2 '+DISK1/redo02.log' size 50M;
    
    Database altered.
    
    SQL> alter database drop logfile group 3;
    
    Database altered.
    
    SQL> alter database add logfile group 3 '+DISK1/redo03.log' size 50M;
    
    Database altered.
    
    SQL> alter system switch logfile;
    
    System altered.
    
    SQL> alter database drop logfile group 1;
    alter database drop logfile group 1
    *
    ERROR at line 1:
    ORA-01624: log 1 needed for crash recovery of instance test (thread 1)
    ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/test/redo01.log'
    
    
    SQL> alter database clear logfile group 1;
    
    Database altered.
    
    SQL> alter database drop logfile group 1;
    
    Database altered.
    
    SQL> alter database add logfile group 1 '+DISK1/redo01.log' size 50M;
    
    Database altered.
    
    

    将数据库从ASM中迁移到文件系统
    1.记录数据库迁移之前的数据文件,控制文件,联机重做日志文件的文件名

    SQL> select member,status from v$logfile;
    
    MEMBER                                                                           STATUS
    -------------------------------------------------------------------------------- -------
    +DISK1/redo03.log
    +DISK1/redo02.log
    +DISK1/redo01.log
    
    SQL> show parameter control_files
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    control_files                        string      +DISK1/control01.ctl
    
    SQL> select name,status from v$datafile;
    
    NAME                                                                             STATUS
    -------------------------------------------------------------------------------- -------
    +DISK1/test/datafile/system.266.875894803                                        SYSTEM
    +DISK1/test/datafile/undotbs1.263.875894899                                      ONLINE
    +DISK1/test/datafile/sysaux.267.875894845                                        ONLINE
    +DISK1/test/datafile/users.262.875894907                                         ONLINE
    +DISK1/test/datafile/example.265.875894871                                       ONLINE
    +DISK1/test/datafile/tspitr.264.875894885                                        ONLINE
    +DISK1/test/datafile/test.261.875894909                                          ONLINE
    
    7 rows selected
    
    

    2.将数据库文件作为副本备份到ASM磁盘组

    RMAN> backup as copy incremental level 0 database format '/u02/asm_backup/%U' tag 'NO_ASM_MIGRATION';
    
    Starting backup at 2015-04-01 20:47:32
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: sid=140 devtype=DISK
    channel ORA_DISK_1: starting datafile copy
    input datafile fno=00001 name=+DISK1/test/datafile/system.266.875894803
    output filename=/u02/asm_backup/data_D-TEST_I-2168949517_TS-SYSTEM_FNO-1_4rq3amf5 tag=NO_ASM_MIGRATION recid=46 stamp=875911696
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
    channel ORA_DISK_1: starting datafile copy
    input datafile fno=00003 name=+DISK1/test/datafile/sysaux.267.875894845
    output filename=/u02/asm_backup/data_D-TEST_I-2168949517_TS-SYSAUX_FNO-3_4sq3amgj tag=NO_ASM_MIGRATION recid=47 stamp=875911724
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
    channel ORA_DISK_1: starting datafile copy
    input datafile fno=00005 name=+DISK1/test/datafile/example.265.875894871
    output filename=/u02/asm_backup/data_D-TEST_I-2168949517_TS-EXAMPLE_FNO-5_4tq3amhm tag=NO_ASM_MIGRATION recid=48 stamp=875911742
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
    channel ORA_DISK_1: starting datafile copy
    input datafile fno=00006 name=+DISK1/test/datafile/tspitr.264.875894885
    output filename=/u02/asm_backup/data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_4uq3ami5 tag=NO_ASM_MIGRATION recid=49 stamp=875911756
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
    channel ORA_DISK_1: starting datafile copy
    input datafile fno=00002 name=+DISK1/test/datafile/undotbs1.263.875894899
    output filename=/u02/asm_backup/data_D-TEST_I-2168949517_TS-UNDOTBS1_FNO-2_4vq3amik tag=NO_ASM_MIGRATION recid=50 stamp=875911766
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
    channel ORA_DISK_1: starting datafile copy
    input datafile fno=00004 name=+DISK1/test/datafile/users.262.875894907
    output filename=/u02/asm_backup/data_D-TEST_I-2168949517_TS-USERS_FNO-4_50q3amin tag=NO_ASM_MIGRATION recid=51 stamp=875911768
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
    channel ORA_DISK_1: starting datafile copy
    input datafile fno=00007 name=+DISK1/test/datafile/test.261.875894909
    output filename=/u02/asm_backup/data_D-TEST_I-2168949517_TS-TEST_FNO-7_51q3amio tag=NO_ASM_MIGRATION recid=52 stamp=875911769
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
    Finished backup at 2015-04-01 20:49:29
    
    Starting Control File and SPFILE Autobackup at 2015-04-01 20:49:30
    piece handle=/u02/c-2168949517-20150401-16 comment=NONE
    Finished Control File and SPFILE Autobackup at 2015-04-01 20:49:34
    
    
    [oracle@oracle11g asm_backup]$ ls -lrt
    total 1014840
    -rw-r----- 1 oracle oinstall 482353152 Apr  1 20:48 data_D-TEST_I-2168949517_TS-SYSTEM_FNO-1_4rq3amf5
    -rw-r----- 1 oracle oinstall 293609472 Apr  1 20:48 data_D-TEST_I-2168949517_TS-SYSAUX_FNO-3_4sq3amgj
    -rw-r----- 1 oracle oinstall 104865792 Apr  1 20:49 data_D-TEST_I-2168949517_TS-EXAMPLE_FNO-5_4tq3amhm
    -rw-r----- 1 oracle oinstall 104865792 Apr  1 20:49 data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_4uq3ami5
    -rw-r----- 1 oracle oinstall  31465472 Apr  1 20:49 data_D-TEST_I-2168949517_TS-UNDOTBS1_FNO-2_4vq3amik
    -rw-r----- 1 oracle oinstall  10493952 Apr  1 20:49 data_D-TEST_I-2168949517_TS-USERS_FNO-4_50q3amin
    -rw-r----- 1 oracle oinstall  10493952 Apr  1 20:49 data_D-TEST_I-2168949517_TS-TEST_FNO-7_51q3amio
    

    为了确保数据库能执行一致性恢复,归档当前联机重做日

    RMAN> sql 'alter system archive log current';
    
    sql statement: alter system archive log current
    
    

    如果数据库很大在执行上面的备份时可能会要很长时间。如果在执行备份时有大量的数据库活动,可以对数据库生成一个增量备份在迁移之前将0级备份之后的改变刷新到0级备份所创建的副本中。

    RMAN> backup incremental level 1 for recover of copy with tag 'NO_ASM_MIGRATION' database;
    
    Starting backup at 2015-04-01 20:51:43
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting incremental level 1 datafile backupset
    channel ORA_DISK_1: specifying datafile(s) in backupset
    input datafile fno=00001 name=+DISK1/test/datafile/system.266.875894803
    input datafile fno=00003 name=+DISK1/test/datafile/sysaux.267.875894845
    input datafile fno=00005 name=+DISK1/test/datafile/example.265.875894871
    input datafile fno=00006 name=+DISK1/test/datafile/tspitr.264.875894885
    input datafile fno=00002 name=+DISK1/test/datafile/undotbs1.263.875894899
    input datafile fno=00004 name=+DISK1/test/datafile/users.262.875894907
    input datafile fno=00007 name=+DISK1/test/datafile/test.261.875894909
    channel ORA_DISK_1: starting piece 1 at 2015-04-01 20:51:44
    channel ORA_DISK_1: finished piece 1 at 2015-04-01 20:52:19
    piece handle=/u02/ora_test875911904_1631 tag=NO_ASM_MIGRATION comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
    Finished backup at 2015-04-01 20:52:19
    
    Starting Control File and SPFILE Autobackup at 2015-04-01 20:52:19
    piece handle=/u02/c-2168949517-20150401-17 comment=NONE
    Finished Control File and SPFILE Autobackup at 2015-04-01 20:52:23
    
    
    RMAN> recover copy of database with tag 'NO_ASM_MIGRATION';
    
    Starting recover at 2015-04-01 20:52:57
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting incremental datafile backupset restore
    channel ORA_DISK_1: specifying datafile copies to recover
    recovering datafile copy fno=00001 name=/u02/asm_backup/data_D-TEST_I-2168949517_TS-SYSTEM_FNO-1_4rq3amf5
    recovering datafile copy fno=00002 name=/u02/asm_backup/data_D-TEST_I-2168949517_TS-UNDOTBS1_FNO-2_4vq3amik
    recovering datafile copy fno=00003 name=/u02/asm_backup/data_D-TEST_I-2168949517_TS-SYSAUX_FNO-3_4sq3amgj
    recovering datafile copy fno=00004 name=/u02/asm_backup/data_D-TEST_I-2168949517_TS-USERS_FNO-4_50q3amin
    recovering datafile copy fno=00005 name=/u02/asm_backup/data_D-TEST_I-2168949517_TS-EXAMPLE_FNO-5_4tq3amhm
    recovering datafile copy fno=00006 name=/u02/asm_backup/data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_4uq3ami5
    recovering datafile copy fno=00007 name=/u02/asm_backup/data_D-TEST_I-2168949517_TS-TEST_FNO-7_51q3amio
    channel ORA_DISK_1: reading from backup piece /u02/ora_test875911904_1631
    channel ORA_DISK_1: restored backup piece 1
    piece handle=/u02/ora_test875911904_1631 tag=NO_ASM_MIGRATION
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
    Finished recover at 2015-04-01 20:53:00
    
    Starting Control File and SPFILE Autobackup at 2015-04-01 20:53:00
    piece handle=/u02/c-2168949517-20150401-18 comment=NONE
    Finished Control File and SPFILE Autobackup at 2015-04-01 20:53:04
    
    

    3.在/u02/asm_backup目录中创建一个SPFILE文件副本。将要迁移的数据库SPFILE文件存储为
    /u02/asm_backup/spfiletest.ora如果数据库是使用的SPFILE启动,就执行以下命令:

    RMAN> run
    2> {
    3> backup as backupset spfile;
    4> restore spfile to '/u02/asm_backup/spfiletest.ora';
    5> }
    
    Starting backup at 2015-04-01 20:55:31
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting full datafile backupset
    channel ORA_DISK_1: specifying datafile(s) in backupset
    including current SPFILE in backupset
    channel ORA_DISK_1: starting piece 1 at 2015-04-01 20:55:32
    channel ORA_DISK_1: finished piece 1 at 2015-04-01 20:55:33
    piece handle=/u02/ora_test875912132_1661 tag=TAG20150401T205531 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 2015-04-01 20:55:33
    
    Starting Control File and SPFILE Autobackup at 2015-04-01 20:55:33
    piece handle=/u02/c-2168949517-20150401-19 comment=NONE
    Finished Control File and SPFILE Autobackup at 2015-04-01 20:55:36
    
    Starting restore at 2015-04-01 20:55:38
    using channel ORA_DISK_1
    
    channel ORA_DISK_1: starting datafile backupset restore
    channel ORA_DISK_1: restoring SPFILE
    output filename=/u02/asm_backup/spfiletest.ora
    channel ORA_DISK_1: reading from backup piece /u02/c-2168949517-20150401-19
    channel ORA_DISK_1: restored backup piece 1
    piece handle=/u02/c-2168949517-20150401-19 tag=TAG20150401T205533
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
    Finished restore at 2015-04-01 20:55:39
    
    [oracle@oracle11g asm_backup]$ ls -lrt
    total 1014844
    -rw-r----- 1 oracle oinstall  10493952 Apr  1 20:52 data_D-TEST_I-2168949517_TS-USERS_FNO-4_50q3amin
    -rw-r----- 1 oracle oinstall  31465472 Apr  1 20:52 data_D-TEST_I-2168949517_TS-UNDOTBS1_FNO-2_4vq3amik
    -rw-r----- 1 oracle oinstall 104865792 Apr  1 20:52 data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_4uq3ami5
    -rw-r----- 1 oracle oinstall  10493952 Apr  1 20:52 data_D-TEST_I-2168949517_TS-TEST_FNO-7_51q3amio
    -rw-r----- 1 oracle oinstall 482353152 Apr  1 20:52 data_D-TEST_I-2168949517_TS-SYSTEM_FNO-1_4rq3amf5
    -rw-r----- 1 oracle oinstall 293609472 Apr  1 20:52 data_D-TEST_I-2168949517_TS-SYSAUX_FNO-3_4sq3amgj
    -rw-r----- 1 oracle oinstall 104865792 Apr  1 20:52 data_D-TEST_I-2168949517_TS-EXAMPLE_FNO-5_4tq3amhm
    -rw-r----- 1 oracle oinstall      2560 Apr  1 20:55 spfiletest.ora
    
    

    如果数据库是使用PFILE启动,可以在SQL*Plus中执行create spfile命令来创建SPFILE

    SQL>create spfile='/u02/asm_backup/spfiletest.ora' from pfile='+DISK1/inittest.ora'
    
    File created.
    
    

    4.如果被迁移的数据库是备库,需要停止管理恢复模式

    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
    

    执行一致性关闭

    RMAN> SHUTDOWN IMMEDIATE;
    
    

    5.在目录/u02/asm_backup中创建一个 pfile参数文件来引用新的SPFILE文件,并重新启动实例到nomount状态。

    [oracle@oracle11g asm_backup]$ vi inittest_temp.ora
    spfile='/u02/asm_backup/spfiletest.ora'
    
    
    SQL> shutdown immediate
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    
    
    
    SQL> startup nomount pfile='/u02/asm_backup/inittest_temp.ora'
    ORACLE instance started.
    
    Total System Global Area  167772160 bytes
    Fixed Size                  1272600 bytes
    Variable Size             109053160 bytes
    Database Buffers           54525952 bytes
    Redo Buffers                2920448 bytes
    

    6.为了下一步将控制文件迁移到文件系统中,修改control_files参数:

    SQL> alter system set control_files='/u02/asm_backup/control01.ctl' scope=spfile;
    
    System altered.
    

    7.通过设置db_recovery_file_dest和db_recovery_file_dest_size来指定闪回区,这里闪回区大小设置为2G(因为这里只是进行迁移测试实验)

    SQL> alter system set db_recovery_file_dest_size=2G;
    
    System altered.
    
    SQL> alter system set db_recovery_file_dest='/u01/app/oracle/oradata/flash_recovery_area' scope=spfile;
    
    System altered.
    
    

    8.将实例重新启动到nomount状态,使用RMAN在文件系统中创建新的控制文件(使用原来控制文件来创建),切换数据文件,并执执恢复

    SQL> shutdown immediate
    ORA-01507: database not mounted
    
    
    ORACLE instance shut down.
    SSQL> startup nomount pfile='/u02/asm_backup/inittest_temp.ora'
    ORACLE instance started.
    
    Total System Global Area  167772160 bytes
    Fixed Size                  1272600 bytes
    Variable Size             109053160 bytes
    Database Buffers           54525952 bytes
    Redo Buffers                2920448 bytes
    
    RMAN> restore controlfile from '+DISK1/control01.ctl';
    
    Starting restore at 2015-04-01 21:17:54
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: sid=155 devtype=DISK
    
    channel ORA_DISK_1: copied control file copy
    output filename=/u02/asm_backup/control01.ctl
    Finished restore at 2015-04-01 21:18:04
    
    
    
    
    RMAN> alter database mount;
    
    database mounted
    released channel: ORA_DISK_1
    
    RMAN> switch database to copy;
    
    datafile 1 switched to datafile copy "/u02/asm_backup/data_D-TEST_I-2168949517_TS-SYSTEM_FNO-1_4rq3amf5"
    datafile 2 switched to datafile copy "/u02/asm_backup/data_D-TEST_I-2168949517_TS-UNDOTBS1_FNO-2_4vq3amik"
    datafile 3 switched to datafile copy "/u02/asm_backup/data_D-TEST_I-2168949517_TS-SYSAUX_FNO-3_4sq3amgj"
    datafile 4 switched to datafile copy "/u02/asm_backup/data_D-TEST_I-2168949517_TS-USERS_FNO-4_50q3amin"
    datafile 5 switched to datafile copy "/u02/asm_backup/data_D-TEST_I-2168949517_TS-EXAMPLE_FNO-5_4tq3amhm"
    datafile 6 switched to datafile copy "/u02/asm_backup/data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_4uq3ami5"
    datafile 7 switched to datafile copy "/u02/asm_backup/data_D-TEST_I-2168949517_TS-TEST_FNO-7_51q3amio"
    starting full resync of recovery catalog
    full resync complete
    
    RMAN> recover database;
    
    Starting recover at 2015-04-01 21:18:38
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: sid=155 devtype=DISK
    
    starting media recovery
    media recovery complete, elapsed time: 00:00:02
    
    Finished recover at 2015-04-01 21:18:41
    

    8.将临时文件迁移到ASM,必须为每个临时文件执行set newname命令,然后执行switch命令

    RMAN> run
    2> {
    3> set newname for tempfile '+DISK1/TEST/TEMPFILE/TEMP.256.875908789' to '/u02/asm_backup/temp01.dbf';
    4> switch tempfile all;
    5> }
    
    executing command: SET NEWNAME
    
    renamed temporary file 1 to /u02/asm_backup/temp01.dbf in control file
    starting full resync of recovery catalog
    full resync complete
    
    

    9.禁用闪回数据库并重新启动闪回数据库让闪回日志创建在ASM中

    SQL> alter database flashback off;
    
    Database altered.
    
    SQL> alter database flashback on;
    
    Database altered.
    
    
    

    10.如果迁移的是主库,打开数据库

    SQL> alter database open;
    
    Database altered.
    

    如果是备库,恢复管理恢复模式

    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE;
    
    11.对于主库,要迁移联机重做日志文件是通过增加新的重做日志文件并存储在文件系统中并删除旧的重做日志文件。对于备库,就是删除旧的备重做日志并增加新的备重做日志并存储在文件系统中。
    
    SQL> select * from v$log;
    
        GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARCHIVED STATUS           FIRST_CHANGE# FIRST_TIME
    ---------- ---------- ---------- ---------- ---------- -------- ---------------- ------------- -----------
             1          1         99   52428800          1 NO       CURRENT                1292113 2015/4/1 20
             2          1         98   52428800          1 YES      INACTIVE               1290567 2015/4/1 20
             3          1          0   52428800          1 YES      UNUSED                       0
    
    
    SQL> alter database drop logfile group 2;
    
    Database altered.
    
    SQL> alter database add logfile group 2 '/u02/asm_backup/redo02.log' size 50M;
    
    Database altered.
    
    SQL> alter database drop logfile group 3;
    
    Database altered.
    
    SQL> alter database add logfile group 3 '/u02/asm_backup/redo03.log' size 50M;
    
    Database altered.
    
    SQL> alter system switch logfile;
    
    System altered.
    
    
    SQL> alter database drop logfile group 1;
    alter database drop logfile group 1
    *
    ERROR at line 1:
    ORA-01623: log 1 is current log for instance test (thread 1) - cannot drop
    ORA-00312: online log 1 thread 1: '+DISK1/redo01.log'
    
    SQL> alter database clear logfile group 1;
    
    Database altered.
    
    SQL> alter database drop logfile group 1;
    
    Database altered.
    
    SQL> alter database add logfile group 1 '/u02/asm_backup/redo01.log' size 50M;
    
    Database altered.

    来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26015009/viewspace-1482364/,如需转载,请注明出处,否则将追究法律责任。

    转载于:http://blog.itpub.net/26015009/viewspace-1482364/

    展开全文
  • Linux为我们提供了两个用于文件copy的命令,一个是cp,一个是scp,但是他们略有不同,cp 主要是用于在同一台电脑上,在不同的目录之间来回copy文件 scp 主要是在不同的Linux系统之间来回copy文件。scp即security ...
  • 在 Linux 系统中,大多数命令从来都是信奉“沉默是金”的准则,所以当我们利用 cp 复制文件的时候并不能看到所谓的进度条。如果你在意这一点,那么不妨来用用 cv。 cv 是 Coreutils Viewer,它能够显示传输...
  • 一、把数据库从asm迁移到文件系统 数据库版本是:Oracle Database 11g Enterprise ...shutdown数据库之后,在asmcmd中利用cp命令复制出参数文件: ASMCMD> cp '+DG/orcl/parameterfile/spfile.265.791417205'
  • 文件或目录配置了ACL后,如果使用cp命令复制时要保留ACL必须使用“-p”选项,如果使用mv命令移动时默认就会保留ACL。当然前题是目标目录所有分区支持ACL功能。下面看几个setfacl命令的例子。 (1) 配置用户ACL。 ...
  • linux文件拷贝

    2020-11-25 15:23:01
    第三种:利用scp命令来进行文件复制。 介绍 scp是secure copy的简写,是linux系统下基于ssh登陆进行安全的远程文件拷贝命令。linux的scp命令可以在linux服务器之间复制文件和目录。和它类似的命令cp,不过
  • 这篇,继续来学习docker命令,上面一篇介绍到了如何通过容器,利用commit命令来制作镜像文件,再次强调,这种方式不推荐。...这个复制文件命令是在容器里面和本地系统进行文件拷贝。 还是上一篇环境,通过do...
  • 在 Linux 系统中 , 大多数命令从来都是信奉 “ 沉默是金 ” 的准则 , 所以当我们利用 cp 复制文件的时候并不能看到所谓的进度条 。 如果你在意这一点 , 那么不妨来用用 cv。 cv 是 Coreutils Viewer, 它能够...
  • 入门学习Linux常用必会60个命令实例详解doc/txt

    千次下载 热门讨论 2011-06-09 00:08:45
    Linux提供了大量的命令利用它可以有效地完成大量的工作,如磁盘操作、文件存取、目录操作、进程管理、文件权限设定等。所以,在Linux系统上工作离不开使用系统提供的命令。要想真正理解Linux系统,就必须从Linux...
  • 一个是cp,一个是scp,可是他们略有不同,cp 主要是用于在同一台电脑上,在不同的文件夹之间来回copy文件 scp 主要是在不同的Linux系统之间来回copy文件。scp即security cp,带有安全性的复制。 在两台linux机...
  • 其实无论windows还是Linux,简单地去实现两个两个文件夹的同步只需系统自带的复制命令加参数就可以了。 WINDOWS : xcopy 源文件夹\* 目标文件夹 /s /e /y Linux : cp -r 源文件夹/* 目标文件夹 ...
  • 可以使用DEFINE命令设置系统变量EDITOR来改变文本编辑器的类型,在login.sql文件中定义如下一行 DEFINE_EDITOR=vi f、运行命令文件 SQL>START test SQL>@test 常用SQL*Plus语句 a、表的创建、修改、删除 创建表的...
  • 需要修改的配置文件:grub.cfg 获取root权限,并进入/boot/grub文件夹: sudo su ...在tmp中去除(或注释)掉多余引导项,保存并用cat命令更新配置文件 利用gedit或vim打开: vim tmp ### menuent...
  • 一.Linux的文件系统结构.....................................................................................................6 二. 文件类型................................................................
  • 其实无论windows还是Linux,简单地去实现两个两个文件夹的同步只需系统自带的复制命令加参数就可以了。WINDOWS :xcopy 源文件夹\* 目标文件夹 /s /e /yLinux :cp -r 源文件夹/* 目标文件夹这里使用python来实现...
  • cve-2015-3306复现

    2019-04-02 16:26:12
    任何未经身份验证的客户端都可以利用这些命令文件文件系统的任何部分复制到选定的目标。 复制命令使用ProFTPD服务的权限执行,默认情况下,该服务在“nobody”用户的权限下运行。 通过使用/ proc / self / ...
  • 在 Linux 系统中,利用()命令可以分页显示文件的内容。 A. list B. cat C. more D. cp ---------------------------------------- 答案: C 解析: 在 Linux 系统中,cat 命令用来在屏幕上滚动显示文件内容; more...
  • linux备份与恢复文档

    千次阅读 2018-10-18 18:07:52
    在Linux中,最简单的文件和目录备份工具就是“cp复制命令。但需要备份文件很多的时候,紧紧用cp显得力不从心了,备份出来的文件数量及其所占用的磁盘空间可能都会对服务器产生不小的压力。因此,有必要对需要备份...
  • Oracle ASM

    2013-11-12 10:56:37
    asmcmd命令是否只在11g中可用说明cd改变目录到指定目录cp是在ASM磁盘组之间复制文件,既可以在相同实例中复制,也可以在远程实例中复制du循环显示当前目录和所有子目录的总体磁盘利用率exit终止asmcmd,并返回到操作...
  • 有一种情况,系统里连vi编辑器都没有,比如在docker容器里,此时你可以利用重定向,sed命令来变向达到一些文件修改功能,如果情况复杂,你还可以利用docker cp这样的命令来把宿主机上的文件复制到容器里去 ...
  • 2.21 sed指令:利用script命令处理文本文件 2.22 sort指令:将文本文件内容加以排序 2.23 spell指令:拼字检查程序 2.24 tr指令:转换文件中的字符 2.25 uniq指令:检查文件中重复出现的行 2.26 vi指令:文字编辑器 ...
  • 312.无法复制文件到软盘 1.10 键盘与鼠标故障 1.10.1 键盘故障 313.启动时提示键盘错误 314.键盘接口出现故障 315.关机后键盘上的指示灯还在亮 316.键盘按键不灵 317.玩游戏导致按键失效 318.按键按下后弹不回来 319...

空空如也

空空如也

1 2
收藏数 34
精华内容 13
关键字:

利用cp命令复制系统文件