Category Archives: Uncategorized

Automating Startup / Shutdown in Linux

As root user create new file “oracle”
(init script for startup and shutdown the database) in /etc/init.d/ directory with following content:


#!/bin/bash
#
# oracle Init file for starting and stopping
# Oracle Database. Script valid for 10g and 11g.
#
# chkconfig: 35 80 30
# description: Oracle Database startup script# Source function library.

. /etc/rc.d/init.d/functions
ORACLE_OWNER=”oracle”
ORACLE_HOME=”/u01/app/oracle/11.2.0/db_1″
case “$1″ in

start)
echo -n $”Starting Oracle DB:”
su – $ORACLE_OWNER -c “$ORACLE_HOME/bin/dbstart $ORACLE_HOME”
echo “OK”
;;

stop)
echo -n $”Stopping Oracle DB:”
su – $ORACLE_OWNER -c “$ORACLE_HOME/bin/dbshut $ORACLE_HOME”
echo “OK”
;;

*)
echo $”Usage: $0 {start|stop}”
esac

Execute (as root) following commands (First script change the permissions, second script is configuring execution for specific runlevels):
chmod 750 /etc/init.d/oracle
chkconfig –add oracle –level 0356

105_cr_usr_dba01.ksh


#!/bin/ksh
#
# Michael Culp
# Schema for the database relationship
# DBA01 Schema is for the DBAdmin App to be built
#
################################################################################
sqlplus -s "/ as sysdba" <<EOF
set serveroutput on size 1000000
set timing on;


drop user dba01 cascade;

create user dba01 identified by password
   default tablespace users;

grant dba      to dba01;
grant resource to dba01;


-- drop table dba01.server;

-- create table dba01.server (
--   domain    varchar2(50),
--   hostname  varchar2(100),
--   database  varchar2(200),
--   env       varchar2(15),
--   aitno     varchar2(20),
--   app       varchar2(35),
--   rdbmsver  varchar2(50),
--   prim_dba  varchar2(50)
--   )
--  tablespace brain_tbs;

DROP USER HC_CORE CASCADE;

CREATE USER HC_CORE
  IDENTIFIED BY password
  DEFAULT TABLESPACE USERS
  TEMPORARY TABLESPACE TEMP
  PROFILE DEFAULT
  ACCOUNT UNLOCK;
  -- 1 System Privilege for HC_CORE
  GRANT CREATE SESSION TO HC_CORE;
  -- 20 Object Privileges for HC_CORE
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_BACKUP            TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_DATABASE          TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_DB_COMP           TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_DB_FRA            TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_DB_INIT_PARAM     TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_DB_INVLD_OBJECTS  TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_DB_OH_PATCHES     TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_DB_PATCHES        TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_DB_SPACE_USAGE    TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_DB_STANDBY_DEST   TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_DB_STANDBY_STATUS TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_DB_TAB            TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_INSTANCE          TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_JOB_RUN           TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_MACHINE           TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_RMAN_BACKUP       TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_STORAGE           TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_SYSCTL_CONF       TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_TBSPC             TO HC_CORE;
--    GRANT DELETE, INSERT, SELECT, UPDATE ON DBA01.HC_TBSPC_DATAFILE    TO HC_CORE;

EOF


stop_wl.ksh


# the following completed using the instructions in this article
#  https://oracle-base.com/articles/12c/weblogic-development-only-installation-on-oracle-linux-5-and-6-1211

# author : susheel tamrakar ; April 2016
#
MW_HOME=/oracle/product/11.2.0/db_1; export MW_HOME
WLS_HOME=$MW_HOME/wlserver; export WLS_HOME
JAVA_HOME=/oracle/product/11.2.0/db_1/jdk18; export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH; export PATH
# JDK 7 Requirement
USER_MEM_ARGS="-Xms32m -Xmx200m -XX:MaxPermSize=350m"
# # Stop WebLogic
/ora01/app/oracle/mydomain/bin/stopWebLogic.sh
# or
# ps -ef|grep weblogic and kill the pid for weblog

PIPE Export / Import

Ask Tom pipe

 

EXPORT AND IMPORT USING UNIX PIPES.

Sometimes, the space on disk may not be enough to hold a full export dump if uncompressed.

EXAMPLE – export schema MCULP from PROD database and import into DEV database.

To avoid space running out, unix pipes and compression can be used.
EXPORT IN PROD DATABASE

cd /u02/oradata/export

CREATE UNIX PIPE IN THIS AREA – WHERE THE EXPORT DUMP WILL BE WRITTEN TO.

mknod pipe p

CREATE PAR FILE –

parfile is mculp.par

vi mculp.par

buffer=2097152
recordlength=65535
consistent=y
owner=mculp
log=/u02/oradata/export/mculp.log
file=/u02/oradata/export/pipe

Now export schema MCULP.

1. nohup gzip -c </u02/oradata/export/pipe > /u02/oradata/export/mculp.dmp.gz &

Immediately enter next command –

2. nohup exp \’/ as sysdba\’ parfile=/u02/oradata/export/mculp.par &

Export of MCULP schema completes – compressed dump mculp.dmp.gz created.

ftp or copy the dump file mculp.dmp.gz to the DEV database box.

IMPORT IN DEV DATABASE – – Presume same directory structure exists on DEV box.

Create UNIX PIPE in area where dump is copied to in DEV box.

cd /u02/oradata/export

mknod import_pipe p

Create import parfile – called imp.par

vi imp.par

fromuser=mculp
touser=mculp
commit=y
buffer=2097152
ignore=y
file=/u02/oradata/export/import_pipe
log=/u02/oradata/export//imp_mculp.log

Enter commands –

1. nohup gzip -dc </u02/oradata/export/mculp.dmp.gz > import_pipe &

Immediately enter next command –

2. nohup imp \’/ as sysdba\’ parfile=/u02/oradata/export/imp.par

Check the logs for output of import.