• Oracle 联机日志文件及归档文件


    管理联机日志文件:

    联机日志文件以组为单位工作

    数据库正常工作至少需要2组日志

    联机日志记录所有数据块的变化,用来做实例recover

    同一组下的成员之间是镜像关系

    more情况日志成员写满redo时发生切换

    日志切换时优先覆盖sequence#最小的组

    成员的位置和数量,由控制文件中的指针决定

    查看日志组的工作状态:

    select * from v$log;

    1. SQL> set pagesize 200
    2. SQL> set linesize 200
    3. SQL>
    4. SQL> select * from v$log;
    5. GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME CON_ID
    6. ---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ --------- ----------
    7. 1 1 49 52428800 512 1 NO INACTIVE 17377140 20-NOV-22 17377187 20-NOV-22 0
    8. 2 1 50 52428800 512 1 NO INACTIVE 17377187 20-NOV-22 17401476 20-NOV-22 0
    9. 3 1 51 52428800 512 1 NO CURRENT 17401476 20-NOV-22 1.8447E+19 0
    10. SQL> col NEXT_CHANGE# for 999999999999999999999999999999999
    11. SQL> select * from v$log;
    12. GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME CON_ID
    13. ---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ---------------------------------- --------- ----------
    14. 1 1 49 52428800 512 1 NO INACTIVE 17377140 20-NOV-22 17377187 20-NOV-22 0
    15. 2 1 50 52428800 512 1 NO INACTIVE 17377187 20-NOV-22 17401476 20-NOV-22 0
    16. 3 1 51 52428800 512 1 NO CURRENT 17401476 20-NOV-22 18446744073709551615 0
    17. SQL>

    查看日志的物理信息:

    select * from v$logfile;
    
    1. SQL>
    2. SQL> select * from v$logfile;
    3. GROUP# STATUS TYPE
    4. ---------- ------- -------
    5. MEMBER
    6. --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    7. IS_ CON_ID
    8. --- ----------
    9. 3 ONLINE
    10. /u02/oradata/CDB1/redo03.log
    11. NO 0
    12. 2 ONLINE
    13. /u02/oradata/CDB1/redo02.log
    14. NO 0
    15. 1 ONLINE
    16. /u02/oradata/CDB1/redo01.log
    17. NO 0
    18. SQL>

    手工切换日志:

    alter system switch logfile;

    手工产生检查点:

    alter system checkpoint;

    Scott/tiger 脚本在系统:

    [oracle@oracle-db-19c admin]$ pwd
    /u01/app/oracle/product/19.3.0/dbhome_1/rdbms/admin
    [oracle@oracle-db-19c admin]$ ls -ltr utlsampl.sql
    -rw-r--r--. 1 oracle oinstall 3978 May 29  2017 utlsampl.sql
    [oracle@oracle-db-19c admin]$

    日志切换的历史:

    1. SQL>
    2. SQL> select * from v$log_history;
    3. RECID STAMP THREAD# SEQUENCE# FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# RESETLOGS_CHANGE# RESETLOGS CON_ID
    4. ---------- ---------- ---------- ---------- ------------- --------- ------------ ----------------- --------- ----------
    5. 1 1119712290 1 1 1920977 02-NOV-22 1944454 1920977 02-NOV-22 0
    6. 2 1119712328 1 2 1944454 02-NOV-22 1955924 1920977 02-NOV-22 0
    7. 3 1119712336 1 3 1955924 02-NOV-22 1957140 1920977 02-NOV-22 0
    8. 4 1119712346 1 4 1957140 02-NOV-22 1958419 1920977 02-NOV-22 0
    9. 5 1119712357 1 5 1958419 02-NOV-22 1959722 1920977 02-NOV-22 0
    10. 6 1119712367 1 6 1959722 02-NOV-22 1961083 1920977 02-NOV-22 0
    11. 7 1119712377 1 7 1961083 02-NOV-22 1962537 1920977 02-NOV-22 0
    12. 8 1119712388 1 8 1962537 02-NOV-22 1964005 1920977 02-NOV-22 0
    13. 9 1119712397 1 9 1964005 02-NOV-22 1965452 1920977 02-NOV-22 0
    14. 10 1119712406 1 10 1965452 02-NOV-22 1966859 1920977 02-NOV-22 0
    15. 11 1119712428 1 11 1966859 02-NOV-22 1970703 1920977 02-NOV-22 0
    16. 12 1119712448 1 12 1970703 02-NOV-22 1974659 1920977 02-NOV-22 0
    17. 13 1119712501 1 13 1974659 02-NOV-22 2003600 1920977 02-NOV-22 0
    18. 14 1119712743 1 14 2003600 02-NOV-22 2017766 1920977 02-NOV-22 0
    19. 15 1119712747 1 15 2017766 02-NOV-22 2017835 1920977 02-NOV-22 0
    20. 16 1119712771 1 16 2017835 02-NOV-22 2026749 1920977 02-NOV-22 0
    21. 17 1119712794 1 17 2026749 02-NOV-22 2030586 1920977 02-NOV-22 0
    22. 18 1119712849 1 18 2030586 02-NOV-22 2049115 1920977 02-NOV-22 0
    23. 19 1119713144 1 19 2049115 02-NOV-22 2088868 1920977 02-NOV-22 0
    24. 20 1119713229 1 20 2088868 02-NOV-22 2100727 1920977 02-NOV-22 0
    25. 21 1119713288 1 21 2100727 02-NOV-22 2139342 1920977 02-NOV-22 0
    26. 22 1119713358 1 22 2139342 02-NOV-22 2146949 1920977 02-NOV-22 0
    27. 23 1119713375 1 23 2146949 02-NOV-22 2150697 1920977 02-NOV-22 0
    28. 24 1119713427 1 24 2150697 02-NOV-22 2153047 1920977 02-NOV-22 0
    29. 25 1119713571 1 25 2153047 02-NOV-22 2163312 1920977 02-NOV-22 0
    30. 26 1119713996 1 26 2163312 02-NOV-22 2264654 1920977 02-NOV-22 0
    31. 27 1120428105 1 27 2264654 02-NOV-22 2282920 1920977 02-NOV-22 0
    32. 28 1120428219 1 28 2282920 10-NOV-22 2300480 1920977 02-NOV-22 0
    33. 29 1120428255 1 29 2300480 10-NOV-22 2318708 1920977 02-NOV-22 0
    34. 30 1120831239 1 30 2318708 10-NOV-22 2347108 1920977 02-NOV-22 0
    35. 31 1120831269 1 31 2347108 15-NOV-22 2366475 1920977 02-NOV-22 0
    36. 32 1120850877 1 32 2366475 15-NOV-22 2397054 1920977 02-NOV-22 0
    37. 33 1120917613 1 33 2397054 15-NOV-22 2425816 1920977 02-NOV-22 0
    38. 34 1120938664 1 34 2425816 16-NOV-22 2465509 1920977 02-NOV-22 0
    39. 35 1120980380 1 35 2465509 16-NOV-22 2575796 1920977 02-NOV-22 0
    40. 36 1121000407 1 36 2575796 17-NOV-22 2601035 1920977 02-NOV-22 0
    41. 37 1121014857 1 37 2601035 17-NOV-22 2629640 1920977 02-NOV-22 0
    42. 38 1121086814 1 38 2629640 17-NOV-22 2668852 1920977 02-NOV-22 0
    43. 39 1121089000 1 39 2668852 18-NOV-22 2771290 1920977 02-NOV-22 0
    44. 40 1121102371 1 40 2771290 18-NOV-22 17019560 1920977 02-NOV-22 0
    45. 41 1121161284 1 41 17019560 18-NOV-22 17140444 1920977 02-NOV-22 0
    46. 42 1121161517 1 42 17140444 19-NOV-22 17156193 1920977 02-NOV-22 0
    47. 43 1121164942 1 43 17156193 19-NOV-22 17277271 1920977 02-NOV-22 0
    48. 44 1121180422 1 44 17277271 19-NOV-22 17311973 1920977 02-NOV-22 0
    49. 45 1121249328 1 45 17311973 19-NOV-22 17337542 1920977 02-NOV-22 0
    50. 46 1121250083 1 46 17337542 20-NOV-22 17351079 1920977 02-NOV-22 0
    51. 47 1121263201 1 47 17351079 20-NOV-22 17377098 1920977 02-NOV-22 0
    52. 48 1121263201 1 48 17377098 20-NOV-22 17377140 1920977 02-NOV-22 0
    53. 49 1121263203 1 49 17377140 20-NOV-22 17377187 1920977 02-NOV-22 0
    54. 50 1121281218 1 50 17377187 20-NOV-22 17401476 1920977 02-NOV-22 0
    55. 51 1121349638 1 51 17401476 20-NOV-22 17441850 1920977 02-NOV-22 0
    56. 51 rows selected.
    57. SQL>

    监控日志切换频率:

    select to_char(FIRST_TIME,'yyyymmddhh24') FIRST_TIME,count(*) from v$log_history group by to_char(FIRST_TIME,'yyyymmddhh24') order by 1;

    放大logfile成员的尺寸:

    1. alter database add logfile '/u02/oradata/CDB1/redo04.log' size 100M;
    2. alter database add logfile '/u02/oradata/CDB1/redo05.log' size 100M;
    1. [oracle@oracle-db-19c admin]$ sqlplus / as sysdba
    2. SQL*Plus: Release 19.0.0.0.0 - Production on Mon Nov 21 14:35:04 2022
    3. Version 19.3.0.0.0
    4. Copyright (c) 1982, 2019, Oracle. All rights reserved.
    5. Connected to:
    6. Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
    7. Version 19.3.0.0.0
    8. SQL> set pagesize 200
    9. SQL> set linesize 200
    10. SQL>
    11. SQL> column STATUS for a15
    12. SQL> column TYPE for a15
    13. SQL> column MEMBER for a30
    14. SQL> select * from v$logfile;
    15. GROUP# STATUS TYPE MEMBER IS_ CON_ID
    16. ---------- --------------- --------------- ------------------------------ --- ----------
    17. 3 ONLINE /u02/oradata/CDB1/redo03.log NO 0
    18. 2 ONLINE /u02/oradata/CDB1/redo02.log NO 0
    19. 1 ONLINE /u02/oradata/CDB1/redo01.log NO 0
    20. SQL> alter database add logfile '/u02/oradata/CDB1/redo04.log' size 100m;
    21. Database altered.
    22. SQL> alter database add logfile '/u02/oradata/CDB1/redo05.log' size 100m;
    23. Database altered.
    24. SQL> select * from v$logfile;
    25. GROUP# STATUS TYPE MEMBER IS_ CON_ID
    26. ---------- --------------- --------------- ------------------------------ --- ----------
    27. 3 ONLINE /u02/oradata/CDB1/redo03.log NO 0
    28. 2 ONLINE /u02/oradata/CDB1/redo02.log NO 0
    29. 1 ONLINE /u02/oradata/CDB1/redo01.log NO 0
    30. 4 ONLINE /u02/oradata/CDB1/redo04.log NO 0
    31. 5 ONLINE /u02/oradata/CDB1/redo05.log NO 0
    32. SQL> select * from v$log;
    33. GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME CON_ID
    34. ---------- ---------- ---------- ---------- ---------- ---------- --- --------------- ------------- --------- ------------ --------- ----------
    35. 1 1 52 52428800 512 1 NO CURRENT 17441850 21-NOV-22 1.8447E+19 0
    36. 2 1 50 52428800 512 1 NO INACTIVE 17377187 20-NOV-22 17401476 20-NOV-22 0
    37. 3 1 51 52428800 512 1 NO INACTIVE 17401476 20-NOV-22 17441850 21-NOV-22 0
    38. 4 1 0 104857600 512 1 YES UNUSED 0 0 0
    39. 5 1 0 104857600 512 1 YES UNUSED 0 0 0
    40. SQL> alter system switch logfile;
    41. System altered.
    42. SQL> select * from v$log;
    43. GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME CON_ID
    44. ---------- ---------- ---------- ---------- ---------- ---------- --- --------------- ------------- --------- ------------ --------- ----------
    45. 1 1 52 52428800 512 1 NO ACTIVE 17441850 21-NOV-22 17444860 21-NOV-22 0
    46. 2 1 50 52428800 512 1 NO INACTIVE 17377187 20-NOV-22 17401476 20-NOV-22 0
    47. 3 1 51 52428800 512 1 NO INACTIVE 17401476 20-NOV-22 17441850 21-NOV-22 0
    48. 4 1 53 104857600 512 1 NO CURRENT 17444860 21-NOV-22 1.8447E+19 0
    49. 5 1 0 104857600 512 1 YES UNUSED 0 0 0
    50. SQL> alter system checkpoint;
    51. System altered.
    52. SQL> select * from v$log;
    53. GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME CON_ID
    54. ---------- ---------- ---------- ---------- ---------- ---------- --- --------------- ------------- --------- ------------ --------- ----------
    55. 1 1 52 52428800 512 1 NO INACTIVE 17441850 21-NOV-22 17444860 21-NOV-22 0
    56. 2 1 50 52428800 512 1 NO INACTIVE 17377187 20-NOV-22 17401476 20-NOV-22 0
    57. 3 1 51 52428800 512 1 NO INACTIVE 17401476 20-NOV-22 17441850 21-NOV-22 0
    58. 4 1 53 104857600 512 1 NO CURRENT 17444860 21-NOV-22 1.8447E+19 0
    59. 5 1 0 104857600 512 1 YES UNUSED 0 0 0
    60. SQL> alter database drop logfile group 1;
    61. Database altered.
    62. SQL> alter database drop logfile group 2;
    63. Database altered.
    64. SQL> alter database drop logfile group 3;
    65. Database altered.
    66. SQL> select * from v$log;
    67. GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME CON_ID
    68. ---------- ---------- ---------- ---------- ---------- ---------- --- --------------- ------------- --------- ------------ --------- ----------
    69. 4 1 53 104857600 512 1 NO CURRENT 17444860 21-NOV-22 1.8447E+19 0
    70. 5 1 0 104857600 512 1 YES UNUSED 0 0 0
    71. SQL> show con_name;
    72. CON_NAME
    73. ------------------------------
    74. CDB$ROOT
    75. SQL>

    删除无用组:

    1. alter database drop logfile group 1;
    2. alter database drop logfile group 2;
    3. alter database drop logfile group 3;

    移动日志文件

    1.数据库要mount

    1. shutdown immediate
    2. startup mount

    2.目标文件要存在

    mv /u02/oradata/CDB1/redo04.log /home/oracle/redo04.log

    3.修改控制文件中的指针

    alter database rename file '/u02/oradata/CDB1/redo04.log' to '/home/oracle/redo04.log';

    4.打开数据库

    alter database open;

    日志文件的多路复用:在同一组下使用多个成员,每组当中只由一个成员可用,数据库就可以正常工作。
     

    1. alter database add logfile member '/u02/oradata/CDB1/redo04a.log' to group 4;
    2. alter database add logfile member '/u02/oradata/CDB1/redo05a.log' to group 5;

    1. SQL> select * from v$log;
    2. GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME CON_ID
    3. ---------- ---------- ---------- ---------- ---------- ---------- --- --------------- ------------- --------- ------------ --------- ----------
    4. 4 1 53 104857600 512 1 NO CURRENT 17444860 21-NOV-22 1.8447E+19 0
    5. 5 1 0 104857600 512 1 YES UNUSED 0 0 0
    6. SQL> select * from v$logfile;
    7. GROUP# STATUS TYPE MEMBER IS_ CON_ID
    8. ---------- --------------- --------------- ------------------------------ --- ----------
    9. 4 ONLINE /u02/oradata/CDB1/redo04.log NO 0
    10. 5 ONLINE /u02/oradata/CDB1/redo05.log NO 0
    11. SQL> alter database add logfile '/u02/oradata/CDB1/redo06.log' size 100m;
    12. Database altered.
    13. SQL> select * from v$log;
    14. GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME CON_ID
    15. ---------- ---------- ---------- ---------- ---------- ---------- --- --------------- ------------- --------- ------------ --------- ----------
    16. 1 1 0 104857600 512 1 YES UNUSED 0 0 0
    17. 4 1 53 104857600 512 1 NO CURRENT 17444860 21-NOV-22 1.8447E+19 0
    18. 5 1 0 104857600 512 1 YES UNUSED 0 0 0
    19. SQL> select * from v$logfile;
    20. GROUP# STATUS TYPE MEMBER IS_ CON_ID
    21. ---------- --------------- --------------- ------------------------------ --- ----------
    22. 1 ONLINE /u02/oradata/CDB1/redo06.log NO 0
    23. 4 ONLINE /u02/oradata/CDB1/redo04.log NO 0
    24. 5 ONLINE /u02/oradata/CDB1/redo05.log NO 0
    25. SQL>
    26. SQL> alter database add logfile member '/u02/oradata/CDB1/redo01.log' to group 1;
    27. Database altered.
    28. SQL> select * from v$logfile;
    29. GROUP# STATUS TYPE MEMBER IS_ CON_ID
    30. ---------- --------------- --------------- ------------------------------ --- ----------
    31. 1 ONLINE /u02/oradata/CDB1/redo06.log NO 0
    32. 1 INVALID ONLINE /u02/oradata/CDB1/redo01.log NO 0
    33. 4 ONLINE /u02/oradata/CDB1/redo04.log NO 0
    34. 5 ONLINE /u02/oradata/CDB1/redo05.log NO 0
    35. SQL>
    36. SQL> select * from v$log;
    37. GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME CON_ID
    38. ---------- ---------- ---------- ---------- ---------- ---------- --- --------------- ------------- --------- ------------ --------- ----------
    39. 1 1 0 104857600 512 2 YES UNUSED 0 0 0
    40. 4 1 53 104857600 512 1 NO CURRENT 17444860 21-NOV-22 1.8447E+19 0
    41. 5 1 0 104857600 512 1 YES UNUSED 0 0 0
    42. SQL> alter database add logfile member '/u02/oradata/CDB1/redo04b.log' to group 4,'/u02/oradata/CDB1/redo05b.log' to group 5;
    43. Database altered.
    44. SQL> select * from v$log;
    45. GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME CON_ID
    46. ---------- ---------- ---------- ---------- ---------- ---------- --- --------------- ------------- --------- ------------ --------- ----------
    47. 1 1 0 104857600 512 2 YES UNUSED 0 0 0
    48. 4 1 53 104857600 512 2 NO CURRENT 17444860 21-NOV-22 1.8447E+19 0
    49. 5 1 0 104857600 512 2 YES UNUSED 0 0 0
    50. SQL> select * from v$logfile;
    51. GROUP# STATUS TYPE MEMBER IS_ CON_ID
    52. ---------- --------------- --------------- ------------------------------ --- ----------
    53. 1 ONLINE /u02/oradata/CDB1/redo06.log NO 0
    54. 1 INVALID ONLINE /u02/oradata/CDB1/redo01.log NO 0
    55. 4 INVALID ONLINE /u02/oradata/CDB1/redo04b.log NO 0
    56. 4 ONLINE /u02/oradata/CDB1/redo04.log NO 0
    57. 5 ONLINE /u02/oradata/CDB1/redo05.log NO 0
    58. 5 INVALID ONLINE /u02/oradata/CDB1/redo05b.log NO 0
    59. 6 rows selected.
    60. SQL> alter system switch logfile;
    61. System altered.
    62. SQL> /
    63. System altered.
    64. SQL> /
    65. System altered.
    66. SQL> select * from v$logfile;
    67. GROUP# STATUS TYPE MEMBER IS_ CON_ID
    68. ---------- --------------- --------------- ------------------------------ --- ----------
    69. 1 ONLINE /u02/oradata/CDB1/redo06.log NO 0
    70. 1 ONLINE /u02/oradata/CDB1/redo01.log NO 0
    71. 4 ONLINE /u02/oradata/CDB1/redo04b.log NO 0
    72. 4 ONLINE /u02/oradata/CDB1/redo04.log NO 0
    73. 5 ONLINE /u02/oradata/CDB1/redo05.log NO 0
    74. 5 ONLINE /u02/oradata/CDB1/redo05b.log NO 0
    75. 6 rows selected.
    76. SQL>

    数据库的归档模式:

    查看数据库归档是否

    1. archive log list
    2. select log_mode from v$database;
    1. SQL>
    2. SQL> archive log list
    3. Database log mode No Archive Mode
    4. Automatic archival Disabled
    5. Archive destination /u01/app/oracle/product/19.3.0/dbhome_1/dbs/arch
    6. Oldest online log sequence 65
    7. Current log sequence 67
    8. SQL>

     如何从非归档模式到归档模式:

    • Step1: 正常停库
    • Step2:启动到mount模式下
    • Step3:执行alter database archivelog命令
    • Step4:将数据库打开为open状态
    • Step5:进行 日志文件转换 alter system switch logfile;
    • Step6:去到归档日志路径下,/u01/app/oracle/product/19.3.0/dbhome_1/dbs/arch 执行tree命令。如下所示:
    1. SQL> archive log list
    2. Database log mode No Archive Mode
    3. Automatic archival Disabled
    4. Archive destination /u01/app/oracle/product/19.3.0/dbhome_1/dbs/arch
    5. Oldest online log sequence 65
    6. Current log sequence 67
    7. SQL>
    8. SQL>
    9. SQL> shutdown immediate
    10. Database closed.
    11. Database dismounted.
    12. ORACLE instance shut down.
    13. SQL>
    14. SQL> startup mount
    15. ORACLE instance started.
    16. Total System Global Area 629145392 bytes
    17. Fixed Size 9137968 bytes
    18. Variable Size 197132288 bytes
    19. Database Buffers 415236096 bytes
    20. Redo Buffers 7639040 bytes
    21. Database mounted.
    22. SQL> alter database archivelog;
    23. Database altered.
    24. SQL> alter database open;
    25. Database altered.
    26. SQL> archive log list
    27. Database log mode Archive Mode
    28. Automatic archival Enabled
    29. Archive destination /u01/app/oracle/product/19.3.0/dbhome_1/dbs/arch
    30. Oldest online log sequence 65
    31. Next log sequence to archive 67
    32. Current log sequence 67
    33. SQL>
    34. SQL>
    35. SQL> select * from v$log;
    36. GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC
    37. ---------- ---------- ---------- ---------- ---------- ---------- ---
    38. STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME CON_ID
    39. ---------------- ------------- --------- ------------ --------- ----------
    40. 1 1 66 104857600 512 2 YES
    41. INACTIVE 17557877 21-NOV-22 17631852 22-NOV-22 0
    42. 4 1 65 104857600 512 2 YES
    43. INACTIVE 17557842 21-NOV-22 17557877 21-NOV-22 0
    44. 5 1 67 104857600 512 2 NO
    45. CURRENT 17631852 22-NOV-22 1.8447E+19 0
    46. SQL>
    47. SQL> alter system switch logfile;
    48. System altered.
    49. SQL> alter system switch logfile;
    50. System altered.
    51. SQL> select * from v$log;
    52. GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC
    53. ---------- ---------- ---------- ---------- ---------- ---------- ---
    54. STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME CON_ID
    55. ---------------- ------------- --------- ------------ --------- ----------
    56. 1 1 69 104857600 512 2 NO
    57. CURRENT 17641141 22-NOV-22 1.8447E+19 0
    58. 4 1 68 104857600 512 2 YES
    59. ACTIVE 17641099 22-NOV-22 17641141 22-NOV-22 0
    60. 5 1 67 104857600 512 2 YES
    61. ACTIVE 17631852 22-NOV-22 17641099 22-NOV-22 0
    62. SQL>
    63. [oracle@oracle-db-19c dbs]$ tree
    64. .
    65. ├── arch
    66. │   ├── 1_68_1119711914.dbf
    67. │   └── 1_67_1119711914.dbf
    68. ├── hc_cdb1.dat
    69. ├── init.ora
    70. ├── lkCDB1
    71. ├── orapwcdb1
    72. ├── orapwcdb1_bkp20221119
    73. └── spfilecdb1.ora
    74. 1 directory, 8 files
    75. [oracle@oracle-db-19c dbs]$

    打开归档:

    1. shutdown immediate
    2. startup mount

    修改存档的终点:

    1. SQL> archive log list
    2. Database log mode Archive Mode
    3. Automatic archival Enabled
    4. Archive destination /u01/app/oracle/product/19.3.0/dbhome_1/dbs/arch
    5. Oldest online log sequence 67
    6. Next log sequence to archive 69
    7. Current log sequence 69
    8. SQL>
    9. SQL> alter system set log_archive_dest_1='location=/u01/app/oracle/product/19.3.0/dbhome_1/dbs/arc_maxwell_dest1/';
    10. System altered.
    11. SQL> alter system switch logfile;
    12. System altered.
    13. SQL>
    14. [oracle@oracle-db-19c dbs]$ tree
    15. .
    16. ├── arch
    17. │   ├── 1_67_1119711914.dbf
    18. │   └── 1_68_1119711914.dbf
    19. ├── arc_maxwell_dest1
    20. │   └── 1_69_1119711914.dbf
    21. ├── hc_cdb1.dat
    22. ├── init.ora
    23. ├── lkCDB1
    24. ├── orapwcdb1
    25. ├── orapwcdb1_bkp20221119
    26. └── spfilecdb1.ora
    27. 2 directories, 9 files
    28. [oracle@oracle-db-19c dbs]$ pwd
    29. /u01/app/oracle/product/19.3.0/dbhome_1/dbs
    30. [oracle@oracle-db-19c dbs]$

    手动归档:

    alter system archive log sequence 67  to '/u01/app/oracle/product/19.3.0/dbhome_1/dbs/arc_maxwell_dest1/';

     

    --查看归档
    -- v$archived_log

    -- 查看归档路径
    -- v$archive_dest

  • 相关阅读:
    盘点常见的动态内存的错误
    1panel 搭建多个网站
    mysql学习笔记-底层原理详解
    〖Python网络爬虫实战㊲〗- JavaScript 逆向实战(一)
    【leetcode】不含重复字符的最长子字符串
    Vue中的生命周期
    Java Web 33道面试题汇总
    unity3d客户端框架 基于类对象池的可回收变量 代码实现
    【Qt控件之QTableWidget】使用及技巧
    成都瀚网科技有限公司:抖店精选联盟怎么用?
  • 原文地址:https://blog.csdn.net/u011868279/article/details/127962644