Tuesday, 11 June 2019

Start/Stop oracle 13c OEM service and agent.



                                                                                  
1] Set oracle AGENT_HOME and OMS_HOME.
export AGENT_HOME=/u01/app/oracle/agent/agent_13.1.0.0.0
export OMS_HOME=/u01/app/oracle/middleware
2] Start oms service.
[oracle@13coem agent_13.1.0.0.0]$ cd $OMS_HOME/bin
[oracle@13coem bin]$ ./emctl start oms
Oracle Enterprise Manager Cloud Control 13c Release 1
Copyright (c) 1996, 2015 Oracle Corporation.  All rights reserved.
Starting Oracle Management Server...
WebTier Successfully Started
Oracle Management Server is Up
JVMD Engine is Up
Starting BI Publisher Server ...
BI Publisher Server Successfully Started
BI Publisher Server is Up
[oracle@13coem bin]$
3] Start OEM Agent
[oracle@13coem bin]$ export AGENT_HOME=/u01/app/oracle/agent/agent_13.1.0.0.0
[oracle@13coem bin]$ $AGENT_HOME/bin/emctl start agent
Oracle Enterprise Manager Cloud Control 13c Release 1
Copyright (c) 1996, 2015 Oracle Corporation.  All rights reserved.
Agent is already running
[oracle@13coem bin]$
4] If you don’t have 13c oem  link details you can check it from below file.
[oracle@13coem install]$ cat setupinfo.txt
location: /u01/app/oracle/middleware/install
[oracle@13coem install]$ cat setupinfo.txt
This information is also available at:
        /u01/app/oracle/middleware/install/setupinfo.txt
See the following for information pertaining to your Enterprise Manager installation:
Use the following URL to access:
        1. Enterprise Manager Cloud Control URL: https://13coem.*****.com:7803/em
        2. Admin Server URL: https://13coem.******.com:7102/console
The following details need to be provided while installing an additional OMS:
        1. Admin Server Host Name: 13coem.example.com
        2. Admin Server Port: 7102
You can find the details on ports used by this deployment at : /u01/app/oracle/middleware/install/portlist.ini
 NOTE:
 An encryption key has been generated to encrypt sensitive data in the Management Repository. If this key is lost, all encrypted data in the Repository becomes unusable.
 A backup of the OMS configuration is available in /u01/app/oracle/gc_inst/em/EMGC_OMS1/sysman/backup on host 13coem.example.com. See Cloud Control Administrators Guide for details on how to back up and recover an OMS.
 NOTE: This backup is valid only for the initial OMS configuration. For example, it will not reflect plug-ins installed later, topology changes like the addition of a load balancer, or changes to other properties made using emctl or emcli. Backups should be created on a regular basis to ensure they capture the current OMS configuration. Use the following command to backup the OMS configuration:
/u01/app/oracle/middleware/bin/emctl exportconfig oms -dir <backup dir>

OEM login page:


5] Stop OMS and Agent service.
[oracle@13coem bin]$ ./emctl stop oms
Oracle Enterprise Manager Cloud Control 13c Release 1
Copyright (c) 1996, 2015 Oracle Corporation.  All rights reserved.
Stopping Oracle Management Server...
Oracle Management Server Successfully Stopped
Oracle Management Server is Down
JVMD Engine is Down
[oracle@13coem bin]$ ./emctl stop agent
Oracle Enterprise Manager Cloud Control 13c Release 1
Copyright (c) 1996, 2015 Oracle Corporation.  All rights reserved.
Stopping agent ... stopped.
[oracle@13coem bin]$


Saturday, 1 June 2019

example of edbldr


                                           èexample of edbldr ç=
smaple .csv file:

city.csv
nashik,MH,2000
pune,MH,3000
bhopal,MP,2000

sample of .ctl file:

city.ctl
LOAD DATA
  INFILE    'city.csv'
    BADFILE 'city.bad'
  insert
  INTO TABLE city_1
    FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
  (name,state,public)

-->insert data into city_1 table(database test)

[enterprisedb@localhost ~]$ edbldr -d test control=city.ctl bad=city.bad log=city.log

EDB*Loader: Copyright (c) 2007-2017, EnterpriseDB Corporation.
Enter the user name : enterprisedb
Enter the password :
Successfully processed (3) records

[enterprisedb@localhost ~]$ edb-psql -d test -U enterprisedb
psql.bin (10.1.5)
Type "help" for help.

test=# select * from city_1;

  name  | state | public
--------+-------+--------
 nashik | MH    |   2000
 pune   | MH    |   3000
 bhopal | MP    |   2000
(3 rows)

test=# exit

 

connect postgres Database from remote/client side

Client ip address: 192.168.64.178
Server ip address: 192.168.64.177

1] Enter remote machin ip_address/host_name in pg_hba.conf

# IPv4 local connections:
host    all             all             192.168.64.177/0        md5
host    all             all             192.168.64.178/0        md5

2] Restart postgres service on server side

sudo systemctl restart postgresql-11.service
sudo systemctl status postgresql-11.service

3] Connect from clinet/remote to postgres server.

[postgres@node1 data]$ psql -U myuser -h 192.168.64.177

Password for user myuser:
psql (11.3)
Type "help" for help.
myuser=> select current_user;
 current_user
--------------
 myuser
(1 row)
myuser=> select current_database();
 current_database
------------------
 myuser
(1 row)
myuser=>

Sunday, 26 May 2019

Install postgreSQL 11 on cent OS 7.6


1] Create user postgres

[root@node1 ~]# adduser postgres
[root@node1 ~]# passwd postgres
Changing password for user postgres.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@node1 ~]#

2] Provide sudo access to postgres User.

3] Configure rpm repos for postgreSQL 11

[root@localhost ~]# yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

Loaded plugins: langpacks, ulninfo
pgdg-redhat-repo-latest.noarch.rpm | 5.6 kB 00:00:00
Examining /var/tmp/yum-root-Qytr2V/pgdg-redhat-repo-latest.noarch.rpm: pgdg-redhat-repo-42.0-4.noarch
Marking /var/tmp/yum-root-Qytr2V/pgdg-redhat-repo-latest.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package pgdg-redhat-repo.noarch 0:42.0-4 will be installed
--> Finished Dependency Resolution
ol7_UEKR5/x86_64 | 1.2 kB 00:00:00
ol7_latest/x86_64 | 1.4 kB 00:00:00
ol7_latest/x86_64/updateinfo | 926 kB 00:00:00
ol7_latest/x86_64/primary | 14 MB 00:00:11
Dependencies Resolved
===============================================================================================
Package Arch Version Repository Size
===============================================================================================
Installing:
pgdg-redhat-repo noarch 42.0-4 /pgdg-redhat-repo-latest.noarch 6.8 k
Transaction Summary
===============================================================================================
Install 1 Package
Total size: 6.8 k
Installed size: 6.8 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : pgdg-redhat-repo-42.0-4.noarch 1/1
Verifying : pgdg-redhat-repo-42.0-4.noarch 1/1
Installed:
pgdg-redhat-repo.noarch 0:42.0-4
Complete!

[postgres@node1 yum.repos.d]$ cd /etc/yum.repos.d
[postgres@node1 yum.repos.d]$ pwd
/etc/yum.repos.d
[postgres@node1 yum.repos.d]$ ls -ltr pgdg-redhat-all.repo
-rw-r--r--. 1 root root 5189 Apr 17 09:42 pgdg-redhat-all.repo


4] Install postgreSQL 11 version using rpm package.

==> install postgresql client and server.

[root@node1 ~]# yum install postgresql11

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos-hcm.viettelidc.com.vn
* extras: centos-hn.viettelidc.com.vn
* updates: centos-hn.viettelidc.com.vn
Resolving Dependencies
--> Running transaction check
---> Package postgresql11.x86_64 0:11.3-1PGDG.rhel7 will be installed
--> Processing Dependency: postgresql11-libs(x86-64) = 11.3-1PGDG.rhel7 for package: postgresql11-11.3-1PGDG.rhel7.x86_64
--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql11-11.3-1PGDG.rhel7.x86_64
--> Running transaction check
---> Package postgresql11-libs.x86_64 0:11.3-1PGDG.rhel7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================
Package Arch Version Repository Size
===============================================================================================
Installing:
postgresql11 x86_64 11.3-1PGDG.rhel7 pgdg11 1.7 M
Installing for dependencies:
postgresql11-libs x86_64 11.3-1PGDG.rhel7 pgdg11 360 k
Transaction Summary
===============================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 2.0 M
Installed size: 10 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/pgdg11/packages/postgresql11-libs-11.3-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Public key for postgresql11-libs-11.3-1PGDG.rhel7.x86_64.rpm is not installed
(1/2): postgresql11-libs-11.3-1PGDG.rhel7.x86_64.rpm | 360 kB 00:00:03
(2/2): postgresql11-11.3-1PGDG.rhel7.x86_64.rpm | 1.7 MB 00:00:07
-----------------------------------------------------------------------------------------------
Total 262 kB/s | 2.0 MB 00:00:07
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsqlrpms-hackers@pgfoundry.org>"
Fingerprint: 68c9 e2b9 1a37 d136 fe74 d176 1f16 d2e1 442d f0f8
Package : pgdg-redhat-repo-42.0-4.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : postgresql11-libs-11.3-1PGDG.rhel7.x86_64 1/2
Installing : postgresql11-11.3-1PGDG.rhel7.x86_64 2/2
Verifying : postgresql11-11.3-1PGDG.rhel7.x86_64 1/2
Verifying : postgresql11-libs-11.3-1PGDG.rhel7.x86_64 2/2
Installed:
postgresql11.x86_64 0:11.3-1PGDG.rhel7
Dependency Installed:
postgresql11-libs.x86_64 0:11.3-1PGDG.rhel7
Complete!
[root@node1 ~]# yum install postgresql11-server
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos-hcm.viettelidc.com.vn
* extras: centos-hn.viettelidc.com.vn
* updates: centos-hn.viettelidc.com.vn
Resolving Dependencies
--> Running transaction check
---> Package postgresql11-server.x86_64 0:11.3-1PGDG.rhel7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================
Package Arch Version Repository Size
===============================================================================================
Installing:
postgresql11-server x86_64 11.3-1PGDG.rhel7 pgdg11 4.7 M
Transaction Summary
===============================================================================================
Install 1 Package
Total download size: 4.7 M
Installed size: 19 M
Is this ok [y/d/N]: y
Downloading packages:
postgresql11-server-11.3-1PGDG.rhel7.x86_64.rpm | 4.7 MB 00:00:18
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : postgresql11-server-11.3-1PGDG.rhel7.x86_64 1/1
Verifying : postgresql11-server-11.3-1PGDG.rhel7.x86_64 1/1
Installed:
postgresql11-server.x86_64 0:11.3-1PGDG.rhel7
Complete!

5] Initialize the database and start database server.

[root@node1 ~]# /usr/pgsql-11/bin/postgresql-11-setup initdb

Initializing database ... OK

[root@node1 ~]# systemctl enable postgresql-11
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-11.service to /usr/lib/systemd/system/postgresql-11.service.

[root@node1 ~]# systemctl start postgresql-11


6] Connect to database

[root@node1 ~]# sudo su - postgres

[postgres@node1 ~]$ psql
psql (11.3)
Type "help" for help.
postgres=#
postgres=# select version();
version
-----------------------------------------------------------------------------------------------
----------
PostgreSQL 11.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36
), 64-bit
(1 row)
postgres=#

Monday, 20 May 2019

How to install postgresql server on linux?


==> Below are the steps to install postgreSQL server.

1] Create user postgres.

[root@node1 ~]# adduser postgres
[root@node1 ~]# passwd postgres
Changing password for user postgres.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@node1 ~]#

2] Provide sudo access to postgres User.

3] Check postgreSQL package install or not.

[root@node1 ~]# rpm -qa | grep postgresql
[root@node1 ~]#

4] Install postgresql package.

[root@node1 ~]# yum install postgresql-server
Loaded plugins: langpacks, ulninfo
ol7_UEKR5                                                               | 1.2 kB  00:00:00
ol7_latest                                                              | 1.4 kB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package postgresql-server.x86_64 0:9.2.24-1.el7_5 will be installed
--> Processing Dependency: postgresql-libs(x86-64) = 9.2.24-1.el7_5 for package: postgresql-server-9.2.24-1.el7_5.x86_64
--> Processing Dependency: postgresql(x86-64) = 9.2.24-1.el7_5 for package: postgresql-server-9.2.24-1.el7_5.x86_64
--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql-server-9.2.24-1.el7_5.x86_64
--> Running transaction check
---> Package postgresql.x86_64 0:9.2.24-1.el7_5 will be installed
---> Package postgresql-libs.x86_64 0:9.2.24-1.el7_5 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================
 Package                    Arch            Version                  Repository           Size
===============================================================================================
Installing:
 postgresql-server          x86_64          9.2.24-1.el7_5           ol7_latest          3.8 M
Installing for dependencies:
 postgresql                 x86_64          9.2.24-1.el7_5           ol7_latest          3.0 M
 postgresql-libs            x86_64          9.2.24-1.el7_5           ol7_latest          233 k
Transaction Summary
===============================================================================================
Install  1 Package (+2 Dependent packages)
Total download size: 7.1 M
Installed size: 33 M
Is this ok [y/d/N]: Y
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/ol7_latest/packages/postgresql-libs-9.2.24-1.el7_5.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Public key for postgresql-libs-9.2.24-1.el7_5.x86_64.rpm is not installed
(1/3): postgresql-libs-9.2.24-1.el7_5.x86_64.rpm                        | 233 kB  00:00:00
(2/3): postgresql-9.2.24-1.el7_5.x86_64.rpm                             | 3.0 MB  00:00:05
(3/3): postgresql-server-9.2.24-1.el7_5.x86_64.rpm                      | 3.8 MB  00:00:05
-----------------------------------------------------------------------------------------------
Total                                                          1.1 MB/s | 7.1 MB  00:00:06
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Importing GPG key 0xEC551F03:
 Userid     : "Oracle OSS group (Open Source Software group) <build@oss.oracle.com>"
 Fingerprint: 4214 4123 fecf c55b 9086 313d 72f9 7b74 ec55 1f03
 Package    : 7:oraclelinux-release-7.6-1.0.15.el7.x86_64 (@anaconda/7.6)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Is this ok [y/N]: Y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : postgresql-libs-9.2.24-1.el7_5.x86_64                                       1/3
  Installing : postgresql-9.2.24-1.el7_5.x86_64                                            2/3
  Installing : postgresql-server-9.2.24-1.el7_5.x86_64                                     3/3
  Verifying  : postgresql-server-9.2.24-1.el7_5.x86_64                                     1/3
  Verifying  : postgresql-libs-9.2.24-1.el7_5.x86_64                                       2/3
  Verifying  : postgresql-9.2.24-1.el7_5.x86_64                                            3/3

Installed:
  postgresql-server.x86_64 0:9.2.24-1.el7_5
Dependency Installed:
  postgresql.x86_64 0:9.2.24-1.el7_5          postgresql-libs.x86_64 0:9.2.24-1.el7_5
Complete!

5] Start and add postgreSQL service.

[root@node1 ~]# postgresql-setup initdb
Initializing database ... OK
[root@node1 ~]# systemctl enable postgresql.service
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql.service to /usr/lib/systemd/system/postgresql.service.
[root@node1 ~]# systemctl start postgresql.service
[root@node1 ~]#

6] Connect to postgresql database.

[root@node1 ~]# sudo su - postgres
[postgres@node1 ~]$ psql
psql (9.2.24)
Type "help" for help.
postgres=#
postgres=# SELECT version();
                                                      version

-----------------------------------------------------------------------------------------------
--------------------
 PostgreSQL 9.2.24 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.
8.5-28.0.1), 64-bit
(1 row)
postgres=#

Sunday, 17 March 2019

How to create pluggable database manually in 12c.

=====How to create pluggable database manually in 12c R2=====

1) Connect to sys user

[oracle@prim admin]$ sqlplus

SQL*Plus: Release 12.2.0.1.0 Production on Mon Mar 18 00:13:01 2019
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Enter user-name: /as sysdba
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL>

2) Create pluggable database.

SQL> CREATE PLUGGABLE DATABASE FIN ADMIN USER sys_fin IDENTIFIED BY *********;
Pluggable database created.

3) Check current status new added pluggable database.

SQL> COLUMN NAME FORMAT A15
           COLUMN RESTRICTED FORMAT A10
           COLUMN OPEN_TIME FORMAT A40

SQL> SELECT NAME, OPEN_MODE, RESTRICTED, OPEN_TIME FROM V$PDBS;

NAME OPEN_MODE RESTRICTED OPEN_TIME
--------------- ---------- ---------- ----------------------------------------
PDB$SEED READ ONLY NO 17-MAR-19 10.17.34.413 PM +05:30
HR READ WRITE NO 17-MAR-19 10.17.57.507 PM +05:30
FIN MOUNTED 17-MAR-19 11.46.33.523 PM +05:30

4) Check pluggable database open_mode to READ WRITE

SQL> alter pluggable database FIN open READ WRITE;

Pluggable database altered.

SQL> SELECT NAME, OPEN_MODE, RESTRICTED, OPEN_TIME FROM V$PDBS;

NAME OPEN_MODE RESTRICTED OPEN_TIME
--------------- ---------- ---------- ----------------------------------------
PDB$SEED READ ONLY NO 17-MAR-19 10.17.34.413 PM +05:30
HR READ WRITE NO 17-MAR-19 10.17.57.507 PM +05:30
FIN READ WRITE NO 17-MAR-19 11.47.28.202 PM +05:30

5) Connect lsnrctl utility check current status and reload it.

[oracle@prim datafile]$ lsnrctl
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 17-MAR-2019 23:50:02
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.

LSNRCTL> status

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=prim.example.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 17-MAR-2019 22:02:16
Uptime 0 days 1 hr. 47 min. 48 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.2.0.1/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/prim/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=prim.example.com)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "844e079f51654a64e053a040a8c09b6a.example.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "844f4557a96a62bee053a040a8c00a75.example.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "fin.example.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "hr.example.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orcl.example.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB.example.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully

==> Reload listener

LSNRCTL> reload listener
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=prim.example.com)(PORT=1521)))
The command completed successfully
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=prim.example.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 17-MAR-2019 22:02:16
Uptime 0 days 1 hr. 48 min. 1 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.2.0.1/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/prim/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=prim.example.com)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "844e079f51654a64e053a040a8c09b6a.example.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "844f4557a96a62bee053a040a8c00a75.example.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "ORCL" has 1 instance(s).
Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
Service "fin.example.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "hr.example.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orcl.example.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB.example.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL> exit

6) Add new pluggable database in to tnsnames.ora

FIN =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = prim.example.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = fin.example.com)
)
)
[oracle@prim admin]$ tnsping fin
TNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 18-MAR-2019 00:05:31
Copyright (c) 1997, 2016, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = prim.example.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = fin.example.com)))
OK (10 msec)

7) Connect to new pluggable database.

[oracle@prim admin]$ sqlplus sys_fin@fin
SQL*Plus: Release 12.2.0.1.0 Production on Mon Mar 18 00:05:09 2019
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> show con_name;
CON_NAME
------------------------------
FIN
SQL> show con_id;
CON_ID
------------------------------
4

Saturday, 30 September 2017

Zero downtime database migration using GG.

Note: In below process i am considaring scott as my Application user.

part I)  setup golden gate on source and target machine.
(below steps perform on both source and target database)

-check archive log mode of both database.

SQL> SELECT log_mode FROM v$database;
LOG_MODE
------------
ARCHIVELOG

SQL> SELECT force_logging, supplemental_log_data_min FROM v$database;

FOR SUPPLEME
-----------
NO NO

SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

Database altered.
SQL> ALTER DATABASE FORCE LOGGING;
Database altered.

SQL> SELECT force_logging, supplemental_log_data_min FROM v$database;

FOR SUPPLEME
-----------
YES YES

SQL> create tablespace ggate
datafile '/u01/app/oracle/oradata/DB11G/ggate.dbf' size 5G;
Tablespace created.

SQL> create user ggate
identified by ****
default tablespace ggate;
User created.

SQL> GRANT dba TO ggate;

paert II) set up extract,datapump and replicate process on both source and targate side.

A) on source side node1:

[oracle@node1 ~]$ cd $GG_HOME
[oracle@node1 gg]$ ./ggsci

GGSCI (node1.example.com) > edit params manager
Saturday, September 30, 2017
7:12 PM
New Section 3 Page 1
----add below parameter
PORT 7809
DYNAMICPORTLIST 7810-7820
PURGEOLDEXTRACTS /u01/app/oracle/product/gg/dirdat/rx*, USECHECKPOINTS, MINKEEPHOURS 2

GGSCI (node1.example.com) > edit params CAPT01
EXTRACT CAPT01
setenv (ORACLE_SID="DB11G")
setenv (NLS_LANG="AMERICAN_AMERICA.WE8MSWIN1252")
USERID ggate, PASSWORD oracle
EXTTRAIL /u01/app/oracle/product/gg/dirdat/rx
TABLE scott.*;

GGSCI (node1.example.com) > edit params dp01
EXTRACT dp01
setenv (ORACLE_SID="DB11G")
setenv (NLS_LANG="AMERICAN_AMERICA.WE8MSWIN1252")
USERID ggate, PASSWORD ****
RMTHOST node2.example.com, MGRPORT 7809
RMTTRAIL /u01/app/oracle/product/gg/dirdat/rt
TABLE scott.*;

GGSCI (node1.example.com) > edit params frep01
REPLICAT frep01
setenv (ORACLE_SID="DB11G")
setenv (NLS_LANG="AMERICAN_AMERICA.WE8MSWIN1252")
USERID ggate, PASSWORD ****
ASSUMETARGETDEFS
MAP scott.*, TARGET scott.*;

GGSCI (node1.example.com) > EDIT PARAMS ./GLOBALS

CHECKPOINTTABLE ggate.OGGCHKPT

GGSCI (node1.example.com) > start mgr

GGSCI (node1.example.com) > dblogin userid ggate, Password ***

GGSCI (node1.example.com) > add trandata scott.*

GGSCI (node1.example.com) > Add CheckpointTable

GGSCI (node1.example.com) > Add Extract capt01, TranLog, Begin Now

GGSCI (node1.example.com) > Add ExtTrail ./u01/app/oracle/product/gg/dirdat/rx, Extract capt01, Megabytes 5

GGSCI (node1.example.com) > Add Extract dp01, ExtTrailSource
/u01/app/oracle/product/gg/dirdat/rt

GGSCI (node1.example.com) > Add RmtTrail /u01/app/oracle/product/gg/dirdat/rt, Extract dp01, Megabytes 5

GGSCI (node1.example.com) > Add Replicat frep01, ExtTrail /u01/app/oracle/product/gg/dirdat/ft ----( this replicate process for fail back target to source)

GGSCI (node1.example.com) > info all

Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER STOPPED
EXTRACT STOPPED CAPT01 00:00:00 00:00:54
EXTRACT STOPPED DP01 00:00:00 00:00:46
REPLICAT STOPPED REP01 00:00:00 00:00:02

B) on target database.

[oracle@node2 ~]$ cd $GG_HOME

[oracle@node2 gg]$ ./ggsci

GGSCI (node2.example.com) > edit params mgr

----add below parameter
PORT 7809
DYNAMICPORTLIST 7810-7820
PURGEOLDEXTRACTS /u01/app/oracle/product/gg/dirdat/fx*, USECHECKPOINTS, MINKEEPHOURS 2

GGSCI (node2.example.com) > edit params FCAPT01

EXTRACT FCAPT01
setenv (ORACLE_SID="DB11G")
setenv (NLS_LANG="AMERICAN_AMERICA.WE8MSWIN1252")
USERID ggate, PASSWORD oracle
EXTTRAIL /u01/app/oracle/product/gg/dirdat/fx
TABLE scott.*;

GGSCI (node2.example.com) > edit params Fdp01

EXTRACT Fdp01
setenv (ORACLE_SID="DB11G")
setenv (NLS_LANG="AMERICAN_AMERICA.WE8MSWIN1252")
USERID ggate, PASSWORD ****
RMTHOST node2.example.com, MGRPORT 7809
RMTTRAIL /u01/app/oracle/product/gg/dirdat/ft
TABLE scott.*;

GGSCI (node2.example.com) > edit params rep01

REPLICAT rep01
setenv (ORACLE_SID="DB11G")
setenv (NLS_LANG="AMERICAN_AMERICA.WE8MSWIN1252")
USERID ggate, PASSWORD ****
ASSUMETARGETDEFS
MAP scott.*, TARGET scott.*;

GGSCI (node2.example.com) > EDIT PARAMS ./GLOBALS

CHECKPOINTTABLE ggate.OGGCHKPT
GGSCI (node2.example.com) > start mgr

GGSCI (node2.example.com) > dblogin userid ggate, Password ***

GGSCI (node2.example.com) > Add CheckpointTable

GGSCI (node2.example.com) > add trandata scott.*

GGSCI (node2.example.com) > Add Extract Fcapt01, TranLog, Begin Now

GGSCI (node2.example.com) > Add ExtTrail ./u01/app/oracle/product/gg/dirdat/fx, Extract capt01, Megabytes 5 ---(process for fail back replication)

GGSCI (node2.example.com) > Add Extract Fdp01, ExtTrailSource /u01/app/oracle/product/gg/dirdat/ft

GGSCI (node2.example.com) > Add RmtTrail /u01/app/oracle/product/gg/dirdat/ft, Extract dp01, Megabytes 5 ----(process for fail back replication)

GGSCI (node2.example.com) > Add Replicat Frep01, ExtTrail /u01/app/oracle/product/gg/dirdat/rt

GGSCI (node2.example.com) > info all

Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER STOPPED
EXTRACT STOPPED FCAPT01 00:00:00 00:00:54
EXTRACT STOPPED FDP01 00:00:00 00:00:46
REPLICAT STOPPED FREP01 00:00:00 00:00:02

part III) start migration process

1)start capture process

GGSCI (node1.example.com) > start EXTRACT FCAPT01
GGSCI (node1.example.com) > start EXTRACT FDP01

2)check latest flshback_scn from source database

SQL> select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------
1189734

3)export application schema data using import and export utility .

[oracle@node1 gg]$ expdp ggate schemas=scott directory=DATA_PUMP_DIR dumpfile=SCHEMA_scott_dp.dmp logfile=SCHEMA_scott_dp.log flashback_scn=1189734

Export: Release 11.2.0.3.0 -Production on Sat Sep 30 10:07:05 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Password:
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 -64bit Production
New Section 3 Page 4
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 -64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
FLASHBACK automatically enabled to preserve database integrity.
Starting "GGATE"."SYS_EXPORT_SCHEMA_01": ggate/******** schemas=scott directory=DATA_PUMP_DIR dumpfile=SCHEMA_scott_dp.dmp logfile=SCHEMA_scott_dp.log
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 192 KB
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "SCOTT"."DEPT" 5.984 KB 6 rows
. . exported "SCOTT"."EMP" 8.570 KB 14 rows
. . exported "SCOTT"."SALGRADE" 5.882 KB 6 rows
. . exported "SCOTT"."BONUS" 0 KB 0 rows
Master table "GGATE"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for GGATE.SYS_EXPORT_SCHEMA_01 is:
/u01/app/oracle/admin/DB11G/dpdump/SCHEMA_scott_dp.dmp
Job "GGATE"."SYS_EXPORT_SCHEMA_01" successfully completed at 10:07:36

4)import Application user data usig import export utility:

[oracle@node1 gg]$ impdp ggate schemas=scott directory=DATA_PUMP_DIR dumpfile=SCHEMA_scott_dp.dmp logfile=SCHEMA_scott_dp.log

5)start replication process on target database.
GGSCI (node2.example.com) > start rep01 aftercsn 1189734;

6)wait utile source and target database in sync.
check lag both capt01 and DP01 process mass will be as follow
as EOF no more record to process

7)stop application.

8)stop exrtact, datapump,replicat process

9)start the GG failback process.

on tagate database which now source.

GGSCI (node2.example.com) > alter FCAPT01 begin now
GGSCI (node2example.com) > info FDP01 detail
GGSCI (node2.example.com) > start extract  FDP01
GGSCI (node1.example.com) > alter FREP01 extseqno 2 ------(on source database)
GGSCI (node2.example.com) > alter FREP01 extrba 0
GGSCI (node2.example.com) > start EXTRACT FCAPT01
GGSCI (node2.example.com) > start EXTRACT FCAPT01
GGSCI (node2.example.com) > start FREP01
step 10)switch application to new database server.

now all Applications running on new database server , old database server is your standby database server once you
confirm about transaction , performance etc about new database server you can stop gg process.

note: during import export operation you can use extra parameter for fast performance and also change some parameter in init.ora file.

Login to the database as user C##GGUSER failed because of error Error while trying to retrieve text for error ORA-01804.

 Error :  2026-09-19 11:28:18  ERROR   OGG-00303  Unable to connect to database using user C##GGUSER@CDB. Ensure that the necessary privileg...