Oracle does not start on system startup - linux

I need to configure oracle database of a remote server to start in system startup.
I followed this tutorial that is almost the same as others.
I am not allowed to restart the server, only can suggest the owner to do something on server.
The server configurations are similar to what the tutorial say but oracle database does not start at system startup. This is the /etc/dbora and /etc/init.d/oratab file contents:
dbora:
#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.
ORA_HOME=/u01/app/oracle/product/11.2.0/db_1
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
su $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" &
su $ORA_OWNER -c $ORA_HOME/bin/dbstart &
touch /var/lock/subsys/dbora
;;
'stop')
su $ORA_OWNER -c $ORA_HOME/bin/dbshut
su $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
rm -f /var/lock/subsys/dbora
;;
esac
oratab:
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
orcl:/u01/app/oracle/product/11.2.0/db_1:Y
orcl:/u01/app/oracle/product/11.2.0/db_1:N
What is wrong with these files?

leave only first row
**# Multiple entries with the same $ORACLE_SID are not allowed.**
#
#
orcl:/u01/app/oracle/product/11.2.0/db_1:Y

Related

Nagios NSCA 4th variable always $OUTPUT$

I have implemented nsca in Nagios for distributed monitoring purposes, and everything seems to be working, except for one oddity that I can't seem to find an answer to anywhere.
The passive checks are sent and received, but the output shows the 4th variable to always be uninitialized, and thus it shows up as $OUTPUT$. It appears as though the checks are showing the proper information on the non-central server, but when it's sent, it doesn't seem to be interpolating properly.
commands.cfg
define command{
command_name submit_check_result
command_line /usr/share/nagios3/plugins/eventhandlers/submit_check_result $HOSTNAME$ '$SERVICEDESC$' $SERVICESTATE$ '$OUTPUT$'
}
submit_check_result
#!/bin/sh
return_code=-1
case "$3" in
OK)
return_code=0
;;
WARNING)
return_code=1
;;
CRITICAL)
return_code=2
;;
UNKNOWN)
return_code=-1
;;
esac
/usr/bin/printf "%s\t%s\t%s\t%s\n" "$1" "$2" "$return_code" "$4" | /usr/sbin/send_nsca 192.168.40.168 -c /etc/send_nsca.cfg
Example service
define service {
host_name example_host
service_description PING
check_command check_icmp
active_checks_enabled 1
passive_checks_enabled 0
obsess_over_service 1
max_check_attempts 5
normal_check_interval 5
retry_check_interval 3
check_period 24x7
notification_interval 30
notification_period 24x7
notification_options w,c,r
contact_groups admins
}
The output from the log on the non-central server shows:
Nov 29 22:52:52 nagios-server nagios3: SERVICE ALERT: example_host;PING;OK;HARD;5;OK - 192.168.1.1: rta nan, lost 0%
The output from the log on the central server shows:
EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;example_host;PING;0;$OUTPUT$
Status information on the central server (web interface) shows:
PING OK 2016-11-29 22:54:50 0d 0h 54m 6s 1/5 $OUTPUT$
It's not just this service either. All services, including those that are essentially preconfigured for the Nagios server itself "check_load, check_proc, etc".
Any assistance would be appreciated.
I found the issue. Turns out the submit_check_result script above is not formatted properly for submitting check results to a remote server. It will do it, but it doesn't account for the status properly. Below is the proper script:
#!/bin/sh
# SUBMIT_CHECK_RESULT_VIA_NSCA
# Written by Ethan Galstad (egalstad#nagios.org)
# Last Modified: 10-15-2008
#
# This script will send passive check results to the
# nsca daemon that runs on the central Nagios server.
# If you simply want to submit passive checks from the
# same machine that Nagios is running on, look at the
# submit_check_result script.
#
# Arguments:
# $1 = host_name (Short name of host that the service is
# associated with)
# $2 = svc_description (Description of the service)
# $3 = return_code (An integer that determines the state
# of the service check, 0=OK, 1=WARNING, 2=CRITICAL,
# 3=UNKNOWN).
# $4 = plugin_output (A text string that should be used
# as the plugin output for the service check)s
#
#
# Note:
# Modify the NagiosHost parameter to match the name or
# IP address of the central server that has the nsca
# daemon running.
printfcmd="/usr/bin/printf"
NscaBin="/usr/sbin/send_nsca"
NscaCfg="/etc/send_nsca.cfg"
NagiosHost="central_host_IP_address"
# Fire the data off to the NSCA daemon using the send_nsca script
$printfcmd "%s\t%s\t%s\t%s\n" "$1" "$2" "$3" "$4" | $NscaBin -H $NagiosHost -c $NscaCfg
# EOF
Much better results.

Run script at boot after MySQL started

I want to start Seafile (cloud-server which needs MySQL) at the boot of my Raspberry Pi. My Problem is, that the Seafile starts befor mysql and caused many errors, because seafile needs mysql.
I took the recommended script:
#! /bin/sh
# /etc/init.d/seafile
### BEGIN INIT INFO
# Provides: seafile
# Required-Start: $local_fs $remote_fs $network mysql
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Script to start/stop/restart seafile
# Description: Simple script to start, stop or restart seafile for the cloud
### END INIT INFO
# Change the value of "user" to your linux user name
user=chromo
# Change the value of "script_path" to your path of seafile installation
seafile_dir=/home/chromo/cloud
script_path=${seafile_dir}/seafile-server-latest
seafile_init_log=${seafile_dir}/logs/seafile.init.log
seahub_init_log=${seafile_dir}/logs/seahub.init.log
# Change the value of fastcgi to true if fastcgi is to be used
fastcgi=true
# Set the port of fastcgi, default is 8000. Change it if you need different.
fastcgi_port=8000
case "$1" in
start)
sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log}
if [ $fastcgi = true ];
then
sudo -u ${user} ${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log}
else
sudo -u ${user} ${script_path}/seahub.sh start >> ${seahub_init_log}
fi
;;
restart)
sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log}
if [ $fastcgi = true ];
then
sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${seahub_init_log}
else
sudo -u ${user} ${script_path}/seahub.sh restart >> ${seahub_init_log}
fi
;;
stop)
sudo -u ${user} ${script_path}/seafile.sh $1 >> ${seafile_init_log}
sudo -u ${user} ${script_path}/seahub.sh $1 >> ${seahub_init_log}
;;
*)
echo "Usage: /etc/init.d/seafile {start|stop|restart}"
exit 1
;;
esac
Can someone help me?
The best thing would be to set priority for starting these services in /etc/rc[runlevel].d file.
In your case, the first thing to check would be the runlevel to which you have boot into. You can check this using the command "runlevel". You can also check
Say, you have been booted in to runlevel 3. You can rename the current seafile file in directory "/etc/rc3.d".
For eg:
If the two files are
/etc/rc3.d/20seafile
/etc/rc3.d/50mysql
Rename the file as 70seafile or anything higher than 50.
This should fix the issue you are facing now.
Another workaround will be removing the seafile link to /etc/init.d directory and put a line saying
/etc/init.d/seafile start
inside the file /etc/rc.local
Please check this and let me know if it has fixed the issue for you.

How to run command in cron job with external string

I need to run corn job every month to update software license.
The license is ready in text file on remote server (example: http://codebox.ir/soft/license.txt) and update every month.
license.txt content Example "tev3vv5-v343".
I want to grab the license and put in some command:
# update xxxx-xxxx
how can I make this?
CentOs 6.4
Write a script which fetches the file from your remoteserver
wget http://codebox.ir/soft/license.txt
Then you get the key out of that textfile and pipe it into your updatecommand
update `cat license.txt`
note the Backticks, so your script could look like this
#!/bin/sh
#
# This script fetches and updates the licensefile
#
wget http://codebox.ir/soft/license.txt;
update `cat license.txt`;
make the file executable
chmod +x updateLicense.sh
and put it in your crontab
cd /path/to/script;./updateLicense.sh
or to keep it compact, allthough i would check if the file is in an expected format first.
#!/bin/sh
#
# This script fetches and updates the licensefile
#
update `wget http://codebox.ir/soft/license.txt`;
And with checking if fetch succeeded
#!/bin/sh
#
# This script fetches and updates the licensefile
#
URL = http://codebox.ir/soft/license.txt
wget_output=$(wget -q "$URL")
if [ $? -ne 0 ]; then
update $wget_output
fi
No you can develop it further, i'd advise to check the format of the key before updating
#!/bin/sh
#
# This script fetches and updates the licensefile
#
# Define URL
URL = http://codebox.ir/soft/license.txt
# Fetch content
wget_output=$(wget -q "$URL")
# Check if fetch suceeded $? is the returnvalue of wget in this case
if [ $? -ne 0 ]; then
# Use mad Regexskillz to check format of licensekey and update if matched
if [[ $wget_output == [a-z0-9]+-[a-z0-9]+ ]] ; then update $wget_output; fi
fi
I'd also return some values to further raise quality of your script, also i'd pass the url and the regex into the function to keep the script reusable but that's a matter of taste

Service doesn't support chkconfig

Good day,programmers. I have a problem. Please help.
I am creating a service, which must load automatically when Linux is being loaded. So,I copied the script into the directory /etc/rc.d/init.d or /etc/init.d/. But when I am preforming the command
chkconfig --add listOfProcesses
an error occurs:
service listOfProcesses doesn't support chkconfig
Here is the content of the script. I have found the first version in the Google and have used it as a pattern.
#!/bin/bash
# listOfProcesses Start the process which will show the list of processes
# chkconfig: 345 110 02
# description: This process shows current time and the list of processes
# processname: listOfProcesses
### BEGIN INIT INFO
# Provides:
# Required-Start:
# Required-Stop:
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: shows current time and the list of processes
# Description: This process shows current time and the list of processes
### END INIT INFO
# Source function library.
KIND="listOfProcesses"
start() {
echo -n $"Starting $KIND services: "
daemon /home/myscript
echo
}
stop() {
echo -n $"Shutting down $KIND services: "
killproc /home/myscript
echo
}
restart() {
echo -n $"Restarting $KIND services: "
killproc /home/myscript
daemon /home/myscript
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
exit 0;
The second version was made from the cron script. I found the cron script,copied it, and changed it, so I used it as the pattern.
#!/bin/sh
#
# crond Start/Stop the cron clock daemon.
#
# chkconfig: 2345 90 60
# description: cron is a standard UNIX program that runs user-specified \
# programs at periodic scheduled times. vixie cron adds a \
# number of features to the basic UNIX cron, including better \
# security and more powerful configuration options.
### BEGIN INIT INFO
# Provides: crond crontab
# Required-Start: $local_fs $syslog
# Required-Stop: $local_fs $syslog
# Default-Start: 2345
# Default-Stop: 90
# Short-Description: run cron daemon
# Description: cron is a standard UNIX program that runs user-specified
# programs at periodic scheduled times. vixie cron adds a
# number of features to the basic UNIX cron, including better
# security and more powerful configuration options.
### END INIT INFO
rights=whoami;
root=root;
[ -f "$rights"=="$root" ] || {
echo "this programme requires root rights";
exit 1;
}
# Source function library.
. /etc/rc.d/init.d/functions
start() {
echo -n $"Starting $KIND services: ";
daemon showListOfProcesses;
}
stop() {
echo -n $"Shutting down $KIND services: ";
killproc showListOfProcesses;
}
restart() {
stop
start
}
reload() {
restart;
}
force_reload() {
# new configuration takes effect after restart
restart
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
force-reload)
force_reload
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
exit 2
esac
exit $?
# Show the list of processes
function showListOfProcesses {
top > /dev/tty2;
}
But the situation hadn't changed. What is the problem? What is wrong in the script?
Look at all the scripts that chkconfig can turn on or off in /etc/rc.d/init.d, you'll notice that the top few comments are very important. See How-To manage services with chkconfig and service
#!/bin/sh
#
# crond Start/Stop the cron clock daemon.
#
# chkconfig: 2345 90 60
# description: cron is a standard UNIX program that runs user-specified \
# programs at periodic scheduled times. vixie cron adds a \
# number of features to the basic UNIX cron, including better \
# security and more powerful configuration options.
You have a script called listofprocesses but to chkconfig this script looks like crond due to the 3rd line and thus it does not find any script called listofprocesses
You'll also most certainly want to change chkconfig: 2345 90 60. Which says which run levels it should be on (in this case 2, 3, 4 and 5), what it's start order is (90) and what its kill order is (60).
You can check the service is correctly set up with chkconfig --list listofprocesses.
Just add the following line at the top:
# chkconfig: - 99 10
it should do the trick
Here is an excellent map of the elements that need to be in an init script, to implement what chkconfig and the init subsystem is doing, and what each element actually does:
http://www.tldp.org/HOWTO/HighQuality-Apps-HOWTO/boot.html
Looks like the max priority is 99, at least on CentOS 6.5, which is what I'm playing with right now.
I was also facing this issue and it was not able to call stop function during shutdown. found the solution after trying so many suggestions on net.
You need to add "touch /var/lock/subsys/" for start and rm -f /var/lock/subsys/" for stop functions in script. Stop may not work for first reboot as lock may be not available during shutdown but will start working from next reboot.
Enjoy....:)
Satya

Starting oc4j and oracle using rc start script

I am having a problem with a couple of my linux boot scripts, specifically the ones that start up my Oracle 10g database and my oc4j container.
I have used chkconfig to tell Linux to start the database before the container, however, it seems that the container starts before the database which oc4j does not like at all. I can get to my application(s), however, I have no DB connections. If I restart oc4j everything works just fine.
Is there a way that I can "pause" the start-up of oc4j until the database (and listener) are both started and ready for connections?
Put them in 1 start script?
start listener
start database
start appserver
This is my /etc/init.d/dbora script. Add the call to start OC4J
#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.
ORA_HOME=/app/oracle/product/10.2.0/db_1
ORA_OWNER=oracle
echo $1
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
su - $ORA_OWNER -c $ORA_HOME/bin/dbstart
su - $ORA_OWNER -c $ORA_HOME/bin/emctl start dbconsole
;;
'stop')
# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c $ORA_HOME/bin/emctl stop dbconsole
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
;;
esac

Resources