Professional Documents
Culture Documents
Informix Database
Administration
1. INTRODUCTION ...........................................................................................3
2. SUGGESTED READING...............................................................................4
3. INVOKING AND USING THE DB-ACCESS UTILITY ...................................5
3.1 INTRODUCTION TO DB-ACCESS ..................................................................5
3.2 STARTING AN INFORMIX INSTANCE ..............................................................5
3.3 CREATING THE DEMONSTRATION DATABASE ................................................6
3.4 PUTTING THE DB-ACCESS UTILITY TO WORK ...............................................8
4. WORKING WITH THE COMMAND LINE UTILITIES..................................11
4.1 ONMODE UTILITY .....................................................................................11
4.2 ONINIT UTILITY.........................................................................................11
4.3 ONSTAT UTILITY .......................................................................................12
4.4 ONPARAMS UTILITY ..................................................................................12
2
1. Introduction
In this lab, you will learn the basics of administering an Informix instance using
some of the command line utilities as well as the OpenAdmin Tool (OAT).
OAT for Informix is a PHP-based Web browser administration tool that provides
the ability to administer multiple database server instances from a single location.
Exciting features in the OpenAdmin Tool allow the ability to:
Health Center: Analyze the current state of the server with detailed statistics and
alert information.
Logs: View previous administration commands, recent messages from the online
log, and the latest backup and recovery information from the ON-Bar Activity log.
Task Scheduler: View and update Scheduler tasks to be run on the current
server.
Space Administration: Manage server space for your system with tools to
administer dbspaces, chunks, checkpoints, and the physical and logical logs.
Server Administration: Configure and validate database servers, as well as
administer high availability clusters (HACs).
Performance Analysis: Get high quality and detailed performance statistics
about databases with SQL exploration of each table, statement, or transaction.
Query drill down and session exploration provide detailed information about
every aspect of transactions and statement types. View over 20 system
performance reports, such as memory pools, the five slowest transactions, and
server memory usage.
SQL Toolbox: Explore databases, view table statistics, browser schemas, run
queries, and view query plans.
3
2. Suggested Reading
4
3. Invoking and Using the DB-Access Utility
5
¾ Change to the “scripts” directory.
cd /home/informix/scripts
6
where:
dbname Name of the stores demo database.
-log Requests transaction logging for the demonstration
database.
-dbspace Requests a particular dbspace location for the
demonstration database.
dbspace_name Indicates the dbspace where the demonstration
database is stored. If you do not specify a dbspace
name, the data for the database is put in the root
dbspaces by default.
¾ Using the same terminal window opened in the previous
section, enter the following command to create a demonstration
database called “stores”.
dbaccessdemo stores –log
You will see the messages similar to the ones shown in the
following screen shot.
7
¾ You will be prompted to enter Y or N to a question about
copying example scripts. Enter “N” and press Enter.
8
¾ Go back to the main menu by selecting Exit twice from the
interactive menu at the top.
9
¾ Press the ESC key when you are finished typing the statement.
This switches from editing mode to interactive mode.
¾ Select Run from the top menu options and press Enter.
The rows in the table should now be displayed on the screen,
one at a time. Select Next from the top menu to see the next
row.
10
4. Working with the Command Line Utilities
In this exercise, you will get to use important command line utilities
with Informix.
Enter each of the commands described in this section with the options
that are discussed.
4.1.1 onmode –j
¾ onmode –j changes the instance mode to single-user. Only
DBSA / Informix can connect to the instance in this mode. This
mode is very useful when you need to perform administrative
tasks on the instance that require restricted access.
4.1.2 onmode -m
¾ onmode –m brings the database server online from quiescent
mode or from administration mode.
4.1.3 onmode –k
¾ onmode –k takes the server off-line.
4.2.1 oninit
¾ Enter oninit to bring the instance online.
11
4.2.2 oninit -version
¾ The oninit -version command displays the version of the
Informix server being used.
4.3.1 onstat –l
¾ Enter onstat -l to display information about the physical and
logical log buffers and log files.
As you see, 5 logical logs were created by default. In the next
exercise, you will add an additional logical log and use onstat -l
again to check the number of log files.
BONUS: Using the Informix documentation or another source, try to
determine what each of the options in the Flags column in output
refers to.
12
¾ Enter the onstat -l command again to check the number of
logical log files. There should now be 7 logical log files.
13
5.2.1 Checking Extents with the ADMIN() function
The following command instructs the database server to check the
extents of a dbspace. Note that if no dbspace is specified, all
dbspaces are checked. This particular function invocation would be
equivalent to running the oncheck command line utility.
EXECUTE FUNCTION admin('check extents').
Execute this function in the DB-Access utility and check the
command_history table for the output of the function.
¾ Start the dbaccess utility and connect to the sysadmin
database from the command window by entering the following
command:
dbaccess sysadmin
¾ Select Query-Language > New and enter the following
EXECUTE FUNCTION statement:
EXECUTE FUNCTION admin('check extents');
¾ Press the ESC key to exit from editing mode and select the
Run option to run the statement and execute the function.
14
¾ Note down the expression number returned after the execution
of the function. You will use that number in the following step.
¾ Select Query-Language > New and enter the following SQL
statement.
select * from command_history where
cmd_number = expression_number;
15
NOTE: In the previous command, we assume that the log
number of the log that was created in the previous exercise is
7. If in doubt, try using the onmonitor utility to check the log
number of the newly created logical log.
¾ Press the ESC key to exit out of editing mode and select the
Run option to run the statement.
¾ If the command is executed successfully, you will see a
message that says that the log file was successfully dropped.
¾ Exit from the DB-Access utility.
16
6. Administering Informix Servers with OAT
OpenAdmin Tool can be very useful for viewing information about and
administering the database servers in your environment.
In this section, you will explore the various features available in OAT.
In reality, you probably do not need instructions about how to
administer servers with OAT because the OAT GUI is very user
friendly and self-explanatory. Feel free to experiment with the tool.
These exercises are designed to highlight a few tasks that can be
done with OAT.
17
¾ This will launch the Firefox web browser with OAT login page.
¾ On the login page, click the Get Servers button to get a list of
available servers.
18
6.2 Health Center and the Logs
Let’s explore the Health Center menu and the Logs menu.
19
6.2.2 Using the Dashboard
¾ Clicking the Dashboard option displays the memory usage
information and the number of transactions information. (Note:
You may need to click the Refresh button in order to display the
graphs)
20
¾ Drag the pointer to all the way to the right. This changes the
refresh rate to every 60 seconds.
21
6.2.4 Viewing the messages in the Online Log
¾ Click the Online Messages option under the Logs menu to
display the messages in the online log. Messages are displayed
in ascending order by date.
22
¾ Click the first dbspace in the table (i.e. rootdbs), to display
detailed information about the space utilization of this dbspace.
23
6.3.2 Adding space to a dbspace
Add a chunk called online_root02 of size 50M to rootdbs
Click the box Chunks pane while you are in the rootdbs detailed view
to expand it.
Path: /data/IBM/informix/demo/demo_on/online_root02
Offset: 0 (default)
Size: 50 M
File Creation: Create File if None Exists (default)
24
¾ Click the Add Chunk button.
This will add a chunk of size 50M to the rootdbs dbspace. You can
then see the new chunk listed in the information about the dbspaces.
25
6.4 Other OAT Features
OAT is a great tool for performance monitoring and troubleshooting.
The Performance Analysis menu has various options that allow you
to control SQL statement tracing, obtain detailed query information,
generate system reports, and examine what all the connections
(sessions) are doing at a given point in time.
¾ Select the Show Dynamic Only option from the drop down list
at the top of the window to display only dynamic parameters.
Changes to dynamic parameters take effect right away; they do
not require an instance re-start.
26
¾ Select the Show Recommendations option from the drop
down list at the top of the window to display the parameters
with some recommendations from OAT.
¾ As you notice, all parameters with recommendations are
highlighted in yellow.
27
¾ Change the EXPLAIN_STAT parameter value to the recommended
value. Click the EXPLAIN_STAT parameter from the list.
¾ The recommended value is 1 (ON). It is currently set to 0 (OFF).
¾ Change the value to 1 and select the Save in Memory and File
Save Option. Click the Save button. Saving the change to memory
and the ONCONFIG file allows you to use this option next time the
instance is started. If you didn’t save it to the ONCONFIG file, the
server will use whatever the existing value in the file is after a
restart.
¾ Click the SQL Explorer menu option. This displays the SQL
Tracing Options. By default, SQL Tracing is turned off.
28
¾ Modify the tracing parameters as seen in the following
screenshot and the click Save.
29
¾ Click the SQL tab to display the SQL statements sorted in
descending order by the number of times they have been
executed.
30
¾ Click on any of the magnifying glasses again to get even more
details.
31
¾ Create a sample report with the Server Configuration,
Computer Resource Information, and Computer OS
Information.
¾ Select the check box next to these items and click the Create
Report button.
¾ OAT creates a consolidated report and displays it in a separate
browser window.
32
¾ Click the STORES database to connect to the database and
see the list of tables in the database.
33
6.4.6 SQL Editor
¾ Click the SQL Editor Menu option to bring up the SQL Editor
Page. The SQL editor page is used to run ad-hoc SQL queries.
¾ Enter the following query in the query editor and click the Run
Query button.
select * from state order by code;
34
7. Working with the DB Scheduler
35
¾ Running the SQL statement above displays the information
stored in the ph_task table for a task with the name Auto
Update Statistics Evaluation.
36
The information includes task name, start time, stop time, run
frequency, days when the task is enabled, and information about
whether the task is enabled or disabled.
37
¾ Click the Scheduler option under the Task Scheduler menu to
go back to the tasks summary page.
¾ You should notice that the task execution is now disabled for
Saturdays and Sundays.
38
7.3 Auto Update Statistics Configuration
The Auto Update Statistics option under the Server Administration
menu allows you to configure this feature in OAT.
¾ Click the Auto Update Statistics option. This will display the
results of the Auto Update Stats Evaluation and Results
tasks by database.
¾ Click the Info tab at the top of the page. This displays the
Evaluation and Refresh schedule information as well as the
parameters that are used by these two tasks.
39
¾ Click the Alerts tab to display AUS Alerts.
¾ Click the List tab to display the list of commands that will be
executed by the Refresh task the next time it runs.
40
¾ Click the Config tab to display and change the values of AUS
configuration parameters. Just for fun, change the
AUS_CHANGE parameter value to “20” and click Save.
41
¾ This brings you back to the AUS main page.
In this section, you will use the new data compression feature in
Informix, introduced in 11.50.xC4. All compression features are
controlled through the SQL Admin API.
There are four steps when compressing a table:
¾ Enable compression
¾ Compress the table
¾ Repack the table (moving the data to the front of the dbspace)
¾ Shrink (freeing the unused space for use by other tables in that
dbspace)
You can use the oncheck –pt command to get the number of data
pages used by the table. Run this command and fill in the first row of
the following table with the results:
oncheck -pt stores:comptab | grep "data pages"
42
Number of data pages after compression
Compression rate in percent (%)
# data pages after compression * 100
# data pages before compression)
43
NOTE: You can also use the compress, repack and shrink
commands separately.
¾ You can also experiment and uncompress the table again using
the following command:
execute function
sysadmin:task(“table uncompress”, “comptab”)
When compressing a larger table, you can use the “onstat –g dsk”
command to monitor the progress, where the OP column will show
one the following flags, depending on the compression action being
performed:
(1 = create_dictionary, 2 = compress, 4 = repack, 8 = repack_offline,
16 = shrink, 32 = uncompress, 64 = uncompress_offline,
128=estimate_compression, 256 = purge_dictionary)
44
¾ Under the Space Administration menu item on the left, click on
Storage:
¾ Click on the box in the Table and Indexes box to expand it:
45
Click the small checkbox ( ) for the comptab table. (open a
terminal and type dbaccess stores
/home/informix/scripts/sqls/createComptab.sql if
the comptab table does not exist yet) and then from the
Actions dropdown, choose Optimize Space:
46
¾ From here, you can execute all the (un)compress, repack and
shrink options:
47
¾ If the table is compressed, select the Uncompress option and
click OK to uncompress the table. Alternatively, try compressing
the table if it is uncompressed. From the resulting window, click
Go To Task List to see the result of that action. In the screen
shot below, the uncompress operation was successful.
48
9. Using a Storage Pool
49
¾ Click on Create
¾ Fill in the fields to create a new dbspace as shown
¾ Click on Add
50
¾ From the Spaces pane, make sure that the “extendable”
dbspace is highlighted and choose Modify.
¾ Fill out the Modify pane so it looks like below and then press
Save:
51
¾ Now, let’s expand it. From the Chunks pane, select the
“extendable_chunk” and click Modify.
52
You should see a pop window saying the chunk is now extendable.
¾ Now, highlight that chunk again, and click on Extend.
¾ Now, fill out the extend pane as shown and click Extend:
53
9.2 Creating a Storage Pool
This can also be done either with the Sysadmin API or OAT. For the
purposes of this lab, we will use OAT.
¾ Bring up OAT, if it is not up already
¾ Click on “Space Administration”
¾ Click on “Storage”
¾ Click on the box above “Storage Pool” as shown in the
screenshot below.
54
You will need to create the file for our pool entry.
¾ $ cd /data/IBM/informix/demo/demo_on
¾ $ touch pool_entry1
¾ $ chmod 660 pool_entry1
¾ $ chgrp informix pool_entry1
¾ Fill out the form so it looks like below and then click on “Add”
55
Now, let’s use that storage pool.
¾ Create a new dbspace called “pool_use” with OAT, onspaces or the
sysadmin API. Have it be 5000 KB in size
¾ Make sure that SP_THRESHOLD is set to 10 with onstat. If it is not, then
set it with onmode –wm SP_THRESHOLD=10.
¾ $ dbaccessdemo pooluse_stores1 –dbspace pool_use
¾ Run onstat –d to see how many pages are free
¾ $ dbaccessdemo pooluse_stores2 –dbspace pool_use
¾ Run onstat –d and you will see that a new chunk was automatically added.
This concludes the lab. If you have completed all the exercises and have
extra time, feel free to continue exploring with the utilities/functionality
described here. Otherwise, you can close any open windows.
56
© Copyright IBM Corporation 2011
All Rights Reserved.
IBM Canada
8200 Warden Avenue
Markham, ON
L6G 1C7
Canada
Printed in Canada
01/2011
IBM, IBM (logo), and Informix are trademarks or registered Information concerning non-IBM products was obtained from the
trademarks of International Business Machines Corporation in the suppliers of those products, their published announcements or
United States, other countries, or both. other publicly available sources. IBM has not tested those products
and cannot confirm the accuracy of performance, compatibility or
Linux is a trademark of Linus Torvalds in the United States, other any other claims related to non-IBM products. Questions on the
countries, or both capabilities of non-IBM products should be addressed to the
suppliers of those products.
UNIX is a registered trademark of The Open Group in the United
States, other countries, or both The information in this publication is provided AS IS without
warranty. Such information was obtained from publicly available
Windows is a trademark of Microsoft Corporation in the United sources, is current as of January 2010, and is subject to change.
States, other countries, or both. Any performance data included in the paper was obtained in the
specific operating environment and is provided as an illustration.
Other company, product, or service names may be trademarks or Performance in other operating environments may vary. More
service marks of others. specific information about the capabilities of products described
should be obtained from the suppliers of those products.
References in this publication to IBM products or services do not
imply that IBM intends to make them available in all countries in
which IBM operates. The following paragraph does not apply to the
United Kingdom or any other country where such provisions are
inconsistent with local law:
57