Monday, February 8, 2021

How to Use In-Database Archiving

Why In-Database Archiving

The simple goal of in-database archiving is to assign values to the data based on business rules of whether the data is current or marked as non-active. As the value of the data lowers over time, the related data can be moved to less costly storage. The challenges are:

  • Databases grow; rarely do they get smaller
  • Data growth rates are accelerating
  • The old data may need to be instantly available in the database at a future time

In-database archiving is a possible solution.

Setting Up Row Archival

Use in-database archiving to distinguish active rows from non-active within the same table. It is also possible to compress the non-active rows as they are moved. Compression requires the Advanced Compression option.

To enable row archival, add the hidden column, ora_archive_state:

CREATE TABLE emp
(empno NUMBER(7),
fullname VARCHAR2(40),
job VARCHAR2(9),
mgr NUMBER(7))
ROW ARCHIVAL; — adds the ora_archive_state column

An existing table can be altered for In-Database Archiving:

ALTER TABLE emp ROW ARCHIVAL;

The row archival attribute indicates whether a row is active or non-active. By default, when a row is inserted, it is set as active, and the ora_archive_state value is ‘0’. After a period of time, the row may be less frequently accessed and is rarely updated, but still considered as active. It needs to be retained for records retention and/or compliance purposes. It is, therefore, considered to be in a non-active state.  The value ‘1’ – or any value other than ‘0’ – in the ora_archive_state column would reflect the non-active state. Update ora_archive_state to ‘1’ for row archiving. ACTIVE is the default value.

in-database archiving

Using Row Archival

View ora_archive_state column:

dec1-2

When it is determined that the rows should not be active, set the rows to the archive state. This could be done with a batch job scheduled to run during the maintenance window.

UPDATE emp
SET ora_archive_state = 1
WHERE  empno < 100;

Set rows back to active state if needed for active use:

UPDATE emp
SET ora_archive_state = 0;

Setting Session Visibility

To view active rows only:

dec1-3

View all rows:

ALTER SESSION SET ROW ARCHIVAL VISIBILITY  = ALL;

dec1-4

To return to active rows only:

ALTER SESSION SET ROW ARCHIVAL VISIBILITY  = ACTIVE;

Disabling Row Archival

When row archival is disabled, the ora_archive_state column is automatically removed. To disable row archival:

ALTER TABLE emp NO ROW ARCHIVAL;

dec1-5

In my next blog, I will be discussing Temporal History.

ora_archive_state Tips

 Starting in Oracle 12c, Oracle provides a new feature that allow you to "logically delete" a row in a table without physically removing the row.  This effectively makes deleted rows "invisible" to all SQL and DML, but they can be revealed at any time, providing a sort of "instant" rollback method.

 

To use ora_archive_state as an alternative to deleting rows, you need the following settings and parameters:

 

1. Create the table with the row archival clause

 

      create table mytab (col1 number, col2 char(200)) row archival;

 

2.  Now that the table is marked as row archival, you have two methods for removing rows, a permanent solution with the standard delete DML, plus the new syntax where you set ora_archive_state to a non-zero value:

 

      update mytab set ora_archive_state=2 where col2='FRED';  

 

3.  To make "invisible rows" visible again, you simply set the rows ora_archive_state to zero:

 

      update mytab set ora_archive_state=0 where col2='FRED';  

 

To see rows that are marked as deleted you can select the pseudo-column ora_archive_state from a table, just as-if it were a real table column.  This is a binary pseudo-column, and a "1" value indicates a logically deleted table row.

 

   select id, col1, col2, ora_archive_state from mytab;

Removing row invisibility

Below we see a case where we set the row archival visibility parameter to "all" thereby allowing us to see all of the rows that have been logically deleted:

   alter session set row archival visibility = all;

   select col1, col2, ora_archive_state from mytab;

We can then turn-on row invisibility back on by changing row archival visibility = "active":

   alter session set row archival visibility = all;

We also see two new data dictionary columns in dba_tab_cols, hidden_column (an indicator) and user_generated:

select
   table_name,
   column_name,
   hidden_column,
   user_generated
from
   dba_tab_cols
where
   table_name='MYTAB';

Monday, January 11, 2021

How use Auditd Tool

 https://linuxhint.com/auditd_linux_tutorial/

https://www.tecmint.com/linux-system-auditing-with-auditd-tool-on-centos-rhel/


How to reset root account password on Exadata Comput nodes for X7-2 (Doc ID 2603917.1)

 In this Document

Goal
Solution
References


APPLIES TO:

Exadata X7-2 Hardware - Version All Versions and later
Information in this document applies to any platform.

GOAL

Reset root account password on Exadata Comput nodes for X7-2.

SOLUTION

Please base on the following steps to change your root password.

From step 2 below all commands have to be executed on System Console (either directly sitting in front of the physical system with console screen attached, via SSH remote SP console or Web Based ILOM remote console option.

  1.Reboot via the ILOM web interface either:
  ○via the web interface:
  ■For current ILOM versions:
  ■go to "Host Management", at "Power Control" choose 'Power Cycle" for "Settings"
  ■For older ILOM versions:
  ■go to "System Overview", at "Host Power" choose 'Power Cycle"
  ■From ILOM web interface start remote console by going to Remote Control -> Launch Remote Console
  ○via ssh remote SP console:
  ■reset /SYS
  ■start /SP/console
  2.On the ILOM web console or ssh remote SP console: when the Grub Menu screen appears, immediately hit the arrow down key. Please note, here is a short window for this , so carefully watch the screen.
  3.Select the proper line to boot from and press "p" to supply the GRUB password .  (<get password from support by filing an SR>)
  4.Press the "e" key to edit the boot entry
  5.Using the down arrow, select the line that starts with "linuxefi", then press the "e" key to edit
  6.At the grub2 line starting with "linuxefi" add at the end the following string: rd.break
  7.Press ctrl+x to boot or start
  8.First we will remount the sysroot file system in read and write mode and then use chroot to got into a chroot jail:

# mount -o remount,rw /sysroot
# chroot /sysroot

  9.Type passwd command in the command line and press same password twice for reset root password:

# passwd

  10.Make sure that all unlabel files ( including shadow ) get relabeled during booting:

# touch /.autorelabel

  11.Type the command to sync:

# sync 

  12. Reboot or power cycle the system.

How to Reset Root Password in Oracle Linux 7 (Doc ID 1954652.1)

 In this Document

Goal
Solution
References


APPLIES TO:

Linux OS - Version Oracle Linux 7.0 and later
Oracle Cloud Infrastructure - Version N/A and later
Linux x86-64

GOAL

This article explains how root password can be reset on Oracle Linux 7.

SOLUTION

1. While booting GRUB 2 Edit Menu Option (by pressing E)

2. Select the line starts with linux16******* (append "rd.break" at the end of the line), e.g.:

linux16 **** rd.break


3. Press ctrl+x to boot or start.

4. First we will remount the sysroot file system in read and write mode and then use chroot to got into a chroot jail:

# mount -o remount,rw /sysroot
# chroot /sysroot


5. Type passwd command in the command line and press same password twice for reset root password:

# passwd


6. Make sure that all unlabel files ( including shadow ) get relabeled during booting:

# touch /.autorelabel


7. Type the command to sync:

# sync


8. Type twice exit command to leave & logout.

9. The system will apply some SELinux contexts and reboot.