Infrastructure at your Service

William Sescu

OUD 11.1.2.3 – How to create an OUD Start/Stop/Status script on Oracle Linux 6

One of the questions that pops up immediately, after you have installed your OUD successfully is how to integrate it into the automatic startup routines of the OS.

My example here show how to do it on Oracle Linux 6. On Oracle Linux 7 it looks a little different. Fortunately, Oracle delivers a script called “create-rc-script”, which can be found in your asinst home directory. It lets you specify the user name under which the OUD will run, the JAVA home and few more stuff. The whole documentation can be found under the following link.

https://docs.oracle.com/cd/E52734_01/oud/OUDAG/appendix_cli.htm#OUDAG01144

Running “–help” gives you all the options.

$ cat /etc/oracle-release
Oracle Linux Server release 6.9

$ ./create-rc-script -V
Oracle Unified Directory 11.1.2.3.170418
Build 20170206221556Z

$ ./create-rc-script --help
Create an RC script that may be used to start, stop, and restart the Directory
Server on UNIX-based systems

Usage:  create-rc-script  {options}
        where {options} include:

-f, --outputFile {path}
    The path to the output file to create
-u, --userName {userName}
    The name of the user account under which the server should run
-j, --javaHome {path}
    The path to the Java installation that should be used to run the server
-J, --javaArgs {args}
    A set of arguments that should be passed to the JVM when running the server

General Options

-V, --version
    Display Directory Server version information
-?, -H, --help
    Display this usage information

Take care that you start the “create-rc-script” script from your asinst_1 home, and not from the Oracle_OUD1 home. The reason for that, is that the “create-rc-script” sets the working directory to your current directory. “WORKING_DIR=`pwd`”, and if not started from the correct directory, you might end up with a not working start/stop script.

So .. to do it correctly, switch to your OUD asinst home first and run it from there. I am using here only a few options. The JAVA home, the user name under which the OUD will run and the output file.

$ cd /u01/app/oracle/product/middleware/asinst_1/OUD/bin

$ pwd
/u01/app/oracle/product/middleware/asinst_1/OUD/bin

$ ./create-rc-script --userName oracle --javaHome /u01/app/oracle/product/middleware/jdk --outputFile /home/oracle/bin/oud

The output generated by the script will be the start/stop script.

$ pwd
/home/oracle/bin

$ ls -l
total 4
-rwxr-xr-x. 1 oracle oinstall 862 Jun 16 13:35 oud

$ cat oud
#!/bin/sh
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
#
#
# chkconfig: 345 90 30
# description: Oracle Unified Directory startup script
#

# Set the path to the Oracle Unified Directory instance to manage
INSTALL_ROOT="/u01/app/oracle/product/middleware/asinst_1/OUD"
export INSTALL_ROOT

# Specify the path to the Java installation to use
OPENDS_JAVA_HOME="/u01/app/oracle/product/middleware/jdk"
export OPENDS_JAVA_HOME

# Determine what action should be performed on the server
case "${1}" in
start)
  /bin/su - oracle -- "${INSTALL_ROOT}/bin/start-ds" --quiet
  exit ${?}
  ;;
stop)
  /bin/su - oracle -- "${INSTALL_ROOT}/bin/stop-ds" --quiet
  exit ${?}
  ;;
restart)
  /bin/su - oracle -- "${INSTALL_ROOT}/bin/stop-ds" --restart --quiet
  exit ${?}
  ;;
*)
  echo "Usage:  $0 { start | stop | restart }"
  exit 1
  ;;
esac

The generated start/stop script looks quite complete. The only thing missing is the “status” section which is quite useful from my point of view. To add the status section, we can use the “status” script, which is also part of the OUD installation.

$ ./status --help
This utility can be used to display basic server information

Usage:  status {options}
        where {options} include:


LDAP Connection Options

-D, --bindDN {bindDN}
    DN to use to bind to the server
    Default value: cn=Directory Manager
-j, --bindPasswordFile {bindPasswordFile}
    Bind password file
-o, --saslOption {name=value}
    SASL bind options
-X, --trustAll
    Trust all server SSL certificates
-P, --trustStorePath {trustStorePath}
    Certificate trust store path
-U, --trustStorePasswordFile {path}
    Certificate trust store PIN file
-K, --keyStorePath {keyStorePath}
    Certificate key store path
-u, --keyStorePasswordFile {keyStorePasswordFile}
    Certificate key store PIN file
-N, --certNickname {nickname}
    Nickname of certificate for SSL client authentication
--connectTimeout {timeout}
    Maximum length of time (in milliseconds) that can be taken to establish a
    connection.  Use '0' to specify no time out
    Default value: 30000

Utility Input/Output Options

-n, --no-prompt
    Use non-interactive mode.  If data in the command is missing, the user is
    not prompted and the tool will fail
-s, --script-friendly
    Use script-friendly mode
--propertiesFilePath {propertiesFilePath}
    Path to the file containing default property values used for command line
    arguments
--noPropertiesFile
    No properties file will be used to get default command line argument values
-r, --refresh {period}
    When this argument is specified, the status command will display its
    contents periodically.  Used to specify the period (in seconds) between two
    displays of the status

General Options

-V, --version
    Display Directory Server version information
-?, -H, --help
    Display this usage information

Take care. Per default, the status utility is an interactive one, and it asks you for the user bind DN and the password. So, the interactive version of that script is not useful for our script.

$ ./status

>>>> Specify Oracle Unified Directory LDAP connection parameters

Administrator user bind DN [cn=Directory Manager]:

Password for user 'cn=Directory Manager':

          --- Server Status ---
Server Run Status:        Started
Open Connections:         6

          --- Server Details ---
Host Name:                dbidg01
Administrative Users:     cn=Directory Manager
Installation Path:        /u01/app/oracle/product/middleware/Oracle_OUD1
Instance Path:            /u01/app/oracle/product/middleware/asinst_1/OUD
Version:                  Oracle Unified Directory 11.1.2.3.170418
Java Version:             1.7.0_141
Administration Connector: Port 4444 (LDAPS)

          --- Connection Handlers ---
Address:Port : Protocol               : State
-------------:------------------------:---------
--           : LDIF                   : Disabled
8899         : Replication (secure)   : Enabled
0.0.0.0:161  : SNMP                   : Disabled
0.0.0.0:1389 : LDAP (allows StartTLS) : Enabled
0.0.0.0:1636 : LDAPS                  : Enabled
0.0.0.0:1689 : JMX                    : Disabled
...
...

And we need to do some adjustments, like in the following example.

./status --trustAll --no-prompt --bindDN cn="Directory Manager" --bindPasswordFile /home/oracle/.oudpwd | head -24

OK. To complete the script, we can add the status section to the script.

$ cat oud

#!/bin/sh
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
#
#
# chkconfig: 345 90 30
# description: Oracle Unified Directory startup script
#

# Set the path to the Oracle Unified Directory instance to manage
INSTALL_ROOT="/u01/app/oracle/product/middleware/asinst_1/OUD"
export INSTALL_ROOT

# Specify the path to the Java installation to use
OPENDS_JAVA_HOME="/u01/app/oracle/product/middleware/jdk"
export OPENDS_JAVA_HOME

# Determine what action should be performed on the server
case "${1}" in
start)
  /bin/su - oracle -- "${INSTALL_ROOT}/bin/start-ds" --quiet
  exit ${?}
  ;;
stop)
  /bin/su - oracle -- "${INSTALL_ROOT}/bin/stop-ds" --quiet
  exit ${?}
  ;;
restart)
  /bin/su - oracle -- "${INSTALL_ROOT}/bin/stop-ds" --restart --quiet
  exit ${?}
  ;;
status)
  /bin/su - oracle -- "${INSTALL_ROOT}/bin/status" --trustAll --no-prompt --bindDN cn="Directory Manager" --bindPasswordFile /home/oracle/.oudpwd | head -24
  exit ${?}
  ;;
*)
  echo "Usage:  $0 { start | stop | restart | status }"
  exit 1
  ;;
esac

Last but not least, we need to move it with the root user to the /etc/init.d directory and add it via chkconfig.

# mv /home/oracle/bin/oud /etc/init.d/
# chkconfig --add oud

# chkconfig --list | grep oud
oud             0:off   1:off   2:off   3:on    4:on    5:on    6:off

That’s all. The OUD part is done now. But what about the ODSM? We want the WebLogic domain to startup automatically as well. For doing so, we need another script.

$ cat /home/oracle/bin/weblogic

#!/bin/sh
#
#
# chkconfig: 345 90 30
# description: WebLogic 10.3.6 startup script
#

# Specify the path to the Java installation to use
JAVA_HOME="/u01/app/oracle/product/middleware/jdk"
export JAVA_HOME

BASE_DOMAIN="/u01/app/oracle/product/middleware/user_projects/domains/base_domain"
export BASE_DOMAIN

# Determine what action should be performed on the server
case "${1}" in
start)
  /bin/su - oracle -c "nohup ${BASE_DOMAIN}/bin/startWebLogic.sh &"
  exit ${?}
  ;;
stop)
  /bin/su - oracle -c "${BASE_DOMAIN}/bin/stopWebLogic.sh"
  exit ${?}
  ;;
restart)
  /bin/su - oracle -c "${BASE_DOMAIN}/bin/stopWebLogic.sh"
  /bin/su - oracle -c "nohup ${BASE_DOMAIN}/bin/startWebLogic.sh &"
  exit ${?}
  ;;
*)
  echo "Usage:  $0 { start | stop | restart }"
  exit 1
  ;;
esac

Now it’s time to move the weblogic to the start routines as well.

# mv /home/oracle/bin/weblogic /etc/init.d/
# chkconfig --add weblogic
# chkconfig --list | grep weblogic
weblogic        0:off   1:off   2:off   3:on    4:on    5:on    6:off

After everything is setup, it is time to test it. ;-)

# chkconfig --list | egrep '(weblogic|oud)'
oud             0:off   1:off   2:off   3:on    4:on    5:on    6:off
weblogic        0:off   1:off   2:off   3:on    4:on    5:on    6:off

# init 6

Now just check if everything came up correctly.

Conclusion

The OUD comes with a script “create-rc-script” which is quite useful. However, in case you have the OSDM and you want the OUD status section as well, some adjustments have to be done.

 

Leave a Reply


− seven = 2

William Sescu
William Sescu

Consultant