Sie sind auf Seite 1von 44

COPY DATA ONE SYSTEM TO ANOTHER SYSTEM

[arjun@localhost Desktop]$ su root


Password:
[root@localhost Desktop]# ls
server v10.1_linuxia32_server.tar.gz
[root@localhost Desktop]# scp v10.1_linuxia32_server.tar.gz trainee@192.168.1.2:~/
The authenticity of host '192.168.1.2 (192.168.1.2)' can't be established.
RSA key fingerprint is 19:9f:9d:19:da:ae:af:25:d1:0d:8f:05:2e:6d:fa:10.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.2' (RSA) to the list of known hosts.
trainee@192.168.1.2's password:
v10.1_linuxia32_server.tar.gz 100% 621MB 2.3MB/s 04:25
INSTALLATION
KERNEL PARAMETERS
[db2inst1@localhost ~]$ ipcs -l

------ Shared Memory Limits ------ Semaphore Limits ------ Messages: Limits --------
-------- -------- max queues system wide =
max number of segments = max number of arrays = 1024 1737
4096 max semaphores per array = max size of message (bytes) =
max seg size (kbytes) = 250 65536
1031316 max semaphores system wide default max size of queue
max total shared memory = 256000 (bytes) = 65536
(kbytes) = 8388608 max ops per semop call = 32
min seg size (bytes) = 1 semaphore max value = 32767

[arjun@localhost Desktop]$ su root Task #20 start


Password: Description: Replication tools
[root@localhost Desktop]# ls Estimated time 19 second(s)
v9.7_linuxia32_server.tar Task #20 end
[root@localhost Desktop]# tar -xvf Task #21 start
v9.7_linuxia32_server.tar Description: Relational wrappers common
[root@localhost Desktop]# ls Estimated time 3 second(s)
server v9.7_linuxia32_server.tar Task #21 end
[root@localhost Desktop]# cd server/ Task #22 start
[root@localhost server]# ls Description: Control Center
db2 db2_deinstall db2ls db2setup installFixPack Estimated time 42 second(s)
db2ckupgrade db2_install db2prereqcheck doc Task #22 end
[root@localhost server]# ./db2prereqcheck Task #23 start
[root@localhost server]# ./db2_install Description: Command Line Processor Plus
Default directory for installation of products - Estimated time 3 second(s)
/opt/ibm/db2/V10.1 Task #23 end
****************************************
Do you want to choose a different directory to Task #24 start
install [yes/no] ? Description: DB2 data source support
no Estimated time 7 second(s)
Specify one of the following keywords to install Task #24 end
DB2 products. Task #25 start
ESE , CONSV , WSE , EXP, PE , CLIENT Description: DB2 LDAP support
RTCL Estimated time 3 second(s)
Enter "help" to redisplay product names. Task #25 end
Enter "quit" to exit. Task #26 start
**************************************** Description: DB2 Instance Setup wizard
Ese Estimated time 8 second(s)
DB2 installation is being initialized. Task #26 end
Total number of tasks to be performed: 46 Task #27 start
Total estimated time for all tasks to be performed: Description: Spatial Extender client
1876 Estimated time 3 second(s)
Task #1 start Task #27 end
Description: Checking license agreement Task #28 start
acceptance Description: Base application development
Estimated time 1 second(s) tools
Task #1 end Estimated time 35 second(s)
Task #2 start Task #28 end
Description: Base Client Support for installation Task #29 start
with root privileges Description: DB2 Update Service
Estimated time 3 second(s) Estimated time 4 second(s)
Task #2 end Task #29 end
Task #3 start Task #30 start
Description: Product Messages - English Description: First Steps
Estimated time 11 second(s) Estimated time 3 second(s)
Task #3 end Task #30 end
Task #4 start Task #31 start
Description: Base client support Description: Product Signature for DB2
Estimated time 101 second(s) Enterprise Server Edition
Task #4 end Estimated time 5 second(s)
Task #5 start Task #31 end
Description: Java Runtime Support Task #32 start
Estimated time 94 second(s) Description: Sample database source
Task #5 end Estimated time 4 second(s)
Task #6 start Task #32 end
Description: Java Help (HTML) - English Task #33 start
Estimated time 7 second(s) Description: DB2 Text Search
Task #6 end Estimated time 200 second(s)
Task #7 start Task #33 end
Description: Base server support for installation Task #34 start
with root privileges Description: Informix data source support
Estimated time 7 second(s) Estimated time 4 second(s)
Task #7 end Task #34 end
Task #8 start Task #35 start
Description: Global Secure ToolKit Description: Setting DB2 library path
Estimated time 27 second(s) Estimated time 180 second(s)
Task #8 end Task #35 end
Task #9 start Task #36 start
Description: Java support Description: Installing or updating SA MP
Estimated time 11 second(s) Estimated time 40 second(s)
Task #9 end Task #36 end
Task #10 start Task #37 start
Description: SQL procedures Description: Executing control tasks
Estimated time 3 second(s) Estimated time 20 second(s)
Task #10 end Task #37 end
Task #11 start Task #38 start
Description: ICU Utilities Description: Updating global registry
Estimated time 41 second(s) Estimated time 20 second(s)
Task #11 end Task #38 end
Task #12 start Task #39 start
Description: Java Common files Description: Installing IBM Tivoli
Estimated time 20 second(s) Monitoring for Databases
Task #12 end Estimated time 600 second(s)
Task #13 start Task #39 end
Description: Base server support Task #40 start
Estimated time 223 second(s) Description: Starting DB2 Fault Monitor
Task #13 end Estimated time 10 second(s)
Task #14 start Task #40 end
Description: IBM Software Development Kit Task #41 start
(SDK) for Java(TM) Description: Updating the db2ls link
Estimated time 44 second(s) Estimated time 1 second(s)
Task #14 end Task #41 end
Task #15 start Task #42 start
Description: Control Center Help (HTML) - Description: Registering DB2 licenses
English Estimated time 5 second(s)
Estimated time 13 second(s) Task #42 end
Task #15 end Task #43 start
Task #16 start Description: Setting default global profile
Description: Connect support registry variables
Estimated time 3 second(s) Estimated time 1 second(s)
Task #16 end Task #43 end
Task #17 start Task #44 start
Description: Communication support - TCP/IP Description: Initializing instance list
Estimated time 3 second(s) Estimated time 5 second(s)
Task #17 end Task #44 end
Task #18 start Task #45 start
Description: Parallel Extension Description: Registering DB2 Update
Estimated time 3 second(s) Service
Task #18 end Estimated time 30 second(s)
Task #19 start Task #45 end
Description: EnterpriseDB code Task #46 start
Estimated time 3 second(s) Description: Updating global profile registry
Task #19 end Estimated time 3 second(s)
Task #46 end

A minor error occurred while installing "DB2 Enterprise Server Edition " on
this computer. Some features may not function correctly.
For more information see the DB2 installation log at
"/tmp/db2_install.log.8878".
DB2LS
[db2inst1@localhost ~]$ db2ls
Install Path Level Fix Pack Special Install Number Install Date
Installer UID
---------------------------------------------------------------------------------------------------------------------
/opt/ibm/db2/V10.1 10.1.0.0 0 Mon Apr 13 04:54:13 2015 PDT
0
DEINSTALL
[arjun@localhost ~]$ ls
Desktop
[arjun@localhost ~]$ cd Desktop/
[arjun@localhost Desktop]$ ls
server v10.1_linuxia32_server.tar.gz v9.7_linuxia32_server.tar
[arjun@localhost Desktop]$ cd server/
[arjun@localhost server]$ su root
Password:
[root@localhost server]# db2ls
Install Path Level Fix Pack Special Install Number Install Date
Installer UID
---------------------------------------------------------------------------------------------------------------------
/opt/ibm/db2/V10.1 10.1.0.0 0 Mon Apr 13 04:54:13 2015 PDT
0
[root@localhost server]# ls
db2 db2_deinstall db2ls db2setup installFixPack
db2ckupgrade db2_install db2prereqcheck doc
DEINSTALL
[root@localhost server]# ./db2_deinstall -a
Enter full path name for the install directory -
------------------------------------------------
/opt/ibm/db2/V10.1
DBI1016I Program db2_deinstall is performing uninstallation. Please
wait.
The deinstallation process cannot continue while there are DB2 instances related to the current
DB2 copy.
If you need to move up or down a level from this DB2 level, use the installFixPack command
from the DB2 image for the level you desire to move to, which will update this copy.
If you are only trying to uninstall this DB2 copy, you must either drop the related instances first,
or you can update the instances to another DB2 copy which is at the same version as this DB2
copy, then restart the db2_deinstall command.
A major error occurred during the execution that caused this program to terminate prematurely.
If the problem persists, contact your technical service representative. For more information see
the DB2 uninstallation log at
"/tmp/db2_deinstall.log.32140".
[root@localhost server]# ./db2_deinstall -a -b /opt/ibm/db2/V10.1
DBI1016I Program db2_deinstall is performing uninstallation. Please wait.
The execution completed successfully.
For more information see the DB2 uninstallation log at
"/tmp/db2_deinstall.log.7482".
GENERATE RESPONSE FILE
[root@localhost ~]# mkdir 2ktech
[root@localhost ~]# su db2inst1
[db2inst1@localhost ~]$ db2rspgn -d /home/db2inst1/2ktech
DBI1070I Program db2rspgn completed successfully.
[db2inst1@localhost ~]$ cd /home/db2inst1/2ktech
[db2inst1@localhost 2ktech]$ ls
db2ese.rsp db2ge.INS db2inst1.INS db2inst2.INS
[db2inst1@localhost 2ktech]$ cat db2ese.rsp
INSTANCE
[root@localhost instance]# useradd db2inst1
[root@localhost instance]# useradd db2fnc1
[root@localhost ~]# cd /opt/ibm/db2/V10.1/instance
[root@localhost instance]# ./db2icrt -u db2fnc1 db2inst1
DBI1070I Program db2icrt completed successfully.
CHANGING PASSWORD
[db2inst1@localhost ~]$ su root
Password:
[root@localhost db2inst1]# cd
[root@localhost ~]# passwd db2inst1
Changing password for user db2inst1.
New password:
BAD PASSWORD: it is based on a dictionary word
Retype new password:
passwd: all authentication tokens updated successfully.
SEE THE FENCED ID
cat /etc/passwd |grep -i f*
fenc1:x:501:501::/home/fenc1:/bin/bash
windows7:x:502:502::/home/windows7:/bin/bash
fenc2:x:503:503::/home/fenc2:/bin/bash
windows8:x:504:504::/home/windows8:/bin/bash
[db2inst1@localhost ~]$ db2pd -fmp
Database Member 0 -- Active -- Up 0 days 01:08:24 -- Date 04/13/2015 23:10:49
FMP:
Pool Size: 1
Max Pool Size: 200 ( Automatic )
Keep FMP: YES
Initialized: YES
Trusted Path: /home/db2inst1/sqllib/function/unfenced
Fenced User: db2fnc1
Shared Memory: 0x117B03C0
IPC Pool: 0x117B0400
DB2ILIST
[db2inst1@localhost ~]$ db2ilist
db2inst2
db2inst1
DB2START; DB2STOP
[db2inst1@localhost ~]$ db2start
03/31/2015 23:25:35 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.
[db2inst1@localhost ~]$ db2stop
04/01/2015 19:33:16 0 0 SQL1064N DB2STOP processing was successful.
SQL1064N DB2STOP processing was successful.
DB2 GET DBM CFG
[db2inst1@localhost ~]$ db2 get dbm cfg
Database Manager Configuration
CPU speed (millisec/instruction) (CPUSPEED) = 5.313873e-07
TCP/IP Service name (SVCENAME) =
Max number of concurrently active databases (NUMDB) = 32
Max number of concurrently active databases (NUMDB) = 8 (V9.7)

DB2 UPDATE DBM CFG USING SVCENAME


[db2inst1@localhost ~]$ db2 update dbm cfg using SVCENAME 60000
DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed
successfully.
DB2LEVEL
[db2inst1@localhost ~]$ db2level
DB21085I Instance "red" uses "32" bits and DB2 code release "SQL09071" with
level identifier "08020107".
Informational tokens are "DB2 v9.7.0.1", "s091114", "IP23033", and Fix Pack "1".
Product is installed at "/opt/ibm/db2/V10.1".
DB2 GET INSTANCE
[db2inst1@localhost ~]$ db2 get instance
The current database manager instance is: db2red
DB2SET –ALL
[db2inst1@localhost ~]$ db2set db2comm=tcpip
[db2inst1@localhost ~]$ db2set –all
[g] db2comm=tcpip
[g] DB2SYSTEM=localhost.localdomain
[g] DB2INSTDEF=red
DATABASE
[db2inst1@localhost ~]$ mkdir apath
[db2inst1@localhost ~]$ mkdir dpath
[db2inst1@localhost ~]$ db2 "create db gee automatic storage yes on /home/db2inst1/geauto
dbpath on /home/db2inst1/gedp alias ge pagesize 4 k"
DB20000I The CREATE DATABASE command completed successfully.
AUTOMATIC STORAGE NO
[db2inst1@localhost ~]$ db2 create db mydb automatic storage no
DB20000I The CREATE DATABASE command completed successfully.
[db2inst1@localhost ~]$ db2 connect to mydb
Database Connection Information
Database server = DB2/LINUX 10.1.0
SQL authorization ID = DB2INST1
Local database alias = MYDB
[db2inst1@localhost ~]$ db2 "create stogroup stg1 on '/home/db2inst1/sgpath'"
DB20000I The SQL command completed successfully.
[db2inst1@localhost ~]$ db2 "alter database mydb add storage on '/home/db2inst1/sgpath'"
DB20000I The SQL command completed successfully.
TO SEE THE AUTOMATIC STORAGE PATHS
[db2inst1@localhost ~]$ db2 "select * from sysibmadm.dbpaths"
DB2 LIST DB DIRECTORY
[db2inst1@localhost ~]$ db2 list db directory
System Database Directory
Number of entries in the directory = 4
Database 1 entry:
Database alias = GEE
Database name = GEE
Local database directory = /home/db2inst1/gedp
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number =0
Alternate server hostname =
Alternate server port number =
DB2 CONNECT TO GEE
[db2inst1@localhost ~]$ db2 connect to gee
Database Connection Information
Database server = DB2/LINUX 9.7.1
SQL authorization ID = DB2INST1
Local database alias = GEE
SEE THE DATABASE SIZE
[db2inst1@localhost ~]$ db2 "call get_dbsize_info (?,?,?,0)"
Value of output parameters --------------------------
Parameter Name : SNAPSHOTTIMESTAMP
Parameter Value : 2015-04-07-23.02.24.635037
Parameter Name : DATABASESIZE
Parameter Value : 300331008
Parameter Name : DATABASECAPACITY
Parameter Value : 39778002432
Return Status = 0
DB2 GET DB CFG
[db2inst1@localhost ~]$ db2 get db cfg
Database Configuration for Database
Log retain for recovery enabled (LOGRETAIN) = OFF
User exit for logging enabled (USEREXIT) = OFF
First log archive method (LOGARCHMETH1) = OFF
Track modified pages (TRACKMOD) = OFF
Number of primary log files (LOGPRIMARY) = 13
Number of secondary log files (LOGSECOND) = 4
Log buffer size (4KB) (LOGBUFSZ) = 256
TABLESPACES
DB2 LIST TABLESPACES
[db2inst1@localhost ~]$ db2 list tablespaces
Tablespaces for Current Database
Tablespace ID =0
Name = SYSCATSPACE
Type = Database managed space
Contents = All permanent data. Regular table space.
State = 0x0000
Detailed explanation:
Normal
Tablespace ID =1
Name = TEMPSPACE1
Type = System managed space
Contents = System Temporary data
State = 0x0000
Detailed explanation:
Normal
Tablespace ID =2
Name = USERSPACE1
Type = Database managed space
Contents = All permanent data. Large table space.
State = 0x0000
Detailed explanation:
Normal
CREATE TABLESPACES
SMS
[db2inst1@localhost ~]$ db2 "create regular tablespace mytab pagesize 4 k managed by system
using ('/home/db2inst1/cont1')"
DB20000I The SQL command completed successfully.
DMS
[db2inst1@localhost ~]$ db2 "create regular tablespace mytab1 pagesize 4 k managed by
database using (file '/home/db2inst1/cont2' 200000)"
DB20000I The SQL command completed successfully.
AUTOMATIC STORAGE
[db2inst1@localhost ~]$ db2 "create regular tablespace mytab2 pagesize 4 k managed by
automatic storage using stogroup stg1 initialsize 4m increasesize 2m maxsize 10m "
DB20000I The SQL command completed successfully.
ALL OPTIONS
[db2inst1@localhost ~]$ db2 "create large tablespace mytab3 pagesize 4 k managed by database
using (file '/home/db2inst1/cont5' 200000) extentsize 32 prefetchsize 400 overhead 30
transferrate 30 "
TABLESPACE STATE
[db2inst1@localhost ~]$ db2tbst 0x0000
State = Normal

ALTER TABLESPACE

db2 LIST TABLESPACES SHOW DETAIL ALTER TABLESPACE <AIX > ADD
[db2inst1@localhost ~]$ db2 "alter tablespace
[db2inst1@localhost ~]$ db2 list tablespaces aix add (file '/home/db2red/cont9' 10000)"
show detail DB20000I The SQL command completed
Tablespace ID =5 successfully.
Name = AIX Tablespace ID =5
Type = Database Name = AIX
managed space Type = Database managed
Contents = All permanent space
data. Regular table space. Contents = All permanent
State = 0x0000 data. Regular table space.
Detailed explanation: State = 0x0000
Normal Detailed explanation:
Total pages = 10000 Normal
Useable pages = 9952 Total pages = 20000
Used pages = 9952 Useable pages = 19904
Free pages =0 Used pages = 9952
High water mark (pages) = 9952 Free pages = 9952
Page size (bytes) = 4096 High water mark (pages) = 9952
Extent size (pages) = 32 Page size (bytes) = 4096
Prefetch size (pages) = 32 Extent size (pages) = 32
Number of containers =1 Prefetch size (pages) = 64
Number of containers =2

[db2inst1@localhost ~]$ db2 "alter stogroup stg1 add '/home/db2inst1/123'"


DB20000I The SQL command completed successfully.
[db2inst1@localhost ~]$ db2pd -d mydb –tablespaces
Containers:
Address TspId ContainNum Type TotalPgs UseablePgs PathID StripeSet Container
0xA738EE10 6 0 File 1280 1248 0 0
/home/db2inst1/sgpath/db2inst1/NODE0000/MYDB/T0000006/C0000000.USR
0xA738F014 6 1 File 1280 1248 1 0
/home/db2inst1/sgpath/db2inst1/NODE0000/MYDB/T0000006/C0000001.USR
[db2inst1@localhost ~]$ db2 alter tablespace mytab2 rebalance
DB20000I The SQL command completed successfully.
[db2inst1@localhost ~]$ db2pd -d mydb –tablespaces
Containers:
Address TspId ContainNum Type TotalPgs UseablePgs PathID StripeSet Container
0xA9055BD0 6 0 File 1280 1248 0 0
/home/db2inst1/sgpath/db2inst1/NODE0000/MYDB/T0000006/C0000000.USR
0xA9055DD4 6 1 File 1280 1248 1 0
/home/db2inst1/sgpath/db2inst1/NODE0000/MYDB/T0000006/C0000001.USR
0xA9055FD8 6 2 File 1280 1248 2 0
/home/db2inst1/123/db2inst1/NODE0000/MYDB/T0000006/C0000002.USR
EXTEND
[db2inst1@localhost ~]$ db2 " alter tablespace sap extend (file '/home/db2red/cont3' 100000)"
DB20000I The SQL command completed successfully.
REDUCE
[db2inst1@localhost ~]$ db2 " alter tablespace sap reduce (file '/home/db2red/cont3' 10000)"
DB20000I The SQL command completed successfully.
ADD
[db2inst1@localhost ~]$ db2 "alter tablespace aix add (file '/home/db2red/cont9' 10000)"
DB20000I The SQL command completed successfully.
RESIZE

[db2inst1@localhost ~]$ db2 "alter tablespace [db2inst1@localhost ~]$ db2 "alter tablespace
tab1 add (file '/home/db2inst1/aaa' 8 G)" tab1 resize (file '/home/db2inst1/aaa' 4 G)"
DB20000I The SQL command completed DB20000I The SQL command completed
successfully. successfully.
[db2inst1@localhost ~]$ db2 list tablespace [db2inst1@localhost ~]$ db2 list tablespace
containers for 4 show detail containers for 4 show detail
Tablespace Containers for Tablespace 4 Tablespace Containers for Tablespace 4
Container ID =0
Name = Container ID =0
/home/db2inst1/cont7 Name =
Type = File /home/db2inst1/cont7
Total pages = 2000000 Type = File
Useable pages = 1999968 Total pages = 2000000
Accessible = Yes Useable pages = 1999968
Container ID =1 Accessible = Yes
Name = Container ID =1
/home/db2inst1/aaa Name =
Type = File /home/db2inst1/aaa
Total pages = 2097152 Type = File
Useable pages = 2097120 Total pages = 1048576
Accessible = Yes Useable pages = 1048544
Accessible = Yes
REBALANCE

[db2inst1@localhost ~]$ db2 list tablespaces [db2inst1@localhost ~]$ db2 "alter stogroup
show detail stg1 add '/home/db2inst1/bdvpk'"
Tablespace ID =6 DB20000I The SQL command completed
Name = MYTAB2 successfully.
Type = Database managed [db2inst1@localhost ~]$ db2 "alter tablespace
space mytab2 rebalance"
Contents = All permanent DB20000I The SQL command completed
data. Regular table space. successfully.
State = 0x0000 [db2inst1@localhost ~]$ db2 list tablespaces
Detailed explanation: show detail
Normal Tablespace ID =6
Total pages = 3840 Name = MYTAB2
Useable pages = 3744 Type = Database managed
Used pages = 2496 space
Free pages = 1248 Contents = All permanent
High water mark (pages) = 2496 data. Regular table space.
Page size (bytes) = 4096 State = 0x0000
Extent size (pages) = 32 Detailed explanation:
Prefetch size (pages) = 96 Normal
Number of containers =3 Total pages = 5120
Useable pages = 4992
Used pages = 2496
Free pages = 2496
High water mark (pages) = 2496
Page size (bytes) = 4096
Extent size (pages) = 32
Prefetch size (pages) = 128
Number of containers =4

PREFETCHSIZE
[db2inst1@localhost ~]$ db2 "alter tablespace mytab3 prefetchsize 200"
DB20000I The SQL command completed successfully.

Tablespace ID =7 Tablespace ID =7
Name = MYTAB3 Name = MYTAB3
Type = Database managed Type = Database managed
space space
Contents = All permanent Contents = All permanent
data. Large table space. data. Large table space.
State = 0x0000 State = 0x0000
Detailed explanation: Detailed explanation:
Normal Normal
Total pages = 200000 Total pages = 200000
Useable pages = 199968 Useable pages = 199968
Used pages = 96 Used pages = 96
Free pages = 199872 Free pages = 199872
High water mark (pages) = 96 High water mark (pages) = 96
Page size (bytes) = 4096 Page size (bytes) = 4096
Extent size (pages) = 32 Extent size (pages) = 32
Prefetch size (pages) = 400 Prefetch size (pages) = 200
Number of containers =1 Number of containers =1

BUFFERPOOL
[db2inst1@localhost ~]$ db2 create bufferpool bp1 size 2000 pagesize 4 k
DB20000I The SQL command completed successfully.
[db2inst1@localhost ~]$ db2 alter tablespace mytab3 bufferpool bp1
DB20000I The SQL command completed successfully.
0xA8BBA540 7 DMS Large 4096 32 No 200 1 2 Off 1 0 31
MYTAB3
[db2inst1@localhost ~]$ db2 "select tbspace,bufferpoolid from syscat.tablespaces"
TBSPACE BUFFERPOOLID
-------------------------------------------------------------------------------------------------------------------
SYSCATSPACE 1
TEMPSPACE1 1
USERSPACE1 1
SYSTOOLSPACE 1
MYTAB2 1
MYTAB3 2
8 record(s) selected.
[db2inst1@localhost ~]$ db2 "select bpname,bufferpoolid from syscat.bufferpools"
BPNAME BUFFERPOOLID

IBMDEFAULTBP 1
BP1 2
OVERHED
[db2inst1@localhost ~]$ db2 alter tablespace mytab3 overhead 40
DB20000I The SQL command completed successfully.
[db2inst1@localhost ~]$ db2 alter tablespace mytab3 overhead 20
DB20000I The SQL command completed successfully.
TRANSDERATE
[db2inst1@localhost ~]$ db2 alter tablespace mytab3 transferrate 30
DB20000I The SQL command completed successfully
SWITCH ONLINE
MAXSIZE
CONCERT TO LARGE
[db2inst1@localhost ~]$ db2 "alter table space mytab1 convert to large"
SQL1237W Table space "MYTAB1" is being converted from REGULAR to LARGE. Indexes
on tables in this table space must be reorganized or rebuilt to support large RIDs.
SQLSTATE=01686
BUFFERPOOL
[db2inst1@localhost ~]$ db2 "select * from syscat.bufferpools"
BPNAME BUFFERPOOLID
DBPGNAME
S BLOCKSIZE NGNAME NPAGES PAGESIZE ESTORE
NUMBLOCKPAGE
---------------------------------------------------------------------------------------------------------------------
IBMDEFAULTBP 1-
0 0- -2 4096 N
1 record(s) selected.
CREATE BUFFERPOOL:
[db2inst1@localhost ~]$ db2 "create bufferpool gebp pagesize 8 k"
DB20000I The SQL command completed successfully.
SEHEMA
[db2inst1@localhost ~]$ db2 "select schemaname from syscat.schemata"
SCHEMANAME

NULLID Sysstat
SQLJ Sysfun
SYSCAT Sysibm
SYSFUN Syscat
SYSIBM Sysibmadm
SYSIBMADM OWNER SYSIBM
SYSIBMINTERNAL
SYSIBMTS
SYSPROC
SYSPUBLIC
SYSSTAT
SYSTOOLS
12 record(s) selected.

CREATE SCHEMA
[db2inst1@localhost ~]$ db2 "create schema geschema "
DB20000I the SQL command completed successfully.
DB2 LIST APPLICATION SHOW DETAIL
[db2inst1@localhost ~]$ db2 list application show detail
CONNECT Auth Id
Application Name Appl. Application Id Seq# Number of
Coordinating DB Coordinator Status Status Change Time DB Name DB
Path
Handle
Agents partition number pid/thread
---------------------------------------------------------------------------------------------------------------------
DB2INST1 db2wlmd
46 *LOCAL.DB2.150402074511 00001 1 0 84
Connect Completed Not Collected GEIS
/home/db2inst1/geidp/db2inst1/NODE0000/SQL00001/
DB2INST1 db2taskd
45 *LOCAL.DB2.150402074510 00001 1 0 83
Connect Completed Not Collected GEIS
/home/db2inst1/geidp/db2inst1/NODE0000/SQL00001/
DB2INST1 db2stmm
44 *LOCAL.DB2.150402074509 00001 1 0 74
Connect Completed Not Colle
TABLES
CREATE TABLE
[db2inst1@localhost ~]$ db2 "create table emp (id int, name varchar(50),jobrole
varchar(30),joindate date, salary int) in aix "
[db2inst1@localhost ~]$ db2 "insert into emp values (08,'abh','dba','08/08/2011',40000)"
DB20000I The SQL command completed successfully.
PRIMARY KEY TABLE
[db2inst1@localhost ~]$ db2 "create table PRIMARY (id int not null, name varchar(50),jobrole
varchar(30),joindate date, salary int,PRIMARY KEY(id)) in mytab2 "
DB20000I The SQL command completed successfully.
FOREIGN KEY TABL
[db2inst1@localhost ~]$ db2 "create table kattas (id int ,name varchar(50),jobrole
varchar(30),joindate date, salary int) in mytab2 "
DB20000I The SQL command completed successfully.
[db2inst1@localhost ~]$ db2 "alter table kattas add constraint dba foreign key (id) references
katta(id)"
DB20000I The SQL command completed successfully.
DB2 LIST TABLES
[db2inst1@localhost ~]$ db2 list tables
Table/View Schema Type Creation time
------------------------------- --------------- ----- --------------------------
0 record(s) selected.
Listing table details
db2 select tabname, tabschema, tbspace from syscat.tables
EMP WINDOWS7 SAP
TEST WINDOWS7 SAP
KATTA WINDOWS7 AIX
ABC WINDOWS7 AIX
Db2 load query table <table name>

[db2inst1@localhost ~]$ db2 "select tbspaceid,tabname from syscat.tables where


tabname='EMP'"
TBSPACEID TABNAME
---------
---------------------------------------------------------------------------------------------------------------------
-----------
6 EMP
1 record(s) selected.

[db2inst1@localhost ~]$ db2 describe table emp

Data type Column


Column name schema Data type name Length Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
ID SYSIBM INTEGER 4 0 Yes
NAME SYSIBM VARCHAR 50 0 Yes
PNAME SYSIBM VARCHAR 30 0 Yes
JOBROLE SYSIBM VARCHAR 30 0 Yes
TRANSACTION LOG
[db2inst1@localhost ~]$ db2 "insert into sap (select * from sap)"
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0964C The transaction log for the database is full. SQLSTATE=57011
[db2inst1@localhost ~]$ db2 get db cfg | grep -i logs
Number of primary log files (LOGPRIMARY) = 13
Number of secondary log files (LOGSECOND) = 20
[db2inst1@localhost ~]$ db2 update db cfg using LOGSECOND 30
DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.
[db2inst1@localhost ~]$ db2 "insert into sap (select * from sap)"
DB20000I The SQL command completed successfully.
[db2inst1@localhost ~]$ db2 update db cfg for linux using LOGARCHMETH1
disk:/home/db2red/newlogs
DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.

BACKUPS
OFFLINE BACKUP
[db2inst1@localhost ~]$ db2 backup db linux to /home/db2red/backup with 4 buffers buffer 8
without prompting
Backup successful. The timestamp for this backup image is : 20150407193238
ONLINE BACKUP
[db2inst1@localhost ~]$ db2 update db cfg using LOGARCHMETH1
disk:/home/windows7/log.out
DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.
[windows7@localhost ~]$ db2 update db cfg using TRACKMOD yes
DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.
[windows7@localhost ~]$ db2 update db cfg using SOFTMAX 256
DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.
[db2inst1@localhost ~]$ db2 backup db linux online to /home/db2red/backup with 4 buffers
buffer 8 without prompting
Backup successful. The timestamp for this backup image is : 20150407194332
ONLINE INCREMENTAL
[db2inst1@localhost ~]$ db2 update db cfg using TRACKMOD yes
DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.
SQL1363W One or more of the parameters submitted for immediate modification were not
changed dynamically. For these configuration parameters, all applications must disconnect from
this database before the changes become
[db2inst1@localhost ~]$ db2 backup db linux online incremental to /home/db2red/backup with 4
buffers buffer 8 without prompting
Backup successful. The timestamp for this backup image is : 20150407194938
ONLINE INCREMENTAL DELTA
[db2inst1@localhost ~]$ db2 backup db linux online incremental delta to /home/db2red/backup
with 4 buffers buffer 8 without prompting
Backup successful. The timestamp for this backup image is : 20150407223654
TABLE SPACE LEVEL BACKUP
[db2inst1@localhost ~]$ db2 backup db linux tablespace sap online incremental to
/home/db2red/backup
Backup successful. The timestamp for this backup image is : 20150407224015
LIST HISTORY BACKUP
[db2inst1@localhost ~]$ db2 list history backup all for linux
List History File for linux
Number of matching file entries = 11
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
B D 20150421220806001 F D S0000000.LOG S0000000.LOG
----------------------------------------------------------------------------
Contains 6 tablespace(s):
00001 SYSCATSPACE
00002 USERSPACE1
00003 SYSTOOLSPACE
00004 MYTAB
00005 MYTAB1
00006 MYTAB3
----------------------------------------------------------------------------
Comment: DB2 BACKUP LINUX OFFLINE
Start Time: 20150421220806
End Time: 20150421220817
Status: A
----------------------------------------------------------------------------
EID: 12 Location: /home/db2inst1/backup
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
B D 20150421220837001 N D S0000000.LOG S0000000.LOG
----------------------------------------------------------------------------
Contains 6 tablespace(s):
00001 SYSCATSPACE
00002 USERSPACE1
00003 SYSTOOLSPACE
00004 MYTAB
00005 MYTAB1
00006 MYTAB3
----------------------------------------------------------------------------
Comment: DB2 BACKUP LINUX ONLINE
Start Time: 20150421220837
End Time: 20150421220848
Status: A
----------------------------------------------------------------------------
EID: 15 Location: /home/db2inst1/backup
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
B D 20150421222230000 O S0000000.LOG S0000000.LOG
----------------------------------------------------------------------------
Comment: DB2 BACKUP LINUX ONLINE
DB2CKBKP
[db2inst1@localhost ~]$ cd backup
[db2red@localhost backup]$ ls -ltr
total 1037384
-rw------- 1 db2red db2red 346378240 Apr 7 19:33
LINUX.0.db2red.NODE0000.CATN0000.20150407193238.001
-rw------- 1 db2red db2red 346411008 Apr 7 19:43
LINUX.0.db2red.NODE0000.CATN0000.20150407194243.001
-rw------- 1 db2red db2red 346443776 Apr 7 19:44
LINUX.0.db2red.NODE0000.CATN0000.20150407194332.001
-rw------- 1 db2red db2red 3788800 Apr 7 19:49
LINUX.0.db2red.NODE0000.CATN0000.20150407194938.001
-rw------- 1 db2red db2red 3198976 Apr 7 22:36
LINUX.0.db2red.NODE0000.CATN0000.20150407223654.001
-rw------- 1 db2red db2red 14974976 Apr 7 22:40
LINUX.3.db2red.NODE0000.CATN0000.20150407224015.001
[db2red@localhost backup]$ db2ckbkp
LINUX.3.db2red.NODE0000.CATN0000.20150407224015.001
[1] Buffers processed: ####
Image Verification Complete - successful.
DB2 GET DB CFG SHOW DETAIL
[db2inst1@localhost ~]$ db2 get db cfg show detail
Database Configuration for Database
Description Parameter Current Value Delayed Value
---------------------------------------------------------------------------------------------------------------
Database collating sequence = IDENTITY IDENTITY
Changed path to log files (NEWLOGPATH) =
/home/db2red/log/NODE0000/
Log retain for recovery enabled (LOGRETAIN) = off RECOVERY
First log archive method (LOGARCHMETH1) = off LOGRETAIN
Track modified pages (TRACKMOD) = no YES
DB2 MOVEMENT UTILITIES

EXPORT

[db2inst1@localhost ~]$ db2 "export to myfile.ixf of ixf messages msgs.txt select * from test"

Number of rows exported: 2064384

[db2inst1@localhost ~]$ db2 "export to myfiles.del of del modified by coldel; messages msgs.txt select *
from test"

Number of rows exported: 2064384

Output

1;"aaa";"dba";20110101;10000

2;"bbb";"dba";20110202;20000

3;"ccc";"dba";20110303;30000

4;"ddd";"dba";20110404;40000

5;"eee";"dba";20110505;50000

6;"fff";"dba";20110606;60000

7;"ggg";"dba";20110707;70000

8;"hhh";"dba";20110808;80000

9;"iii";"dba";20110909;90000

IMPORT

[db2inst1@localhost ~]$ db2 import from myfile.ixf of ixf messages msg.txt "create into katta"

Number of rows read = 2064384

Number of rows skipped =0

Number of rows inserted = 2064384


Number of rows updated =0

Number of rows rejected =0

Number of rows committed = 2064384

LOAD (copy yes option that time all table spaces in normal state)

[db2inst1@localhost ~]$ db2 "load from myfile.ixf of ixf savecount 10000 tempfiles path
/home/db2inst1/111 insert into emp copy yes to /home/db2inst1/333"

SQL3519W Begin Load Consistency Point. Input record count = "2018461".

SQL3520W Load Consistency Point was successful.

SQL3519W Begin Load Consistency Point. Input record count = "2031005".

SQL3520W Load Consistency Point was successful.

SQL3519W Begin Load Consistency Point. Input record count = "2043549".

SQL3520W Load Consistency Point was successful.

SQL3519W Begin Load Consistency Point. Input record count = "2056093".

SQL3520W Load Consistency Point was successful.

SQL3110N The utility has completed processing. "2064384" rows were read from the input file.

SQL3519W Begin Load Consistency Point. Input record count = "2064384".

SQL3520W Load Consistency Point was successful.

SQL3515W The utility has finished the "LOAD" phase at time "04/16/2015

01:46:57.473913".

Number of rows read = 2064384

Number of rows skipped =0

Number of rows loaded = 2064384

Number of rows rejected =0

Number of rows deleted =0

Number of rows committed = 2064384

[db2inst1@localhost ~]$ db2 list tables

Table/View Schema Type Creation time

------------------------------- --------------- ----- --------------------------


EMP DB2INST1 T 2015-04-16-01.45.23.254684

KATTA DB2INST1 T 2015-04-15-22.14.24.590311

MYTEST DB2INST1 T 2015-04-14-04.20.12.203944

STAFF DB2INST1 T 2015-04-15-21.41.37.942071

TEST DB2INST1 T 2015-04-14-04.19.59.894182

5 record(s) selected.

[db2inst1@localhost ~]$ db2 "select count (*) from emp"

-----------

2064384

1 record(s) selected.

(not use copy yes options)

[db2inst1@localhost ~]$ db2 "load from myfile.ixf of ixf savecount 10000 tempfiles path
/home/db2inst1/111 insert into emp1 “

[db2inst1@localhost ~]$ db2 list tablespaces

Tablespace ID =4

Name = TAB1

Type = Database managed space

Contents = All permanent data. Regular table space.

State = 0x0020

Detailed explanation:

Backup pending

[db2inst1@localhost ~]$ db2 "backup db linux tablespace (tab1) online"

Backup successful. The timestamp for this backup image is : 20150416015703

[db2inst1@localhost ~]$ db2 connect to linux

Database Connection Information

Database server = DB2/LINUX 10.1.0


SQL authorization ID = DB2INST1

Local database alias = LINUX

[db2inst1@localhost ~]$ db2 list tablespaces

Tablespace ID =4

Name = TAB1

Type = Database managed space

Contents = All permanent data. Regular table space.

State = 0x0000

Detailed explanation:

Normal

(Check pending state)

[db2inst1@localhost ~]$ db2 "create table tb2 (id int not null, name varchar(20),primary key(id))"

DB20000I The SQL command completed successfully.

[db2inst1@localhost ~]$ db2 "create table tb3 (id int, name varchar(20))"DB20000I The SQL command
completed successfully.

[db2inst1@localhost ~]$ db2 "alter table tb3 add constraint fk foreign key(id) references tb2(id)"

DB20000I The SQL command completed successfully.

[db2inst1@localhost ~]$

[db2inst1@localhost ~]$ db2 "insert into tb2 values (05,'hhh')"

DB20000I The SQL command completed successfully.

[db2inst1@localhost ~]$ db2 "insert into tb2 values (06,'hhh')"

DB20000I The SQL command completed successfully.


[db2inst1@localhost ~]$ db2 "export to k12.ixf of ixf select * from tb3"

SQL3104N The Export utility is beginning to export data to file "k12.ixf".

SQL3105N The Export utility has finished exporting "1" rows.

Number of rows exported: 1

[db2inst1@localhost ~]$ db2 "load from k12.ixf of ixf insert into tb1"

SQL3109N The utility is beginning to load data from file

"/home/db2inst1/k12.ixf".

SQL3500W The utility is beginning the "LOAD" phase at time "04/16/2015 02:20:39.114074".

SQL3150N The H record in the PC/IXF file has product "DB2 02.00", date "20150416", and time
"021934".

SQL3153N The T record in the PC/IXF file has name "k12.ixf", qualifier "", and source " ".

SQL3519W Begin Load Consistency Point. Input record count = "0".

SQL3520W Load Consistency Point was successful.

SQL3110N The utility has completed processing. "1" rows were read from the input file.

SQL3519W Begin Load Consistency Point. Input record count = "1".

SQL3520W Load Consistency Point was successful.

SQL3515W The utility has finished the "LOAD" phase at time "04/16/2015 02:20:39.307473".

Number of rows read =1

Number of rows skipped =0

Number of rows loaded =1

Number of rows rejected =0

Number of rows deleted =0

Number of rows committed = 1

[db2inst1@localhost ~]$ db2 list tablespaces show detail

Tablespaces for Current Database

Tablespace ID =4
Name = TAB1

Type = Database managed space

Contents = All permanent data. Regular table space.

State = 0x0020

Detailed explanation:

Backup pending

[db2inst1@localhost ~]$ db2 backup db linux online

Backup successful. The timestamp for this backup image is : 20150416022253

[db2inst1@localhost ~]$ db2 connect to linux

Database Connection Information

Database server = DB2/LINUX 10.1.0

SQL authorization ID = DB2INST1

Local database alias = LINUX

CURSOR LOAD

[db2inst1@localhost ~]$ db2 "declare cu2 cursor database linux user db2inst1 using db2inst1 for select
* from tb1 "

DB20000I The SQL command completed successfully.

[db2inst1@localhost ~]$ db2 describe table tb1

Data type Column

Column name schema Data type name Length Scale Nulls

------------------------------- --------- ------------------- ---------- ----- ------

ID SYSIBM INTEGER 4 0 Yes

NAME SYSIBM VARCHAR 20 0 Yes

2 record(s) selected.

[db2inst1@localhost ~]$ db2 "create table tb11 (id int, name varchar(20))"

DB20000I The SQL command completed successfully.


[db2inst1@localhost ~]$ db2 "load from cu2 of cursor insert into tb11"

SQL3253N The utility is beginning to load data from the SQL statement " select * from tb1" in database
"linux".

SQL3500W The utility is beginning the "LOAD" phase at time "04/17/2015 03:05:58.161204".

SQL3519W Begin Load Consistency Point. Input record count = "0".

SQL3520W Load Consistency Point was successful.

SQL3110N The utility has completed processing. "1" rows were read from the input file.

SQL3519W Begin Load Consistency Point. Input record count = "1".

SQL3520W Load Consistency Point was successful.

SQL3515W The utility has finished the "LOAD" phase at time "04/17/2015 03:05:58.316679".

Number of rows read =1

Number of rows skipped =0

Number of rows loaded =1

Number of rows rejected =0

Number of rows deleted =0

Number of rows committed = 1

[db2inst1@localhost ~]$ db2 "select * from tb11"

ID NAME

----------- --------------------

3 ddd

1 record(s) selected.

MOVE THE TABLE ONE INSTANCE TO ANOTHER INSTANCE WITH DB2MOVE OPTION

[db2inst1@localhost ~]$ db2 list tables

Table/View Schema Type Creation time

------------------------------- --------------- ----- --------------------------


MYTEST DB2INST1 T 2015-04-14-04.20.12.203944

TEST DB2INST1 T 2015-04-14-04.19.59.894182

2 record(s) selected.

[db2inst1@localhost ~]$ mkdir 000

[db2inst1@localhost ~]$ cd 000

[db2inst1@localhost 000]$ db2move linux export -tn test

Application code page not determined, using ANSI codepage 1208

***** DB2MOVE *****

Action: EXPORT

Start time: Thu Apr 16 01:05:16 2015

All table names matching: TEST;

Connecting to database LINUX ... successful! Server : DB2 Common Server V10.1.0

EXPORT: 2064384 rows from table "DB2INST1"."TEST"

Disconnecting from database ... successful!

End time: Thu Apr 16 01:07:16 2015

[arjun@localhost Desktop]$ su root

Password:

[root@localhost Desktop]# cd

[root@localhost ~]# mv /home/db2inst1/000 /home/db2inst2

[root@localhost ~]# cd /home/db2inst2

[root@localhost db2inst2]# ls

000 db2inst2 ex_load mov sqllib

[root@localhost db2inst2]# chmod 777 000

[root@localhost db2inst2]# cd 000

[root@localhost 000]# ls
db2move.lst EXPORT.out tab1.ixf tab1.msg

[root@localhost 000]# chmod 777 db2move.lst EXPORT.out tab1.ixf tab1.msg

[arjun@localhost Desktop]$ su db2inst2

Password:

[db2inst2@localhost Desktop]$ cd

[db2inst2@localhost ~]$ ls

000 db2inst2 ex_load mov sqllib

[db2inst2@localhost ~]$ cd 000

[db2inst2@localhost 000]$ db2move mydbs import -io create

Application code page not determined, using ANSI codepage 1208

***** DB2MOVE *****

Action: IMPORT

Start time: Thu Apr 16 01:13:08 2015

Connecting to database MYDBS ... successful! Server : DB2 Common Server V10.1.0

Binding package automatically ... /home/db2inst2/sqllib/bnd/db2common.bnd ... successful!

Binding package automatically ... /home/db2inst2/sqllib/bnd/db2move.bnd ... successful!

* IMPORT: table "DB2INST1"."TEST"

-Rows read: 2064384

-Inserted: 2064384

-Rejected: 0

-Committed: 2064384

Disconnecting from database ... successful!

[db2inst2@localhost ~]$ db2 connect to mydbs

Database Connection Information

Database server = DB2/LINUX 10.1.0


SQL authorization ID = DB2INST2

Local database alias = MYDBS

[db2inst2@localhost ~]$ db2 list tables

Table/View Schema Type Creation time

------------------------------- --------------- ----- --------------------------

0 record(s) selected.

[db2inst2@localhost ~]$ db2 list tables for schema db2inst1.tables

Table/View Schema Type Creation time

------------------------------- --------------- ----- --------------------------

TEST DB2INST1 T 2015-04-16-01.13.18.503928

1 record(s) selected.

RESTORE

SAME DATABASE RESTORE


[db2inst1@localhost ~]$ db2 connect to linux
Database Connection Information
Database server = DB2/LINUX 9.7.1
SQL authorization ID = DB2RED
Local database alias = LINUX
[db2inst1@localhost ~]$ db2 backup db linux online to /home/db2red/backup with 4 buffers
buffer 8 without prompting
Backup successful. The timestamp for this backup image is : 20150407225656
[db2inst1@localhost ~]$ cd backup
[db2red@localhost backup]$ ls -ltr
total 1376048
-rw------- 1 db2red db2red 346443776 Apr 7 22:58
LINUX.0.db2red.NODE0000.CATN0000.20150407225656.001
[db2red@localhost backup]$ db2ckbkp
LINUX.0.db2red.NODE0000.CATN0000.20150407225656.001
[1] Buffers processed: #########################################################
Image Verification Complete - successful.
[db2inst1@localhost ~]$ db2 "restore db linux from /home/db2red/backup taken at
20150407194243 to linux"
SQL2539W Warning! Restoring to an existing database that is the same as the
backup image database. The database files will be deleted.
Do you want to continue ? (y/n) y
DB20000I The RESTORE DATABASE command completed successfully.
[db2inst1@localhost ~]$ db2 connect to linux
SQL1117N A connection to or activation of database "LINUX" cannot be made
because of ROLL-FORWARD PENDING. SQLSTATE=57019
[db2inst1@localhost ~]$ db2 rollforward db linux to end of logs and complete
Rollforward Status
Input database alias = linux
Number of nodes have returned status = 1
Node number =0
Rollforward status = not pending
Next log file to be read =
Log files processed = -
Last committed transaction = 2015-04-08-02.43.24.000000 UTC
DB20000I The ROLLFORWARD command completed successfully.
[db2inst1@localhost ~]$ db2 connect to linux
Database Connection Information
Database server = DB2/LINUX 9.7.1
SQL authorization ID = DB2RED
Local database alias = LINUX

ONE DATE BASE TO ANOTHER DATA BASE( REDIRECT GENERATE SCRIPT)

[db2inst1@localhost ~]$ db2 connect to Linux

Database Connection Information

Database server = DB2/LINUX 10.1.0

SQL authorization ID = DB2INST1

Local database alias = LINUX

[db2inst1@localhost ~]$ db2 backup db linux online to /home/db2inst1/backup with 4 buffers buffer 8
without prompting

Backup successful. The timestamp for this backup image is : 20150422012159

[db2inst1@localhost ~]$ db2 restore db linux from /home/db2inst1/backup taken at 20150422012159


into windows redirect generate script rrs

DB20000I The RESTORE DATABASE command completed successfully.

[db2inst1@localhost ~]$ vi rrs

[db2inst1@localhost ~]$ db2 -tvf rrs

UPDATE COMMAND OPTIONS USING S ON Z ON LINUX_NODE0000.out V ON

DB20000I The UPDATE COMMAND OPTIONS command completed successfully.

SET CLIENT ATTACH_MEMBER 0

DB20000I The SET CLIENT command completed successfully.

SET CLIENT CONNECT_MEMBER 0

DB20000I The SET CLIENT command completed successfully.

RESTORE DATABASE LINUX FROM '/home/db2inst1/backup' TAKEN AT 20150422012159 INTO


WINDOWS REDIRECT

SQL1277W A redirected restore operation is being performed. During a table

space restore, only table spaces being restored can have their paths

reconfigured. During a database restore, storage group storage paths and DMS
table space containers can be reconfigured.

DB20000I The RESTORE DATABASE command completed successfully.

SET TABLESPACE CONTAINERS FOR 4 USING ( PATH '/home/db2inst1/cont10' )

DB20000I The SET TABLESPACE CONTAINERS command completed successfully. SET TABLESPACE
CONTAINERS FOR 5 USING ( FILE '/home/db2inst1/cont20' 200000 )

DB20000I The SET TABLESPACE CONTAINERS command completed successfully. SET TABLESPACE
CONTAINERS FOR 6 USING ( FILE '/home/db2inst1/cont50' 200000 )

DB20000I The SET TABLESPACE CONTAINERS command completed successfully.RESTORE DATABASE


LINUX CONTINUE

DB20000I The RESTORE DATABASE command completed successfully.

[db2inst1@localhost ~]$ db2 restore db linux from /home/db2inst1/backup taken at 20150422012159


logtarget /home/db2inst1/log.out

SQL2539W Warning! Restoring to an existing database that is the same as the

backup image database. The database files will be deleted.

Do you want to continue ? (y/n) y

DB20000I The RESTORE DATABASE command completed successfully.

[db2inst1@localhost ~]$ db2 rollforward db WINDOWS to end of logs and complete

SQL4970N Rollforward recovery stopped on the database named "WINDOWS" because

the rollforward utility cannot reach the specified stop point (end-of-log or

point-in-time) on the following database partitions: "0".

[db2inst1@localhost ~]$ db2 rollforward db windows query status

Rollforward Status

Input database alias = windows

Number of members have returned status = 1

Member ID =0

Rollforward status = DB working


Next log file to be read = S0000019.LOG

Log files processed = S0000019.LOG - S0000019.LOG

Last committed transaction = 2015-04-22-08.22.22.000000 UTC

[db2inst1@localhost ~]$ mkdir 123

[db2inst1@localhost ~]$ db2 get db cfg |grep -i loga

[db2inst1@localhost ~]$ db2 connect to linux

SQL1117N A connection to or activation of database "LINUX" cannot be made

because of ROLL-FORWARD PENDING. SQLSTATE=57019

[db2inst1@localhost ~]$ db2 rollforward db linux to end of logs and complete

Rollforward Status

Input database alias = linux

Number of members have returned status = 1

Member ID =0

Rollforward status = not pending

Next log file to be read =

Log files processed = S0000019.LOG - S0000020.LOG

Last committed transaction = 2015-04-22-08.22.22.000000 UTC

DB20000I The ROLLFORWARD command completed successfully.

[db2inst1localhost ~]$ db2 connect to linux

Database Connection Information

Database server = DB2/LINUX 10.1.0

SQL authorization ID = DB2INST1

Local database alias = LINUX

[db2inst1@localhost ~]$ db2 get db cfg |grep -i loga

First log archive method (LOGARCHMETH1) = DISK:/home/db2inst1/log.out/


Archive compression for logarchmeth1 (LOGARCHCOMPR1) = OFF

Options for logarchmeth1 (LOGARCHOPT1) =

Second log archive method (LOGARCHMETH2) = OFF

Archive compression for logarchmeth2 (LOGARCHCOMPR2) = OFF

Options for logarchmeth2 (LOGARCHOPT2) =

[db2inst1@localhost ~]$ cd /home/db2inst1/log.out/

[db2inst1@localhost log.out]$ ls

db2inst1 NODE0000

[db2inst1@localhost log.out]$ cd NODE0000/

[db2inst1@localhost NODE0000]$ ls

LOGSTREAM0000

[db2inst1@localhost NODE0000]$ cd LOGSTREAM0000/

[db2inst1@localhost LOGSTREAM0000]$ ls

S0000019.LOG

[db2inst1@localhost LOGSTREAM0000]$ cp S0000019.LOG /home/db2inst1/123

[db2inst1@localhost LOGSTREAM0000]$ ls

S0000019.LOG

[db2inst1@localhost LOGSTREAM0000]$ cd

[db2inst1@localhost ~]$ cd 123

[db2inst1@localhost 123]$ ls

S0000019.LOG

[db2inst1@localhost 123]$ cd

[db2inst1@localhost ~]$ db2 "rollforward db windows to end of logs and complete overflow log path
(/home/db2inst1/123)"

SQL1433N The application is already connected to "LINUX" while the command

issued requires a connection to "WINDOWS" for successful execution.


[db2inst1@localhost ~]$ db2 connect to linux

Database Connection Information

Database server = DB2/LINUX 10.1.0

SQL authorization ID = DB2INST1

Local database alias = LINUX

[db2inst1@localhost ~]$ db2 connect reset

DB20000I The SQL command completed successfully.

[db2inst1@localhost ~]$ db2 "rollforward db windows to end of logs and complete overflow log path
(/home/db2inst1/123)"

Rollforward Status

Input database alias = windows

Number of members have returned status = 1

Member ID =0

Rollforward status = not pending

Next log file to be read =

Log files processed = S0000019.LOG - S0000019.LOG

Last committed transaction = 2015-04-22-08.22.22.000000 UTC

DB20000I The ROLLFORWARD command completed successfully.

ONE INSTANCE TO ANOTHER INSTANCE ( REDIRECT GENERATE SCRIPT)

[db2inst1@localhost ~]$ db2 connect to unix

Database Connection Information

Database server = DB2/LINUX 10.1.0

SQL authorization ID = DB2INST1

Local database alias = UNIX

[db2inst1@localhost ~]$ db2 list tables


Table/View Schema Type Creation time

------------------------------- --------------- ----- --------------------------

EMP DB2INST1 T 2015-04-22-02.22.27.547926

EMP_S DB2INST1 T 2015-04-22-02.22.37.911700

2 record(s) selected.

[db2inst1@localhost ~]$ db2 grant dbadm on database to user db2inst2

DB20000I The SQL command completed successfully.

[db2inst1@localhost ~]$ db2 backup db unix online to /home/db2inst1/000

Backup successful. The timestamp for this backup image is : 20150422023228

[db2inst1@localhost ~]$ cd 000

[db2inst1@localhost 000]$ ls

UNIX.0.db2inst1.DBPART000.20150422023228.001

[db2inst1@localhost 000]$ chmod 777 UNIX.0.db2inst1.DBPART000.20150422023228.001

[db2inst2@localhost ~]$ db2 restore db unix from /home/db2inst1/000 taken at 20150422023228


REDIRECT GENERATE SCRIPT u.out

DB20000I The RESTORE DATABASE command completed successfully.

[db2inst2@localhost ~]$ vi u.out

ON PATH, DBPATH ON, TABLESPACES CONT

[db2inst2@localhost ~]$ db2 -tvf u.out

RESTORE DATABASE UNIX CONTINUE

DB20000I The RESTORE DATABASE command completed successfully.

[db2inst2@localhost ~]$ db2 connect to unix

SQL1117N A connection to or activation of database "UNIX" cannot be made

because of ROLL-FORWARD PENDING. SQLSTATE=57019

[db2inst2@localhost ~]$ db2 rollforward db unix query status

Rollforward Status
Input database alias = unix

Number of members have returned status = 1

Member ID =0

Rollforward status = DB pending

Next log file to be read = S0000000.LOG

Log files processed = -

Last committed transaction = 2015-04-22-09.32.37.000000 UTC

[db2inst2@localhost ~]$ db2 rollforward db unix to end of logs and complete

SQL4970N Rollforward recovery stopped on the database named "UNIX" because

the rollforward utility cannot reach the specified stop point (end-of-log or

point-in-time) on the following database partitions: "0".

[db2inst2@localhost ~]$ db2 rollforward db unix query status

Rollforward Status

Input database alias = unix

Number of members have returned status = 1

Member ID =0

Rollforward status = DB working

Next log file to be read = S0000000.LOG

Log files processed = S0000000.LOG - S0000000.LOG

Last committed transaction = 2015-04-22-09.32.37.000000 UTC

[db2inst2@localhost ~]$ db2 connect to unix

SQL1117N A connection to or activation of database "UNIX" cannot be made

because of ROLL-FORWARD PENDING. SQLSTATE=57019

[db2inst2@localhost ~]$ db2 rollforward db unix query status

Rollforward Status
Input database alias = unix

Number of members have returned status = 1

Member ID =0

Rollforward status = DB pending

Next log file to be read = S0000000.LOG

Log files processed = -

Last committed transaction = 2015-04-22-09.32.37.000000 UTC

[db2inst2@localhost ~]$ db2 rollforward db unix to end of logs and complete

SQL4970N Rollforward recovery stopped on the database named "UNIX" because

the rollforward utility cannot reach the specified stop point (end-of-log or

point-in-time) on the following database partitions: "0".

[db2inst2@localhost ~]$ db2 rollforward db unix query status

Rollforward Status

Input database alias = unix

Number of members have returned status = 1

Member ID =0

Rollforward status = DB working

Next log file to be read = S0000000.LOG

Log files processed = S0000000.LOG - S0000000.LOG

Last committed transaction = 2015-04-22-09.32.37.000000 UTC

[db2inst1@localhost ~]$ db2 get db cfg |grep -i log *

[db2inst1@localhost ~]$ cd /home/db2inst1/pathd/db2inst1/NODE0000/SQL00001/LOGSTREAM0000/

[db2inst1@localhost LOGSTREAM0000]$ ls

S0000000.LOG S0000003.LOG S0000006.LOG S0000009.LOG S0000012.LOG

S0000001.LOG S0000004.LOG S0000007.LOG S0000010.LOG S0000013.LOG


S0000002.LOG S0000005.LOG S0000008.LOG S0000011.LOG

db2inst2@localhost ~]$ mkdir login

[db2inst1@localhost LOGSTREAM0000]$ scp S0000000.LOG db2inst2@localhost:/home/db2inst2/login

db2inst2@localhost's password:

S0000000.LOG 100% 12KB 12.0KB/s 00:00

[db2inst2@localhost ~]$ db2 "rollforward db unix to end of logs and complete overflow log path
('/home/db2inst2/login')"

Rollforward Status

Input database alias = unix

Number of members have returned status = 1

Member ID =0

Rollforward status = not pending

Next log file to be read =

Log files processed = S0000000.LOG - S0000000.LOG

Last committed transaction = 2015-04-22-09.32.37.000000 UTC

DB20000I The ROLLFORWARD command completed successfully.

[db2inst2@localhost ~]$ db2 connect to unix

Database Connection Information

Database server = DB2/LINUX 10.1.0

SQL authorization ID = DB2INST2

Local database alias = UNIX

Das könnte Ihnen auch gefallen