Businesses today face increasing pressures for real-time data availability; data accuracy; and details about who accessed or changed what data and when. These requirements are arising from a number of areas, most commonly these:
- Regulation and compliance
- Business process consolidation
- IT infrastructure
- Electronic commerce
Each of these business drivers is forcing application developers and IT managers to investigate and administer new technologies and solutions. The challenge for IT professionals is to solve these issues with a minimum of investment and maximum return. For each of these IT and business issues, IBM's System i5 journaling technology can provide relief to the pain.
What Is Journaling?
System i5 journaling enables you to create a list of activity to physical files, IFS files, data areas, and data queues. The activities that are tracked include what changes and updates are made to existing objects, when the objects are accessed, and when they are closed. The operating system automatically performs this tracking once journaling is activated on these objects. With the new journal-at-birth option availability in OS/400 V5R3, the operating system tracks creation, deletion, and attribute changes.
In order to understand how this is done, you must first understand the core components of journaling. System i5 journaling consists of three main components: a journal receiver, a journal receiver entry, and a journal.
A journal receiver is the object in which the list of activity is recorded. Each activity that is recorded via the use of an entry is appended to the end of the journal receiver. The journal entries include the following information and more:
- Date and time the activity occurred
- User performing the activity
- Job performing the activity
- Program performing the activity
- Object being updated or accessed
- Location of object
- Type of activity (update, open, close, etc.)
- Details of the specific activity, such as the data as it looked prior to the update or just after the update
Think of the journal receiver as a box and each entry as a paper receipt. As an activity occurs, the operating system writes down the information on the receipt and places it in the box. At some point, the box (journal receiver) will be filled up and a new box (journal receiver) must be added to collect new paper receipts (journal entries). When this happens, a new journal receiver must be created, the old journal receiver must be detached from the journal, and the new journal receiver must be attached. The good news is that i5/OS automatically detects when a journal receiver becomes full and creates new journal receivers to allow the system to continue to collect the journal entries.
As journal entries collect in the journal receivers, the receivers increase in size and take up disk space on the system. It is important to have a strategy for saving the journal receivers and deleting them from the system once they have been saved. In addition, it is important to set up the journal receiver so i5/OS automatically changes the journal receiver once it reaches a certain size.
A journal is the object that connects the journal entries to the journal receiver. The journal plays a key role because it remains constant even as the journal receivers are changed and deleted. For this reason, when you start or stop journaling on an object, you indicate the name of the journal, not the journal receiver. The journal also contains the configuration information, which provides the operating system with the following information:
- Whether and when to change the associated journal receivers
- Whether to automatically delete the associated journal receivers
- What types of information should be captured (e.g., job, program, etc.)
Creating a Journal
To create a journal, you must first create the journal receiver and then create the journal. When you create the journal, you tell it which journal receiver to use or to "attach."
To create a journal receiver, use the Create Journal Receiver (CRTJRNRCV) command. The following example will create journal receiver TEST001 in library TEST and assign a threshold value of 1000000 KB.
To create a journal, use the Create Journal (CRTJRN) command. The following example will create journal TESTJRN in library TSTJRNLIB and attach it to journal receiver TEST001 in library TEST.
CRTJRN JRN(TSTJRNLIB/TESTJRN) JRNRCV(TEST/TEST001) MNGRCV(*SYSTEM)
The MNGRCV(*SYSTEM) parameter on the CRTJRN command tells the operating system to monitor the threshold size of the journal receiver. When it reaches the size indicated on the journal receiver (in our example, 1000000 KB), the operating system will automatically create a new receiver, detach the current receiver, and attach the new receiver. When the operating system does this process, it creates a new journal receiver named based on the current name plus one. In this example, the new journal receiver name would be TEST002. The next journal receiver would be TEST003, and so on.
The DLTRCV(*NO) parameter on the CRTJRN command tells the operating system not to automatically delete the journal receiver. This means you will need to incorporate into your backup process the saving of these journal receivers and the subsequent deletion of the journal receivers after they have been saved. The journal receiver objects are saved using standard SAV and RST commands. In addition, you can use the Display Journal Receiver (DSPJRNRCV) command to determine if a journal receiver has been saved. If so, delete the journal receiver using the Delete Journal Receiver (DLTJRNRCV) command.
Once you have the journal and journal receiver built, you can tell the operating system you would like to journal a file or an object. This very simple task utilizes one of three commands, depending on what type of object you would like to journal.
Journaling on Database Files
The Start Journal Physical File (STRJRNPF) command starts journaling on a physical file. The following example starts journaling on file TESTPF in library TESTLIB. This file is journaled to journal TESTJRN in library TSTJRNLIB.
STRJRNPF FILE(TESTLIB/TESTPF) JRN(TSTJRNLIB/TESTJRN) IMAGES(*BOTH)
The two additional parameters, IMAGES and OMTJRNE, are important to note.
In this example, we have told the operating system to capture both (*BOTH) images on the IMAGES parameter. This means that when a record is changed, there will be two journal entries written to the journal receiver: The "before" entry includes the record content prior to being changed, along with details about the user, program, date, time, etc. The "after" entry includes the same information, except it details the record content after the change occurred. The other option for this parameter is *AFTER, which would create only the "after" entry.
In addition, we have told the operating system to omit no (*NONE) images on the Omit Journal Entry (OMTJRNE) parameter. This means that whenever the file is opened or closed, a journal entry will be created with details such as the date, time, user, program, etc. In many environments, files are opened and closed often. This can add a large number of journal receiver entries and cause the journal receiver size to quickly increase. The *NONE setting is the correct setting if you want to capture all information about file access. However, unless you plan to use the journal receiver entries to determine who is reading (but not changing) files, set this attribute to *OPNCLO, which will cause the operating system to not create journal receiver entries for open and close activity.
Journaling on Data Areas, Data Queues, and IFS Files
The Start Journal Object (STRJRNOBJ) and Start Journal (STRJRN) commands work much like the STRJRNPF command except that they start journaling on different object types. STRJRNOBJ starts journaling on data areas and data queues. STRJRN starts journaling on IFS commands. The main difference from the functionality detailed above is that STRJRNOBJ does not include the OMTJRNE parameter and functionality. This is because data areas and data queues are not files and thus do not have the concepts of being opened or closed.
You may be wondering, "What about the other objects on my system? How do I journal objects besides physical files, data areas, data queues, and IFS files?" In order to journal these objects, use the QAUDJRN Security Audit Journal, since these objects are only created, deleted, and used—never updated. The topic of setting up and using QAUDJRN and Security Audit Journaling is too large to cover in this article.
Data Accuracy, Compliance, and Availability
Increasing Data Accuracy
Journaling enables you to increase data accuracy by taking advantage of two advanced database technologies: commitment control and auto-recovery. These features ensure that you always have accurate data in your database even if the system or program crashes while data is being updated.
This database feature allows an application program to be designed so that a user must complete all changes related to a database transaction before the transaction is permanently reflected in the database. This helps ensure the data integrity of the database in the event of a system failure in the middle of a transaction. It also allows a transaction to be canceled in process if the user feels the transaction is erroneous. There are numerous methods to take advantage of commitment control within i5/OS, including using SQL-based applications, RPG, COBOL, and C development. If you are concerned about data accuracy, it is critical you review your applications to ensure they utilize commitment control for any financial or regulated transaction. In addition, commitment control is recommended for any process that updates more than one file and for long-running batch jobs that don't have batch restart logic.
As mentioned, i5/OS utilizes journaling to track changes to the data as they occur. The journal provides the operating system with the necessary information to recover the database with full integrity if an error (hardware or software) occurs that causes the database "service" to end abnormally. If journaling is active, the database will review the journal information whenever the database starts in order to determine whether the database ended abnormally and to address any database corruption. For example, if a user is in the middle of updating a record when the database abnormally ends, the database will detect the situation when the database is started and either roll-back or roll-forward the change to a point of full data integrity.
Increasing Data Compliance
Journaling is the key to increasing data compliance because it allows the operating system to generate a record of all activity on files. This record can be completely trusted because it includes the following information:
- The time and date journaling was started on a file
- The time and date journaling was stopped
- A complete list of all changes to the file
- A complete list of all opens or closes of the file
Since journaling can provide exact dates and times as well as identify users, programs, and other critical pieces of information, you can use it to meet compliance or audit obligations. The only caveat is if there is a very large amount of information in the journal receiver; some effort is required to create the reports and audits necessary for auditors and regulators. Numerous applications for the i5 simplify this problem if you need assistance.
Increasing Data Availability
Journaling can also provide increased availability by minimizing some (but not all) of the planned downtime due to tape backups. Instead of having to end your application and all updates to the database to get a usable tape backup of your physical files, data areas, data queues, and IFS files, you can simply back up the journal receivers since they contain a list of the changes to these objects. This does not eliminate the requirement to back up the database and objects, but backing up the journal receivers can reduce the frequency of backups and thus increase data availability. (To truly eliminate planned downtime, you will need a high availability solution.)
To recover from tape, you will need to perform the following process:
- Restore the object(s) from tape.
- Restore the journal receivers from tape because they contain all changes to the object that occurred after the save that was used to create the tape backup used for the restore in step 1.
- Use the Apply Journal Change (APYJRNCHG) command to apply all the journal entries that occurred after the save.
This process is complex, but it can be done successfully if you work at it and test, test, test. The keys to success are having a well-documented, well-planned, and well-tested process and ensuring that your application does not perform any actions not supported by the APYJRNCHG command.
Increasing High Availability
Journaling is the key to i5 high availability. More precisely, remote journaling is the key to an i5 high availability solution because it enables the operating system to maintain a copy of the journal and journal receivers on a second i5 or LPAR. The advanced availability solutions are able to read the remote journal and keep an accurate real-time copy of the database on the target i5 or LPAR.
In addition, the database and application is cluster-enabled, so it can be switched to run on the second i5 or LPAR. The cluster will then detect whether the production "services" are active or not. If the production services are inactive, the cluster will take over and provide database and application services to the users from the second i5 or LPAR. This clustering can be performed by the operating system or via high availability cluster software.
The two database features mentioned above work together or individually to provide availability. For example, consider a database server that has an unplanned outage and needs to be activated on the backup server. The database replication and clustering enables the data to be available on the second server and the database "service" to be active. Likewise, if this is a planned downtime event (hardware upgrade, full backup, etc.), you can again use the second server. However, no recovery will be needed since this is a planned switch. Another example is if the database is not clustered but has some type of planned or unplanned downtime and supports journaling and auto-recovery; then, it will have a much higher chance of recovering with little downtime and data loss.
As you can see, journaling is a unique and powerful technology that can empower your business and IT operations for a wide variety of needs and enable exciting technologies such as commitment control, remote journaling, and high availability. Evaluate your IT and application environment to see how journaling can help you succeed today and in the future.