Disclaimer

Wednesday 12 January 2022

Create Manual Database in Oracle 19c

 Oracle 19c Pre-requisites


Manual Setup

If you have not used the "oracle-database-preinstall-19c" package to perform all prerequisites, you will need to manually perform the following setup tasks.


Step-1 : Packages should be installed.

Step-2 : Add the following lines to /etc/sysctl.conf file

fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500

Run one of the following commands to change the current kernel parameters, depending on which file you edited.

/sbin/sysctl -p

Step-3 : Add the following lines to a file limits.conf

/etc/security/limits.conf"

#] vi /etc/security/limits.conf


oracle   soft   nofile    1024
oracle   hard   nofile    65536
oracle   soft   nproc    16384
oracle   hard   nproc    16384
oracle   soft   stack    10240
oracle   hard   stack    32768
oracle   hard   memlock    134217728
oracle   soft   memlock    134217728

Step-4 : Create the new groups and user


groupadd -g 54321 oinstall
groupadd -g 54322 dba
groupadd -g 54323 oper

useradd -u 54321 -g oinstall -G dba,oper oracle


Set the password for the "oracle" user.

passwd oracle

Step-5 : Set secure Linux to permissive

Set secure Linux to permissive by editing the "/etc/selinux/config" file, making sure the SELINUX flag is set as follows.

SELINUX=permissive

Step-6 : Disable firewall

If you have the Linux firewall enabled, you will need to disable or configure it, 

 To disable it, do the following.

# systemctl stop firewalld
# systemctl disable firewalld


Step-7 : Create the directories 

Create the directories in which the Oracle software will be installed.


mkdir -p /u01/app/oracle/product/19.0.0/dbhome_1
chown -R oracle:oinstall /u01/app/oracle/product/19.0.0/dbhome_1
chmod -R 775 /u01/app/oracle/product/19.0.0/dbhome_1


Step-8 : Install Oracle 19c software


==================================

Prerequisites for create a database manually:

Step-1 First, create a profile with a correct environment variable.

[oracle@vm-1 ~]$
[oracle@vm-1 ~]$ vi .ORCL.env
[oracle@vm-1 ~]$
[oracle@vm-1 ~]$ cat .ORCL.env

# Oracle Settings
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=ORCL
export ORACLE_UNQNAME=ORCL
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.0.0/dbhome_1
export ORA_INVENTORY=/u01/app/oraInventory
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

Step-2 Create a password file:

[oracle@vm-1 ~]$ orapwd file=$ORACLE_HOME/dbs/orapwORCL password=Welcome_123 entries=10 force=y ignorecase=y

Step-3 Now create the Pfile(init.ora) file( in $ORACLE_HOME/dbs location)

After we start the instance, it’ll read this file and set values accordingly.


[root@vm-1 ~]# mkdir -p /data1/ORCL
[root@vm-1 ~]# chown -R oracle:oinstall /data1
[root@vm-1 ~]# chmod -R 775 /data1 [root@rac5 ~]# su - oracle [oracle@vm-1 ~]$ [oracle@vm-1 ~]$ . .ORCL.env [oracle@vm-1 ~]$ [oracle@vm-1 ~]$ cd $ORACLE_HOME/dbs [oracle@vm-1 dbs]$ [oracle@vm-1 dbs]$ pwd /u01/app/oracle/product/19.0.0/dbhome_1/dbs [oracle@vm-1 dbs]$ [oracle@vm-1 dbs]$ vi initORCL.ora [oracle@vm-1 dbs]$ [oracle@vm-1 dbs]$ cat initORCL.ora *.compatible='19.0.0' *.control_files='/data1/ORCL/control01.ctl' *.db_name='ORCL' *.diagnostic_dest='/u01/app/oracle' *.memory_max_target=1024m *.memory_target=1024m *.remote_login_passwordfile='EXCLUSIVE' *.undo_tablespace='UNDOTBS1'

Step-4 Create a database creation script:

During this script or SQL file making you’d wish to specify about the datafiles, tempfiles, redolog files, and default user details(sys, system).


[oracle@vm-1 ~]$ [oracle@vm-1 ~]$ vi create_database.sql [oracle@vm-1 ~]$ [oracle@vm-1 ~]$ cat create_database.sql create database ORCL LOGFILE group 1 ('/data1/ORCL/redo01.log') SIZE 10M, group 2 ('/data1/ORCL/redo02.log') SIZE 10M, group 3 ('/data1/ORCL/redo03.log') SIZE 10M datafile '/data1/ORCL/system01.dbf' SIZE 500M SYSAUX datafile '/data1/ORCL/sysaux01.dbf' SIZE 300M DEFAULT TABLESPACE USERS datafile '/data1/ORCLusers01.dbf' size 50M DEFAULT TEMPORARY TABLESPACE temp tempfile '/data1/ORCL/temp01.dbf' SIZE 50M UNDO TABLESPACE undotbs1 datafile '/data1/ORCL/undotbs01.dbf' SIZE 50M CHARACTER SET AL32UTF8;


Now we are going to create a database

Step-1 Firstly, run to set environment variable:

[oracle@vm-1 ~]$
[oracle@vm-1 ~]$ . .ORCL.env
[oracle@vm-1 ~]$

Step-2 Start the database in nomount stage:

[oracle@vm-1 ~]$
[oracle@vm-1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sat Jan 16 13:43:21 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 1073737800 bytes
Fixed Size                  8904776 bytes
Variable Size             616562688 bytes
Database Buffers          444596224 bytes
Redo Buffers                3674112 bytes
SQL>

Step-3 Create a Server Parameter File

SQL>
SQL> create spfile from pfile;

File created.

SQL>

Step-4 Run create database script to create the database:

SQL>
SQL> @create_database.sql

Database created.

SQL>

Step-5 Check and verify

After completion step-3 : You would like to test the database status.

SQL>
SQL> select name, open_mode, instance_name, status from v$database, v$instance;

NAME      OPEN_MODE            INSTANCE_NAME    STATUS
--------- -------------------- ---------------- ------------
ORCL      READ WRITE           ORCL             OPEN

SQL>

Post Creation Steps:

Step-1 Builds the data dictionary.

These three scripts you need to run must after creating a database. Below given three scripts will create the dictionary views and tables.

This script runs using the catctl.pl program (and not using SQL*Plus) and internally runs the scripts catalog.sql and catproc.sql with parallel processes, thus improving the performance of building the information dictionary.

SQL>
SQL> @$ORACLE_HOME/rdbms/admin/catalog.sql
SQL>
SQL>
SQL> @$ORACLE_HOME/rdbms/admin/catproc.sql

Step-2 In SQL*Plus, run the following script as the SYSTEM user:

SQL>
SQL> @$ORACLE_HOME/sqlplus/admin/pupbld.sql
SQL>
























Step-3 In SQL*Plus, run the following script as a user with the SYSDBA privileges:

SQL>
SQL> @$ORACLE_HOME/sqlplus/admin/utlrp.sql
SQL>

Step-4 Connect SQL*Plus 



No comments:

Post a Comment

100 Oracle DBA Interview Questions and Answers

  Here are 100 tricky interview questions tailored for a Senior Oracle DBA role. These questions span a wide range of topics, including perf...