How to make a physical copy of database? - db2

I am looking for a solution to make a copy of a DB2 databaseusing Toad.
I have tried the db2move command like this:
db2move sample COPY -sn BASESAT -co target_db schema_map "((BASESAT,BASESAT4))" -u SATURNE
BASESAT is my database and BASESAT4 is the copy I want to create
I get this error:
When I tried on command mode. I got this

Maybe this could help you.
to create a sample database;
user#host:/home/db2inst1:>db2 "create db sampledb"
DB20000I The CREATE DATABASE command completed successfully.
user#host:/home/db2inst1:>db2 connect to sampledb
Database Connection Information
Database server = DB2
SQL authorization ID = DB2INST1
Local database alias = SAMPLEDB
sample table;
user#host:/home/db2inst1:>db2 "CREATE TABLE SAMPLETABLE (COL1 CHAR(6) NOT NULL, COL2 VARCHAR(24) NOT NULL)"
DB20000I The SQL command completed successfully.
insert an dummy row;
user#host:/home/db2inst1:>db2 "insert into SAMPLETABLE VALUES ('test1','test2')"
DB20000I The SQL command completed successfully.
this is export;
user#host:/home/db2inst1:>mkdir data
user#host:/home/db2inst1:>cd data/
user#host:/home/db2inst1/data:>db2move sampledb export
Application code page not determined, using ANSI codepage 819
***** DB2MOVE *****
Action: EXPORT
Start time: Mon Jul 18 17:49:49 2016
Connecting to database SAMPLEDB ... successful! Server : DB2 Common Server V10.5.7
EXPORT: 147 rows from table "SYSTOOLS"."HMON_ATM_INFO"
EXPORT: 0 rows from table "SYSTOOLS"."HMON_COLLECTION"
EXPORT: 5 rows from table "SYSTOOLS"."POLICY"
EXPORT: 1 rows from table "DB2INST1"."SAMPLETABLE"
Disconnecting from database ... successful!
End time: Mon Jul 18 17:49:49 2016
to generate ddls.
user#host:/home/db2inst1/data:>db2look -d sampledb -e -a -o db2look.sql
-- Generate statistics for all creators
-- Creating DDL for table(s)
-- Output is sent to file: db2look.sql
-- Binding package automatically ...
-- Bind is successful
-- Binding package automatically ...
-- Bind is successful
user#host:/home/db2inst1/data:>db2 terminate
DB20000I The TERMINATE command completed successfully.
this is second database.
user#host:/home/db2inst1/data:>db2 "create db copydb"
DB20000I The CREATE DATABASE command completed successfully.
user#host:/home/db2inst1/data:>db2 "connect to copydb"
Database Connection Information
Database server = DB2
SQL authorization ID = DB2INST1
Local database alias = COPYDB
change database name in db2look as below
CONNECT TO COPYDB;
user#host:/home/db2inst1/data:>db2 -tvf db2look.sql
CONNECT TO COPYDB
Database Connection Information
Database server = DB2
SQL authorization ID = DB2INST1
Local database alias = COPYDB
CREATE SCHEMA "DB2INST1"
DB20000I The SQL command completed successfully.
CREATE TABLE "DB2INST1"."SAMPLETABLE" ( "COL1" CHAR(6 OCTETS) NOT NULL , "COL2" VARCHAR(24 OCTETS) NOT NULL ) IN "USERSPACE1" ORGANIZE BY ROW
DB20000I The SQL command completed successfully.
COMMIT WORK
DB20000I The SQL command completed successfully.
CONNECT RESET
DB20000I The SQL command completed successfully.
TERMINATE
DB20000I The TERMINATE command completed successfully.
You can also use import instead of load.
user#host:/home/db2inst1/data:>db2move copydb load
Application code page not determined, using ANSI codepage 819
***** DB2MOVE *****
Action: LOAD
Start time: Mon Jul 18 17:57:41 2016
Connecting to database COPYDB ... successful! Server : DB2 Common Server V10.5.7
Binding package automatically ... /home/db2inst1/sqllib/bnd/db2common.bnd ... successful!
Binding package automatically ... /home/db2inst1/sqllib/bnd/db2move.bnd ... successful!
* LOAD: table "SYSTOOLS"."HMON_ATM_INFO"
*** ERROR -3304. Check message file tab1.msg!
*** SQLCODE: -3304 - SQLSTATE:
*** SQL3304N The table does not exist.
* LOAD: table "SYSTOOLS"."HMON_COLLECTION"
*** ERROR -3304. Check message file tab2.msg!
*** SQLCODE: -3304 - SQLSTATE:
*** SQL3304N The table does not exist.
* LOAD: table "SYSTOOLS"."POLICY"
*** ERROR -3304. Check message file tab3.msg!
*** SQLCODE: -3304 - SQLSTATE:
*** SQL3304N The table does not exist.
* LOAD: table "DB2INST1"."SAMPLETABLE"
-Rows read: 1
-Loaded: 1
-Rejected: 0
-Deleted: 0
-Committed: 1
**Error occured -1
Disconnecting from database ... successful!
End time: Mon Jul 18 17:57:43 2016
user#host:/home/db2inst1/data:>db2 "connect to copydb"
Database Connection Information
Database server = DB2
SQL authorization ID = DB2INST1
Local database alias = COPYDB
user#host:/home/db2inst1/data:>db2 "select * from SAMPLETABLE"
COL1 COL2
------ ------------------------
test1 test2
1 record(s) selected.

I got the solution thanks to your help.
Here are the steps if someone else has the same problem:
1-create the database in which to copy (in my case BASESAT2)
2-use db2move in command mode like this:
db2move dbname COPY -sn SCHEMA_OF_YOUR_DBname -co TARGET_DB dbname_copy USER user_name USING password
Here is a screenshot.

Related

Not able to run oracle database 12 on kubernetes with persistent volume

Hi I am trying to run oracle db 12 on k8s, with a persistent volume, but it's throwing the error below. please what I am missing
I have created a pv/pvc, mount path /opt/oracle/oradata
permissions to uid 54321 are provided
Listener Log File /opt/oracle/diag/tnslsnr/oracledb-c6867b8cf-v6bnf/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
The listener supports no services
The command completed successfully
[WARNING] [DBT-10328] Specified GDB Name (ORCLCDB) may have a potential conflict with an already existing database on the system.
ACTION: Specify a different GDB Name that does not conflict with existing databases on the system.
[FATAL] [DBT-10317] Specified SID Name (ORCLCDB) already exists.
ACTION: Specify a different SID Name that does not already exist.
SQL> ALTER SYSTEM SET control_files='/opt/oracle/oradata/ORCLCDB/control01.ctl' scope=spfile
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
SQL> ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
SQL> BEGIN DBMS_XDB_CONFIG.SETGLOBALPORTENABLED (TRUE); END;
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
SQL> Disconnected
mv: cannot stat '/opt/oracle/product/12.2.0.1/dbhome_1/dbs/spfileORCLCDB.ora': No such file or directory
mv: cannot stat '/opt/oracle/product/12.2.0.1/dbhome_1/dbs/orapwORCLCDB': No such file or directory
The Oracle base remains unchanged with value /opt/oracle
#####################################
########### E R R O R ###############
DATABASE SETUP WAS NOT SUCCESSFUL!
Please check output for further info!
########### E R R O R ###############
please what I am missing. can be related to env
where can I find more logs

Can not create backup of Firebird database because of the errors

At the time of backup firebird database (gbak -g -ig) I have the following error:
gbak: writing data for table ORDERS
gbak: ERROR:message length error (encountered 532, expected 528)
gbak: ERROR:gds_$receive failed
gbak:Exiting before completion due to errors
When I'm using gfix with different parameters (-v -full, -mend, -ignore), I have the message:
Summary of validation errors
Number of index page errors : 540
In firebird.log file I see the lines:
PC (Server) Thu Sep 20 08:37:01 2018
Database: E:\...GDB
Index 2 is corrupt on page 134706 level 1. File: ..\..\..\src\jrd\validation.cpp, line: 1699
in table COMPONENTS (197)
However, the database works OK without problems.
Please help me to fix the error and make a backup.
(I need the backup to migrate to on 64bit server).

How to monitor a deadlock in DB2

I am following this link and try to simulate the deadlock issue:
http://www.dba-db2.com/2012/06/how-to-monitor-a-deadlock-in-db2.html
I can see my command run successful.
After that I go to simulate a deadlock error through DbVisualiser tool. However I didnt see any file being generated to the path.
Can someone point the mistake to me?
And also, I try to read back those old 0000000.evt file, it show me something as follow:
EVENT LOG HEADER
Event Monitor name: DB2DETAILDEADLOCK
Server Product ID: SQL10059
Version of event monitor data: 12
Byte order: BIG ENDIAN
Number of nodes in db2 instance: 1
Codepage of database: 1208
Territory code of database: 1
Server instance name: db2inst1
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Database Name: MYDB
Database Path: /db2home/db2inst1/NODE0000/SQL00003/MEMBER0000/
First connection timestamp: 01/29/2018 10:00:17.694784
Event Monitor Start time: 01/29/2018 10:00:18.951331
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Database Name: MYDB
Database Path: /db2home/db2inst1/NODE0000/SQL00003/MEMBER0000/
First connection timestamp: 01/29/2018 10:12:54.382936
Event Monitor Start time: 01/29/2018 10:12:54.697223
--------------------------------------------------------------------------
This means no deadlock?
Works correctly for me (linux, Db2 v11.1). Here are some command lines with annotations. You need to have suitable authorisation/privilege for each command. I was using the instance owner account.
Disable default db2detaildeadlock monitor first and then create your own:
$ db2 "set event monitor db2detaildeadlock state=0"
DB20000I The SQL command completed successfully.
$
$ db2 "create event monitor dlmon for deadlocks write to file '/tmp'"
DB20000I The SQL command completed successfully.
$
$ db2 "set event monitor dlmon state=1"
DB20000I The SQL command completed successfully.
$
Generate a deadlock, ensure you see this SQLCODE -911 with reason code 2.
If you dont' see the reason code 2 then you don't have any deadlock but you might have a timeout and timeouts don't get recorded in the deadlock monitor.
Here I show the victim of the deadlock getting notified of rollback and you can see the correct reason code:
$ db2 +c "select * from db2inst1.dlk where a=4 with rr"
SQL0911N The current transaction has been rolled back because of a deadlock
or timeout. Reason code "2". SQLSTATE=40001
Investigate the monitor output with db2evmon and view resulting file
$ db2evmon -db mydb -evm dlmon > /tmp/db2evmon.dlmon.1
Reading /tmp/00000000.evt ...
$ view /tmp/db2evmon.dlmon.1
...<snip>
...
3) Deadlock Event ...
Deadlock ID: 2
Number of applications deadlocked: 2
Deadlock detection time: 01/03/2018 09:06:39.019854
Rolled back Appl participant no: 2
Rolled back Appl Id: *LOCAL.db2inst1.180301090546
Rolled back Appl seq number: 00001
Rolled back Appl handle: 11872
...<snip>

ERROR: Transaction not found

I have just found in pg_log some line of this specific error:
ERROR: Transaction not found //some_hash
error + surrounding lines:
2014-06-04 15:08:49 CEST my_user db_name LOCATION: exec_bind_message, postgres.c:1771
2014-06-04 15:08:49 CEST my_user db_name NOTICE: 00000: Transaction expired
2014-06-04 15:08:49 CEST my_user db_name LOCATION: exec_stmt_raise, pl_exec.c:3041
2014-06-04 15:08:49 CEST my_user db_name ERROR: P0001: Transaction not found egcrppnddxt82frc
2014-06-04 15:08:49 CEST my_user db_name LOCATION: exec_stmt_raise, pl_exec.c:3041
I have found this error only in postgres source code. Is it some internal error? When it can occur?
PostgreSQL version:
PostgreSQL 9.3.2 on x86_64-unknown-linux-gnu,
compiled by gcc (Debian 4.4.5-8) 4.4.5, 64-bit
It's a comment I have found in the source code:
/* We check the transaction's database ID for paranoia's sake: if
it's in another DB then its xmin does not cover us. Caller
should have detected this already, so we just treat any funny
cases as "transaction not found".*/
Your errors are being thrown by user defined code written in PL/PgSQL.
They are not coming from PostgreSQL. That is why the message Transaction not found does not appear in PostgreSQL's source code except in comments. You're barking up entirely the wrong tree.
This:
2014-06-04 15:08:49 CEST my_user db_name ERROR: P0001: Transaction not found egcrppnddxt82frc
2014-06-04 15:08:49 CEST my_user db_name LOCATION: exec_stmt_raise, pl_exec.c:3041
shows:
The SQLSTATE is P0001, the default code used by RAISE ERROR in PL/PgSQL if you don't override it;
It's being logged from exec_stmt_raise, the RAISE statement, inside pl_exec.c, the PL/PgSQL executor;
Transaction not found egcrppnddxt82frc is a message from your application
I would've expected to see more context lines showing the PL/PgSQL procedure name, too, but perhaps in an explicit RAISE they're only emitted to the client, not the server error log. I don't remember.
You might be able to locate the culprit with:
\x
SELECT *
FROM pg_proc p
INNER JOIN pg_language l ON (p.prolang = l.oid)
WHERE l.lanname = 'plpgsql'
AND p.prosrc LIKE '%Transaction not found%';
.. assuming that the procedure isn't forming the error from several separate strings or getting it from somewhere else.
This is why you always include complete, un-edited error messages. If you'd just showed the whole error line I could've told you what was going on hours ago.

mySQL Workbench Importing

I was trying to import it but i am encountering some errors.
this is my error:
08:49:13 PM Restoring dbDB (contact)
Running: mysql --defaults-extra-file="/tmp/tmpdwf14l/extraparams.cnf" --host=127.0.0.1 --user=root --port=3306 --default-character-set=utf8 --comments
ERROR 1046 (3D000) at line 22: No database selected
Operation failed with exitcode 1
08:49:13 PM Restoring dbDBB (course)
Running: mysql --defaults-extra-file="/tmp/tmpMW20Fb/extraparams.cnf" --host=127.0.0.1 --user=root --port=3306 --default-character-set=utf8
ERROR 1046 (3D000) at line 22: No database selected
Error: You have not selected the default target schema in which to import the data from dump
Create a schema/database in MySQL and select that database in MySQL Workbench while importing data from Dump.
Or
You can edit the dump file and append a SQL statement at the start with some thing like this
create database test;
use test;
Solution as per the dump file of user:
--
-- Table structure for table `course`
--
Write the code as :
create database test1;
use test1;
--
-- Table structure for table `course`
--
This should do.
The error is because you havent selected any database; In the dump right below create schema 'database_name' (or create database 'database_name') add this : use 'database_name';
Replace the database_name with your DB name;