19.1 Rebuilding the Sybase Database

If your ZENworks database is an embedded or external Sybase database, you should rebuild the database so that it runs on the latest version of the Sybase database engine.

  1. Ensure that you have archived your database credentials.

    To archive the credentials of an external Sybase database, contact your database administrator.

    To archive the credentials of an embedded or external OEM Sybase database, perform the following tasks on the database server:

    1. Ensure the database service is running.

      On Windows: In the Windows Services, ensure that the status of Novell ZENworks Embedded Datastore is Started.

      On Linux: At the console prompt, enter /etc/init.d/sybase-asa status to verify the status of the database. If the database is not running, enter /etc/init.d/sybase-asa start.

    2. Obtain the Sybase connection information by running the zman dgc command.

    3. Provide the credentials of the ZENworks administrator when prompted.

    4. Copy and save the database user name and password into a text file.

  2. Stop the Novell ZENworks Embedded Datastore service, if it is running.

    • On Windows: Do the following:

      1. From the Start menu, click Settings > Control Panel.

      2. Double-click Administrative Tools > Services.

      3. Right-click the Novell ZENworks Embedded Datastore service, then click Stop, or select the Novell ZENworks Embedded Datastore service, then click Stop icon on the toolbar.

    • On Linux: At the console prompt, enter /etc/init.d/sybase-asa stop.

  3. Stop the ZENworks Services on all other ZENworks Servers in the Management Zone. For more information, see Step 2.a in the Section 3.1, Backing Up the Embedded Sybase SQL Anywhere Database on a Windows or Linux Server.

  4. At the console prompt, go to the Sybase database directory. By default, it is %ZENWORKS_HOME%\database on Windows, and /var/opt/novell/zenworks/database on Linux.

  5. Take a reliable backup of the zenworks_zone_name.db and Zenworks_zone_name.log files.

    For detailed information on how to take an immediate backup of the files of the embedded Sybase database, see Section 3.0, Backing Up the Embedded Sybase SQL Anywhere Database. For detailed information on how to take an immediate backup of the files of the external Sybase database, see Section 8.0, Backing Up the External Sybase Database.

  6. Start the Novell ZENworks Embedded Datastore service.

    • On Windows: Perform the following:

      1. From the Windows desktop Start menu, click Settings > Control Panel.

      2. Double-click Administrative Tools > Services.

      3. Right-click the Novell ZENworks Embedded Datastore service, then click Start, or select the Novell ZENworks Embedded Datastore service, then click Start icon on the toolbar.

    • On Linux: At the console prompt, enter /etc/init.d/sybase-asa start.

  7. (Conditional) If your database is installed on Linux, run the following script file:

    source /opt/novell/zenworks/share/sybase/bin32/sa_config.sh

  8. Ensure that the database authentication has been set up by verifying that the database_authentication attribute in the saopts.sql file has been configured.

    The saopts.sql file is located in the %ZENWORKS_HOME%\share\asa\scripts\ directory on Windows, and in the /opt/novell/zenworks/share/sybase/scripts/ directory on Linux. The database_authentication attribute is located in the following entry in the saopts.sql file:

    if not exists( select * from SYS.SYSOPTION
     where ucase( "option" )  = ucase( 'database_authentication' ) ) then
        set option PUBLIC.database_authentication = <value>;
    end if
    go
    

    If the value of set option PUBLIC.database_authentication is empty or does not exist in the script, continue with Step 8.a to launch the DBISQL utility and to configure the database authentication; else skip to Step 9.

    1. Launch the DBISQL utility. For more information, see Step 1 in the Section 8.1, Backing Up the External Sybase Database on a Windows or Linux Server.

    2. In the SQL Statements section, specify the following query:

      select setting
      from sysoptions 
         where "option" like 'database%' >># output_filename
      
    3. Click Execute SQL Statement(s).

      The results of the query are written in the output file that you specify in the query.

    4. Copy the result of the query from the output file, and paste it as the value of the database_authentication attribute in the saopts.sql file. The saopts.sql file is located in the %zenworks_home%\share\asa\scripts\ directory on Windows, and in the /opt/novell/zenworks/share/sybase/scripts/ directory on Linux.

      The database_authentication attribute is located in the following entry in the saopts.sql file:

      if not exists( select * from SYS.SYSOPTION
       where ucase( "option" )  = ucase( 'database_authentication' ) ) then
          set option PUBLIC.database_authentication = <output_of_the_query_run_in_Step_8b>;
      end if
      go
      
  9. Stop the Novell ZENworks Embedded Datastore service.

    • For the Embedded Database: Stop the ZENworks services, including the Novell ZENworks Embedded Datastore service:

      1. At the console prompt, run the novell-zenworks-configure -c Start command.

      2. Type the option number corresponding to Stop.

      3. Press Enter twice.

    • For the External Database: Stop the Novell ZENworks Embedded Datastore Service by stopping the Windows Services manager on Windows, or by running the /etc/init.d/sybase-asa stop command on Linux.

  10. Create a temporary directory with the name as unload within c:\dbreload\ on Windows or within /tmp/dbreload/ on Linux.

  11. At the console prompt of the database server, run the following command to start the database service:

    On Windows: dbeng12 %ZENWORKS_HOME%\database\zenworks_ZONE_NAME.db -n rebuild

    On Linux: dbeng12 /var/opt/novell/zenworks/database/zenworks_ZONE_NAME.db -n rebuild

  12. Open another command prompt on the database server, and run the unload command.

    1. At the command prompt, go to the following directories:

      On Windows: %ZENWORKS_HOME%\share\ASA\ BIN64

      On Linux: /opt/novell/zenworks/share/sybase/bin64s

    2. Run the appropriate command:

      On Windows: dbunload -c "UID=zenadmin;PWD=database_password;ENG=rebuild" -an c:\dbreload\unload\zenworks_<management_zone_name>.db

      On Linux: dbunload -c "UID=zenadmin;PWD=database_password;ENG=rebuild" -an /tmp/dbreload/unload/zenworks_<management_zone_name>.db

    3. Run the appropriate command for encrypting the database file:

      On Windows: <ZENWORKS_HOME>\share\ASA\BIN64\dbunload.exe -c "UID=username;PWD=password;DBF=<ZENWORKS_HOME>\database\zenworks_<ZoneName>.db" -ar -ap 4096 -ii -et"

      On Linux: /opt/novell/zenworks/share/sybase/bin64s/dbunload -c "UID=username;PWD=password;DBF=/var/opt/novell/zenworks/database/zenworks_<ZoneName>.db" -ar -ap 4096 -ii -et"

      where ZENWORKS_HOME is the folder path that is selected during installation, and ZoneName is the name that is specified in the Zone Name field during installation.

  13. After the database rebuild has been successfully completed, take a reliable backup of the newly built database. The database is located in the c:\dbreload\unload directory on Windows and in the /tmp/dbreload/unload directory on Linux.

    If you encounter any issues during the rebuild process, contact Novell Support.

  14. Stop the Novell ZENworks Embedded Datastore service by using the dbeng12 command:

    • On Windows: Right-click the Rebuild icon located in Windows taskbar, then click Shutdown.

    • On Linux: At the console prompt, enter q.

  15. Overwrite the database and applicable log file in the database directory with the new ones located in the unload directory (zenworks_management_zone_name.*).

    The unload directory is located in c:\dbreload\ on Windows or in /tmp/dbreload/ on Linux.

  16. Start the Novell ZENworks Embedded Datastore service.

    • For the Embedded Database: Start all the ZENworks services, including the Novell ZENworks Embedded Datastore service:

      1. At the console prompt, run the novell-zenworks-configure -c Start command.

      2. Type the option number corresponding to Start.

      3. Press Enter twice.

    • For the External Database: Start the Novell ZENworks Embedded Datastore service in the Services window on Windows, or run the /etc/init.d/sybase-asa start command on Linux.

  17. Start the ZENworks Services on the the ZENworks Servers in the Management Zone. For more information, see Step 2.c in the Section 3.1, Backing Up the Embedded Sybase SQL Anywhere Database on a Windows or Linux Server.

  18. Take a backup of the newly created database on a regular basis (daily or weekly).