Copy File (CPYF) Command

AS400 table is a *FILE object, the CPYF command is used to copy all or part of the table structure in the database to another table. The following is the copy file command that I usually use:

Member Option > MBROPT

# MBROPT(*ADD) - Copy all record source files to the target file
# MBROPT(*REPLACE) - Copy all the record source files to the target file starting with delete member files first

Create File > CRTFILE

# CRTFILE(*YES) - Create a new file in the target library
# CRTFILE(*NO) - If file is already available in the target library

Copy From – To Record Number > FROMRCD – TORCD

# FROMRCD (*START/<rrn>) - *START if you want to copy the first record from the source file, or <rrn> relative record number if you want from a specific record number
# TORCD (*END/<rrn>) - *END if you want to copy until the last record from the source file, or <rrn> relative record number if you want to reach a certain record number

Record Format Field Mapping – FMTOPT

This parameter is used if the source file format is different from the target file format
# FMTOPT (*NOCHK) - Copy files based on the length of the existing records
# FMTOPT (*MAP *DROP) - Copy files based on existing field names (*MAP) and ignore non-existent fields (*DROP)

Examples:

# CPYF FROMFILE(SRCLIB/SRCFILE) TOFILE(TGTLIB/TGTFILE) MBROPT(*ADD) CRTFILE(*YES)
# CPYF FROMFILE(SRCLIB/SRCFILE) TOFILE(TGTLIB/TGTFILE) MBROPT(*ADD)
# CPYF FROMFILE(SRCLIB/SRCFILE) TOFILE(TGTLIB/TGTFILE) MBROPT(*REPLACE)
# CPYF FROMFILE(SRCLIB/SRCFILE) TOFILE(TGTLIB/TGTFILE) MBROPT(*ADD) FROMRCD(*START) TORCD(*END)
# CPYF FROMFILE(SRCLIB/SRCFILE) TOFILE(TGTLIB/TGTFILE) MBROPT(*ADD) FROMRCD(10) TORCD(*END)
# CPYF FROMFILE(SRCLIB/SRCFILE) TOFILE(TGTLIB/TGTFILE) MBROPT(*ADD) FMTOPT(*NOCHK) 
# CPYF FROMFILE(SRCLIB/SRCFILE) TOFILE(TGTLIB/TGTFILE) MBROPT(*ADD) FMTOPT(*MAP *DROP) 
                                  

Recovery Point Object and Recovery Time Object

Disaster Recovery always been associated with Recovery Point Objects and Recovery Time Objects (RPO and RTO).

Source: MIMIX Documentation

Recovery Point Object (RPO) is the last point in time that an IT system can be recovered. In this section, the technology used determines how far behind the data or even the loss of a company when there is a disruption to the main system. RPO is used in technologies such as backup, storage replication, data replication and others.

Recovery Time Object (RTO) is related to the time it takes for an IT system to operate normally again when a planned / unplanned interruption occurs. For unplanned interruptions, error detection, data recovery and bringing the application back online are included in RTO.

AIX Create Volume Group, Logical Volume dan File System From New Disk /LUN

Create Volume Group (VG)

Use the cfgmgr command to scan and identify all installed configurations.

#cfgmgr

Use lspv command to see the pv configuration.

#lspv

root@xxx:/>cfgmgr
root@xxx:/>lspv
hdisk18         00f86d5fa9781a05                    rootvg          active
hdisk27         00f86d5fa99e3994                    datavg          active
hdisk30         none                                None            active

Based on the example above, there is a hdisk30 on the system that has not been configured anything. Use the command bootinfo -s hdiskxx to find out the size of the LUN.

#bootinfo -s hdisk30

Continue reading AIX Create Volume Group, Logical Volume dan File System From New Disk /LUN

Backup, Restore and Check the History of DB2 AIX

Backup, restore and check history that I often use. Login using DB2 user.

Interactively backup database and logs:

db2 backup database <dbname> online to </filesystem> include logs

To submit into background job:

nohup db2 backup database <dbname> online to </filesystem> include logs &

To restore, you can use:

db2 restore database RP1 from </filesystem> taken at <yyyymmddhhmmss>
or for background job:
nohup db2 restore database RP1 from </filesystem> taken at <yyyymmddhhmmss> &

To check backup/restore process:

db2top and then press u
or
db2 list utilities show detail

To find out the history of backup activities by:

db2 list history backup since <yyyymmdd> for <dbname>

AIX HADR Reconfiguration

The assumption is that we are going to reconfigure an existing HADR replication.

PRIMARY :
   db2 update db cfg for dbname using HADR_LOCAL_HOST ip_addr_primary
   db2 update db cfg for dbname using HADR_LOCAL_SVC port1
   db2 update db cfg for dbname using HADR_REMOTE_HOST ip_addr_standby
   db2 update db cfg for dbname using HADR_REMOTE_SVC port2
   db2 update db cfg for dbname using HADR_REMOTE_INST instancename
   db2 update db cfg for dbname using HADR_SYNCMODE ASYNC
   db2 update db cfg for dbname using HADR_PEER_WINDOW 120
   
STANDBY :
   db2 update db cfg for dbname using HADR_LOCAL_HOST ip_addr_standby
   db2 update db cfg for dbname using HADR_LOCAL_SVC port2
   db2 update db cfg for dbname using HADR_REMOTE_HOST ip_addr_primary
   db2 update db cfg for dbname using HADR_REMOTE_SVC port1
   db2 update db cfg for dbname using HADR_REMOTE_INST instancename
   db2 update db cfg for dbname using HADR_SYNCMODE ASYNC
   db2 update db cfg for dbname using HADR_PEER_WINDOW 120
   
notes: Port antara DC dan DRC berbeda

Find WWN (Worldwide port Name) on AS400 Fiber Card

Here’s how you can find out the WWN of a Fiber Card.

From command line, type WRKHDWRSC *STG

On the Work With Hardware Status page, type option 7 = Display resource detail on DCXX that you want to check.

On the Display Resource Details page, press page down until you find the Word wide port name parameter. Congratulations, WWN has been successfully obtained.

Logika Bergantung Logistik