Автостарт oracle на linux

How Oracle Auto Start Database in Linux

For Solaris OS, you should check this post: How to Auto Start Oracle Database on Solaris.

Assuming that you already have some knowledge about how to start Oracle database manually and Oracle provided shell script dbstart , then we can keep going to design and deploy our automatic startup scripts.

By default, Oracle software installation does not deploy automatic startup and shutdown init scripts on the platform, you have to create them by yourself. Here I introduce my scripts for you to use or modify with.

oratab in Linux

Please turn on the startup option by changing «N» to «Y» at the last character of the line.

[oracle@test ~]$ vi /etc/oratab
ORCL:/u01/app/oracle/product/11.2.0/dbhome_1: Y

As for the format of oratab , allow me to interpret this line as followings:

«Hello, my name is ORCL ($ORACLE_SID). I live at /u01/app/oracle/product/11.2.0/dbhome_1 ($ORACLE_HOME). You can find my SPFILE or PFILE in the default location. My answer is Y if you were asking me whether startup is required.»

Creating an init script for Oracle service

[oracle@test ~]$ su —
Password:
[root@test ~]# cd /etc/init.d
[root@test init.d]# vi dbora
#!/bin/sh
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_OWNER=oracle

case «$1» in
‘start’) # Start the Oracle databases and listeners
su — $ORACLE_OWNER -c «$ORACLE_HOME/bin/dbstart $ORACLE_HOME»
;;
‘stop’) # Stop the Oracle databases and listeners
su — $ORACLE_OWNER -c «$ORACLE_HOME/bin/dbshut $ORACLE_HOME»
;;
esac

Also, the listener will be started or shutdown automatically at their running levels respectively.

Adding this init script to rc0, rc3 and rc5

We use 3 soft links to add them into different running levels and prioritize the execution orders by naming the file.

[root@test init.d]# chgrp dba dbora
[root@test init.d]# chmod 750 dbora
[root@test init.d]# ln -s /etc/init.d/dbora /etc/rc.d/rc0.d/K01dbora
[root@test init.d]# ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora
[root@test init.d]# ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dbora

Testing the script

Then check the instance status

[oracle@test ~]$ ps -ef | grep smon | grep -v grep
oracle 3991 1 0 19:20 ? 00:00:00 ora_smon_ORCL
[oracle@test ~]$ sqlplus / as sysdba

Читайте также:  What linux distributions have you used

SQL*Plus: Release 11.2.0.4.0 Production on Thu May 24 19:21:39 2018

Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 — 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name, open_mode from v$database;

Check the listener status

[oracle@test ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 — Production on 24-MAY-2018 19:22:05

Copyright (c) 1991, 2013, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
————————
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 — Production
Start Date 24-MAY-2018 19:19:58
Uptime 0 days 0 hr. 2 min. 7 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/test/listener/alert/log.xml
Listening Endpoints Summary.
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test)(PORT=1521)))
Services Summary.
Service «ORCL» has 1 instance(s).
Instance «ORCL», status READY, has 1 handler(s) for this service.
Service «ORCLXDB» has 1 instance(s).
Instance «ORCL», status READY, has 1 handler(s) for this service.
The command completed successfully

Now the shell script will auto start Oracle database when the server boots.

Источник

How to Automate Startup/Shutdown of Oracle Database on Linux (Doc ID 222813.1)

Oracle Cloud Infrastructure — Version N/A and later
Oracle Database — Standard Edition — Version 12.1.0.2 to 12.1.0.2 [Release 12.1]
Linux OS
Oracle Database — Enterprise Edition — Version 8.0.3.0 and later
Oracle Database Cloud Schema Service — Version N/A and later
Linux x86
Linux x86-64
This document applies to:
SLES7, SLES8, SLES9, SLES10
RHAS 2.1, RHEL 3,4,5,6 OL 4,5,6

Purpose

This document aims to demonstrate the automatic startup and shutdown of Oracle databases on Linux.

Scope

The information in this document is useful for system administrators and database administrators trying to automate Oracle database startup and shutdown. The document describes the detailed steps for configuration on Red Hat Advanced Server 2.1, RedHat Enterprise Linux (RHEL) 3,4,5,6 SuSE SLES7, United Linux 1.0 (SuSE SLES8 Edition), SLES9, SLES10, Oracle Linux (OL) 4,5,6. The information may not apply to other Linux distributions. The main solution does not work on OL7. References provided at the end for Oracle Linux 7 and later.

The following configuration is done to allow Oracle database be up and running in runlevels 3 (character mode) and 5 (X-Window system) and the start / stop commands does not provide the exhaustive list of all possibilities and it presents an example. Therefore the exact scripts may not work with your configuration

Since the configuration is based on dbstart and dbshut scripts provided by the Oracle Server installation, please see

Читайте также:  Puppy linux sfs пакеты

The configuration also facilitates automated startup shutdown of Intelligent Agent, Management Server and HTTP Server, which are available with Oracle Server.

The information in this document does not apply to Oracle Internet Application Server. Still the script can be configured to handle starting up and shutting down iAS processes.

As per Note:105957.1 and Note 1397813.1,
When using an 11.2 ASM or CRS managed database (using the 11.2 Grid Infrastructure), the startup/shutdown script may no longer be used. CRS manages automatic restarts/startups for RAC and single instance databases are managed with Oracle Restart. See the following for more information:

  • How to setup Oracle to startup automatically if the system is restarted
  • Oratab — # Line Added By Agent

Details

To view full details, sign in with your My Oracle Support account.

Don’t have a My Oracle Support account? Click to get started!

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.

Oracle offers a comprehensive and fully integrated stack of cloud applications and platform services. For more information about Oracle (NYSE:ORCL), visit oracle.com. � Oracle | Contact and Chat | Support | Communities | Connect with us | | | | Legal Notices | Terms of Use

Источник

dbaks

#!/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.

case «$1» in
‘start’)
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
# Remove «&» if you don’t want startup as a background process.
su $ORA_OWNER -c «$ORA_HOME/bin/lsnrctl start» &
su $ORA_OWNER -c $ORA_HOME/bin/dbstart &
touch /var/lock/subsys/dbora
;;
‘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/dbshut
su $ORA_OWNER -c «$ORA_HOME/bin/lsnrctl stop»
rm -f /var/lock/subsys/dbora
;;
esac

  • Получить ссылку
  • Facebook
  • Twitter
  • Pinterest
  • Электронная почта
  • Другие приложения

Ярлыки

  • Получить ссылку
  • Facebook
  • Twitter
  • Pinterest
  • Электронная почта
  • Другие приложения

Комментарии

Отправить комментарий

Популярные сообщения из этого блога

Установка и настройка pgAgent(планировщика заданий PostgreSQL)

Установка pgAgent Последняя версия скрипта для установки агента тут . Перенести инструкцию по агенту в отдельную тему. 1. Создать пользователя ОС, и сделать ему домашний каталог: useradd -s /bin/false -r -M pgagent mkdir /home/pgagent 2. Установить и настроить демон: yum install pgagent_94 При наличии ошибок вида (была на Oracle Linux 6.8) Error: Package: pgagent_94-3.4.0-1.rhel6.x86_64 (pgdg94) Requires: libwx_baseu-2.8.so.0(WXU_2.8)(64bit) Нужно установить EPEL systemctl enable pgagent_94 chown pgagent:pgagent /var/log/pgagent_94.log 3. Установить схему агента в базе: sudo -u postgres psql -f /usr/share/pgagent_94-3.4.0/pgagent.sql postgres 4. Создать файл паролей для подключения агента к базе. vi /home/pgagent/.pgpass localhost:5432:*:postgres:postgres chown pgagent.pgagent /home/pgagent -R chmod 600 /home/pagent/.pgpass 5. Запустить и проверить работу агента systemctl start pgagent_94.service systemctl status pga

  • Получить ссылку
  • Facebook
  • Twitter
  • Pinterest
  • Электронная почта
  • Другие приложения
Читайте также:  Gaming engines for linux

Источник

Remote Oracle Database Support

[root@oraclesrv ~]# cat /etc/init.d/dbora
#! /bin/sh -x
#
# chkconfig: 2345 80 05
# description: start and stop Oracle Database Enterprise Edition on Oracle Linux 5 and 6
#
# In /etc/oratab, change the autostart field from N to Y for any
# databases that you want autostarted.
#
# Create this file as /etc/init.d/dbora and execute:
# chmod 750 /etc/init.d/dbora
# chkconfig —add dbora
# chkconfig dbora on
# Note: Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for your installation.
# ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
ORACLE_HOME=/u01/app/oracle/db1
#
# Note: Change the value of ORACLE to the login name of the oracle owner
ORACLE=oracle
PATH=$:$ORACLE_HOME/bin
HOST=`hostname`
PLATFORM=`uname`
export ORACLE_HOME PATH
case $1 in
‘status’)
echo -n $»Oracle Process: »
su $ORACLE -c «ps -ef | grep pmon | grep -v grep; ps -ef | grep -i listener | grep -v grep;» &
;;
‘start’)
echo -n $»Starting Oracle: »
su $ORACLE -c «$ORACLE_HOME/bin/dbstart $ORACLE_HOME» &
;;
‘stop’)
echo -n $»Shutting down Oracle: »
su $ORACLE -c «$ORACLE_HOME/bin/dbshut $ORACLE_HOME» &
;;
‘restart’)
echo -n $»Shutting down Oracle: »
su $ORACLE -c «$ORACLE_HOME/bin/dbshut $ORACLE_HOME» &
sleep 5
echo -n $»Starting Oracle: »
su $ORACLE -c «$ORACLE_HOME/bin/dbstart $ORACLE_HOME» &
;;
*)
echo «usage: $0 »
exit
;;
esac
exit

2. Update oratab file

[root@oraclesrv ~]# cat /etc/oratab
#

# This file is used by ORACLE utilities. It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.
# 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::
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third field 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.
#
#
LEARN:/u01/app/oracle/db1:Y

Источник

Оцените статью
Adblock
detector