Oracle Setup
Oracle Setup
Oracle Setup
//
reboot
getenforce
//permissive
** set network
nmtui
edit connection of enp0s3
curl -o compat-openssl10-1.0.2o-3.el8.x86_64.rpm
https://yum.oracle.com/repo/OracleLinux/OL9/latest/x86_64/getPackage/compat-
openssl10-1.0.2o-3.el8.x86_64.rpm
su - oracle
vi .bash_profile
mkdir -p /d01/app/oracle/product/19.3.0/dbhome
mkdir -p /d02/oradata
chown -R oracle:oinstall /d02 /d02
chmod -R 775 /d01 /d02
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_HOSTNAME=home.db
export ORACLE_UNQNAME=cdb1
export ORACLE_BASE=/d01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.3.0/dbhome
export ORA_INVENTORY=/d01/app/oraInventory
export ORACLE_SID=cdb1
export PDB_NAME=pdb1
export DATA_DIR=/d02/oradata
export PATH=/usr/sbin:/usr/local/bin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
1)CREATE
2)SERVER CLASS
3)ENTERPRISE EDITIOB
select value /1024 /1024 M from v$pgastat where name='maximum PGA allocated';
Use a fast recovery area, which automates storage management for most backuprelated
files,
and specify it as an archived redo log file destination. Run the database in
ARCHIVELOG mode
so you can perform online backups and have data recovery options such as complete
and point-in-time media recovery.
Oracle recommends placing the fast recovery area on a separate storage device from
the working set of database files.
SCN =>System Change Number
It is great if we have tape backup then we can move some files to tape . But
restore from fra is faster.
To perform backup and recovery tasks with Oracle Recovery Manager (RMAN), you
must connect to the target database as a user with the SYSDBA or SYSBACKUP
administrative privilege.
The SYSBACKUP user.
When you install the database, the SYSBACKUP user, with the SYSBACKUP privilege,
is created automatically.
� Database users to whom you grant the SYSBACKUP privilege.
� Database host users who are members of the OSBACKUPDBA operating system
group�for operating system authentication.
The OSBACKUPDBA group is assigned to a specific operating system group
during database installation. For example, on UNIX and Linux systems, the
backupdba group is typically designated as the OSBACKUPDBA group. Host users
in this group can connect to the target database using operating system
authentication; they do not need to be defined as a database user.
A target database is the Oracle database that must be backed
up or restored using RMAN. Connections to the target database require the SYSDBA or
SYSBACKUP administrative privilege.
When you do not explicitly specify SYSDBA or SYSBACKUP, you are connected to
the target database with the SYSDBA privilege.
=======
rman target /
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 10G;
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = '/d01/oracle/fra';
LOG_MODE
------------
NOARCHIVELOG
You must ensure that there is sufficient disk space at all times for archived
log file destinations. If the database encounters a disk full error as it attempts
to archive a log file, a fatal error occurs and the database stops responding.
You can check the alert log for a disk full message.
SHUTDOWN DATABASE;
STARTUP MOUNT;
BACKUP DATABASE;
FLASHBACK_ON
------------------
NO
***Configure Backup
Specify that the backups must be stored on disk in the form of backup sets. Also
set the parallelism to 1.
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET PARALLELISM 1;
Backups on disk can be stored in the form of backup sets or image copies. Image
copies are exact copies of database files. They are not stored in an RMAN-specific
format and can be used as-is to perform recovery. Backup sets use an RMANspecific
format. With backup sets, RMAN uses unused block compression to save
space by backing up only the blocks that contain data. RMAN can also encrypt
backups and create incremental backups.
To configure automatic backups for the control file and server parameter file:
The following command specifies that the backups and archived logs must be
retained for 31 days.
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 31 DAYS;
Specify that archived logs can be automatically deleted only when they have been
backed up to tape or are obsolete based on the retention policy by using the
following command.
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
To determine if block change tracking is enabled, check the STATUS and FILENAME
columns in the V$BLOCK_CHANGE_TRACKING view, using the following statement from the
SQL or RMAN prompt:
SELECT status, filename FROM V$BLOCK_CHANGE_TRACKING;
Determine the current location of the database data files by submitting the
following query:
RMAN> SELECT NAME FROM V$DATAFILE;
Enable block change tracking for the database using the following command:
ALTER DATABASE ENABLE BLOCK CHANGE TRACKING;
If the database runs in ARCHIVELOG mode, then an autobackup is also taken whenever
the database structure metadata in the control file changes.
tail /etc/group
slocate:x:21:
tcpdump:x:72:
sajib:x:1000:
oinstall:x:54321:oracle
dba:x:54322:oracle
oper:x:54323:oracle
backupdba:x:54324:oracle
dgdba:x:54325:oracle
kmdba:x:54326:oracle
racdba:x:54330:oracle
*** startup
alter session set container=pdb1;
alter pluggable database pdb1 open;
alter user hr identified by hr account unlock;
. oraenv
sqlplus / as sysdba
lsnrctl start
sqlplus system/oracle@home:1521/pdb1
create user jim identified by jim;
create user tom identified by tom;
create user ann identified by ann;
***Flashback:
BEFORE APPPLYING "ALERT DATABASE OPEN RESETLOGS;" must need to be confirmed about
the flashback point.
sqlpus sys/oracle@home:1521/pdb1;
drop table test_tab1 purge;
Go back to container db
sqlplus sys / as sysdba;
shutdown immediate;
startup mount;
flashback database to scn xyz;
alter database open resetlogs;
***SQL
LISTAGG FUNCTION
From
Where
Group By
Having
Select
Order By
Group By Clasue:
All the single column in select must be in group by clause but all the fields in
group by clause not necessarily
We can not use where clause in group data because where clasue comes before group
by in execution order.
having clause comes before order by .
Nest group function not works if any single row column is in select clause and also
it not works if no group by clause in command.
***TABLESPACES:
Three types:
Permanent=>Persistent schema objects
Undo=> Undo data automatic undo management mode
Temporary=> Temporary for a session
command:
BEGIN
FOR count IN 1..100000 loop
INSERT INTO T1(COLUMN1)
VALUES(sys_guid());
END loop;
END;
/
**You must login as SYS or SYSTEM to perform sehutdown and startup operation. If
SYS then LOGON as SYSDBA.