Friday, August 30, 2019

Find Out Virtual Memory PAGESIZE on Linux




[root@localhost ~]# getconf PAGESIZE
4096
[root@localhost ~]# getconf PAGE_SIZE
4096
[root@localhost ~]#


[root@localhost ~]# getconf -a | grep -i pagesize
PAGESIZE                           4096
[root@localhost ~]#

Flush Bad SQL Plan from Shared Pool



SQL>
SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SQL>
SQL> select ADDRESS, HASH_VALUE from V$SQLAREA where SQL_Id='c99yw1xkb4f1u';

ADDRESS          HASH_VALUE
---------------- ----------
0000000064E29800 1689401402

SQL> exec DBMS_SHARED_POOL.PURGE ('0000000064E29800,1689401402','C');

PL/SQL procedure successfully completed.

SQL> select ADDRESS, HASH_VALUE from V$SQLAREA where SQL_Id='c99yw1xkb4f1u';

no rows selected

SQL>

PLS-00201: identifier 'DBMS_SHARED_POOL.PURGE' must be declared


To declare the DBMS_SHARED_POOL.PURGE you have to run dbmspool.sql under ORACLE_HOME/rdbms/admin/  directory

SQL> exec DBMS_SHARED_POOL.PURGE ('0000000064E29800,1689401402','C');
BEGIN DBMS_SHARED_POOL.PURGE ('0000000064E29800,1689401402','C'); END;

      *
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00201: identifier 'DBMS_SHARED_POOL.PURGE' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored



[oracle@localhost admin]$ sqlplus "/as sysdba"

SQL*Plus: Release 12.2.0.1.0 Production on Fri Aug 30 16:55:58 2019

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SQL>

SQL> @?/rdbms/admin/dbmspool.sql

Session altered.


Package created.


Grant succeeded.


Session altered.

SQL>

SQL> select ADDRESS, HASH_VALUE from V$SQLAREA where SQL_Id='c99yw1xkb4f1u';

ADDRESS          HASH_VALUE
---------------- ----------
0000000064E29800 1689401402

SQL> exec DBMS_SHARED_POOL.PURGE ('0000000064E29800,1689401402','C');

PL/SQL procedure successfully completed.

SQL> select ADDRESS, HASH_VALUE from V$SQLAREA where SQL_Id='c99yw1xkb4f1u';

no rows selected

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SQL>


How To Clone A Pluggable Database From Existing PDB

[oracle@localhost ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 12.2.0.1.0 Production on Fri Aug 30 16:13:57 2019

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select name,open_mode from v$pdbs;

NAME          OPEN_MODE
------------- ----------
PDB$SEED      READ ONLY
DB            MOUNTED

SQL>
SQL>
SQL>
SQL> alter session set container=db;

Session altered.

SQL> alter database open;

Database altered.

SQL> select file_name from dba_data_files;

FILE_NAME
----------------------------------------------------------------------
/u01/app/oracle/oradata/cdb/db/system01.dbf
/u01/app/oracle/oradata/cdb/db/sysaux01.dbf
/u01/app/oracle/oradata/cdb/db/undotbs01.dbf
/u01/app/oracle/oradata/cdb/db/users01.dbf

SQL>
SQL> show con_name

CON_NAME
------------------------------
DB
SQL> shut immediate
Pluggable Database closed.
SQL> startup open read only;
Pluggable Database opened.
SQL> show con_name

CON_NAME
------------------------------
DB
SQL>
SQL> alter session set container=CDB$ROOT;

Session altered.


SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SQL> create pluggable database PROD_DB from DB FILE_NAME_CONVERT=('/u01/app/oracle/oradata/cdb/db','/u01/app/oracle/oradata/cdb/db/prod_db');

Pluggable database created.

SQL> select name,open_mode from v$pdbs;

NAME            OPEN_MODE
------------    ----------
PDB$SEED        READ ONLY
DB              READ ONLY
PROD_DB         MOUNTED

SQL> alter session set container=DB;

Session altered.

SQL> shut immediate
Pluggable Database closed.
SQL> startup
Pluggable Database opened.
SQL>
SQL> select name,open_mode from v$pdbs;

NAME           OPEN_MODE
-------------- ----------
DB             READ WRITE

SQL> alter session set container=PROD_DB;

Session altered.

SQL> startup
Pluggable Database opened.
SQL>
SQL> select name,open_mode from v$pdbs;

NAME                          OPEN_MODE
----------------------------- ----------
PROD_DB                       READ WRITE


SQL> alter session set container=CDB$ROOT;

Session altered.

SQL>  select name,open_mode from v$pdbs;

NAME             OPEN_MODE
---------------  -----------
PDB$SEED         READ ONLY
DB               READ WRITE
PROD_DB          READ WRITE

SQL>


[oracle@localhost ~]$ ls -lrt /u01/app/oracle/oradata/cdb/db
total 843692
-rw-r-----. 1 oracle oinstall 135274496 Jul 26 19:20 temp01.dbf
drwxr-x---. 2 oracle oinstall       104 Aug 30 16:19 prod_db
-rw-r-----. 1 oracle oinstall   5251072 Aug 30 16:20 users01.dbf
-rw-r-----. 1 oracle oinstall 104865792 Aug 30 16:20 undotbs01.dbf
-rw-r-----. 1 oracle oinstall 367009792 Aug 30 16:20 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 262152192 Aug 30 16:20 system01.dbf
[oracle@localhost ~]$
[oracle@localhost ~]$ ls -lrt /u01/app/oracle/oradata/cdb/db/prod_db/
total 722008
-rw-r-----. 1 oracle oinstall   5251072 Aug 30 16:21 users01.dbf
-rw-r-----. 1 oracle oinstall 104865792 Aug 30 16:21 undotbs01.dbf
-rw-r-----. 1 oracle oinstall 367009792 Aug 30 16:21 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 262152192 Aug 30 16:21 system01.dbf
-rw-r-----. 1 oracle oinstall 135274496 Aug 30 16:21 temp01.dbf
[oracle@localhost ~]$

Monday, August 12, 2019

Add/Remove port in Linux firewall



Add port in firewall-cmd
===============================

[root@localhost ~]# firewall-cmd --zone=public --add-port=1521/tcp --permanent
success
[root@localhost ~]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: enp0s3
  sources:
  services: ssh dhcpv6-client
  ports:
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: enp0s3
  sources:
  services: ssh dhcpv6-client
  ports: 1521/tcp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

[root@localhost ~]#

Remove port from Firewall 
===================================

[root@localhost ~]# firewall-cmd --zone=public --remove-port=1521/tcp --permanent
success
[root@localhost ~]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: enp0s3
  sources:
  services: ssh dhcpv6-client
  ports: 1521/tcp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: enp0s3
  sources:
  services: ssh dhcpv6-client
  ports:
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

[root@localhost ~]#