Kevin Kempf's Blog

July 17, 2012

Agent Autostart process on Linux

Filed under: Enterprise Manager, Oracle — kkempf @ 2:40 pm

Ever wonder how EM agents automagically start up during host restarts on Linux?

I recently had cause to dig into this, and figured I’d share the architecture for general knowledge sake.

For purposes of this entry, I’m making the rather obvious assumption that the agent has been successfully installed on the Linux host.

Relevant scripts:

These scripts should be landed by the Agent install.

/etc/rc.d/init.d/gcstartup

  • call the $AGENT_HOME/install/unix/scripts/agentstup script with an argument of start or stop

$AGENT_HOME/install/unix/scripts/agentstup

  • start or stop the agent (based on argument $1) via $AGENT_HOME/bin/emctl start|stop agent

$AGENT_HOME/install/unix/scripts/lockgcstartup (/etc/rc.d/init.d/lockgcstartup)

  • touch /var/lock/subsys/gcstartup
  • touch /var/lock/subsys/unlockgcstartup

$AGENT_HOME/install/unix/scripts/unlockgcstartup (/etc/rc.d/init.d/unlockgcstartup)

  • rm -f /var/lock/subsys/gcstartup
  • rm -rf /var/lock/subsys/unlockgcstartup

Relevant Symbolic Links by Run Level:

These sym links should be created during the Agent install.

Run Level 2

/etc/rc2.d/S98gcstartup → /etc/rc.d/init.d/gcstartup

/etc/rc2.d/K98gcstartup → /etc/rc.d/init.d/gcstartup

/etc/rc2.d/S99lockgcstartup -> /etc/rc.d/init.d/lockgcstartup

/etc/rc2.d/K99unlockgcstartup -> /etc/rc.d/init.d/unlockgcstartup

Run Level 3

/etc/rc3.d/S98gcstartup → /etc/rc.d/init.d/gcstartup

/etc/rc3.d/K98gcstartup → /etc/rc.d/init.d/gcstartup

/etc/rc3.d/S99lockgcstartup -> /etc/rc.d/init.d/lockgcstartup

/etc/rc3.d/K99unlockgcstartup -> /etc/rc.d/init.d/unlockgcstartup

Run Level 5

/etc/rc5.d/S98gcstartup → /etc/rc.d/init.d/gcstartup

/etc/rc5.d/K98gcstartup → /etc/rc.d/init.d/gcstartup

/etc/rc5.d/S99lockgcstartup -> /etc/rc.d/init.d/lockgcstartup

/etc/rc5.d/K99unlockgcstartup -> /etc/rc.d/init.d/unlockgcstartup

Walking through the bootup sequence for Runlevel 5:

  • /etc/rc calls the kill scripts (for i in /etc/rc$runlevel.d/K* ; do ) with the command “stop”
    • /etc/rc5.d/K98gcstartup stop {awesome oracle syntax there!}
    • /etc/rc5.d/ K99unlockgcstartup stop {takes no arguments though one is passed}
  • /etc/rc calls the startup scripts (for i in /etc/rc$runlevel.d/S* ; do ) with the command “start”
    • /etc/rc5.d/S98gcstartup start {startup, start!}
    • /etc/rc5.d/S99lockgcstartup start {takes no arguments though one is passed}

Incidentally:

  • Note ID 374068.1 covers some of this information.
  • I’m testing EM 12c and the agent install hooks are exactly the same (now gcstartup calls $AGENT_HOME/core/12.1.0.1.0/install/unix/scripts/agentstup)

Another Oddity

  • For some reason, a Linux x86_64 agent of mine was failing to start on boot
  • The console error was <AgentHome>/install/unix/scripts/agentstup: line 19: [: =: unary operator expected
  • The “fix” from support was to use quotes to protect shell variables in their startup script
    • vi $AGENT_HOME/install/unix/scripts/agentstup
    • change both occurrences of $executingUser to “$executingUser”
    • change both occurrences of $installUser to “$installUser”
  • This is detailed in 789363.1
  • I’m floored that the fix, from support, is to manually edit an Oracle provided script, but at least I got a solution!

 

Blog at WordPress.com.