Using Debezium Connector for Oracle with LogMiner and without XSTREAM - oracle

I am trying to create a connector for oracle using LogMiner adapter.
I preconfigured my oracle db in that way.
My dockerfile
FROM store/oracle/database-enterprise:12.2.0.1
# creating directory inside the container, where all sql scripts will be locaited
#WORKDIR /home/oracle/setup/custom_scripts
WORKDIR /opt/oracle/oradata
WORKDIR /opt/oracle/oradata/recovery_area
WORKDIR /opt/oracle/oradata/ORCLCDB
WORKDIR /opt/oracle/oradata/ORCLCDB/ORCLPDB1/
WORKDIR /u01/app/oracle/product/12.2.0/dbhome_1/inventory
WORKDIR /u01/app/oracle/product/12.2.0/dbhome_1/bin
#Running my custom scripts
COPY configDBora.sh /home/oracle/setup/
RUN chgrp 54321 /opt/oracle/oradata
RUN chown 54321 /opt/oracle/oradata
RUN chgrp 54321 /opt/oracle/oradata/recovery_area
RUN chown 54321 /opt/oracle/oradata/recovery_area
RUN chgrp 54321 /u01/app/oracle/product/12.2.0/dbhome_1/inventory
RUN chown 54321 /u01/app/oracle/product/12.2.0/dbhome_1/inventory
RUN chgrp 54321 /u01/app/oracle/product/12.2.0/dbhome_1/bin
RUN chown 54321 /u01/app/oracle/product/12.2.0/dbhome_1/bin
My configDBora.sh based on Debezium oracle set up that I copy to image when building it
echo "STAGE 1"
sqlplus /nolog 2>&1 <<EOF
CONNECT sys/Admin123 AS SYSDBA
alter system set db_recovery_file_dest_size = 15G;
alter system set db_recovery_file_dest = '/opt/oracle/oradata/recovery_area' scope=spfile;
shutdown immediate
startup mount
alter database archivelog;
alter database open;
archive log list
exit;
EOF
echo "STAGE 2"
# Enable LogMiner required database features/settings
sqlplus sys/Admin123 as sysdba <<- 'EOF'
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
SELECT SUPPLEMENTAL_LOG_DATA_MIN min,
SUPPLEMENTAL_LOG_DATA_PK pk,
SUPPLEMENTAL_LOG_DATA_UI ui,
SUPPLEMENTAL_LOG_DATA_FK fk,
SUPPLEMENTAL_LOG_DATA_ALL "all"
from v$database;
ALTER PROFILE DEFAULT LIMIT FAILED_LOGIN_ATTEMPTS UNLIMITED;
exit;
EOF
echo "STAGE 3"
# Create Log Miner Tablespace and User
sqlplus sys/Admin123 as sysdba <<- EOF
CREATE TABLESPACE LOGMINER_TBS DATAFILE '/opt/oracle/oradata/ORCLCDB/logminer_tbs.dbf' SIZE 25M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
exit;
EOF
sqlplus sys/Admin123 as sysdba <<- EOF
alter session set container=ORCLPDB1;
CREATE TABLESPACE LOGMINER_TBS DATAFILE '/opt/oracle/oradata/ORCLCDB/ORCLPDB1/logminer_tbs.dbf' SIZE 25M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
exit;
EOF
echo "STAGE 4"
sqlplus sys/Admin123 as sysdba <<- 'EOF' #THE MOST IMPORTANT PART
CREATE USER c##dbzuser IDENTIFIED BY dbz DEFAULT TABLESPACE LOGMINER_TBS QUOTA UNLIMITED ON LOGMINER_TBS CONTAINER=ALL;
GRANT CREATE SESSION TO c##dbzuser CONTAINER=ALL;
GRANT SET CONTAINER TO c##dbzuser CONTAINER=ALL;
GRANT SELECT ON V_$DATABASE TO c##dbzuser CONTAINER=ALL;
GRANT FLASHBACK ANY TABLE TO c##dbzuser CONTAINER=ALL;
GRANT SELECT ANY TABLE TO c##dbzuser CONTAINER=ALL;
GRANT SELECT_CATALOG_ROLE TO c##dbzuser CONTAINER=ALL;
GRANT EXECUTE_CATALOG_ROLE TO c##dbzuser CONTAINER=ALL;
GRANT SELECT ANY TRANSACTION TO c##dbzuser CONTAINER=ALL;
GRANT SELECT ANY DICTIONARY TO c##dbzuser CONTAINER=ALL;
GRANT LOGMINING TO c##dbzuser CONTAINER=ALL;
GRANT CREATE TABLE TO c##dbzuser CONTAINER=ALL;
GRANT LOCK ANY TABLE TO c##dbzuser CONTAINER=ALL;
GRANT CREATE SEQUENCE TO c##dbzuser CONTAINER=ALL;
GRANT EXECUTE ON DBMS_LOGMNR TO c##dbzuser CONTAINER=ALL;
GRANT EXECUTE ON DBMS_LOGMNR_D TO c##dbzuser CONTAINER=ALL;
GRANT SELECT ON V_$LOGMNR_LOGS TO c##dbzuser CONTAINER=ALL;
GRANT SELECT ON V_$LOGMNR_CONTENTS TO c##dbzuser CONTAINER=ALL;
GRANT SELECT ON V_$LOGFILE TO c##dbzuser CONTAINER=ALL;
GRANT SELECT ON V_$ARCHIVED_LOG TO c##dbzuser CONTAINER=ALL;
GRANT SELECT ON V_$ARCHIVE_DEST_STATUS TO c##dbzuser CONTAINER=ALL;
exit;
EOF
echo "STAGE 5"
sqlplus sys/Admin123 as sysdba <<- EOF
alter session set container=ORCLPDB1;
CREATE USER debezium IDENTIFIED BY dbz;
GRANT CONNECT TO debezium;
GRANT CREATE SESSION TO debezium;
GRANT CREATE TABLE TO debezium;
GRANT CREATE SEQUENCE to debezium;
ALTER USER debezium QUOTA 100M on users;
exit;
EOF
echo "STAGE 6"
sqlplus sys/Admin123 as sysdba <<- EOF
alter session set current_schema = C##DBZUSER;
exit;
EOF
My Source CDC Connector:
"tasks.max": 1,
"connector.class": "io.debezium.connector.oracle.OracleConnector",
"database.server.name": "server1",
"database.hostname" : "oracle",
"database.port" : "1521",
"database.user" : "c##dbzuser",
"database.password" : "dbz",
"database.dbname" : "ORCLCDB",
"database.history.kafka.bootstrap.servers" : "broker:29092",
"database.history.kafka.topic": "server1.oracle.history",
"database.history.skip.unparseable.ddl": "true",
"include.schema.changes": "true",
"table.include.list": "C##DBZUSER.*",
"database.connection.adapter": "logminer",
"database.tablename.case.insensitive": "true",
"database.url": "jdbc:oracle:thin:#oracle:1521:ORCLCDB",
"snapshot.mode": "initial",
"errors.log.enable": "true",
"key.converter": "io.confluent.connect.avro.AvroConverter",
"key.converter.schema.registry.url": "http://schema-registry:8081",
"value.converter": "io.confluent.connect.avro.AvroConverter",
"value.converter.schema.registry.url": "http://schema-registry:8081"
Connector launches successfully and generate topics with my tables.
When I try to insert into any of this table on oracle db there is no capture of insert (or update) query.
Who can tell me where have I gone wrong ?
I really need help over this question.

The first step that I decided to do moving my DB to Oracle 19c Enterprise Edition.
I added setup-logminer.sh from my repo based on this debezium repo.
I copied setup-logminer.sh to this path /opt/oracle/scripts/extensions/startup/ when I was building a new docker image.
FROM container-registry.oracle.com/database/enterprise:19.3.0.0
WORKDIR /opt/oracle/oradata
WORKDIR /opt/oracle/oradata/recovery_area
WORKDIR /opt/oracle/oradata/ORCLCDB
WORKDIR /opt/oracle/oradata/ORCLCDB/ORCLPDB1/
WORKDIR /u01/app/oracle/product/19c/dbhome_1/inventory
WORKDIR /u01/app/oracle/product/19c/dbhome_1/bin
#Running my custom scripts
COPY setup-logminer.sh /opt/oracle/scripts/extensions/startup/
RUN chgrp 54321 /opt/oracle/oradata
RUN chown 54321 /opt/oracle/oradata
RUN chgrp 54321 /opt/oracle/oradata/recovery_area
RUN chown 54321 /opt/oracle/oradata/recovery_area
RUN chgrp 54321 /u01/app/oracle/product/19c/dbhome_1/inventory
RUN chown 54321 /u01/app/oracle/product/19c/dbhome_1/inventory
RUN chgrp 54321 /u01/app/oracle/product/19c/dbhome_1/bin
RUN chown 54321 /u01/app/oracle/product/19c/dbhome_1/bin
I modified a little bit original script of setup-logminer.sh because I had this error in connector logs (STRUCT) type doesn't have a mapping to the SQL database column type.
After that I had to SET AUTOCOMMIT ON. By default in Oracle AUTOCOMMIT is off and I had to turn it on. As I am working in IDE I have to always set AUTO (look image) because it was Manual always. P.S. I also turned on autocommit in Oracle 12c but I had no result and I decided to drop it totally and move to Oracle 19c.
3. I moved my DB from CDB to PDB because it's bad to work in CDB. You have to use pluggable database.
{
...
"table.include.list": "DEBEZIUM.*",
...
}

Related

ORA-01109 Database not open error while running a script

I am running a script with SQLPlus in an Oracle DB which creates extra tablespaces. Here is the code of the script:
CREATE TABLESPACE FAR_YELLOW_FISH
DATAFILE
'$ORADATA/node03/faryellowfish01.dbf' SIZE 200M,
'$ORADATA/node03/faryellowfish02.dbf' SIZE 200M;
CREATE TABLESPACE WET_BROWN_SOUP
DATAFILE
'$ORADATA/node01/wetbrownsoup01.dbf' SIZE 100M,
'$ORADATA/node03/wetbrownsoup02.dbf' SIZE 100M;
CREATE TABLESPACE EASY_ORANGE_DISK
DATAFILE
'$ORADATA/node03/easyorangedisk01.dbf' SIZE 100M,
'$ORADATA/node03/easyorangedisk02.dbf' SIZE 100M,
'$ORADATA/node02/easyorangedisk03.dbf' SIZE 100M,
'$ORADATA/node02/easyorangedisk04.dbf' SIZE 100M;
CREATE TABLESPACE WET_YELLOW_OVEN
DATAFILE
'$ORADATA/node01/wetyellowoven01.dbf' SIZE 100M;
Before this I run the following:
sqlplus /nolog
connect / as sysdba
create SPFILE from PFILE;
startup nomount
and a script which creates main tablespaces - it works properly.
When running the script, that I mentioned first, I get the following error: ORA-01109: database not open. It appears for each CREATE TABLESPACE expression.
As a solution I tried to run ALTER DATABASE OPEN; but the answer was ORA-01507: database not mounted.
I guess, there is something wrong with the script, but not sure about that.
How can I solve it?
Your startup script isn't starting the database.
To start the database, do this:
sqlplus /nolog
connect / as sysdba
startup
Also, do not use environment variables (i.e. $ORADATA) in your SQL script. sqlplus won't know what they mean. Include the full path.

SP2-0310: unable to open file "__SUB__CWD__/sales_history/csh_v3.sql"

I am trying to install the sales_history sample schema, but I'm getting errors:
SP2-0310: unable to open file "__SUB__CWD__/sales_history/csh_v3.sql"
SP2-0310: unable to open file "__SUB__CWD__/sales_history/lsh_v3.sql"
SP2-0310: unable to open file "__SUB__CWD__/sales_history/psh_v3.sql"
How can I resolve this issue? The csh_v3.sql has full permissions,
Full session output:
SQL> #?/demo/schema/sales_history/sh_main.sql
specify password for SH as parameter 1:
Enter value for 1: password
specify default tablespace for SH as parameter 2:
Enter value for 2: users
specify temporary tablespace for SH as parameter 3:
Enter value for 3: temp
specify password for SYS as parameter 4:
Enter value for 4: password
specify directory path for the data files as parameter 5:
Enter value for 5: /u01/app/oracle/product/12.2/db_1/demo/schema/sales_history/
writeable directory path for the log files as parameter 6:
Enter value for 6: /u01/app/oracle/product/12.2/db_1/demo/schema/log/
specify version as parameter 7:
Enter value for 7: v3
specify connect string as parameter 8:
Enter value for 8: localhost:1522/techfuturepdb.elom.tg
Session altered.
DROP USER sh CASCADE
*
ERROR at line 1:
ORA-01940: cannot drop a user that is currently connected
old 1: CREATE USER sh IDENTIFIED BY &pass
new 1: CREATE USER sh IDENTIFIED BY password
CREATE USER sh IDENTIFIED BY password
*
ERROR at line 1:
ORA-01920: user name 'SH' conflicts with another user or role name
old 1: ALTER USER sh DEFAULT TABLESPACE &tbs
new 1: ALTER USER sh DEFAULT TABLESPACE users
old 2: QUOTA UNLIMITED ON &tbs
new 2: QUOTA UNLIMITED ON users
User altered.
old 1: ALTER USER sh TEMPORARY TABLESPACE &ttbs
new 1: ALTER USER sh TEMPORARY TABLESPACE temp
User altered.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Connected.
Grant succeeded.
old 1: CREATE OR REPLACE DIRECTORY data_file_dir AS '&data_dir'
new 1: CREATE OR REPLACE DIRECTORY data_file_dir AS '/u01/app/oracle/product/12.2/db_1/demo/schema/sales_history/'
Directory created.
old 1: CREATE OR REPLACE DIRECTORY log_file_dir AS '&log_dir'
new 1: CREATE OR REPLACE DIRECTORY log_file_dir AS '/u01/app/oracle/product/12.2/db_1/demo/schema/log/'
Directory created.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Connected.
Session altered.
Session altered.
SP2-0310: unable to open file "__SUB__CWD__/sales_history/csh_v3.sql"
SP2-0310: unable to open file "__SUB__CWD__/sales_history/lsh_v3.sql"
SP2-0310: unable to open file "__SUB__CWD__/sales_history/psh_v3.sql"
I just renamed the directory and it worked as expected:
mv db-sample-schemas-19.2 "__SUB__CWD__" ;
sqlplus system/Welcome1#node3/pdb1 #"__SUB__CWD__"/mksample.sql

database logical full backup export using expdp

I wrote the following commands:
create directory orcl_full as '/oradata3/datapump/full_export';
create user user1 identified by admin12;
grant read,write on directory orcl_full to user1;
grant exp_full_database to user1;
But when I tried exporting data using expdp command, it did not work:
expdp user1#ri/admin12#ORCL directory=orcl_full dumpfile=orclfull.dmp logfile=full_export.log FULL=YES;
Here is the error I get:
ORA-31626: job does not exist
ORA-31633: unable to create master table "user1.SYS_EXPORT_FULL_05"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPV$FT", line 1048
ORA-01950: no privileges on tablespace 'USERS'
I am stuck here, can someone kindly help me. In the tutorials, this command was working.
ORA-31626: job does not exist
ORA-31633: unable to create master table
Datapump uses a master table to manage the export job. Like any other table it needs storage which means it needs to write to a tablespace.
ORA-01950: no privileges on tablespace 'USERS'
When you created user1 account you did not grant it any tablespace privileges. So it cannot create any tables and that's why the job fails. The solution is quite simple: grant quota on the USERS tablespace (the default tablespace if no other is specified for the user account).
alter user user1 quota unlimited on users;
"got the following error :SP2-0734: unknown command beginning "expdp use..." - rest of line ignored. "
expdp is an OS executable. Your error is a SQL*plus error, which is a SQL client. Either fire up a terminal window and run the OS command there, or shell out from SQL*Plus using the host command.
This command worked :
expdp user1#ri15/$d_pass directory=orcl_full dumpfile=orclfull.dmp logfile=full_export.log FULL=YES;`

ORA-28000: the account is locked error getting frequently

I am facing this error given below :
ORA-28000: the account is locked
Is this a DB Issue ? Whenever I unlock the user account using the alter SQL query, that is ALTER USER username ACCOUNT UNLOCK, it will be temporarily OK.
Then after sometime the same account gets locked again. The database is using oracle XE version. Does anybody else have the same issue?
One of the reasons of your problem could be the password policy you are using.
And if there is no such policy of yours then check your settings for the password properties in the DEFAULT profile with the following query:
SELECT resource_name, limit
FROM dba_profiles
WHERE profile = 'DEFAULT'
AND resource_type = 'PASSWORD';
And If required, you just need to change the PASSWORD_LIFE_TIME to unlimited with the following query:
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
And this Link might be helpful for your problem.
Way to unlock the user :
$ sqlplus /nolog
SQL > conn sys as sysdba
SQL > ALTER USER USER_NAME ACCOUNT UNLOCK;
and open new terminal
SQL > sqlplus / as sysdba
connected
SQL > conn username/password //which username u gave before unlock
it will ask new password:password
it will ask re-type password:password
press enter u will get loggedin
Here other solution to only unlock the blocked user. From your command prompt log as SYSDBA:
sqlplus "/ as sysdba"
Then type the following command:
alter user <your_username> account unlock;
Check the PASSWORD_LOCK_TIME parameter. If it is set to 1 then you won't be able to unlock the password for 1 day even after you issue the alter user unlock command.
I have faced this similar issue and resolved it by using following steps :
Open windows command prompt.
Login using the command sqlplus "/ as sysdba"
Then executed the command alter user HR identified by password account unlock
Please note, the password is the password that I have used.
By using above steps you can connect to Oracle Database as user HR with the password password.
Solution 01
Account Unlock by using below query :
SQL> select USERNAME,ACCOUNT_STATUS from dba_users where username='ABCD_DEV';
USERNAME ACCOUNT_STATUS
-------------------- --------------------------------
ABCD_DEV LOCKED
SQL> alter user ABCD_DEV account unlock;
User altered.
SQL> select USERNAME,ACCOUNT_STATUS from dba_users where username='ABCD_DEV';
USERNAME ACCOUNT_STATUS
-------------------- --------------------------------
ABCD_DEV OPEN
Solution 02
Check PASSWORD_LIFE_TIME parameter by using below query :
SELECT resource_name, limit FROM dba_profiles WHERE profile = 'DEFAULT' AND resource_type = 'PASSWORD';
RESOURCE_NAME LIMIT
-------------------------------- ------------------------------
FAILED_LOGIN_ATTEMPTS 10
PASSWORD_LIFE_TIME 10
PASSWORD_REUSE_TIME 10
PASSWORD_REUSE_MAX UNLIMITED
PASSWORD_VERIFY_FUNCTION NULL
PASSWORD_LOCK_TIME 1
PASSWORD_GRACE_TIME 7
INACTIVE_ACCOUNT_TIME UNLIMITED
Change the parameter using below query
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
Login to SQL Plus client on the oracle database server machine.
enter user-name: system
enter password: password [Only if, if you have not changed your default password while DB installation]
press enter. after which, you will be seeing the connection status.
Now,
SQL> ALTER USER [USER_NAME] ACCOUNT UNLOCK;
press enter.
you will be seeing message: user altered.
Now try login with the user name on db client[sqldeveloper].
Unlock the particular user account with username:
ALTER USER [USER_NAME] ACCOUNT UNLOCK;
Unlock all the user accounts
SELECT 'alter user ' || username || ' account unlock;' FROM dba_users;

database not open

I am trying to create database using Oracle 11g R2 on windows 2008 server, when I run script to create database instance I will get the following error message
ERROR at line 1:
ORA-01109: database not open
grant select on ALL_MVIEW_DETAIL_PARTITION to public with grant option
*
ERROR at line 1:
ORA-01109: database not open
logged on as administrator.`
Thanks,
usermma
Login to Oracle with root
su - oracle
sqlplus / as sysdba
create user username identified by password;
Exception : ORA-01109 Database not open
To resolve this i trie below steps and succesfully created the schema.
Please verify the ORA_HOMEPATH/dbs/sgadef.dbf
Make ensure that after shutting down the Oracle server,if you find any services running on machine by entering below command
ps -ef | grep ora_ | grep DBName(sid)
Kill the processes if you find any by using kill command
kill -9 PID
Please check below file exists in mentioned path; if not please create.
ORACLE_HOMEPATH/dbs/lk<sid>
start mount; If the server is started use close immediate
SQL> alter database close;
Database altered.
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down
SQL> startup mount
ORACLE instance started.
Total System Global Area 126951228 bytes
Fixed Size 454460 bytes
Variable Size 109051904 bytes
Database Buffers 16777216 bytes
Redo Buffers 667648 bytes
Database mounted.
SQL> select open_mode from v$database;
OPEN_MODE
----------
MOUNTED
SQL> alter database open;
Database altered.
Now you can create your own schema as the database is open
SQL> create user schemaname identified by password;
SQL> grant resource,connect to schema name;
grant permission succeded.
I have done above steps to create a schema when database is not open.
Execute below Commands Sequentially....
> sqlplus
username/password = sys/*******
SQL> shutdown immediate;
SQL> startup mount;
SQL> recover database;
SQL> alter database open;
How did you create the script(s)? What does it do? Is there some reason you're not using the Database Configuration Assistant to do this? It may be simply a matter of not having the service for the instance created via oradim.

Resources