Automatically start Zend DBi MySQL at start up

One of the nice features of Zend Server for IBM i is that it will start up automatically whenever the IBM i is restarted.  To be more specific, it starts whenever subsystem QSYSWRK is started.  Zend DBi does not provide for automatic start up of the Zend DBi MySQL server daemon.  In a production environment using MySQL, it would be beneficial to have MySQL start up after IPL.  This article suggests a couple of ways to make that happen.

Prerequisites:  Before you set up automatic start up for Zend DBi, you must first install Zend DBi and verify that you can start the MySQL server daemon.  These articles can help with that:

Install MySQL using the Zend DBi installer with Zend Server

Start the Zend DBi MySQL Daemon job and verify it is running

The command to start up the ZENDDBI subsystem and Zend DBI MySQL server daemon is simply this:

strsbs zmysql/zenddbi

It seems from my own testing that any user with *JOBCTL special authority can run this command successfully. Keep in mind this will only work if subsystem ZENDDBI is not already active.  If the subsystem is active but the daemon is not, then a different command is needed:

CALL ZMYSQL/ZMYSQLSTRT

At start up, subsystem ZENDDBI is probably not active, so the strsbs command is the one to use.

Method 1

One way to run the strsbs command at start up is to simply add the ‘strsbs zmysql/zenddbi’ command to the start up program defined by the QSTRUPPGM system value. If this program is QSYS/QSTRUP, you should create a new start up program by retrieving the CL source for QSYS/QSTRUP into another library, adding your commands to it, and then changing the QSTRUPPGM system value to use your new QSTRUP program. You can see documentation for this process here:

Changing the IPL startup program

Method 2

Another way to do it is to add an autostart job entry to a subsystem that already starts automatically at IPL. In the following example, we will use the QSYSWRK subsystem, which is also used by Zend Server for IBM i.

First, create a job description to be used by the autostart job entry:

CRTDUPOBJ OBJ(ZMYSQLJBDA) FROMLIB(ZMYSQL) OBJTYPE(*JOBD) NEWOBJ(ZMYSQLJBDX)

Next, change the request data for the new job description to start the ZENDDBI subsystem, and assign a user profile with *JOBCTL special authority (ZENDADMIN in this example):

CHGJOBD JOBD(ZMYSQL/ZMYSQLJBDX) TEXT('ZendDBi MySQL autostart JOBD')
USER(ZENDADMIN) RQSDTA('QSYS/STRSBS SBSD(ZMYSQL/ZENDDBI)')

Finally, add the autostart job entry to the QSYSWRK subsystem:

ADDAJE SBSD(QSYS/QSYSWRK) JOB(ZDBI_STR) JOBD(ZMYSQL/ZMYSQLJBDX)

Verify the automatic start up

After setting up either method, check after the next few IPLs to make sure the ZENDDBI subsystem and ZENDDBID server daemon are starting up as expected.  From the command line:

wrkactjob sbs(zenddbi)

The output should be this:

               Current                            
Subsystem/Job  User        Type  CPU %  Function  
ZENDDBI        QSYS        SBS      .0            
  ZENDDBID     MYSQL       BCI      .0  PGM-mysqld

 

Bookmark the permalink.

Leave a Reply