Tuesday, September 25, 2007

Ins and Outs of Journaling:

Journaling on the iSeries typically involves the recording of the activity related to files, namely, physical files. When a file is being journaled, activity such as file-opens, file-closes and data updates are recorded. For example, when a program writes out a new record or updates an existing one, the system makes an entry in the associated journal. The entry contains such information as the job name and program name that made the change(s) to the file, as well as a copy of the record that was changed.

How to set up journaling in three easy steps
1. Create one or more journal receivers. Use the Create Journal Receiver (CRTJRNRCV) command to create a journal receiver. Think of the journal as a notebook binder and the journal receiver as the pages (i.e., the notebook paper where information is written). The journal receiver is where the journal entries are actually recorded. The journal "connects" the receiver to the file. It's a good habit to name the journal receiver the same as the journal, plus a numeric suffix such as 0 or 1. Also, you should put journal receivers in the same library as the file. For maximum protection, consider storing the journal receiver in a different ASP than the file so that their storage will not be on the same disk unit.
2. Create a journal. Use the Create Journal (CRTJRN) command to create a journal and specify the receiver created in step 1. Although you can journal multiple files to the same journal (and, in some cases, that is actually preferable), you will generally want to have a journal "serving" a single file. A good practice is to name the journal the same as the file and put it in the same library as the file, but store it in the same ASP as the journal receiver.
3. Start journaling the file. This is done by using the Start Journal Physical File (STRJRNPF) command. This is how you associate a file to a journal. Once the association is made, the system will record in the journal receiver a copy of any record added, updated or deleted from the file. Other activity, such as when the file is opened and closed, can also be recorded in the journal receiver if you choose by selecting the appropriate options on the STRJRNPF command.
Four basic journal entry categories
The most common journal entries fall into four basic categories. Each category is represented by a one-character code (shown in parenthesis in the following list). Within each category are a number of different journal entry types. Each journal entry type is represented by a two-character entry code (also shown in parenthesis within the category descriptions below).
1. Journal and journal receiver operations (J). These include such things as references to the previous receiver (PR) or the next receiver (NR) in a chain. Also, at IPL-time, an entry is made (e.g., an IN entry for IPL after normal end) marking a critical chronological boundary in the file activity.
2. File operations (F). This category includes file opens (OP) and file closes (CL).
3. Record operations (R). Record updates (UP), deletes (DL), and new records written (PT and PX) all fall into this category.
4. Commitment control (C). Anything related to commitment control falls into this category. Some examples are begin commitment control (BC), start a commit cycle (SC), commit operation (CM) and rollback operation (RB).

No comments: