<?php
/**
* Twenty Fourteen functions and definitions
*
* Set up the theme and provides some helper functions, which are used in the theme as custom template tags.
* Others are attached to action and filter hooks in WordPress to change core functionality.
*
* When using a child theme you can override certain functions (those wrapped
* in a function_exists() call) by defining them first in your child theme's
* functions.php file. The child theme's functions.php file is included before
* the parent theme's file, so the child theme functions would be used.
*
* @link https://codex.wordpress.org/Theme_Development
* @link https://codex.wordpress.org/Child_Themes
*
* Functions that are not pluggable (not wrapped in function_exists()) are
* instead attached to a filter or action hook.
*
* For more information on hooks, actions, and filters,
* @link https://codex.wordpress.org/Plugin_API
*
* @package WordPress
* @subpackage Twenty_Fourteen
* @since Twenty Fourteen 1.0
*/
/**
* Set up the content width value based on the theme's design.
*
* @see twentyfourteen_content_width()
*
* @since Twenty Fourteen 1.0
*/
if ( ! isset( $content_width ) ) {
$content_width = 474;
}
/**
* Twenty Fourteen only works in WordPress 3.6 or later.
*/
if ( version_compare( $GLOBALS['wp_version'], '3.6', '<' ) ) {
require get_template_directory() . '/inc/back-compat.php';
}
if ( ! function_exists( 'twentyfourteen_setup' ) ) :
/**
* Twenty Fourteen setup.
*
* Set up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support post thumbnails.
*
* @since Twenty Fourteen 1.0
*/
function twentyfourteen_setup() {
/*
* Make Twenty Fourteen available for translation.
*
* Translations can be filed at WordPress.org. See: https://translate.wordpress.org/projects/wp-themes/twentyfourteen
* If you're building a theme based on Twenty Fourteen, use a find and
* replace to change 'twentyfourteen' to the name of your theme in all
* template files.
*/
load_theme_textdomain( 'twentyfourteen' );
/*
// This theme styles the visual editor to resemble the theme style.
add_editor_style( array( 'css/editor-style.css', twentyfourteen_font_url(), 'genericons/genericons.css' ) );
*/
// Add RSS feed links to <head> for posts and comments.
add_theme_support( 'automatic-feed-links' );
// Enable support for Post Thumbnails, and declare two sizes.
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 672, 372, true );
add_image_size( 'twentyfourteen-full-width', 1038, 576, true );
// This theme uses wp_nav_menu() in two locations.
register_nav_menus(
array(
'primary' => __( 'Top primary menu', 'twentyfourteen' ),
'secondary' => __( 'Secondary menu in left sidebar', 'twentyfourteen' ),
)
);
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support(
'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
)
);
/*
* Enable support for Post Formats.
* See https://codex.wordpress.org/Post_Formats
*/
add_theme_support(
'post-formats', array(
'aside',
'image',
'video',
'audio',
'quote',
'link',
'gallery',
)
);
// This theme allows users to set a custom background.
add_theme_support(
'custom-background', apply_filters(
'twentyfourteen_custom_background_args', array(
'default-color' => 'f5f5f5',
)
)
);
// Add support for featured content.
add_theme_support(
'featured-content', array(
'featured_content_filter' => 'twentyfourteen_get_featured_posts',
'max_posts' => 6,
)
);
// This theme uses its own gallery styles.
add_filter( 'use_default_gallery_style', '__return_false' );
// Indicate widget sidebars can use selective refresh in the Customizer.
add_theme_support( 'customize-selective-refresh-widgets' );
}
endif; // twentyfourteen_setup
add_action( 'after_setup_theme', 'twentyfourteen_setup' );
/**
* Adjust content_width value for image attachment template.
*
* @since Twenty Fourteen 1.0
*/
function twentyfourteen_content_width() {
if ( is_attachment() && wp_attachment_is_image() ) {
$GLOBALS['content_width'] = 810;
}
}
add_action( 'template_redirect', 'twentyfourteen_content_width' );
/**
* Getter function for Featured Content Plugin.
*
* @since Twenty Fourteen 1.0
*
* @return array An array of WP_Post objects.
*/
function twentyfourteen_get_featured_posts() {
/**
* Filter the featured posts to return in Twenty Fourteen.
*
* @since Twenty Fourteen 1.0
*
* @param array|bool $posts Array of featured posts, otherwise false.
*/
return apply_filters( 'twentyfourteen_get_featured_posts', array() );
}
/**
* A helper conditional function that returns a boolean value.
*
* @since Twenty Fourteen 1.0
*
* @return bool Whether there are featured posts.
*/
function twentyfourteen_has_featured_posts() {
return ! is_paged() && (bool) twentyfourteen_get_featured_posts();
}
/**
* Register three Twenty Fourteen widget areas.
*
* @since Twenty Fourteen 1.0
*/
function twentyfourteen_widgets_init() {
require get_template_directory() . '/inc/widgets.php';
register_widget( 'Twenty_Fourteen_Ephemera_Widget' );
register_sidebar(
array(
'name' => __( 'Primary Sidebar', 'twentyfourteen' ),
'id' => 'sidebar-1',
'description' => __( 'Main sidebar that appears on the left.', 'twentyfourteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
)
);
register_sidebar(
array(
'name' => __( 'Content Sidebar', 'twentyfourteen' ),
'id' => 'sidebar-2',
'description' => __( 'Additional sidebar that appears on the right.', 'twentyfourteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
)
);
register_sidebar(
array(
'name' => __( 'Footer Widget Area', 'twentyfourteen' ),
'id' => 'sidebar-3',
'description' => __( 'Appears in the footer section of the site.', 'twentyfourteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
)
);
}
add_action( 'widgets_init', 'twentyfourteen_widgets_init' );
/**
* Register Lato Google font for Twenty Fourteen.
*
* @since Twenty Fourteen 1.0
*
* @return string
*/
function twentyfourteen_font_url() {
$font_url = '';
/*
* Translators: If there are characters in your language that are not supported
* by Lato, translate this to 'off'. Do not translate into your own language.
*/
if ( 'off' !== _x( 'on', 'Lato font: on or off', 'twentyfourteen' ) ) {
$query_args = array(
'family' => urlencode( 'Lato:300,400,700,900,300italic,400italic,700italic' ),
'subset' => urlencode( 'latin,latin-ext' ),
);
$font_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
}
return $font_url;
}
/**
* Enqueue scripts and styles for the front end.
*
* @since Twenty Fourteen 1.0
*/
function twentyfourteen_scripts() {
// Add Lato font, used in the main stylesheet.
wp_enqueue_style( 'twentyfourteen-lato', twentyfourteen_font_url(), array(), null );
// Add Genericons font, used in the main stylesheet.
wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.0.3' );
// Load our main stylesheet.
wp_enqueue_style( 'twentyfourteen-style', get_stylesheet_uri() );
// Load the Internet Explorer specific stylesheet.
wp_enqueue_style( 'twentyfourteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentyfourteen-style' ), '20131205' );
wp_style_add_data( 'twentyfourteen-ie', 'conditional', 'lt IE 9' );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_singular() && wp_attachment_is_image() ) {
wp_enqueue_script( 'twentyfourteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20130402' );
}
if ( is_active_sidebar( 'sidebar-3' ) ) {
wp_enqueue_script( 'jquery-masonry' );
}
if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) ) {
wp_enqueue_script( 'twentyfourteen-slider', get_template_directory_uri() . '/js/slider.js', array( 'jquery' ), '20131205', true );
wp_localize_script(
'twentyfourteen-slider', 'featuredSliderDefaults', array(
'prevText' => __( 'Previous', 'twentyfourteen' ),
'nextText' => __( 'Next', 'twentyfourteen' ),
)
);
}
wp_enqueue_script( 'twentyfourteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20150315', true );
}
add_action( 'wp_enqueue_scripts', 'twentyfourteen_scripts' );
/**
* Enqueue Google fonts style to admin screen for custom header display.
*
* @since Twenty Fourteen 1.0
*/
function twentyfourteen_admin_fonts() {
wp_enqueue_style( 'twentyfourteen-lato', twentyfourteen_font_url(), array(), null );
}
add_action( 'admin_print_scripts-appearance_page_custom-header', 'twentyfourteen_admin_fonts' );
/**
* Add preconnect for Google Fonts.
*
* @since Twenty Fourteen 1.9
*
* @param array $urls URLs to print for resource hints.
* @param string $relation_type The relation type the URLs are printed.
* @return array URLs to print for resource hints.
*/
function twentyfourteen_resource_hints( $urls, $relation_type ) {
if ( wp_style_is( 'twentyfourteen-lato', 'queue' ) && 'preconnect' === $relation_type ) {
if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '>=' ) ) {
$urls[] = array(
'href' => 'https://fonts.gstatic.com',
'crossorigin',
);
} else {
$urls[] = 'https://fonts.gstatic.com';
}
}
return $urls;
}
add_filter( 'wp_resource_hints', 'twentyfourteen_resource_hints', 10, 2 );
if ( ! function_exists( 'twentyfourteen_the_attached_image' ) ) :
/**
* Print the attached image with a link to the next attached image.
*
* @since Twenty Fourteen 1.0
*/
function twentyfourteen_the_attached_image() {
$post = get_post();
/**
* Filter the default Twenty Fourteen attachment size.
*
* @since Twenty Fourteen 1.0
*
* @param array $dimensions {
* An array of height and width dimensions.
*
* @type int $height Height of the image in pixels. Default 810.
* @type int $width Width of the image in pixels. Default 810.
* }
*/
$attachment_size = apply_filters( 'twentyfourteen_attachment_size', array( 810, 810 ) );
$next_attachment_url = wp_get_attachment_url();
/*
* Grab the IDs of all the image attachments in a gallery so we can get the URL
* of the next adjacent image in a gallery, or the first image (if we're
* looking at the last image in a gallery), or, in a gallery of one, just the
* link to that image file.
*/
$attachment_ids = get_posts(
array(
'post_parent' => $post->post_parent,
'fields' => 'ids',
'numberposts' => -1,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order ID',
)
);
// If there is more than 1 attachment in a gallery...
if ( count( $attachment_ids ) > 1 ) {
foreach ( $attachment_ids as $idx => $attachment_id ) {
if ( $attachment_id == $post->ID ) {
$next_id = $attachment_ids[ ( $idx + 1 ) % count( $attachment_ids ) ];
break;
}
}
// get the URL of the next image attachment...
if ( $next_id ) {
$next_attachment_url = get_attachment_link( $next_id );
} // or get the URL of the first image attachment.
else {
$next_attachment_url = get_attachment_link( reset( $attachment_ids ) );
}
}
printf(
'<a href="%1$s" rel="attachment">%2$s</a>',
esc_url( $next_attachment_url ),
wp_get_attachment_image( $post->ID, $attachment_size )
);
}
endif;
if ( ! function_exists( 'twentyfourteen_list_authors' ) ) :
/**
* Print a list of all site contributors who published at least one post.
*
* @since Twenty Fourteen 1.0
*/
function twentyfourteen_list_authors() {
$contributor_ids = get_users(
array(
'fields' => 'ID',
'orderby' => 'post_count',
'order' => 'DESC',
'who' => 'authors',
)
);
foreach ( $contributor_ids as $contributor_id ) :
$post_count = count_user_posts( $contributor_id );
// Move on if user has not published a post (yet).
if ( ! $post_count ) {
continue;
}
?>
<div class="contributor">
<div class="contributor-info">
<div class="contributor-avatar"><?php echo get_avatar( $contributor_id, 132 ); ?></div>
<div class="contributor-summary">
<h2 class="contributor-name"><?php echo get_the_author_meta( 'display_name', $contributor_id ); ?></h2>
<p class="contributor-bio">
<?php echo get_the_author_meta( 'description', $contributor_id ); ?>
</p>
<a class="button contributor-posts-link" href="<?php echo esc_url( get_author_posts_url( $contributor_id ) ); ?>">
<?php printf( _n( '%d Article', '%d Articles', $post_count, 'twentyfourteen' ), $post_count ); ?>
</a>
</div><!-- .contributor-summary -->
</div><!-- .contributor-info -->
</div><!-- .contributor -->
<?php
endforeach;
}
endif;
/**
* Extend the default WordPress body classes.
*
* Adds body classes to denote:
* 1. Single or multiple authors.
* 2. Presence of header image except in Multisite signup and activate pages.
* 3. Index views.
* 4. Full-width content layout.
* 5. Presence of footer widgets.
* 6. Single views.
* 7. Featured content layout.
*
* @since Twenty Fourteen 1.0
*
* @param array $classes A list of existing body class values.
* @return array The filtered body class list.
*/
function twentyfourteen_body_classes( $classes ) {
if ( is_multi_author() ) {
$classes[] = 'group-blog';
}
if ( get_header_image() ) {
$classes[] = 'header-image';
} elseif ( ! in_array( $GLOBALS['pagenow'], array( 'wp-activate.php', 'wp-signup.php' ) ) ) {
$classes[] = 'masthead-fixed';
}
if ( is_archive() || is_search() || is_home() ) {
$classes[] = 'list-view';
}
if ( ( ! is_active_sidebar( 'sidebar-2' ) )
|| is_page_template( 'page-templates/full-width.php' )
|| is_page_template( 'page-templates/contributors.php' )
|| is_attachment() ) {
$classes[] = 'full-width';
}
if ( is_active_sidebar( 'sidebar-3' ) ) {
$classes[] = 'footer-widgets';
}
if ( is_singular() && ! is_front_page() ) {
$classes[] = 'singular';
}
if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) ) {
$classes[] = 'slider';
} elseif ( is_front_page() ) {
$classes[] = 'grid';
}
return $classes;
}
add_filter( 'body_class', 'twentyfourteen_body_classes' );
/**
* Extend the default WordPress post classes.
*
* Adds a post class to denote:
* Non-password protected page with a post thumbnail.
*
* @since Twenty Fourteen 1.0
*
* @param array $classes A list of existing post class values.
* @return array The filtered post class list.
*/
function twentyfourteen_post_classes( $classes ) {
if ( ! post_password_required() && ! is_attachment() && has_post_thumbnail() ) {
$classes[] = 'has-post-thumbnail';
}
return $classes;
}
add_filter( 'post_class', 'twentyfourteen_post_classes' );
/**
* Create a nicely formatted and more specific title element text for output
* in head of document, based on current view.
*
* @since Twenty Fourteen 1.0
*
* @global int $paged WordPress archive pagination page count.
* @global int $page WordPress paginated post page count.
*
* @param string $title Default title text for current view.
* @param string $sep Optional separator.
* @return string The filtered title.
*/
function twentyfourteen_wp_title( $title, $sep ) {
global $paged, $page;
if ( is_feed() ) {
return $title;
}
// Add the site name.
$title .= get_bloginfo( 'name', 'display' );
// Add the site description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) ) {
$title = "$title $sep $site_description";
}
// Add a page number if necessary.
if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
$title = "$title $sep " . sprintf( __( 'Page %s', 'twentyfourteen' ), max( $paged, $page ) );
}
return $title;
}
add_filter( 'wp_title', 'twentyfourteen_wp_title', 10, 2 );
/**
* Modifies tag cloud widget arguments to display all tags in the same font size
* and use list format for better accessibility.
*
* @since Twenty Fourteen 2.1
*
* @param array $args Arguments for tag cloud widget.
* @return array The filtered arguments for tag cloud widget.
*/
function twentyfourteen_widget_tag_cloud_args( $args ) {
$args['largest'] = 22;
$args['smallest'] = 8;
$args['unit'] = 'pt';
$args['format'] = 'list';
return $args;
}
add_filter( 'widget_tag_cloud_args', 'twentyfourteen_widget_tag_cloud_args' );
// Implement Custom Header features.
require get_template_directory() . '/inc/custom-header.php';
// Custom template tags for this theme.
require get_template_directory() . '/inc/template-tags.php';
// Add Customizer functionality.
require get_template_directory() . '/inc/customizer.php';
/*
* Add Featured Content functionality.
*
* To overwrite in a plugin, define your own Featured_Content class on or
* before the 'setup_theme' hook.
*/
if ( ! class_exists( 'Featured_Content' ) && 'plugins.php' !== $GLOBALS['pagenow'] ) {
require get_template_directory() . '/inc/featured-content.php';
}
/**
* Add an `is_customize_preview` function if it is missing.
*
* Enables installing Twenty Fourteen in WordPress versions before 4.0.0 when the
* `is_customize_preview` function was introduced.
*/
if ( ! function_exists( 'is_customize_preview' ) ) :
function is_customize_preview() {
global $wp_customize;
return ( $wp_customize instanceof WP_Customize_Manager ) && $wp_customize->is_preview();
}
endif;
#################################################################
# #
# #
#################################################################
# #
# #
# USAGE : To be executed as oracle user #
# (pbrun to oracle or pboracle) #
# #
# Manual execution #
# sh bl_stop.ksh #
# #
# Via job scheduler tools and by-passing the prompt #
# sh bl_stop.ksh y #
# #
#---------------------------------------------------------------#
# #
# //Generic information about the batch of scripts developed// #
# bl_status.ksh #
# bl_stop.ksh #
# bl_stop_crs.ksh #
# bl_start_crs.ksh #
# bl_start.ksh #
# #
# Versions/Combinations Supported #
# Clustware 11g #
# Clustware 10g #
# NON-RAC with ASM 11g #
# NON-RAC with ASM 10g #
# NON-RAC & NON-ASM #
# #
# Components in scope #
# Clusterware #
# ASM Instance #
# Database Instance #
# Cluster Listener #
# Local Listener #
# Manager Recovery Process #
# GoldenGate Replication #
# Port Utility #
# Enterprise Manager Agent #
# OSWatcher Utility #
# Foglight Monitoring Agent #
# Filesystem #
# Rawdisk #
# #
#################################################################
export OS=`uname -a | awk '{ print $1 }'`
eval timevalue=`date '+%m%d%Y_%H%M%S'`
eval filename=$(echo $(hostname) | cut -d. -f1)_$timevalue
# Check for Redhat
if [[ -f /etc/redhat-release ]]; then
export RH_VER=`cat /etc/redhat-release | grep "Linux Server release" | sed -n 's/.*\(Linux Server release.*\).*/\1/p' | awk '{ print $4 }'`
else
export RH_VER=0
fi
# CHECK IF AAR DATABASE SERVER
if [ ! -f $OUTPUT_DIRECTORY/execute.flag ]
then
sleep 2
elif [ "$(cat $OUTPUT_DIRECTORY/execute.flag)" = "no" ]
then
echo "This is an AAR Database Server, exiting cleanly." | tee -a ${LOG}
#insert_repdb
exit 0
else
sleep 2
fi
# CHECK IF MYSQL DATABASE SERVER
if [ "$(ps -ef | grep -i mysql | grep -v grep | wc -l)" -ge 1 ]
then
echo "This is a MySQL Database Server" | tee -a ${LOG}
#insert_repdb
exit 0
fi
# Check if user really wants to STOP the services
if [ $# -eq 0 ]
then
read -r -p "Are you sure you want to STOP the Oracle services ? [y/n] " response
if [ $response = y ]
then
echo ""; echo "Please wait while the services are brought down... "; echo ""
export oracred=oracle:dba
export oraowner=oracle
export oragroup=dba
else
exit; >/dev/null
fi
elif [ $1 == y ]
then
echo ""; echo "Please wait while the services are brought down... "; echo ""
#Handle second Argument
if [[ ! -z $2 ]]; then
export oracred=$2
export oraowner=`echo $oracred | cut -d":" -f1 -s`
export oragroup=`echo $oracred | cut -d":" -f2 -s`
echo "Oracle Ownership Captured ARGUMENTS ...
oracred=$oracred
oraowner=$oraowner
oragroup=$oragroup
"
else
export oracred=oracle:dba
export oraowner=oracle
export oragroup=dba
fi
else
exit; >/dev/null
fi
# CHECK IF THE USER IS Correct as per Arg#2
echo " "
if [ $(whoami) != "${oraowner}" ]
then
echo "ATTENTION : Please execute this script as ${oraowner} user"
exit 0;
fi
# SCRIPT AND OUTPUT DIRECTORIES INITIALIZATION
SCRIPT_DIRECTORY=/var/opt/oracle/BACS/script
if [[ ${oraowner} = "oracle" ]]; then
if [[ -d /oracle/dba/output/generic ]]; then
OUTPUT_DIRECTORY=/oracle/dba/output/generic
else
OUTPUT_DIRECTORY=/var/bl_ora/log
if [[ ! -d $OUTPUT_DIRECTORY ]]; then
echo "OUTPUT_DIRECTORY: $OUTPUT_DIRECTORY was not found on this server ... Exiting"
exit 0
fi
fi
else
if [[ -d /oracle/dba/output/generic ]]; then
OUTPUT_DIRECTORY=/oracle/dba/output/generic/${oraowner}
else
OUTPUT_DIRECTORY=/var/bl_ora/log/${oraowner}
if [[ ! -d $OUTPUT_DIRECTORY ]]; then
echo "OUTPUT_DIRECTORY: $OUTPUT_DIRECTORY was not found on this server ... Exiting"
exit 0
fi
fi
fi
# REMOVE THE TEMPORARY LOG FILE
rm -f $OUTPUT_DIRECTORY/stop.log
#Purge pre/post files from previous executions before moving on ...
if [[ -d ${OUTPUT_DIRECTORY} ]]; then
rm -f ${OUTPUT_DIRECTORY}/pre_stop*.log
rm -f ${OUTPUT_DIRECTORY}/post_stop*.log
rm -f ${OUTPUT_DIRECTORY}/post_start*.log
fi
# ASSIGN A NEW LOG FILE
LOG=$OUTPUT_DIRECTORY/stop.log; echo "" >> ${LOG};
# CHECK THE SERVER TYPE
if [ -f $OUTPUT_DIRECTORY/server_type.log ];
then
server_type=$(<$OUTPUT_DIRECTORY/server_type.log)
else
if [ "$(ps -ef | grep crsd.bin | grep -v grep | wc -l)" -eq 1 ]
then
if [ "$(ps -ef | grep crsd.bin | grep -v grep | grep "12\." | wc -l)" -eq 1 ]
then
export server_type="rac_12c"
elif [ "$(ps -ef | grep crsd.bin | grep -v grep | grep "11\." | wc -l)" -eq 1 ]
then
export server_type="rac_11g"
else
export server_type="rac_10g"
fi
else
if [ "$(ps -ef | grep ohasd.bin | grep -v grep | grep "12\." | wc -l)" -eq 1 ]
then
export server_type="norac_asm12c"
elif [ "$(ps -ef | grep ohasd.bin | grep -v grep | grep "11\." | wc -l)" -eq 1 ]
then
export server_type="norac_asm11g"
elif [ "$(ps -ef | grep pmon | grep -v grep | grep "+ASM" | grep -v onitor | wc -l)" -eq 1 ]
then
export server_type="norac_asm10g"
else
export server_type="norac_noasm"
fi
fi
# Address rare issue seen where crsd.bin not picked up even though it is in fact a RAC system!
if [[ "$server_type" == norac_asm* ]] && [[ -f /etc/oratab ]]; then
ASM_LAST_CHAR=`grep "^\+ASM" /etc/oratab | cut -d":" -f1 -s | sed -e "s/.*\(.\)/\1/"`
#ASM_LAST_CHAR=`ps -ef | grep "asm_pmon_" | grep -v grep | awk '{ print $NF }' | cut -d"_" -f3 -s | sed -e "s/.*\(.\)/\1/"`
echo $ASM_LAST_CHAR | egrep '^[0-9]+$'
if [ $? -eq 0 ]; then
#echo "$ASM_LAST_CHAR is a number .. So it's a RAC "
server_str_2=`echo $server_type | sed 's/asm//g' |cut -d"_" -f2 -s`
export server_type="rac_${server_str_2}"
fi
fi
echo $server_type > $OUTPUT_DIRECTORY/server_type.log
fi
# COLLECT PRE-STATUS INFORMATION BEFORE STOPPING THE SERVICES
# echo "Collecting pre-status report before stopping the services.... " ; echo "";
# sh $SCRIPT_DIRECTORY/bl_status.ksh $oracred ;echo ""
collect_lsnr()
{
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep lsnr | grep "^.*${oraowner} " | grep -v grep |sed -n 's/.*\(tnslsnr.*\).*/\1/p' | awk '{ print $2 }' | sed '/^\s*$/d' >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
#elif [ $(( (`date +%s` - `stat -L --format %Y $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log`) > (2880*60) )) -eq 1 ]
#then
#rm -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
#ps -ef | grep lsnr | grep "^.*${oraowner} " | grep -v grep |sed -n 's/.*\(tnslsnr.*\).*/\1/p' | awk '{ print $2 }' | sed '/^\s*$/d' >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
for LSNR in `ps -ef | grep lsnr | grep "^.*${oraowner} " | grep -v grep |sed -n 's/.*\(tnslsnr.*\).*/\1/p' | awk '{ print $2 }' | sed '/^\s*$/d'`
do
if [ $(grep -w "$LSNR" $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log | wc -l) -eq 1 ]
then
sleep 0
else
echo $LSNR >> $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
fi
done
fi
#Capture lsnr name and OHs on this host
if [[ -f $OUTPUT_DIRECTORY/pre_config_lsnr.log ]]; then
rm $OUTPUT_DIRECTORY/pre_config_lsnr.log
fi
ps -ef | grep tnslsnr | grep "^.*${oraowner} " | grep -v grep | while read LSNR_PROC
do
#LSNR_NAME=`echo $LSNR_PROC | grep -oP '(?<=tnslsnr )\w+'`
#LSNR_HOME=`echo $LSNR_PROC | grep -oP '....................................................../bin/tnslsnr ' | awk '{ print $NF }' | awk -F'/' '{for(i = 1; i <= NF - 2; i++) printf("%s%s", $i, i == NF - 2 ? "" : OFS)}' OFS="/"`
LSNR_NAME=`echo $LSNR_PROC | sed -n 's/.*\(tnslsnr.*\).*/\1/p' | awk '{ print $2 }'`
LSNR_HOME=`echo $LSNR_PROC | sed -n 's/.*\(..........................................................tnslsnr\).*/\1/p' | awk '{ print $NF }' | grep -v "\.\.\.\.tnslsnr" | sed 's/\/bin\/tnslsnr//g' | head -1`
echo "${LSNR_NAME}:${LSNR_HOME}" >> $OUTPUT_DIRECTORY/pre_config_lsnr.log
done
elif [ $when = post ]
then
ps -ef | grep lsnr | grep "^.*${oraowner} " | grep -v grep | sed -n 's/.*\(tnslsnr.*\).*/\1/p' | awk '{ print $2 }' | sed '/^\s*$/d' >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
sleep 0
fi
}
collect_mrp()
{
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep mrp | sort -k9 | grep "^.*${oraowner} " | grep -v grep | awk '{ print $NF }' | cut -d"_" -f3,4 -s >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
for MRP in `ps -ef | grep mrp | sort -k9 | grep "^.*${oraowner} " | awk '{ print $NF }' | cut -d"_" -f3,4 -s`
do
if [ $(grep -w "$MRP" $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log | wc -l) -eq 1 ]
then
sleep 1
else
echo $MRP >> $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
fi
done
fi
elif [ $when = post ]
then
ps -ef | grep mrp | sort -k9 | grep "^.*${oraowner} " | grep -v grep | awk '{ print $NF }' | cut -d"_" -f3,4 -s >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
sleep 0
fi
}
collect_dbinst()
{
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s>$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
for DBINST in `ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s`
do
if [ $(grep -w "$DBINST" $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log | wc -l) -eq 1 ]
then
sleep 1
else
echo $DBINST >> $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
fi
done
fi
elif [ $when = post ]
then
ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s>$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
sleep 0
fi
}
collect_asm()
{
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'>$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
for ASM in `ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'`
do
if [ $(grep -w "$ASM" $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log | wc -l) -eq 1 ]
then
sleep 1
else
echo $ASM >> $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
fi
done
fi
elif [ $when = post ]
then
ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'>$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
sleep 0
fi
}
collect_agent()
{
if [ $(ps -ef | grep emagent | grep "^.*${oraowner} " | grep -v grep | wc -l) -ne 0 ]
then
ORACLE_SID=`cat /etc/oratab | awk 'BEGIN{FS=":"}{print $1}' | grep OEM | grep -v "^#"`
export ORAENV_ASK=NO >/dev/null;
if [[ ! -z $ORACLE_SID ]]; then
. oraenv >/dev/null
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
emctl status agent | grep "Agent is Running and Ready" | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
if [ $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) -gt 0 ]
then
sleep 1
else
emctl status agent | grep "Agent is Running and Ready" | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
fi
fi
elif [ $when = post ]
then
emctl status agent | grep "Agent is Running and Ready" | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
sleep 0
fi
fi
else
echo 0 > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
fi
}
collect_fgl()
{
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep -i foglight | grep "^.*${oraowner} " | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
if [ $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) -gt 0 ]
then
sleep 1
else
ps -ef | grep -i foglight | grep "^.*${oraowner} " | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
fi
fi
elif [ $when = post ]
then
ps -ef | grep -i foglight | grep "^.*${oraowner} " | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
sleep 0
fi
}
collect_portutil()
{
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep "portdaemon.pl" | grep -v grep | grep port | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
if [ $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) -gt 0 ]
then
sleep 1
else
ps -ef | grep "portdaemon.pl" | grep -v grep | grep port | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
fi
fi
elif [ $when = post ]
then
ps -ef | grep "portdaemon.pl" | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
sleep 0
fi
#Capturing the port information
if [ ! -f $OUTPUT_DIRECTORY/portnum.val ]
then
touch $OUTPUT_DIRECTORY/portnum.val
ps -ef | grep portdaemon.pl | grep -v grep | awk 'BEGIN{FS=" "}{print $NF}' > $OUTPUT_DIRECTORY/portnum.val
elif [ $(( (`date +%s` - `stat -L --format %Y $OUTPUT_DIRECTORY/portnum.val`) > (2880*60) )) = 1 ]
then
rm -f $OUTPUT_DIRECTORY/portnum.val
ps -ef | grep portdaemon.pl | grep -v grep | awk 'BEGIN{FS=" "}{print $NF}' > $OUTPUT_DIRECTORY/portnum.val
else
sleep 1
fi
}
collect_osw()
{
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep -i OSW | grep "^.*${oraowner} " | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
if [ $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) -gt 0 ]
then
sleep 1
else
ps -ef | grep -i OSW | grep "^.*${oraowner} " | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
fi
fi
elif [ $when = post ]
then
ps -ef | grep -i OSW | grep "^.*${oraowner} " | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
sleep 0
fi
}
collect_instancestatus()
{
if [ "$(ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | wc -l)" -ne 0 ]
then
rm -f $OUTPUT_DIRECTORY/db:inst
rm -f $OUTPUT_DIRECTORY/db:inst.log
rm -f $OUTPUT_DIRECTORY/unidb:inst.log
rm -f $OUTPUT_DIRECTORY/pre_gg_inst.log
rm -f $OUTPUT_DIRECTORY/pre_stop_dbopen.log
rm -f $OUTPUT_DIRECTORY/pre_stop_dbopenronly.log
rm -f $OUTPUT_DIRECTORY/pre_stop_dbmount.log
# Grab unique name and other info from each runing Instance
for SID in `ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s`
do
export ORACLE_SID=$SID
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
op=`$ORACLE_HOME/bin/sqlplus -s '/ as sysdba'<< EOFUDB1
set echo off;
set heading off;
set linesize 200 pages 100;
select 'DBINST_ENTRY:'||d.DB_UNIQUE_NAME||':'||i.INSTANCE_NAME from v\\$database d, v\\$instance i;
select 'PRE_OGG_DBINST:'||username||':${ORACLE_SID}' from gv\\$session where upper(username) like 'GGSADMIN%' and rownum < 2;
EOFUDB1`
echo "$op" | grep "DBINST_ENTRY:" >> $OUTPUT_DIRECTORY/unidb:inst.log
echo "$op" | grep "PRE_OGG_DBINST:" >> $OUTPUT_DIRECTORY/pre_gg_inst.log
done
if [[ $server_type = "rac_12c" ]] || [[ $server_type = "rac_11g" ]] || [[ $server_type = "rac_10g" ]]
then
export ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'`
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
for SID in `ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s`
do
if [[ ! -f $ORACLE_HOME/bin/crs_stat ]]; then
# To support 10gRAC where CRS may be runing from different home than +ASM
CRSD=`ps -ef | grep -v grep | grep root | sed -n 's/.*\(......................................................crsd.bin\).*/\1/p' | awk '{ print $NF }' | tail -1`
CRS_BIN=`dirname $CRSD`
UNIQUE_NAME=`echo $(crs_stat | grep "ora." | grep ".db$" | grep -i ${SID%?} | tr "[:lower:]" "[:upper:]")`
if [[ ! -z $UNIQUE_NAME ]]; then
echo $(${CRS_BIN}/crs_stat | grep "ora." | grep ".db$" | grep -i ${SID%?} | tr "[:lower:]" "[:upper:]" | awk 'BEGIN{FS="."}{print $2}')":"$SID >> $OUTPUT_DIRECTORY/db:inst
else
if [[ -f $OUTPUT_DIRECTORY/unidb:inst.log ]]; then
#Do lookup from status file to find correct Unique name
UNI_NAME=`grep "DBINST_ENTRY:" $OUTPUT_DIRECTORY/unidb:inst.log | grep ":${SID}$"| cut -d":" -f2 -s`
if [[ ! -z $UNI_NAME ]]; then
echo $(${CRS_BIN}/crs_stat | grep "ora." | grep ".db$" | grep -i ${UNI_NAME} | tr "[:lower:]" "[:upper:]" | awk 'BEGIN{FS="."}{print $2}')":"$SID >> $OUTPUT_DIRECTORY/db:inst
else
echo $(${CRS_BIN}/crs_stat | grep "ora." | grep ".db$" | grep -i ${SID%?} | tr "[:lower:]" "[:upper:]" | awk 'BEGIN{FS="."}{print $2}')":"$SID >> $OUTPUT_DIRECTORY/db:inst
fi
else
echo $(${CRS_BIN}/crs_stat | grep "ora." | grep ".db$" | grep -i ${SID%?} | tr "[:lower:]" "[:upper:]" | awk 'BEGIN{FS="."}{print $2}')":"$SID >> $OUTPUT_DIRECTORY/db:inst
fi
fi
else
R_DBNAME=` echo $SID | sed "s/[1-9]$//g"|sed "s/_$//g"` ;ONENode_DB="";
if [ "$(srvctl config database -d $R_DBNAME |grep -w "RACOneNode" | wc -l)" -eq 1 ]
then
export LOCAL_NODE=`hostname -s`
export ONENode_DB=`echo ":$LOCAL_NODE"`
fi
UNIQUE_NAME=`echo $(crs_stat | grep "ora." | grep ".db$" | grep -i $R_DBNAME | tr "[:lower:]" "[:upper:]")`
if [[ -f $OUTPUT_DIRECTORY/unidb:inst.log ]] && [[ ! -z $UNIQUE_NAME ]]; then
UNIQUE_SID=`echo $UNIQUE_NAME | cut -d"." -f2 -s`
CHK_UNI_LOG=`grep ":${UNIQUE_SID}:" $OUTPUT_DIRECTORY/unidb:inst.log`
if [[ -z $CHK_UNI_LOG ]]; then
UNIQUE_NAME=""
fi
fi
if [[ ! -z $UNIQUE_NAME ]]; then
echo $(crs_stat | grep "ora." | grep ".db$" | grep -i $R_DBNAME | tr "[:lower:]" "[:upper:]" | awk 'BEGIN{FS="."}{print $2}')":"$SID$ONENode_DB >> $OUTPUT_DIRECTORY/db:inst
else
if [[ -f $OUTPUT_DIRECTORY/unidb:inst.log ]]; then
#Do lookup from status file to find correct Unique name and then try to match it with crs "*.db" resource .. if nothing then default UNIQ NAME as ${SID%?}
UNI_NAME=`grep "DBINST_ENTRY:" $OUTPUT_DIRECTORY/unidb:inst.log | grep ":${SID}$"| cut -d":" -f2 -s`
if [[ ! -z $UNI_NAME ]]; then
CRS_UNI_MATCH=`echo $(crs_stat | grep "ora." | grep ".db$" | grep -i ${UNI_NAME} | tr "[:lower:]" "[:upper:]" | awk 'BEGIN{FS="."}{print $2}')`
### if [[ ! -z $CRS_UNI_MATCH ]]; then
if [[ "$(crs_stat | grep "ora." | grep ".db$" | grep -i ${UNI_NAME} | wc -l)" -eq 1 ]]; then
echo $(crs_stat | grep "ora." | grep ".db$" | grep -i ${UNI_NAME} | tr "[:lower:]" "[:upper:]" | awk 'BEGIN{FS="."}{print $2}')":"$SID >> $OUTPUT_DIRECTORY/db:inst
else
echo $(crs_stat | grep "ora." | grep ".db$" | grep -i $R_DBNAME | tr "[:lower:]" "[:upper:]" | awk 'BEGIN{FS="."}{print $2}')":"$SID >> $OUTPUT_DIRECTORY/db:inst
fi
else
echo $(crs_stat | grep "ora." | grep ".db$" | grep -i $R_DBNAME | tr "[:lower:]" "[:upper:]" | awk 'BEGIN{FS="."}{print $2}')":"$SID >> $OUTPUT_DIRECTORY/db:inst
fi
else
echo $(crs_stat | grep "ora." | grep ".db$" | grep -i $R_DBNAME | tr "[:lower:]" "[:upper:]" | awk 'BEGIN{FS="."}{print $2}')":"$SID >> $OUTPUT_DIRECTORY/db:inst
fi
fi
fi
done
else
for SID in `ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s`
do
echo $SID":"$SID >> $OUTPUT_DIRECTORY/db:inst
done
fi
cp $OUTPUT_DIRECTORY/db:inst $OUTPUT_DIRECTORY/db:inst.log
find_instancestatus()
{
while read data
do
export ORACLE_DB=$(echo $data | awk 'BEGIN{FS=":"}{print $1}') >/dev/null
export ORACLE_SID=$(echo $data | awk 'BEGIN{FS=":"}{print $2}') >/dev/null
export RAC_ONEDB=$(echo $data | awk 'BEGIN{FS=":"}{print $3}') >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
op=`$ORACLE_HOME/bin/sqlplus -s '/ as sysdba'<< EOFSTATUS
set echo off;
set head off;
select open_mode from v\\$database;
EOFSTATUS`
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$dbopmnt".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$dbopmnt".log
if [ "$(echo "$op" | grep "$STATUS" | wc -l)" -eq 1 ]
then
echo $ORACLE_DB":"$ORACLE_SID":"$RAC_ONEDB > $OUTPUT_DIRECTORY/"$when"_"$why"_"$dbopmnt".log
fi
else
if [ "$(echo "$op" | grep "$STATUS" | wc -l)" -eq 1 ]
then
if [ $(grep -w "$ORACLE_DB" $OUTPUT_DIRECTORY/"$when"_"$why"_"$dbopmnt".log | wc -l) -eq 1 ]
then
sleep 1
else
echo $ORACLE_DB":"$ORACLE_SID":"$RAC_ONEDB >> $OUTPUT_DIRECTORY/"$when"_"$why"_"$dbopmnt".log
fi
fi
fi
elif [ $when = post ]
then
if [ "$(echo "$op" | grep "$STATUS" | wc -l)" -eq 1 ]
then
echo $ORACLE_DB":"$ORACLE_SID":"$RAC_ONEDB >> $OUTPUT_DIRECTORY/"$when"_"$why"_"$dbopmnt".log
fi
else
sleep 0
fi
done < $OUTPUT_DIRECTORY/db:inst.log
}
STATUS="READ WRITE"; dbopmnt=dbopen; find_instancestatus
STATUS="READ ONLY"; dbopmnt=dbopenronly; find_instancestatus
STATUS=MOUNT; dbopmnt=dbmount; find_instancestatus
else
touch $OUTPUT_DIRECTORY/pre_stop_dbopen.log
touch $OUTPUT_DIRECTORY/pre_stop_dbmount.log
touch $OUTPUT_DIRECTORY/pre_stop_dbopenronly.log
fi
echo "OPEN READ WRITE mode " ' ' ":" $(cat $OUTPUT_DIRECTORY/pre_stop_dbopen.log)
echo "OPEN READ ONLY mode " ' ' ":" $(cat $OUTPUT_DIRECTORY/pre_stop_dbopenronly.log)
echo "MOUNT mode " ' ' ":" $(cat $OUTPUT_DIRECTORY/pre_stop_dbmount.log)
echo "" >> ${LOG}
echo "OPEN READ WRITE mode " ' ' ":" $(cat $OUTPUT_DIRECTORY/pre_stop_dbopen.log) >> ${LOG}
echo "OPEN READ ONLY mode " ' ' ":" $(cat $OUTPUT_DIRECTORY/pre_stop_dbopenronly.log) >> ${LOG}
echo "MOUNT mode " ' ' ":" $(cat $OUTPUT_DIRECTORY/pre_stop_dbmount.log) >> ${LOG}
echo "" >> ${LOG}
}
collect_dbservices()
{
rm -f $OUTPUT_DIRECTORY/"$when"_"$why"_dbservices.log
while read data
do
export ORACLE_DB=$(echo $data | awk 'BEGIN{FS=":"}{print $1}') >/dev/null
export ORACLE_SID=$(echo $data | awk 'BEGIN{FS=":"}{print $2}') >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
#echo $ORACLE_DB:$ORACLE_SID":"$(srvctl status service -d $ORACLE_DB | grep $ORACLE_SID | awk 'BEGIN{FS=" "}{print $(NF-5)}') >> $OUTPUT_DIRECTORY/"$when"_"$why"_dbservices.log
echo $ORACLE_DB:$ORACLE_SID":"$(srvctl status service -d $ORACLE_DB | grep $ORACLE_SID | grep -i "is running" | awk '{ print $2 }') >> $OUTPUT_DIRECTORY/"$when"_"$why"_dbservices.log
done < $OUTPUT_DIRECTORY/db:inst.log
}
# OGG Support
##############
collect_ogg()
{
ps -ef | grep -v grep | grep "mgr PARAMFILE" | grep "^.*${oraowner} " | sed -n 's/.*\(....................................................................\/....prm \).*/\1/p' | awk '{ print $NF }' | grep -v "\.\.\.\.mgr.prm" >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
}
# DBFS Support
###############
collect_dbfs()
{
ps -ef | grep -v grep | grep "dbfs_client" | grep "^.*${oraowner} " | sed -n 's/.*\(................................................................\/bin\/dbfs_client\).*/\1/p' | awk '{ print $NF }' | grep -v "\.\.\.\.dbfs_client" >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
}
display_pre_post()
{
if [ $when = pre ]
then
if [ $what = fgl ] || [ $what = agent ] || [ $what = mrp ] || [ $what = osw ] || [ $what = ogg ] || [ $what = dbfs ]
then
if [ "$(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log)" = 0 ] || [ ! -s $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
echo "PRE stop" $what "running " ":" "NO" | tee -a ${LOG}
else
echo "PRE stop" $what "running " ":" "YES" | tee -a ${LOG}
fi
elif [ $what = asm ] || [ $what = dbinst ] || [ $what = lsnr ]
then
if [ "$(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log)" = 0 ] || [ ! -s $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
echo "PRE stop" $what "running " ":" "NO" | tee -a ${LOG}
else
echo "PRE stop" $what "running " ":" $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) | tee -a ${LOG}
fi
fi
elif [ $when = post ]
then
if [ $what = fgl ] || [ $what = agent ] || [ $what = mrp ] || [ $what = osw ] || [ $what = ogg ] || [ $what = dbfs ]
then
if [ "$(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log)" = 0 ] || [ ! -s $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
echo "POST stop" $what "running " ":" "NO" | tee -a ${LOG}
echo "" | tee -a ${LOG}
else
echo "POST stop" $what "running " ":" "YES" | tee -a ${LOG}
echo "" | tee -a ${LOG}
fi
elif [ $what = asm ] || [ $what = dbinst ] || [ $what = lsnr ]
then
if [ "$(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log)" = 0 ] || [ ! -s $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
echo "POST stop" $what "running " ":" "NO" | tee -a ${LOG}
echo "" | tee -a ${LOG}
else
echo "POST stop" $what "running " ":" $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) | tee -a ${LOG}
echo "" | tee -a ${LOG}
fi
fi
fi
}
stopped_status()
{
if [[ -f $OUTPUT_DIRECTORY/post_"$why"_"$what".log ]]; then
if [ "$(cat $OUTPUT_DIRECTORY/post_"$why"_"$what".log)" = 0 ] || [ ! -s $OUTPUT_DIRECTORY/post_"$why"_"$what".log ]
then
echo "yes" > $OUTPUT_DIRECTORY/stopped_$what.log
echo "OK : successfully stopped $what" | tee -a ${LOG}
else
echo "no" > $OUTPUT_DIRECTORY/stopped_$what.log
echo "ATTENTION : $what didn't stop. Please check" | tee -a ${LOG}
fi
fi
}
# STOPPING THE SERVICES
stop_asm_10g()
{
echo "STOPPING" $what | tee -a ${LOG}
for SID in `ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'`
do
export ORACLE_SID=${SID} >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
echo "Stopping instance " $ORACLE_SID | tee -a ${LOG}
op=`$ORACLE_HOME/bin/sqlplus -s '/ as sysdba'<< EOF
set echo off;
set linesize 200 pages 100;
shutdown immediate;
EOF`
echo "$op" >> ${LOG};echo "" >> ${LOG}
done
sleep 5
}
stop_db_rac()
{
echo "STOPPING" $what | tee -a ${LOG}
while read data
do
export ORACLE_DB=$(echo $data | awk 'BEGIN{FS=":"}{print $1}') >/dev/null
export ORACLE_SID=$(echo $data | awk 'BEGIN{FS=":"}{print $2}') >/dev/null
export RACONE_DB=$(echo $data | awk 'BEGIN{FS=":"}{print $3}') >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
if [ $ORACLE_DB = $ORACLE_SID ] || [[ ! -z $RACONE_DB ]]
then
echo "Stopping Database " $ORACLE_SID | tee -a ${LOG}
srvctl stop database -d $ORACLE_DB | tee -a ${LOG}
else
echo "Stopping instance " $ORACLE_SID | tee -a ${LOG}
srvctl stop instance -d $ORACLE_DB -i $ORACLE_SID | tee -a ${LOG} # >/dev/null
fi
sleep 5
done < $OUTPUT_DIRECTORY/db:inst.log
}
stop_dbservices()
{
echo "STOPPING ANY DB SERVICE(S) on " $what | tee -a ${LOG}
while read data
do
export ORACLE_DB=$(echo $data | awk 'BEGIN{FS=":"}{print $1}') >/dev/null
export ORACLE_SID=$(echo $data | awk 'BEGIN{FS=":"}{print $2}') >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
export LOCAL_NODE=`hostname -s`
if [[ "$server_type" == rac* ]]; then
# Stop Any services for $ORACLE_DB on this node
if [ $(srvctl status service -d $ORACLE_DB | grep $ORACLE_SID | grep -i "is running" | awk '{ print $2 }' | wc -l) -ne 0 ]
then
#Loop Through Running Services
srvctl status service -d $ORACLE_DB | grep $ORACLE_SID | grep -i "is running" | awk '{ print $2 }' | while read DB_SERV_NAME
do
echo "srvctl disable service -d $ORACLE_DB -s $DB_SERV_NAME" >> ${LOG}
srvctl disable service -d $ORACLE_DB -s $DB_SERV_NAME >> ${LOG}
echo " srvctl stop service -d $ORACLE_DB -s $DB_SERV_NAME -n $LOCAL_NODE" >> ${LOG}
srvctl stop service -d $ORACLE_DB -s $DB_SERV_NAME -n $LOCAL_NODE >> ${LOG}
done
fi
else
# Stop Any services for $ORACLE_DB on this node
if [ $(srvctl status service -d $ORACLE_DB | grep -i "is running" | awk '{ print $2 }' | wc -l) -ne 0 ]
then
echo "srvctl stop service -d $ORACLE_DB" >> ${LOG}
srvctl stop service -d $ORACLE_DB >> ${LOG}
fi
fi
sleep 5
done < $OUTPUT_DIRECTORY/db:inst.log
}
stop_db_standalone()
{
echo "STOPPING" $what | tee -a ${LOG}
for SID in `ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s`
do
export ORACLE_SID=${SID} >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
echo "Stopping instance " $ORACLE_SID | tee -a ${LOG}
op=`$ORACLE_HOME/bin/sqlplus -s '/ as sysdba'<< EOF
set echo off;
shutdown immediate;
EOF`
echo "$op" >> ${LOG};echo "" >> ${LOG}
done
sleep 5
}
stop_mrp()
{
echo "STOPPING" $what | tee -a ${LOG}
for SID in `ps -ef | grep mrp | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s`
do
export ORACLE_SID=${SID} >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
echo "Stopping MRP " $ORACLE_SID | tee -a ${LOG}
op=`$ORACLE_HOME/bin/sqlplus -s '/ as sysdba'<< EOF
set echo off;
alter database recover managed standby database cancel;
EOF`
echo "$op" >> ${LOG};echo "" >> ${LOG}
done
sleep 5
}
stop_lsnr()
{
echo "STOPPING" $what | tee -a ${LOG}
if [[ $server_type = "rac_12c" ]] || [[ $server_type = "rac_11g" ]] || [[ $server_type = "norac_asm11g" ]] || [[ $server_type = "norac_asm12c" ]]
then
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}' | head -1`
else
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s | head -1`
fi
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
#for lsnr in `ps -ef | grep lsnr | grep "^.*${oraowner} " | grep -v grep | grep $ORACLE_HOME | grep -oP '(?<=tnslsnr )\w+'`
for lsnr in `ps -ef | grep lsnr | grep "^.*${oraowner} " | grep -v grep | grep $ORACLE_HOME | sed -n 's/.*\(tnslsnr.*\).*/\1/p' | awk '{ print $2 }' | sed '/^\s*$/d'`
do
echo "" >> ${LOG}
echo "Stopping listener $lsnr running from OH=${ORACLE_HOME} " | tee -a ${LOG}
echo "lsnrctl stop $lsnr" >> ${LOG}
echo "" >> ${LOG}
lsnrctl stop $lsnr >> ${LOG}
sleep 10
done
for lsnr in `ps -ef | grep lsnr | grep "^.*${oraowner} " | grep -v grep | sed -n 's/.*\(tnslsnr.*\).*/\1/p' | awk '{ print $2 }' | sed '/^\s*$/d'`
do
#echo "Stopping listener " $lsnr | tee -a ${LOG}
if [[ -f $OUTPUT_DIRECTORY/pre_config_lsnr.log ]]; then
LSNR_HOME=`cat $OUTPUT_DIRECTORY/pre_config_lsnr.log | grep "^${lsnr}:" | cut -d":" -f2 -s |tail -1`
if [[ $ORACLE_HOME != $LSNR_HOME ]]; then
if [[ -f /etc/oratab ]]; then
ORACLE_SID=`grep $LSNR_HOME /etc/oratab | grep -v "^#" | cut -d":" -f1 -s |tail -1`
export ORAENV_ASK=NO >/dev/null
if [[ ! -z $ORACLE_SID ]]; then
. oraenv >/dev/null
fi
fi
fi
fi
echo "" >> ${LOG}
echo "Stopping listener $lsnr running from OH=${ORACLE_HOME} " | tee -a ${LOG}
echo "lsnrctl stop $lsnr" >> ${LOG}
lsnrctl stop $lsnr >> ${LOG}
echo "" >> ${LOG}
done
sleep 5
}
stop_agent()
{
echo "STOPPING" $what | tee -a ${LOG}
if [ $(ps -ef | grep emagent | grep "^.*${oraowner} " | grep -v grep | wc -l) -ne 0 ]
then
ORACLE_SID=`cat /etc/oratab | awk 'BEGIN{FS=":"}{print $1}' | grep OEM | grep -v "^#"`
export ORAENV_ASK=NO >/dev/null;
if [[ ! -z $ORACLE_SID ]]; then
. oraenv >/dev/null
if [[ -f $ORACLE_HOME/bin/emctl ]]; then
emctl stop agent >/dev/null;
sleep 5
fi
fi
else
sleep 1
fi
}
stop_fgl()
{
echo "STOPPING" $what | tee -a ${LOG}
if [[ -f /oracle/dba/foglight/fgl_5/bin/fglam ]]; then
/oracle/dba/foglight/fgl_5/bin/fglam --stop >/dev/null
sleep 60
else
# Search for non standard Foglight bin and execute stop
if [ "$(ps -ef | grep -i foglight | grep "^.*${oraowner} " | grep -v grep | wc -l)" -eq 0 ]
then
echo "Foglight is not running" >> ${LOG} ; echo "" >> ${LOG}
else
FOGLIGHTBASE=`ps -ef | grep -i foglight | grep "^.*${oraowner} " | grep -v grep | sed -n 's/.*\(...............................................\/foglight\/fgl_5\).*/\1/p' | awk '{ print $NF }' | tail -1`
if [[ ! -z $FOGLIGHTBASE ]]; then
FOGLIGHTBIN=${FOGLIGHTBASE}/bin/fglam
if [[ -f $FOGLIGHTBIN ]]; then
$FOGLIGHTBIN --stop >/dev/null
sleep 60
echo "$FOGLIGHTBIN -d" > $OUTPUT_DIRECTORY/non_standard_fgl_start.cmd
chmod 755 $OUTPUT_DIRECTORY/non_standard_fgl_start.cmd
fi
fi
fi
fi
}
stop_portutil()
{
echo -e ' \t ' "STOPPING" $what | tee -a ${LOG}
if [ "$(cat $OUTPUT_DIRECTORY/portnum.val | wc -l)" != 0 ]
then
while read portnum
do
/opt/portdaemon/bin/stop_port_daemon $portnum >/dev/null;
sleep 10
done < $OUTPUT_DIRECTORY/portnum.val
fi
}
stop_osw()
{
echo "STOPPING" $what | tee -a ${LOG}
if [ $(ps -ef | grep -i OSW | grep "^.*${oraowner} " | grep -v grep | wc -l) -ne 0 ]
then
ps -ef | grep -i OSW | grep "^.*${oraowner} " | grep -v grep| grep -v osw | awk 'BEGIN{FS=" "}{print $(NF-3)" "$(NF-2)" "$(NF-1)" "$(NF-0)}' > $OUTPUT_DIRECTORY/start_osw.cmd
if [[ -f /oracle/dba/diagtools/oswbb/stopOSWbb.sh ]]; then
/oracle/dba/diagtools/oswbb/stopOSWbb.sh >/dev/null
sleep 5
fi
# Non standard path
OSW_PIDVALUE=`ps -e | grep -i OSWatcher.sh | awk '{print $1}'`
OSW_BASEPATH=`ls -l /proc/$OSW_PIDVALUE/cwd | awk '{print $NF}'`
OSWNONSTOP=$OSW_BASEPATH/stopOSWbb.sh
if [[ -f $OSWNONSTOP ]]; then
$OSWNONSTOP >/dev/null
sleep 1
fi
else
touch $OUTPUT_DIRECTORY/start_osw.cmd
fi
}
######################
# DBFS and OGG Support
######################
stop_ogg()
{
echo "STOPPING" $what | tee -a ${LOG}
#Initialise any previous gg config files
if [[ -f ${OUTPUT_DIRECTORY}/gg_config.txt ]]; then
rm ${OUTPUT_DIRECTORY}/gg_config.txt
fi
if [[ -f ${OUTPUT_DIRECTORY}/pre_stop_gg_autostart.prm ]]; then
rm ${OUTPUT_DIRECTORY}/pre_stop_gg_autostart.prm
fi
# Set Ora env
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep "+ASM" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s`
export ORAENV_ASK=NO >/dev/null;
if [[ ! -z $ORACLE_SID ]]; then
. oraenv >/dev/null
else
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s| tail -1`
. oraenv >/dev/null
fi
ps -ef | grep -v grep | grep "mgr PARAMFILE" | grep "^.*${oraowner} " | sed -n 's/.*\(...................................................................\/....prm \).*/\1/p' | awk '{ print $NF }' | grep -v "\.\.\.\.mgr.prm" | while read GG_MGRPROC
do
# Proceed only if Golden Gate Manager is running
if [[ ! -z $GG_MGRPROC ]]; then
GG_HOME=`echo $GG_MGRPROC | sed 's/\/dirprm\/mgr.prm//g' | sed 's/\/dirprm\/MGR.prm//g'`
#############################
LOCAL_NODE=`hostname -s`
# Loop through any GG CRS res and shut them down
if [[ -f ${ORACLE_HOME}/bin/crsctl ]]; then
${ORACLE_HOME}/bin/crsctl stat res -p |grep "^NAME=" | grep -iE 'gg|golden' | grep -v vip | grep -v "\.svc" | grep -v "\.db" | grep -v "ora\." | cut -d"=" -f2 -s | while read CRS_RES_GG
do
if [[ ! -z $CRS_RES_GG ]]; then
CRS_STATE=`${ORACLE_HOME}/bin/crsctl stat res $CRS_RES_GG | grep "STATE=" | awk '{ print $1 }' | cut -d"=" -f2 -s`
if [[ "$CRS_STATE" == "ONLINE" ]]; then
echo "${ORACLE_HOME}/bin/crsctl stop res $CRS_RES_GG" >> ${LOG}
${ORACLE_HOME}/bin/crsctl stop res $CRS_RES_GG >> ${LOG}
sleep 60
# Capture gg start config for each GG_HOME on this node
echo "GGCRS@${CRS_RES_GG}:${GG_HOME}:${LOCAL_NODE}" >> ${OUTPUT_DIRECTORY}/gg_config.txt
if [[ -n `find ${GG_HOME}/dirprm/ -maxdepth 1 -iname mgr.prm` ]]; then
if [[ -f ${GG_HOME}/dirprm/mgr.prm ]]; then
grep -i "AUTOSTART " ${GG_HOME}/dirprm/mgr.prm | grep -v "^#" | grep -v "^--" >> ${OUTPUT_DIRECTORY}/pre_stop_gg_autostart.prm
else
grep -i "AUTOSTART " ${GG_HOME}/dirprm/MGR.prm | grep -v "^#" | grep -v "^--" >> ${OUTPUT_DIRECTORY}/pre_stop_gg_autostart.prm
fi
fi
fi
fi
#sleep 5
done
fi
#############################
# Check to see if GG mgr is still running from this GG_HOME - if so shutdown manually ..
if [[ -f ${GG_HOME}/dirpcs/MGR.pcm ]]; then
if [[ -f ${OUTPUT_DIRECTORY}/pre_gg_inst.log ]]; then
ORACLE_GG_SID=`cat ${OUTPUT_DIRECTORY}/pre_gg_inst.log | grep "PRE_OGG_DBINST:" | cut -d":" -f3 -s | tail -1`
fi
if [[ ! -z $ORACLE_GG_SID ]]; then
ORACLE_SID=$ORACLE_GG_SID
. oraenv
else
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s | tail -1`
if [[ ! -z $ORACLE_SID ]]; then
. oraenv
fi
fi
${GG_HOME}/ggsci << EOF >>${LOG}
stop *
stop mgr !
exit
EOF
sleep 60
echo "GGNOCRS:${GG_HOME}:${LOCAL_NODE}" >> ${OUTPUT_DIRECTORY}/gg_config.txt
if [[ -n `find ${GG_HOME}/dirprm/ -maxdepth 1 -iname mgr.prm` ]]; then
if [[ -f ${GG_HOME}/dirprm/mgr.prm ]]; then
grep -i "AUTOSTART " ${GG_HOME}/dirprm/mgr.prm | grep -v "^#" | grep -v "^--" >> ${OUTPUT_DIRECTORY}/pre_stop_gg_autostart.prm
else
grep -i "AUTOSTART " ${GG_HOME}/dirprm/MGR.prm | grep -v "^#" | grep -v "^--" >> ${OUTPUT_DIRECTORY}/pre_stop_gg_autostart.prm
fi
fi
fi
else
echo " No Oracle Golden Gate processes detected on this host ... " >> ${LOG}
fi
done
}
stop_dbfs()
{
echo "STOPPING" $what | tee -a ${LOG}
#Initialise any previous dbfs config files
if [[ -f ${OUTPUT_DIRECTORY}/dbfs_config.txt ]]; then
rm ${OUTPUT_DIRECTORY}/dbfs_config.txt
fi
# Set Ora env
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'`
export ORAENV_ASK=NO >/dev/null;
if [[ ! -z $ORACLE_SID ]]; then
. oraenv >/dev/null
else
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s | tail -1`
. oraenv >/dev/null
fi
ps -ef | grep -v grep | grep "dbfs_client" | grep "^.*${oraowner} " | sed -n 's/.*\(................................................................\/bin\/dbfs_client\).*/\1/p' | awk '{ print $NF }' | grep -v "\.\.\.\.dbfs_client" | sort -u | while read DBFS_PROC
do
# Proceed only if DBFS is running
if [[ ! -z $DBFS_PROC ]]; then
#Check if this dbfs is setup as a crs resource
DBFS_HOME=`echo $DBFS_PROC | sed 's/\/bin\/dbfs_client//g'`
#############################
LOCAL_NODE=`hostname -s`
if [[ -f ${ORACLE_HOME}/bin/crsctl ]]; then
# Loop through any DBFS CRS res and shut them down
${ORACLE_HOME}/bin/crsctl stat res -p |grep "^NAME=" | grep -i dbfs | grep -v "\.svc" | grep -v "\.db" | grep -v "ora\." | cut -d"=" -f2 -s | while read CRS_RES_DBFS
do
if [[ ! -z $CRS_RES_DBFS ]]; then
CRS_STATE=`${ORACLE_HOME}/bin/crsctl stat res $CRS_RES_DBFS | grep "STATE=" | awk '{ print $1 }' | cut -d"=" -f2 -s`
if [[ "$CRS_STATE" == "ONLINE" ]]; then
echo "DBFS CRS Resource: $CRS_RES_DBFS was detected. Now stopping this resource ..." >>${LOG}
echo "${ORACLE_HOME}/bin/crsctl stop res $CRS_RES_DBFS -f" >>${LOG}
${ORACLE_HOME}/bin/crsctl stop res $CRS_RES_DBFS -f >>${LOG}
# Capture dbfs start config for each DBFS_HOME on this node
echo "DBFSCRS@${CRS_RES_DBFS}:${DBFS_HOME}:${LOCAL_NODE}" >> ${OUTPUT_DIRECTORY}/dbfs_config.txt
else
echo "" >>${LOG}
echo "DBFS CRS Resource: $CRS_RES_DBFS was detected but found to be in $CRS_STATE STATE ... No action taken! " >>${LOG}
echo "" >>${LOG}
fi
fi
sleep 30
done
fi
#############################
# Check to see if dbfs is still running from this DBFS_HOME - if so shutdown manually ..
if [ $(ps -ef | grep "^.*${oraowner} " | grep -v grep | grep "${DBFS_HOME}/bin/dbfs_client" | wc -l) -ne 0 ]; then
#get DBFS_MOUNT
#DBFS_MOUNT=`ps -ef | grep "^.*${oraowner} " | grep -v grep | grep "dbfs_client" | awk '{ print $NF }'`
ps -ef | grep "^.*${oraowner} " | grep -v grep | grep "${DBFS_HOME}/bin/dbfs_client" | awk '{ print $NF }' | while read DBFS_MOUNT
do
if [[ ! -z $DBFS_MOUNT ]]; then
echo "" >>${LOG}
echo "Will Try to stop dbfs processes manually. Because either dbfs CRS resources not found OR DBFS still running even after CRS resource stopped .." >>${LOG}
echo "Manually Stopping dbfs mount dir: $DBFS_MOUNT ..." >>${LOG}
echo "/bin/fusermount -u -z $DBFS_MOUNT" >>${LOG}
/bin/fusermount -u -z $DBFS_MOUNT >>${LOG}
echo "" >>${LOG}
fi
sleep 10
# Capture dbfs start config for each GG_HOME on this node
if [[ -f ${OUTPUT_DIRECTORY}/dbfs_config.txt ]]; then
CHK_DBFSHOME_CONFIGFILE=`grep ":${DBFS_HOME}:" ${OUTPUT_DIRECTORY}/dbfs_config.txt`
fi
if [[ -z $CHK_DBFSHOME_CONFIGFILE ]]; then
echo "DBFSNOCRS:${DBFS_HOME}:${LOCAL_NODE}" >> ${OUTPUT_DIRECTORY}/dbfs_config.txt
fi
done
#Check if any dbfs process still running on this host and kill it ..
ps -ef | grep "^.*${oraowner} " | grep -v grep | grep "${DBFS_HOME}/bin/dbfs_client" | awk '{ print $2 }' | while read DBFS_PID
do
if [[ ! -z $DBFS_PID ]]; then
echo "" >>${LOG}
echo "No Luck ... Looks like below DBFS OSPID:$DBFS_PID is still Running! ..." >>${LOG}
echo "ps -ef | grep -v grep | grep $DBFS_PID | grep dbfs_client =>" >>${LOG}
ps -ef | grep -v grep | grep "$DBFS_PID" | grep dbfs_client >> ${LOG}
echo "" >>${LOG}
echo "Will try to KILL it .." >>${LOG}
echo "kill -9 $DBFS_PID" >>${LOG}
kill -9 $DBFS_PID >> ${LOG}
sleep 5
echo "Checking if DBFS OSPID:$DBFS_PID has gone ..." >>${LOG}
echo "ps -ef | grep -v grep | grep $DBFS_PID =>" >>${LOG}
ps -ef | grep -v grep | grep "$DBFS_PID" >> ${LOG}
echo "" >>${LOG}
fi
done
fi
else
echo " No dbfs processes detected on this host ... " >/dev/null
fi
done
}
fgl_Autosys_blackout()
{
if [[ $OS != "AIX" ]]; then
export EFS_BLK_SCRIPT=/efs/dist/gmrtdba/dbascripts/scripts/common/bl_fgl_autosys_blkout.ksh
#Set Env with any running Instance;
for SID in `ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s | tail -1`
do
export ORACLE_SID=${SID} >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
done
if [[ ! -z $ORACLE_SID ]]; then
if [[ -f $EFS_BLK_SCRIPT ]]; then
echo "Attempting to apply HOST level BLACKOUTS for Foglight and Autosys via efs script: bl_fgl_autosys_blkout.ksh " | tee -a ${LOG}
echo " Foglight_Autosys_blackout Call Starting @ `date` " >> ${LOG}
export BLK_USR=ORA_BL_AUTO
export BLK_PHOST=`hostname -s`
export BLK_HOURS=4
export BLK_TYPE=h
sh $EFS_BLK_SCRIPT << ANSWERS
${BLK_USR}
${BLK_TYPE}
${BLK_PHOST}
${BLK_HOURS}
ANSWERS
echo " Foglight_Autosys_blackout Call Finished @ `date` " >> ${LOG}
echo "" >> ${LOG}
fi
fi
fi
}
#INSERT INTO REPOSITORY DATABASE
#ASSIGNING THE OUTPUT VARIABLES
assign_log()
{
if [ -s $OUTPUT_DIRECTORY/pre_stop_crs.log ]
then
crs_output=`cat $OUTPUT_DIRECTORY/pre_stop_crs.log`
else
crs_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_stop_asm.log ]
then
asm_output=`cat $OUTPUT_DIRECTORY/pre_stop_asm.log`
else
asm_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_stop_esm.log ]
then
esm_agent_output=`cat $OUTPUT_DIRECTORY/pre_stop_esm.log`
else
esm_agent_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_stop_dma.log ]
then
dma_agent_output=`cat $OUTPUT_DIRECTORY/pre_stop_dma.log`
else
dma_agent_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_stop_lsnr.log ]
then
listener_output=`cat $OUTPUT_DIRECTORY/pre_stop_lsnr.log`
else
listener_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_stop_dbinst.log ]
then
db_instance_output=`cat $OUTPUT_DIRECTORY/pre_stop_dbinst.log`
else
db_instance_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/unidb:inst.log ]
then
db_unique_output=`cat $OUTPUT_DIRECTORY/unidb:inst.log`
else
db_unique_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_stop_dbopen.log ]
then
db_open_output=`cat $OUTPUT_DIRECTORY/pre_stop_dbopen.log`
else
db_open_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_stop_dbopenro.log ]
then
db_openro_output=`cat $OUTPUT_DIRECTORY/pre_stop_dbopenro.log`
else
db_openro_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_stop_dbmount.log ]
then
db_mount_output=`cat $OUTPUT_DIRECTORY/pre_stop_dbmount.log`
else
db_mount_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_stop_dbservices.log ]
then
service_alignment_output=`cat $OUTPUT_DIRECTORY/pre_stop_dbservices.log`
else
service_alignment_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_stop_mrp.log ]
then
mrp_output=`cat $OUTPUT_DIRECTORY/pre_stop_mrp.log`
else
mrp_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_stop_agent.log ]
then
oem_agent_output=`cat $OUTPUT_DIRECTORY/pre_stop_agent.log`
else
oem_agent_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_stop_portutil.log ]
then
port_utility_output=`cat $OUTPUT_DIRECTORY/pre_stop_portutil.log`
else
port_utility_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_stop_fgl.log ]
then
foglight_output=`cat $OUTPUT_DIRECTORY/pre_stop_fgl.log`
else
foglight_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_stop_osw.log ]
then
os_watcher_output=`cat $OUTPUT_DIRECTORY/pre_stop_osw.log`
else
os_watcher_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_stop_usb.log ]
then
usb_output=`cat $OUTPUT_DIRECTORY/pre_stop_usb.log`
else
usb_output="no_status"
fi
if [ -s /oracle/dba/foglight/fgl_5/bin/fglam ]
then
fglam_output=`/oracle/dba/foglight/fgl_5/bin/fglam --check-connection`
else
fglam_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/server_type.log ]
then
instance_type=`cat $OUTPUT_DIRECTORY/server_type.log`
else
instance_type="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/version_executed_status.log ]
then
script_version=`cat $OUTPUT_DIRECTORY/version_executed_status.log`
else
script_version="no_status"
fi
}
insert_repdb()
{
for what in fgl osw agent portutil lsnr mrp dbinst asm
do
if [ -f $OUTPUT_DIRECTORY/stopped_$what.log ]
then
if [ "$(cat $OUTPUT_DIRECTORY/stopped_$what.log)" = yes ]
then
eval var_$what="success"
fi
if [ "$(cat $OUTPUT_DIRECTORY/stopped_$what.log)" = no ]
then
eval var_$what="failure"
fi
else
eval var_$what="no_status"
fi
done
var_dma="na"
var_esm="na"
var_crs="na"
if [[ $server_type = "rac_11g" ]] || [[ $server_type = "norac_asm11g" ]]
then
var_lsnr="na"
var_asm="na"
elif [[ $server_type = "norac_noasm" ]]
then
var_asm="na"
fi
#PREPARING THE INSERT STATEMENT
if [ $(cat /etc/oratab | grep oracle | grep -v -i asm | grep -v -i crs | grep -v -i oem | grep -v "#" | awk 'BEGIN{FS=":"}{print $1}' | head -1 | wc -l) = 1 ]
then
export ORACLE_SID=`cat /etc/oratab | grep oracle | grep -v -i asm | grep -v -i crs | grep -v -i oem | grep -v "#" | awk 'BEGIN{FS=":"}{print $1}' | head -1`
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
$ORACLE_HOME/bin/sqlplus -s OSH_SEH/dbaas_operations1@SUNDVD94 << EOFSTATUS
set echo off;
set head off;
set feedback off;
insert into OSH_SEH.dbss_log (DBSS_ID,
SCRIPT_VERSION,
INSTANCE_TYPE,
STOP_OR_START,
CRS_OR_DB,
SERVER_NAME,
SERVER_TIMESTAMP,
CRS,
ASM,
LISTENER,
DB_INSTANCE,
MRP_PROCESS,
ESM_AGENT,
DMA_AGENT,
OEM_AGENT,
PORT_UTILITY,
FOGLIGHT,
OS_WATCHER,
SENT_MAIL,
CRS_OUTPUT,
ASM_OUTPUT,
LISTENER_OUTPUT,
DB_INSTANCE_OUTPUT,
DB_OPEN_OUTPUT,
DB_OPENRO_OUTPUT,
DB_MOUNT_OUTPUT,
SERVICE_ALIGNMENT_OUTPUT,
MRP_OUTPUT,
ESM_AGENT_OUTPUT,
DMA_AGENT_OUTPUT,
OEM_AGENT_OUTPUT,
PORT_UTILITY_OUTPUT,
FOGLIGHT_OUTPUT,
OS_WATCHER_OUTPUT,
USB_OUTPUT,
FGLAM_OUTPUT,
DB_UNIQUE_OUTPUT)
values (DBSS_LOG_SEQ.nextval,
'$script_version',
'$instance_type',
'stop',
'db',
'$(hostname -f)',
'$timevalue',
'$var_crs',
'$var_asm',
'$var_lsnr',
'$var_dbinst',
'$var_mrp',
'$var_esm',
'$var_dma',
'$var_agent',
'$var_portutil',
'$var_fgl',
'$var_osw',
0,
'$crs_output',
'$asm_output',
'$listener_output',
'$db_instance_output',
'$db_open_output',
'$db_openro_output',
'$db_mount_output',
'$service_alignment_output',
'$mrp_output',
'$esm_agent_output',
'$dma_agent_output',
'$oem_agent_output',
'$port_utility_output',
'$foglight_output',
'$os_watcher_output',
'$usb_output',
'$fglam_output',
'$db_unique_output');
commit;
EOFSTATUS
fi
}
# STOP THE APPROPRIATE SERVICES BASED ON SERVER TYPE
echo ""; echo "Please wait while the services are brought down... "; echo ""
case $server_type in
"rac_12c")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "---------------------------> THIS IS A 12c CLUSTERWARE SYSTEM <------------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
why=stop;
#Apply FGL and Autosys Blackout for defined X Hours
fgl_Autosys_blackout
for what in fgl osw agent mrp ogg dbfs
do
when=pre; collect_$what; display_pre_post
stop_$what;
when=post; collect_$what; display_pre_post
done
when=pre; what=dbinst; collect_$what; display_pre_post
collect_instancestatus
collect_dbservices
# Stop and disable db services before the instance for RAC
stop_dbservices
stop_db_rac;
when=post; what=dbinst; collect_$what; display_pre_post
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in fgl osw agent mrp ogg dbfs dbinst
do
stopped_status
done
if [ "$(cat $OUTPUT_DIRECTORY/stopped_fgl.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_osw.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_agent.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_mrp.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_dbinst.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_ogg.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_dbfs.log)" = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_stop_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
else
echo "0" > $OUTPUT_DIRECTORY/bl_stop_flag.log
echo ""
echo "ATTENTION : Some services didn't stop. Please check" | tee -a ${LOG}
fi
assign_log
insert_repdb
echo "**************************************************"
;;
"rac_11g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "---------------------------> THIS IS A 11g CLUSTERWARE SYSTEM <------------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
why=stop;
#Apply FGL and Autosys Blackout for defined X Hours
fgl_Autosys_blackout
for what in fgl osw agent mrp ogg dbfs
do
when=pre; collect_$what; display_pre_post
stop_$what;
when=post; collect_$what; display_pre_post
done
when=pre; what=dbinst; collect_$what; display_pre_post
collect_instancestatus
collect_dbservices
stop_dbservices
stop_db_rac;
when=post; what=dbinst; collect_$what; display_pre_post
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in fgl osw agent mrp ogg dbfs dbinst
do
stopped_status
done
if [ "$(cat $OUTPUT_DIRECTORY/stopped_fgl.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_osw.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_agent.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_mrp.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_dbinst.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_ogg.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_dbfs.log)" = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_stop_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
else
echo "0" > $OUTPUT_DIRECTORY/bl_stop_flag.log
echo ""
echo "ATTENTION : Some services didn't stop. Please check" | tee -a ${LOG}
fi
assign_log
insert_repdb
echo "**************************************************"
;;
"rac_10g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "---------------------------> THIS IS A 10g CLUSTERWARE SYSTEM <------------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
why=stop;
#Apply FGL and Autosys Blackout for defined X Hours
fgl_Autosys_blackout
for what in fgl osw agent lsnr mrp ogg
do
when=pre; collect_$what; display_pre_post
stop_$what;
when=post; collect_$what; display_pre_post
done
when=pre; what=dbinst; collect_$what; display_pre_post
collect_instancestatus
collect_dbservices
stop_db_rac;
when=post; what=dbinst; collect_$what; display_pre_post
when=pre; what=asm; collect_$what; display_pre_post
collect_instancestatus
stop_asm_10g;
when=post; what=asm; collect_$what; display_pre_post
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in fgl osw agent lsnr mrp dbinst asm ogg
do
stopped_status
done
if [ "$(cat $OUTPUT_DIRECTORY/stopped_fgl.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_osw.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_agent.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_lsnr.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_mrp.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_dbinst.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_asm.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_ogg.log)" = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_stop_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
else
echo "0" > $OUTPUT_DIRECTORY/bl_stop_flag.log
echo ""
echo "ATTENTION : Some services didn't stop. Please check" | tee -a ${LOG}
fi
assign_log
insert_repdb
echo "**************************************************"
;;
"norac_asm12c")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "-------------------------> THIS IS A NON-RAC SYSTEM BUT WITH ASM 12c <----------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
why=stop;
#Apply FGL and Autosys Blackout for defined X Hours
fgl_Autosys_blackout
for what in fgl osw agent mrp ogg dbfs lsnr
do
when=pre; collect_$what; display_pre_post
stop_$what;
when=post; collect_$what; display_pre_post
done
when=pre; what=dbinst; collect_$what; display_pre_post
collect_instancestatus
collect_dbservices
stop_dbservices
stop_db_standalone;
when=post; what=dbinst; collect_$what; display_pre_post
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in fgl osw agent mrp ogg dbfs dbinst lsnr
do
stopped_status
done
if [ "$(cat $OUTPUT_DIRECTORY/stopped_fgl.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_osw.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_agent.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_mrp.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_dbinst.log)" = yes ]&& [ "$(cat $OUTPUT_DIRECTORY/stopped_ogg.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_dbfs.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_lsnr.log)" = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_stop_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
else
echo "0" > $OUTPUT_DIRECTORY/bl_stop_flag.log
echo ""
echo "ATTENTION : Some services didn't stop. Please check" | tee -a ${LOG}
fi
assign_log
insert_repdb
echo "**************************************************"
;;
"norac_asm11g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "-------------------------> THIS IS A NON-RAC SYSTEM BUT WITH ASM 11g <----------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
why=stop;
#Apply FGL and Autosys Blackout for defined X Hours
fgl_Autosys_blackout
for what in fgl osw agent mrp ogg dbfs lsnr
do
when=pre; collect_$what; display_pre_post
stop_$what;
when=post; collect_$what; display_pre_post
done
when=pre; what=dbinst; collect_$what; display_pre_post
collect_instancestatus
collect_dbservices
stop_db_standalone;
when=post; what=dbinst; collect_$what; display_pre_post
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in fgl osw agent mrp ogg dbfs dbinst lsnr
do
stopped_status
done
if [ "$(cat $OUTPUT_DIRECTORY/stopped_fgl.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_osw.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_agent.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_mrp.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_dbinst.log)" = yes ]&& [ "$(cat $OUTPUT_DIRECTORY/stopped_ogg.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_dbfs.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_lsnr.log)" = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_stop_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
else
echo "0" > $OUTPUT_DIRECTORY/bl_stop_flag.log
echo ""
echo "ATTENTION : Some services didn't stop. Please check" | tee -a ${LOG}
fi
assign_log
insert_repdb
echo "**************************************************"
;;
"norac_asm10g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "-------------------------> THIS IS A NON-RAC SYSTEM BUT WITH ASM 10g <----------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
why=stop;
#Apply FGL and Autosys Blackout for defined X Hours
fgl_Autosys_blackout
for what in fgl osw agent lsnr mrp ogg
do
when=pre; collect_$what; display_pre_post
stop_$what;
when=post; collect_$what; display_pre_post
done
when=pre; what=dbinst; collect_$what; display_pre_post
collect_instancestatus
#stop_db_rac;
stop_db_standalone;
when=post; what=dbinst; collect_$what; display_pre_post
when=pre; what=asm; collect_$what; display_pre_post
collect_instancestatus
stop_asm_10g;
when=post; what=asm; collect_$what; display_pre_post
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in fgl osw agent lsnr mrp dbinst asm ogg
do
stopped_status
done
if [ "$(cat $OUTPUT_DIRECTORY/stopped_fgl.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_osw.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_agent.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_lsnr.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_mrp.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_dbinst.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_asm.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_ogg.log)" = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_stop_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
else
echo "0" > $OUTPUT_DIRECTORY/bl_stop_flag.log
echo ""
echo "ATTENTION : Some services didn't stop. Please check" | tee -a ${LOG}
fi
assign_log
insert_repdb
echo "**************************************************"
;;
"norac_noasm")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "--------------------------> THIS IS A NON-RAC & NON-ASM SYSTEM <----------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
why=stop;
#Apply FGL and Autosys Blackout for defined X Hours
fgl_Autosys_blackout
for what in fgl osw agent lsnr mrp ogg
do
when=pre; collect_$what; display_pre_post
stop_$what;
when=post; collect_$what; display_pre_post
done
echo "" >> ${LOG}
if [[ "$RH_VER" == 7.* ]]; then
when=pre; what=dbinst; collect_$what; display_pre_post
collect_instancestatus
echo "***********" >> ${LOG}
echo "RH7 System .. No db stop will be performed here .." >> ${LOG}
echo "oracle_db.service Status: " >> $LOG
systemctl status oracle_db.service | grep "Active: " >> $LOG
echo "***********" >> ${LOG}
else
when=pre; what=dbinst; collect_$what; display_pre_post
collect_instancestatus
stop_db_standalone;
when=post; what=dbinst; collect_$what; display_pre_post
fi
echo "" >> ${LOG}
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in fgl osw agent lsnr mrp dbinst ogg
do
stopped_status
done
if [ "$(cat $OUTPUT_DIRECTORY/stopped_fgl.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_osw.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_agent.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_lsnr.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_mrp.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_dbinst.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_ogg.log)" = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_stop_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
else
echo "0" > $OUTPUT_DIRECTORY/bl_stop_flag.log
echo ""
echo "ATTENTION : Some services didn't stop. Please check" | tee -a ${LOG}
fi
assign_log
insert_repdb
echo "**************************************************"
;;
*)
echo "Invalid Selection : $server_type "
esac
# RENAME THE LOGS
chmod 755 $OUTPUT_DIRECTORY/pre_stop*.log 1> /dev/null 2>&1
chmod 755 $OUTPUT_DIRECTORY/post_stop*.log 1> /dev/null 2>&1
chmod 755 $OUTPUT_DIRECTORY/stopped*.log 1> /dev/null 2>&1
chmod 755 $OUTPUT_DIRECTORY/bl_stop*.log 1> /dev/null 2>&1
chown $oracred $OUTPUT_DIRECTORY/pre_stop*.log 1> /dev/null 2>&1
chown $oracred $OUTPUT_DIRECTORY/post_stop*.log 1> /dev/null 2>&1
chown $oracred $OUTPUT_DIRECTORY/stopped*.log 1> /dev/null 2>&1
chown $oracred $OUTPUT_DIRECTORY/bl_stop*.log 1> /dev/null 2>&1
filename=$(echo $(hostname) | cut -d. -f1)_$(date '+%m%d%Y_%H%M%S')
mv ${LOG} $OUTPUT_DIRECTORY/stop_$filename.log
echo ""
echo ""
echo "****************************************************************************************************";
echo "Please check the detailed STOP report at $OUTPUT_DIRECTORY/stop_$filename.log"
echo "****************************************************************************************************";
echo ""
#################################################################
# #
# #
#################################################################
# #
# Modified by EMEA OracleDBA Team for enhancements & automation #
# APRIL 2016 #
# #
#################################################################
# #
# #
# USAGE : To be executed as root user #
# #
# Manual execution #
# sh bl_stop_crs.ksh #
# #
# Via job scheduler tools and by-passing the prompt #
# sh bl_stop_crs.ksh y #
# #
#---------------------------------------------------------------#
# #
# //Generic information about the batch of scripts developed// #
# bl_status.ksh #
# bl_stop.ksh #
# bl_stop_crs.ksh #
# bl_start_crs.ksh #
# bl_start.ksh #
# #
# Versions/Combinations Supported #
# Clustware 12c
# Clustware 11g #
# Clustware 10g #
# NON-RAC with ASM 11g #
# NON-RAC with ASM 10g #
# NON-RAC & NON-ASM #
# #
# Components in scope #
# Clusterware #
# ASM Instance #
# Database Instance #
# Cluster Listener #
# Local Listener #
# Manager Recovery Process #
# GoldenGate Replication #
# Port Utility #
# Enterprise Manager Agent #
# OSWatcher Utility #
# Foglight Monitoring Agent #
# Filesystem #
# Rawdisk #
# #
#################################################################
export OS=`uname -a | awk '{ print $1 }'`
eval timevalue=`date '+%m%d%Y_%H%M%S'`
eval filename=$(echo $(hostname) | cut -d. -f1)_$timevalue
export PATH=$PATH:/usr/local/bin
if [[ -f /etc/redhat-release ]]; then
export RH_VER=`cat /etc/redhat-release | grep "Linux Server release" | sed -n 's/.*\(Linux Server release.*\).*/\1/p' | awk '{ print $4 }'`
else
export RH_VER=0
fi
# CHECK IF MYSQL DATABASE SERVER
if [ "$(ps -ef | grep -i mysql | grep -v grep | wc -l)" -ge 1 ]
then
echo "This is a MySQL Database Server"
exit 0
fi
# CHECK IF THE USER IS ROOT
echo " "
if [ $(whoami) != "root" ]
then
echo "ATTENTION : Please execute this script as root user"
exit 0;
fi
# SCRIPT AND OUTPUT DIRECTORIES INITIALIZATION
if [[ -d /oracle/dba/output/generic ]]; then
OUTPUT_DIRECTORY=/oracle/dba/output/generic
else
OUTPUT_DIRECTORY=/var/bl_ora/log
if [[ ! -d $OUTPUT_DIRECTORY ]]; then
echo "OUTPUT_DIRECTORY: $OUTPUT_DIRECTORY was not found on this server ... Exiting"
exit 0
fi
fi
# Check if user really wants to STOP the services
if [ $# -eq 0 ]
then
read -r -p "Are you sure you want to STOP the Clusterware services ? [y/n] " response
if [ $response = y ]
then
echo ""; echo "Please wait while the services are brought down... "; echo ""
else
exit; >/dev/null
fi
elif [ $1 == y ]
then
echo ""; echo "Please wait while the services are brought down... "; echo ""
else
exit; >/dev/null
fi
if [ -f $OUTPUT_DIRECTORY/server_type.log ];
then
server_type=$(<$OUTPUT_DIRECTORY/server_type.log)
else
if [ "$(ps -ef | grep crsd.bin | grep -v grep | wc -l)" -eq 1 ]
then
if [ "$(ps -ef | grep crsd.bin | grep -v grep | grep "12\." | wc -l)" -eq 1 ]
then
export server_type="rac_12c"
elif [ "$(ps -ef | grep crsd.bin | grep -v grep | grep "11\." | wc -l)" -eq 1 ]
then
export server_type="rac_11g"
else
export server_type="rac_10g"
fi
else
if [ "$(ps -ef | grep ohasd.bin | grep -v grep | grep "12\." | wc -l)" -eq 1 ]
then
export server_type="norac_asm12c"
elif [ "$(ps -ef | grep ohasd.bin | grep -v grep | grep "11\." | wc -l)" -eq 1 ]
then
export server_type="norac_asm11g"
elif [ "$(ps -ef | grep pmon | grep -v grep | grep "+ASM" | grep -v onitor | wc -l)" -eq 1 ]
then
export server_type="norac_asm10g"
else
export server_type="norac_noasm"
fi
fi
# Address rare issue seen where crsd.bin not picked up even though it is in fact a RAC system!
if [[ "$server_type" == norac_asm* ]] && [[ -f /etc/oratab ]]; then
ASM_LAST_CHAR=`grep "^\+ASM" /etc/oratab | cut -d":" -f1 -s | sed -e "s/.*\(.\)/\1/"`
#ASM_LAST_CHAR=`ps -ef | grep "asm_pmon_" | grep -v grep | awk '{ print $NF }' | cut -d"_" -f3 -s | sed -e "s/.*\(.\)/\1/"`
echo $ASM_LAST_CHAR | egrep '^[0-9]+$'
if [ $? -eq 0 ]; then
#echo "$ASM_LAST_CHAR is a number .. So it's a RAC "
server_str_2=`echo $server_type | sed 's/asm//g' |cut -d"_" -f2 -s`
export server_type="rac_${server_str_2}"
fi
fi
echo $server_type > $OUTPUT_DIRECTORY/server_type.log
fi
collect_dma()
{
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep opsware | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
elif [ $(( (`date +%s` - `stat -L --format %Y $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log`) > (2880*60) )) = 1 ]
then
rm -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep opsware | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
if [ $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) -gt 0 ]
then
sleep 1
else
ps -ef | grep opsware | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
fi
fi
elif [ $when = post ]
then
ps -ef | grep opsware | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
sleep 0
fi
}
collect_esm()
{
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep -i esm | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
elif [ $(( (`date +%s` - `stat -L --format %Y $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log`) > (2880*60) )) = 1 ]
then
rm -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep -i esm | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
if [ $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) -gt 0 ]
then
sleep 1
else
ps -ef | grep -i esm | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
fi
fi
elif [ $when = post ]
then
ps -ef | grep -i esm | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
sleep 0
fi
}
collect_lsnr()
{
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep lsnr |grep -v grep | sed -n 's/.*\(tnslsnr.*\).*/\1/p' | awk '{ print $2 }'| sed '/^\s*$/d' >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
#elif [ $(( (`date +%s` - `stat -L --format %Y $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log`) > (2880*60) )) -eq 1 ]
#then
#rm -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
#ps -ef | grep lsnr |grep -v grep | sed -n 's/.*\(tnslsnr.*\).*/\1/p' | awk '{ print $2 }'| sed '/^\s*$/d' >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
for LSNR in `ps -ef | grep lsnr |grep -v grep | sed -n 's/.*\(tnslsnr.*\).*/\1/p' | awk '{ print $2 }'| sed '/^\s*$/d'`
do
if [ $(grep -w "$LSNR" $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log | wc -l) -eq 1 ]
then
sleep 0
else
echo $LSNR >> $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
fi
done
fi
elif [ $when = post ]
then
ps -ef | grep lsnr |grep -v grep | sed -n 's/.*\(tnslsnr.*\).*/\1/p' | awk '{ print $2 }' | sed '/^\s*$/d' >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
sleep 0
fi
}
collect_asm()
{
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep pmon | sort -k9 | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'>$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
#elif [ $(( (`date +%s` - `stat -L --format %Y $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log`) > (2880*60) )) -eq 1 ]
#then
#rm -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
#ps -ef | grep pmon | sort -k9 | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'>$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
for ASM in `ps -ef | grep pmon | sort -k9 | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'`
do
if [ $(grep -w "$ASM" $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log | wc -l) -eq 1 ]
then
sleep 1
else
echo $ASM >> $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
fi
done
fi
elif [ $when = post ]
then
ps -ef | grep pmon | sort -k9 | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'>$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
sleep 0
fi
}
collect_crs()
{
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep crs | grep -v grep | grep -v tfa | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
#elif [ $(( (`date +%s` - `stat -L --format %Y $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log`) > (2880*60) )) -eq 1 ]
#then
#rm -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
#ps -ef | grep crs | grep -v grep | grep -v tfa | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
if [ $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) -gt 0 ]
then
sleep 1
else
ps -ef | grep crs | grep -v grep | grep -v tfa | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
fi
fi
elif [ $when = post ]
then
ps -ef | grep crs | grep -v grep | grep -v tfa | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
sleep 0
fi
}
#Portdaemon detection
collect_portutil()
{
ps -ef | grep "portdaemon.pl" | grep -v grep | grep port | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
}
display_pre_post()
{
if [ $when = pre ]
then
if [ $what = esm ] || [ $what = dma ]
then
if [ "$(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log)" = 0 ] || [ ! -s $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
echo -e ' \t ' "PRE stop" $what "running " ' \t ' ":" ' \t \t' "NO" | tee -a ${LOG}
else
echo -e ' \t ' "PRE stop" $what "running " ' \t ' ":" ' \t \t' "YES" | tee -a ${LOG}
fi
elif [ $what = asm ] || [ $what = lsnr ] || [ $what = portutil ]
then
if [ "$(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log)" = 0 ] || [ ! -s $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
echo "PRE stop" $what "running " ":" "NO" | tee -a ${LOG}
else
echo "PRE stop" $what "running " ":" $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) | tee -a ${LOG}
fi
elif [ $what = crs ]
then
if [ "$(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log)" -lt 3 ] || [ ! -s $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
echo "PRE stop" $what "running " ":" "NO" | tee -a ${LOG}
else
echo "PRE stop" $what "running " ":" "YES" | tee -a ${LOG}
fi
fi
elif [ $when = post ]
then
if [ $what = asm ] || [ $what = lsnr ] || [ $what = portutil ]
then
if [ "$(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log)" = 0 ] || [ ! -s $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
echo "POST stop" $what "running " ":" "NO" | tee -a ${LOG}
else
echo "POST stop" $what "running " ":" $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) | tee -a ${LOG}
fi
elif [ $what = crs ]
then
if [ "$(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log)" -lt 3 ] || [ ! -s $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
echo "POST stop" $what "running " ":" "NO" | tee -a ${LOG}
else
echo "POST stop" $what "running " ":" "YES" | tee -a ${LOG}
fi
fi
fi
}
stopped_status()
{
if [ $what = asm ] || [ $what = lsnr ] || [ $what = portutil ]
then
if [ "$(cat $OUTPUT_DIRECTORY/post_"$why"_"$what".log)" = 0 ] || [ ! -s $OUTPUT_DIRECTORY/post_"$why"_"$what".log ]
then
echo "yes" > $OUTPUT_DIRECTORY/stopped_$what.log
echo "OK : successfully stopped $what" | tee -a ${LOG}
else
echo "no" > $OUTPUT_DIRECTORY/stopped_$what.log
echo "ATTENTION : $what didn't stop. Please check" | tee -a ${LOG}
fi
elif [ $what = crs ]
then
if [ "$(cat $OUTPUT_DIRECTORY/post_"$why"_"$what".log)" -lt 3 ] || [ ! -s $OUTPUT_DIRECTORY/post_"$why"_"$what".log ]
then
echo "yes" > $OUTPUT_DIRECTORY/stopped_$what.log
echo "OK : successfully stopped $what" | tee -a ${LOG}
else
echo "no" > $OUTPUT_DIRECTORY/stopped_$what.log
echo "ATTENTION : $what didn't stop. Please check" | tee -a ${LOG}
fi
fi
}
stop_has()
{
export ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'`
#ORACLE_SID=`cat /etc/oratab | awk 'BEGIN{FS=":"}{print $1}' | grep ASM | grep -v "#"`
export ORAENV_ASK=NO >/dev/null;
. oraenv >/dev/null
crs_en_dis=`cat /etc/oracle/scls_scr/$(echo $(hostname) | cut -d. -f1)/root/crsstart | awk 'BEGIN{FS=":"}{print $1}'`
echo "CRS status : $crs_en_dis" >> ${LOG}; echo "" >> ${LOG}
crsctl stop has >> ${LOG} ; echo "" >> ${LOG}
sleep 10
if [ "$(crsctl check crs | grep online || crsctl check crs | grep healthy | wc -l)" -eq 0 ]
then
echo "Clusterware Services stopped" >> ${LOG}; echo "" >> ${LOG}
crsctl disable has | tee -a ${LOG}
crs_en_dis=`cat /etc/oracle/scls_scr/$(echo $(hostname) | cut -d. -f1)/root/crsstart | awk 'BEGIN{FS=":"}{print $1}'`
echo "CRS status : $crs_en_dis" >> ${LOG}; echo "" >> ${LOG}
echo "CRS is now disabled" >> ${LOG}
else
echo "ATTENTION : Clusterware services do not appear to have stopped properly" >> ${LOG} ; echo "" >> ${LOG}
echo "ATTENTION : CRS not disabled" >> ${LOG} ; echo "" >> ${LOG}
fi
}
stop_crs()
{
ORACLE_SID=`cat /etc/oratab | awk 'BEGIN{FS=":"}{print $1}' | grep CRS | grep -v "#"`
export ORAENV_ASK=NO >/dev/null;
. oraenv >/dev/null
crsctl stop crs >> ${LOG} ; echo "" >> ${LOG}
sleep 10
if [ "$(crsctl check crs | grep online || crsctl check crs | grep healthy | wc -l)" -eq 0 ]
then
echo "Clusterware Services stopped" >> ${LOG}; echo "" >> ${LOG}
crsctl disable crs | tee -a ${LOG}
crs_en_dis=`cat /etc/oracle/scls_scr/$(echo $(hostname) | cut -d. -f1)/root/crsstart | awk 'BEGIN{FS=":"}{print $1}'`
echo "CRS status : $crs_en_dis" >> ${LOG}; echo "" >> ${LOG}
echo "CRS is now disabled" >> ${LOG}
else
echo "ATTENTION : Clusterware services do not appear to have stopped properly" >> ${LOG} ; echo "" >> ${LOG}
echo "ATTENTION : CRS not disabled" >> ${LOG} ; echo "" >> ${LOG}
fi
}
stop_portutil()
{
# Initialise any previous Portdaemon Config files
if [[ -f $OUTPUT_DIRECTORY/Portdaemon_config.txt ]]; then
rm $OUTPUT_DIRECTORY/Portdaemon_config.txt
fi
if [[ -f $OUTPUT_DIRECTORY/Portdaemon_stop.sh ]]; then
rm $OUTPUT_DIRECTORY/Portdaemon_stop.sh
fi
# Capture all Runtime Portdaemon parameters for running Portdaemon processes
ps -ef | grep "portdaemon.pl" | grep -v grep | grep port | while read PORT_CONFIG
do
PORT_USER=`echo $PORT_CONFIG | awk '{ print $1 }'`
#PORT_PROC=`echo $PORT_CONFIG | grep -o '..................................................portdaemon.pl' | awk '{ print $NF }'`
PORT_PROC=`echo $PORT_CONFIG | sed -n 's/.*\(..................................................portdaemon.pl\).*/\1/p' | awk '{ print $NF }'| grep -v "\.\.\.\.portdaemon.pl"`
PORT_DIR=`dirname $PORT_PROC`
PORT_NUMB=`echo $PORT_CONFIG | awk '{ print $NF }'`
echo "${PORT_USER}:${PORT_PROC}:${PORT_NUMB}" >> $OUTPUT_DIRECTORY/Portdaemon_config.txt
# Stop the Portdaemon for this POrt ..
echo "su - $PORT_USER -c 'sh ${PORT_DIR}/stop_port_daemon ${PORT_NUMB}'" >> $OUTPUT_DIRECTORY/Portdaemon_stop.sh
done
# Loop through and stop all detected Portdaemon(s)
if [[ -f $OUTPUT_DIRECTORY/Portdaemon_stop.sh ]]; then
chmod 744 $OUTPUT_DIRECTORY/Portdaemon_stop.sh
sh $OUTPUT_DIRECTORY/Portdaemon_stop.sh > /dev/null 2>&1
fi
}
stop_tfa()
{
if [[ "$(ps -ef | grep tfa_home | grep -v grep | wc -l)" -ne 0 ]]; then
if [[ -f /etc/init.d/init.tfa ]]; then
/etc/init.d/init.tfa stop > /dev/null 2>&1
fi
fi
}
disable_standalone_autostart()
{
DDMMYY=`date '+%m%d%y_%H:%M:%S'`
if [[ -f /etc/oratab ]]; then
oracred=`ls -l /etc/oratab | awk '{ print $3":"$4 }'`
if [[ -f /etc/oratab_bl_backup ]]; then
rm -rf /etc/oratab_bl_backup
fi
cp -p /etc/oratab $OUTPUT_DIRECTORY/oratab_${DDMMYY}
mv /etc/oratab /etc/oratab_bl_backup
if [[ -f /etc/oratab_bl_backup ]]; then
sed '/^$/d' /etc/oratab_bl_backup | grep -v "^#" | sed 's/:Y$/:N/g' | sed 's/:M$/:N/g' | sed 's/:Y:/:N:/g' | sed 's/:A$/:N/g' > /etc/oratab
if [[ -f /etc/oratab ]]; then
chown $oracred /etc/oratab
fi
fi
fi
if [[ -f /etc/lsnrtab ]]; then
oracred=`ls -l /etc/lsnrtab | awk '{ print $3":"$4 }'`
if [[ -f /etc/lsnrtab_bl_backup ]]; then
rm -rf /etc/lsnrtab_bl_backup
fi
cp -p /etc/lsnrtab $OUTPUT_DIRECTORY/lsnrtab_${DDMMYY}
mv /etc/lsnrtab /etc/lsnrtab_bl_backup
if [[ -f /etc/lsnrtab_bl_backup ]]; then
sed '/^$/d' /etc/lsnrtab_bl_backup | grep -v "^#" | sed 's/:Y$/:N/g' > /etc/lsnrtab
if [[ -f /etc/lsnrtab ]]; then
chown $oracred /etc/lsnrtab
fi
fi
fi
}
stop_rh7_dbserv()
{
if [[ -f /etc/redhat-release ]] && [[ "$RH_VER" == 7.* ]]; then
export RH7_ORASTR=`systemctl status oracle_db.service | grep "Active: " | awk '{ print $1,$2,$3 }'`
#echo " RH_VER => $RH_VER :: RH7_ORASTR => $RH7_ORASTR "
echo "" >> $LOG
echo "########################################################################" >> $LOG
echo "`date`" >> $LOG
echo "Note: RedHat7 Oracle Service: oracle_db.service will be stopped here ... " >> $LOG
echo "" >> $LOG
echo "PRE Shutdown Status: " >> $LOG
systemctl status oracle_db.service | grep "Active: " >> $LOG
echo "" >> $LOG
echo " => Attempting to Stop it ..." >> $LOG
echo "" >> $LOG
systemctl stop oracle_db.service >> $LOG
sleep 3
echo "POST Shutdown Status: " >> $LOG
systemctl status oracle_db.service | grep "Active: " >> $LOG
echo "########################################################################" >> $LOG
echo "" >> $LOG
fi
}
# Remove the temporary log file
rm -f $OUTPUT_DIRECTORY/stop_crs.log
# Assign a new log file
LOG=$OUTPUT_DIRECTORY/stop_crs.log;
#INSERT INTO REPOSITORY DATABASE
#ASSIGNING THE OUTPUT VARIABLES
assign_log()
{
if [ -s $OUTPUT_DIRECTORY/post_start_crs.log ]
then
crs_output=`cat $OUTPUT_DIRECTORY/post_start_crs.log`
else
crs_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_asm.log ]
then
asm_output=`cat $OUTPUT_DIRECTORY/post_start_asm.log`
else
asm_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_esm.log ]
then
esm_agent_output=`cat $OUTPUT_DIRECTORY/post_start_esm.log`
else
esm_agent_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_dma.log ]
then
dma_agent_output=`cat $OUTPUT_DIRECTORY/post_start_dma.log`
else
dma_agent_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_lsnr.log ]
then
listener_output=`cat $OUTPUT_DIRECTORY/post_start_lsnr.log`
else
listener_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_dbinst.log ]
then
db_instance_output=`cat $OUTPUT_DIRECTORY/post_start_dbinst.log`
else
db_instance_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_dbopen.log ]
then
db_open_output=`cat $OUTPUT_DIRECTORY/post_start_dbopen.log`
else
db_open_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_dbopenro.log ]
then
db_openro_output=`cat $OUTPUT_DIRECTORY/post_start_dbopenro.log`
else
db_openro_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_dbmount.log ]
then
db_mount_output=`cat $OUTPUT_DIRECTORY/post_start_dbmount.log`
else
db_mount_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_dbservices.log ]
then
service_alignment_output=`cat $OUTPUT_DIRECTORY/post_start_dbservices.log`
else
service_alignment_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_mrp.log ]
then
mrp_output=`cat $OUTPUT_DIRECTORY/post_start_mrp.log`
else
mrp_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_agent.log ]
then
oem_agent_output=`cat $OUTPUT_DIRECTORY/post_start_agent.log`
else
oem_agent_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_portutil.log ]
then
port_utility_output=`cat $OUTPUT_DIRECTORY/post_start_portutil.log`
else
port_utility_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_fgl.log ]
then
foglight_output=`cat $OUTPUT_DIRECTORY/post_start_fgl.log`
else
foglight_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_osw.log ]
then
os_watcher_output=`cat $OUTPUT_DIRECTORY/post_start_osw.log`
else
os_watcher_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_usb.log ]
then
usb_output=`cat $OUTPUT_DIRECTORY/post_start_usb.log`
else
usb_output="no_status"
fi
if [ -s /oracle/dba/foglight/fgl_5/bin/fglam ]
then
fglam_output=`/oracle/dba/foglight/fgl_5/bin/fglam --check-connection`
else
fglam_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/server_type.log ]
then
instance_type=`cat $OUTPUT_DIRECTORY/server_type.log`
else
instance_type="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/version_executed_status.log ]
then
script_version=`cat $OUTPUT_DIRECTORY/version_executed_status.log`
else
script_version="no_status"
fi
}
insert_repdb()
{
for what in dma esm lsnr asm crs
do
if [ -f $OUTPUT_DIRECTORY/stopped_$what.log ]
then
if [ "$(cat $OUTPUT_DIRECTORY/stopped_$what.log)" = yes ]
then
eval var_$what="success"
fi
if [ "$(cat $OUTPUT_DIRECTORY/stopped_$what.log)" = no ]
then
eval var_$what="failure"
fi
else
eval var_$what="no_status"
fi
done
if [[ $server_type = "rac_10g" ]]
then
var_lsnr="na"
var_asm="na"
elif [[ $server_type = "norac_asm10" ]] || [[ $server_type = "norac_noasm" ]]
then
var_dma="na"
var_esm="na"
var_lsnr="na"
var_asm="na"
var_crs="na"
fi
for what in fgl osw agent portutil mrp dbinst
do
eval var_$what="na"
done
#PREPARING THE INSERT STATEMENT
if [ $(cat /etc/oratab | grep oracle | grep -v -i asm | grep -v -i crs | grep -v -i oem | grep -v "#" | awk 'BEGIN{FS=":"}{print $1}' | head -1 | wc -l) = 1 ]
then
export ORACLE_SID=`cat /etc/oratab | grep oracle | grep -v -i asm | grep -v -i crs | grep -v -i oem | grep -v "#" | awk 'BEGIN{FS=":"}{print $1}' | head -1`
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
$ORACLE_HOME/bin/sqlplus -s OSH_SEH/dbaas_operations1@SUNDVD94 << EOFSTATUS
set echo off;
set head off;
set feedback off;
insert into OSH_SEH.dbss_log (DBSS_ID,
SCRIPT_VERSION,
INSTANCE_TYPE,
STOP_OR_START,
CRS_OR_DB,
SERVER_NAME,
SERVER_TIMESTAMP,
CRS,
ASM,
LISTENER,
DB_INSTANCE,
MRP_PROCESS,
ESM_AGENT,
DMA_AGENT,
OEM_AGENT,
PORT_UTILITY,
FOGLIGHT,
OS_WATCHER,
SENT_MAIL,
CRS_OUTPUT,
ASM_OUTPUT,
LISTENER_OUTPUT,
DB_INSTANCE_OUTPUT,
DB_OPEN_OUTPUT,
DB_OPENRO_OUTPUT,
DB_MOUNT_OUTPUT,
SERVICE_ALIGNMENT_OUTPUT,
MRP_OUTPUT,
ESM_AGENT_OUTPUT,
DMA_AGENT_OUTPUT,
OEM_AGENT_OUTPUT,
PORT_UTILITY_OUTPUT,
FOGLIGHT_OUTPUT,
OS_WATCHER_OUTPUT,
USB_OUTPUT,
FGLAM_OUTPUT)
values (DBSS_LOG_SEQ.nextval,
'$script_version',
'$instance_type',
'stop',
'crs',
'$(hostname -f)',
'$timevalue',
'$var_crs',
'$var_asm',
'$var_lsnr',
'$var_dbinst',
'$var_mrp',
'$var_esm',
'$var_dma',
'$var_agent',
'$var_portutil',
'$var_fgl',
'$var_osw',
0,
'$crs_output',
'$asm_output',
'$listener_output',
'$db_instance_output',
'$db_open_output',
'$db_openro_output',
'$db_mount_output',
'$service_alignment_output',
'$mrp_output',
'$esm_agent_output',
'$dma_agent_output',
'$oem_agent_output',
'$port_utility_output',
'$foglight_output',
'$os_watcher_output',
'$usb_output',
'$fglam_output');
commit;
EOFSTATUS
fi
}
echo "" >> ${LOG};
echo "************************* START TIME : $(date) ************************" >> ${LOG}; echo "" >> ${LOG}
case $server_type in
"rac_12c")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "---------------------------> THIS IS A 12c CLUSTERWARE SYSTEM <------------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
#if [ "$(ps -ef | grep pmon | grep -v grep |grep -v "+ASM" | grep -v onitor | wc -l)" -eq 0 ]
#then
why=stop;
for what in dma esm lsnr asm crs portutil
do
when=pre; collect_$what; display_pre_post
done
echo "";
echo "Stopping High Availability Services"; echo "";
stop_has
echo ""
echo "Stopping Any Portdaemon Services if any "; echo "";
stop_portutil
echo " "
if [[ $OS != "AIX" ]]; then
echo "Waiting for 2 minutes to allow all the CRS processes to go down"
for i in {1..2}
do
echo -n -e ' '
for i in {1..60}
do
echo -n ".";sleep 1;
done
echo "";
done
else
echo "Waiting for 2 minutes to allow all the CRS processes to go down"
i=1
while [[ $i -le 60 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
echo ""
i=1
while [[ $i -le 60 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
fi
for what in lsnr asm crs portutil
do
when=post; collect_$what; display_pre_post
done
# Stop TFA if running
stop_tfa
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in lsnr asm crs portutil
do
stopped_status
done
echo ""
if [ "$(cat $OUTPUT_DIRECTORY/stopped_lsnr.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_asm.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_crs.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_portutil.log)" = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_stop_crs_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
echo ""
else
echo "0" > $OUTPUT_DIRECTORY/bl_stop_crs_flag.log
echo ""
echo "ATTENTION : Some services didn't stop. Please check" | tee -a ${LOG}
echo ""
fi
assign_log
insert_repdb
#else
#echo "";
#echo "ATTENTION : Please stop Oracle instances using 'stop.ksh' and then rerun this script" ;echo ""
#fi
echo "**************************************************"
;;
"rac_11g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "---------------------------> THIS IS A 11g CLUSTERWARE SYSTEM <------------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
#if [ "$(ps -ef | grep pmon | grep -v grep |grep -v "+ASM" | grep -v onitor | wc -l)" -eq 0 ]
#then
why=stop;
for what in dma esm lsnr asm crs portutil
do
when=pre; collect_$what; display_pre_post
done
echo "";
echo "Stopping High Availability Services"; echo "";
stop_has
echo ""
echo "";
echo "Stopping Any Portdaemon Services if any "; echo "";
stop_portutil
echo " "
if [[ $OS != "AIX" ]]; then
echo "Waiting for 2 minutes to allow all the CRS processes to go down"
for i in {1..2}
do
echo -n -e ' '
for i in {1..60}
do
echo -n ".";sleep 1;
done
echo "";
done
else
echo "Waiting for 2 minutes to allow all the CRS processes to go down"
i=1
while [[ $i -le 60 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
echo ""
i=1
while [[ $i -le 60 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
fi
for what in lsnr asm crs portutil
do
when=post; collect_$what; display_pre_post
done
# Stop TFA if running
stop_tfa
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in lsnr asm crs portutil
do
stopped_status
done
echo ""
if [ "$(cat $OUTPUT_DIRECTORY/stopped_lsnr.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_asm.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_crs.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_portutil.log)" = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_stop_crs_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
echo ""
else
echo "0" > $OUTPUT_DIRECTORY/bl_stop_crs_flag.log
echo ""
echo "ATTENTION : Some services didn't stop. Please check" | tee -a ${LOG}
echo ""
fi
assign_log
insert_repdb
#else
#echo "";
#echo "ATTENTION : Please stop Oracle instances using 'stop.ksh' and then rerun this script" ;echo ""
#fi
echo "**************************************************"
;;
"rac_10g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "---------------------------> THIS IS A 10g CLUSTERWARE SYSTEM <------------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
#if [ "$(ps -ef | grep pmon | grep -v grep |grep -v "+ASM" | grep -v onitor | wc -l)" -eq 0 ]
#then
why=stop;
for what in dma esm crs portutil
do
when=pre; collect_$what; display_pre_post
done
echo "";
echo "Stopping CRS"; echo "";
stop_crs
echo ""
echo "";
echo "Stopping Any Portdaemon Services if any "; echo "";
stop_portutil
if [[ $OS != "AIX" ]]; then
echo "Waiting for 2 minutes to allow all the CRS processes to go down"
for i in {1..2}
do
echo -n -e ' '
for i in {1..60}
do
echo -n ".";sleep 1;
done
echo "";
done
else
echo "Waiting for 2 minutes to allow all the CRS processes to go down"
i=1
while [[ $i -le 60 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
echo ""
i=1
while [[ $i -le 60 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
fi
for what in crs portutil
do
when=post; collect_$what; display_pre_post
done
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in crs portutil
do
stopped_status
done
echo ""
if [ "$(cat $OUTPUT_DIRECTORY/stopped_crs.log)" = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_stop_crs_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
echo ""
else
echo "0" > $OUTPUT_DIRECTORY/bl_stop_crs_flag.log
echo ""
echo "ATTENTION : Some services didn't stop. Please check" | tee -a ${LOG}
echo ""
fi
assign_log
insert_repdb
#else
#echo "";
#echo "ATTENTION : Please stop Oracle instances using 'stop.ksh' and then rerun this script" ;echo ""
#fi
echo "**************************************************"
;;
"norac_asm12c")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "-------------------------> THIS IS A NON-RAC SYSTEM BUT WITH ASM 12c <----------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
#if [ "$(ps -ef | grep pmon | grep -v grep |grep -v "+ASM" | grep -v onitor | wc -l)" -eq 0 ]
#then
if [ "$(cat /etc/oratab | grep "^+ASM:" | wc -l)" -eq 1 ]
then
why=stop;
for what in dma esm lsnr asm crs portutil
do
when=pre; collect_$what; display_pre_post
done
echo "";
echo "Stopping High Availability Services"; echo "";
stop_has
echo " "
echo "";
echo "Stopping Any Portdaemon Services if any "; echo "";
stop_portutil
if [[ $OS != "AIX" ]]; then
echo "Waiting for 2 minutes to allow all the CRS processes to go down"
for i in {1..2}
do
echo -n -e ' '
for i in {1..60}
do
echo -n ".";sleep 1;
done
echo "";
done
else
echo "Waiting for 2 minutes to allow all the CRS processes to go down"
i=1
while [[ $i -le 60 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
echo ""
i=1
while [[ $i -le 60 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
fi
for what in lsnr asm crs portutil
do
when=post; collect_$what; display_pre_post
done
# Stop TFA if running
stop_tfa
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in lsnr asm crs portutil
do
stopped_status
done
echo ""
if [ "$(cat $OUTPUT_DIRECTORY/stopped_crs.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_asm.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_lsnr.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_portutil.log)" = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_stop_crs_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
echo ""
else
echo "0" > $OUTPUT_DIRECTORY/bl_stop_crs_flag.log
echo ""
echo "ATTENTION : Some services didn't stop. Please check" | tee -a ${LOG}
echo ""
fi
else
echo "";
echo " No +ASM entry found in /etc/oratab -> This script has no relevance to this server" >> ${LOG}; echo "" >> ${LOG}
fi
assign_log
insert_repdb
#else
#echo "ATTENTION : Please stop Oracle instances using 'stop.ksh' and then rerun this script" >> ${LOG}; echo "" >> ${LOG}
#fi
echo "**************************************************"
;;
"norac_asm11g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "-------------------------> THIS IS A NON-RAC SYSTEM BUT WITH ASM 11g <----------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
#if [ "$(ps -ef | grep pmon | grep -v grep |grep -v "+ASM" | grep -v onitor | wc -l)" -eq 0 ]
#then
if [ "$(cat /etc/oratab | grep "^+ASM:" | wc -l)" -eq 1 ]
then
why=stop;
for what in dma esm lsnr asm crs portutil
do
when=pre; collect_$what; display_pre_post
done
echo "";
echo "Stopping High Availability Services"; echo "";
stop_has
echo " "
echo "";
echo "Stopping Any Portdaemon Services if any "; echo "";
stop_portutil
if [[ $OS != "AIX" ]]; then
echo "Waiting for 2 minutes to allow all the CRS processes to go down"
for i in {1..2}
do
echo -n -e
for i in {1..60}
do
echo -n ".";sleep 1;
done
echo "";
done
else
echo "Waiting for 2 minutes to allow all the CRS processes to go down"
i=1
while [[ $i -le 60 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
echo ""
i=1
while [[ $i -le 60 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
fi
for what in lsnr asm crs portutil
do
when=post; collect_$what; display_pre_post
done
# Stop TFA if running
stop_tfa
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in lsnr asm crs portutil
do
stopped_status
done
echo ""
if [ "$(cat $OUTPUT_DIRECTORY/stopped_crs.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_asm.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_lsnr.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/stopped_portutil.log)" = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_stop_crs_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
echo ""
else
echo "0" > $OUTPUT_DIRECTORY/bl_stop_crs_flag.log
echo ""
echo "ATTENTION : Some services didn't stop. Please check" | tee -a ${LOG}
echo ""
fi
else
echo "";
echo " No +ASM entry found in /etc/oratab -> This script has no relevance to this server" >> ${LOG}; echo "" >> ${LOG}
fi
assign_log
insert_repdb
#else
#echo "ATTENTION : Please stop Oracle instances using 'stop.ksh' and then rerun this script" >> ${LOG}; echo "" >> ${LOG}
#fi
echo "**************************************************"
;;
"norac_asm10g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "--------------------------> THIS IS A NON-RAC SYSTEM BUT WITH ASM 10g <---------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
echo " This script has no relevance to this server" | tee -a ${LOG}; echo "" | tee -a ${LOG}
echo "1" > $OUTPUT_DIRECTORY/bl_stop_crs_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
echo ""
assign_log
insert_repdb
;;
"norac_noasm")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "--------------------------> THIS IS A NON-RAC & NON-ASM SYSTEM <----------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
echo " This script will only check/stop any Port daemons that may be running and if RH7 system -> stop db service, disable db/lsnr Autostart - otherwise it has no relevance to this server " | tee -a ${LOG}; echo "" | tee -a ${LOG}
why=stop;
for what in portutil
do
when=pre; collect_$what; display_pre_post
done
echo " "
echo "";
echo "Stopping Any Portdaemon Services if any "; echo "";
stop_portutil
for what in portutil
do
when=post; collect_$what; display_pre_post
done
if [[ "$RH_VER" == 7.* ]]; then
echo "";
echo "RedHat7 ... Stopping RH7 db Service "
stop_rh7_dbserv
fi
echo "";
echo "Disabling Auto-start for this standalone host : "; echo "";
disable_standalone_autostart
echo "New content of ORATAB on this host "; echo "";
if [[ -f /etc/oratab ]]; then
echo "`cat /etc/oratab `"
fi
echo "";
echo "New content of LSNRTAB on this host : "; echo "";
if [[ -f /etc/lsnrtab ]]; then
echo "`cat /etc/lsnrtab `"
fi
echo "";
echo "1" > $OUTPUT_DIRECTORY/bl_stop_crs_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
echo ""
assign_log
insert_repdb
;;
*)
echo "Invalid Selection"
esac
chmod 777 $OUTPUT_DIRECTORY/pre_stop*.log 1> /dev/null 2>&1
chmod 777 $OUTPUT_DIRECTORY/post_stop*.log 1> /dev/null 2>&1
chmod 777 $OUTPUT_DIRECTORY/stopped*.log 1> /dev/null 2>&1
chmod 777 $OUTPUT_DIRECTORY/stop_crs*.log 1> /dev/null 2>&1
chmod 777 $OUTPUT_DIRECTORY/bl_stop*.log 1> /dev/null 2>&1
#chown oracle:dba $OUTPUT_DIRECTORY/pre_stop*.log 1> /dev/null 2>&1
#chown oracle:dba $OUTPUT_DIRECTORY/post_stop*.log 1> /dev/null 2>&1
#chown oracle:dba $OUTPUT_DIRECTORY/stopped*.log 1> /dev/null 2>&1
#chown oracle:dba $OUTPUT_DIRECTORY/stop_crs*.log 1> /dev/null 2>&1
#chown oracle:dba $OUTPUT_DIRECTORY/bl_stop*.log 1> /dev/null 2>&1
if ls $OUTPUT_DIRECTORY/Portdaemon* 1> /dev/null 2>&1; then
chmod 777 $OUTPUT_DIRECTORY/Portdaemon*
#chown oracle:dba $OUTPUT_DIRECTORY/Portdaemon*
fi
filename=$(echo $(hostname) | cut -d. -f1)_$(date '+%m%d%Y_%H%M%S')
mv ${LOG} $OUTPUT_DIRECTORY/stop_crs_$filename.log
echo ""
echo ""
echo "************************************************************************************************************";
echo "Please check the detailed CRS STOP report at $OUTPUT_DIRECTORY/stop_crs_$filename.log"
echo "************************************************************************************************************";
echo ""
echo ""
echo " INFO: Remaining "ora" processes on this host are ... "
echo "`ps -ef | grep ora | grep -v grep | grep -v "^root " | grep -v pbrun | grep -v "ksh"`"
echo ""
#################################################################
# Modified by EMEA OracleDBA Team for enhancements & automation #
# DEC 2016 #
#################################################################
# #
# USAGE : To be executed as oracle user #
# (pbrun to oracle or pboracle) #
# #
# Manual execution #
# sh bl_start.ksh #
# #
# Via job scheduler tools and by-passing the prompt #
# sh bl_start.ksh y #
# #
#---------------------------------------------------------------#
# //Generic information about the batch of scripts developed// #
# bl_status.ksh #
# bl_stop.ksh #
# bl_stop_crs.ksh #
# bl_start_crs.ksh #
# bl_start.ksh #
# #
# Versions/Combinations Supported #
# Clustware 12c #
# Clustware 11g #
# Clustware 10g #
# NON-RAC with ASM 11g #
# NON-RAC with ASM 10g #
# NON-RAC & NON-ASM #
# #
# Components in scope #
# Clusterware #
# ASM Instance #
# Database Instance #
# Cluster Listener #
# Local Listener #
# Manager Recovery Process #
# GoldenGate Replication #
# Port Utility #
# Enterprise Manager Agent #
# OSWatcher Utility #
# Foglight Monitoring Agent #
# Filesystem #
# Rawdisk #
# #
#################################################################
export OS=`uname -a | awk '{ print $1 }'`
eval timevalue=`date '+%m%d%Y_%H%M%S'`
eval filename=$(echo $(hostname) | cut -d. -f1)_$timevalue
# Check if user really wants to START the services
# CHECK IF MYSQL DATABASE SERVER
if [ "$(ps -ef | grep -i mysql | grep -v grep | wc -l)" -ge 1 ]
then
echo "This is a MySQL Database Server"
exit 0
fi
if [ $# -eq 0 ]
then
read -r -p "Are you sure you want to START the Oracle services ? [y/n] " response
if [ $response = y ]
then
echo ""; echo "Please wait while the services are started up... "; echo ""
export oracred=oracle:dba
export oraowner=oracle
export oragroup=dba
else
exit; >/dev/null
fi
elif [ $1 == y ]
then
echo ""; echo "Please wait while the services are started up... "; echo ""
#Handle second Argument
if [[ ! -z $2 ]]; then
export oracred=$2
export oraowner=`echo $oracred | cut -d":" -f1 -s`
export oragroup=`echo $oracred | cut -d":" -f2 -s`
echo "Oracle Ownership Captured ARGUMENTS ...
oracred=$oracred
oraowner=$oraowner
oragroup=$oragroup
"
else
export oracred=oracle:dba
export oraowner=oracle
export oragroup=dba
fi
else
exit; >/dev/null
fi
# CHECK IF THE USER IS Correct as per Arg#2
echo " "
if [ $(whoami) != "${oraowner}" ]
then
echo "ATTENTION : Please execute this script as ${oraowner} user"
exit 0;
fi
# SCRIPT AND OUTPUT DIRECTORIES INITIALIZATION
if [[ ${oraowner} = "oracle" ]]; then
if [[ -d /oracle/dba/output/generic ]]; then
OUTPUT_DIRECTORY=/oracle/dba/output/generic
else
OUTPUT_DIRECTORY=/var/bl_ora/log
if [[ ! -d $OUTPUT_DIRECTORY ]]; then
echo "OUTPUT_DIRECTORY: $OUTPUT_DIRECTORY was not found on this server ... Exiting"
exit 0
fi
fi
else
if [[ -d /oracle/dba/output/generic ]]; then
OUTPUT_DIRECTORY=/oracle/dba/output/generic/${oraowner}
else
OUTPUT_DIRECTORY=/var/bl_ora/log/${oraowner}
if [[ ! -d $OUTPUT_DIRECTORY ]]; then
echo "OUTPUT_DIRECTORY: $OUTPUT_DIRECTORY was not found on this server ... Exiting"
exit 0
fi
fi
fi
# Remove the temporary log file
rm -f $OUTPUT_DIRECTORY/start.log
# Assign a new log file
LOG=$OUTPUT_DIRECTORY/start.log; echo "" >> ${LOG};
# Check the server type
export server_type=$(cat $OUTPUT_DIRECTORY/server_type.log)
# Collecting service runnning information
collect_lsnr()
{
#ps -ef | grep lsnr | grep "^.*${oraowner} " | grep -v grep | grep -oP '(?<=tnslsnr )\w+' >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep lsnr | grep "^.*${oraowner} " | grep -v grep | sed -n 's/.*\(tnslsnr.*\).*/\1/p' | awk '{ print $2 }' | sed '/^\s*$/d' >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
}
collect_mrp()
{
ps -ef | grep mrp | sort -k9 | grep "^.*${oraowner} " | grep -v grep | awk '{ print $NF }' | cut -d"_" -f3,4 -s>$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
}
collect_dbinst()
{
ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v ASM | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s>$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
}
collect_dbservices()
{
rm -f $OUTPUT_DIRECTORY/"$when"_"$why"_dbservices.log
while read data
do
export ORACLE_DB=$(echo $data | awk 'BEGIN{FS=":"}{print $1}') >/dev/null
export ORACLE_SID=$(echo $data | awk 'BEGIN{FS=":"}{print $2}') >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
echo $ORACLE_DB:$ORACLE_SID":"$(srvctl status service -d $ORACLE_DB | grep $ORACLE_SID | grep -i "is running" | awk '{ print $2 }') >> $OUTPUT_DIRECTORY/"$when"_"$why"_dbservices.log
done < $OUTPUT_DIRECTORY/db:inst.log
}
collect_asm()
{
ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'>$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
}
collect_agent()
{
sleep 5
ORACLE_SID=`cat /etc/oratab | awk 'BEGIN{FS=":"}{print $1}' | grep OEM | grep -v "^#"`
export ORAENV_ASK=NO >/dev/null;
if [[ ! -z $ORACLE_SID ]]; then
. oraenv >/dev/null
if [[ -f $ORACLE_HOME/bin/emctl ]]; then
emctl status agent | grep "Agent is Running and Ready" | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
fi
fi
}
collect_fgl()
{
sleep 10
ps -ef | grep -i foglight | grep "^.*${oraowner} " | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
}
collect_portutil()
{
ps -ef | grep "portdaemon.pl" | grep -v grep | grep port | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
}
# OGG Support
##############
collect_ogg()
{
ps -ef | grep -v grep | grep "mgr PARAMFILE" | grep "^.*${oraowner} " | sed -n 's/.*\(....................................................................\/....prm \).*/\1/p' | awk '{ print $NF }' | grep -v "\.\.\.\.mgr.prm" >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
}
# DBFS Support
###############
collect_dbfs()
{
ps -ef | grep -v grep | grep "dbfs_client" | grep "^.*${oraowner} " | sed -n 's/.*\(................................................................\/bin\/dbfs_client\).*/\1/p' | awk '{ print $NF }' | grep -v "\.\.\.\.dbfs_client" >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
}
started_status()
{
rm -f $OUTPUT_DIRECTORY/diff_file; rm -f $OUTPUT_DIRECTORY/diff_1; rm -f $OUTPUT_DIRECTORY/diff_2
if [[ -f $OUTPUT_DIRECTORY/pre_stop_$what.log ]]; then
cat $OUTPUT_DIRECTORY/pre_stop_$what.log | sort > $OUTPUT_DIRECTORY/diff_1;
fi
if [[ -f $OUTPUT_DIRECTORY/post_start_$what.log ]]; then
cat $OUTPUT_DIRECTORY/post_start_$what.log | sort > $OUTPUT_DIRECTORY/diff_2;
fi
if [[ -f $OUTPUT_DIRECTORY/diff_2 ]]; then
diff -b -i -w $OUTPUT_DIRECTORY/diff_1 $OUTPUT_DIRECTORY/diff_2 > $OUTPUT_DIRECTORY/diff_file
chown $oracred $OUTPUT_DIRECTORY/diff_file
chmod 755 $OUTPUT_DIRECTORY/diff_file
fi
if [ ! -s $OUTPUT_DIRECTORY/diff_file ]
then
echo "yes" > $OUTPUT_DIRECTORY/started_$what.log
echo "OK : pre-post status matches for $what"
else
if [[ $what == "fgl" ]]; then
if [[ -f $OUTPUT_DIRECTORY/post_start_$what.log ]]; then
if [[ $(cat $OUTPUT_DIRECTORY/post_start_$what.log) -gt 0 ]]; then
echo "yes" > $OUTPUT_DIRECTORY/started_$what.log
echo "OK : pre-post status matches for $what"
else
echo "no" > $OUTPUT_DIRECTORY/started_$what.log
echo "ATTENTION : $what didn't start. Please check"
fi
fi
else
echo "no" > $OUTPUT_DIRECTORY/started_$what.log
echo "ATTENTION : $what didn't start. Please check"
fi
fi
}
service_alignment()
{
rm -f $OUTPUT_DIRECTORY/diff_file; rm -f $OUTPUT_DIRECTORY/diff_1; rm -f $OUTPUT_DIRECTORY/diff_2
cat $OUTPUT_DIRECTORY/pre_stop_dbservices.log | sort > $OUTPUT_DIRECTORY/diff_1;
cat $OUTPUT_DIRECTORY/post_start_dbservices.log | sort > $OUTPUT_DIRECTORY/diff_2;
diff -b -i -w $OUTPUT_DIRECTORY/diff_1 $OUTPUT_DIRECTORY/diff_2 > $OUTPUT_DIRECTORY/diff_file
chown $oracred $OUTPUT_DIRECTORY/diff_file
chmod 755 $OUTPUT_DIRECTORY/diff_file
if [ ! -s $OUTPUT_DIRECTORY/diff_file ]
then
echo "" >> ${LOG}
echo "***************************** DB SERVICES ************************" >> ${LOG}
echo "" >> ${LOG}
echo "OK : pre-post status matches for DB service alignment" >> ${LOG}
echo "" >> ${LOG}
echo ""
echo "OK : pre-post status matches for DB service alignment"
echo ""
else
echo ""
#echo "ATTENTION : Please verify DB service alignment"
#echo "pre-stop status (db:instance:service) is available at $OUTPUT_DIRECTORY/pre_stop_dbservices.log"
#echo ""
echo "Attempting to Fix DB service alignment mismatch on this node"
echo ""
echo "***************************** DB SERVICES ************************" >> ${LOG}
echo "" >> ${LOG}
echo "Attempting to Fix DB service alignment mismatch on this node" >> ${LOG}
echo "" >> ${LOG}
# Try to fix the mis-alignment of services on this node per database (ORACLE_DB)
cat $OUTPUT_DIRECTORY/diff_file | grep "^<" |awk '{ print $2 }' | cut -d":" -f1 | sort -u | while read ORACLE_DB
do
export ORACLE_DB >/dev/null
export ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep $ORACLE_DB | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s | tail -1` >/dev/null
export ORAENV_ASK=NO >/dev/null
if [[ ! -z $ORACLE_SID ]]; then
. oraenv >/dev/null
fi
export LOCAL_NODE=`hostname -s`
if [[ "$server_type" == rac* ]]; then
srvctl status service -d $ORACLE_DB | grep $ORACLE_SID | grep -i "is running" | awk '{ print $2 }' | while read SERV_NAME
do
echo "srvctl stop service -d $ORACLE_DB -s $SERV_NAME -n $LOCAL_NODE" >> ${LOG}
srvctl stop service -d $ORACLE_DB -s $SERV_NAME -n $LOCAL_NODE >> ${LOG}
done
# Read pre_stop_dbservices.log and start only those services
cat $OUTPUT_DIRECTORY/pre_stop_dbservices.log | grep $ORACLE_DB | while read SERV_LINE
do
DB_SERV_LIST=`echo $SERV_LINE | cut -d":" -f3 -s`
for DB_SERV_NAME in $DB_SERV_LIST
do
echo "srvctl enable service -d $ORACLE_DB -s $DB_SERV_NAME" >> ${LOG}
srvctl enable service -d $ORACLE_DB -s $DB_SERV_NAME >> ${LOG}
#Check if the database config is SINGLE_NODE even though this is a RAC cluster!
RAC_SINGLE=`${ORACLE_HOME}/bin/srvctl config database -d $ORACLE_DB | grep "^Type:" | awk '{print $2}' | grep -i "single"`
if [[ -z $RAC_SINGLE ]]; then
echo "srvctl start service -d $ORACLE_DB -s $DB_SERV_NAME -n $LOCAL_NODE" >> ${LOG}
srvctl start service -d $ORACLE_DB -s $DB_SERV_NAME -n $LOCAL_NODE >> ${LOG}
else
echo "srvctl start service -d $ORACLE_DB -s $DB_SERV_NAME" >> ${LOG}
srvctl start service -d $ORACLE_DB -s $DB_SERV_NAME >> ${LOG}
fi
done
done
else
# Stop Any services for $ORACLE_DB on this node
if [ $(srvctl status service -d $ORACLE_DB | grep -i "is running" | awk '{ print $2 }' | wc -l) -ne 0 ]
then
echo "srvctl stop service -d $ORACLE_DB" >> ${LOG}
srvctl stop service -d $ORACLE_DB >> ${LOG}
fi
# Read pre_stop_dbservices.log and start only those services
cat $OUTPUT_DIRECTORY/pre_stop_dbservices.log | grep $ORACLE_DB | while read SERV_LINE
do
DB_SERV_LIST=`echo $SERV_LINE | cut -d":" -f3 -s`
for DB_SERV_NAME in $DB_SERV_LIST
do
echo "srvctl start service -d $ORACLE_DB -s $DB_SERV_NAME" >> ${LOG}
srvctl start service -d $ORACLE_DB -s $DB_SERV_NAME >> ${LOG}
done
done
fi
echo "" >> ${LOG}
done
# Do another round of service checks and report accordingly
collect_dbservices
service_alignment_basic
fi
}
service_alignment_basic()
{
rm -f $OUTPUT_DIRECTORY/diff_file; rm -f $OUTPUT_DIRECTORY/diff_1; rm -f $OUTPUT_DIRECTORY/diff_2
cat $OUTPUT_DIRECTORY/pre_stop_dbservices.log | sort > $OUTPUT_DIRECTORY/diff_1;
cat $OUTPUT_DIRECTORY/post_start_dbservices.log | sort > $OUTPUT_DIRECTORY/diff_2;
diff -b -i -w $OUTPUT_DIRECTORY/diff_1 $OUTPUT_DIRECTORY/diff_2 > $OUTPUT_DIRECTORY/diff_file
chown $oracred $OUTPUT_DIRECTORY/diff_file
chmod 755 $OUTPUT_DIRECTORY/diff_file
if [ ! -s $OUTPUT_DIRECTORY/diff_file ]
then
echo ""
echo "OK : pre-post status matches for DB service alignment"
echo ""
echo "" >> ${LOG}
echo "OK : pre-post status matches for DB service alignment" >> ${LOG}
echo "" >> ${LOG}
else
echo ""
echo "ATTENTION : Please verify DB service alignment"
echo "pre-stop status (db:instance:service) is available at $OUTPUT_DIRECTORY/pre_stop_dbservices.log"
echo ""
echo "" >> ${LOG}
echo "DB_SERVICE_MISMATCH: Please verify DB service alignment" >> ${LOG}
echo "pre-stop status (db:instance:service) is available at $OUTPUT_DIRECTORY/pre_stop_dbservices.log" >> ${LOG}
echo "" >> ${LOG}
fi
}
display_pre_post()
{
if [ $why = stop ]
then
if [ $when = pre ]
then
if [ $what = fgl ] || [ $what = agent ] || [ $what = mrp ] || [ $what = dbfs ] || [ $what = ogg ]
then
if [ "$(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log)" = 0 ] || [ ! -s $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
echo "PRE stop" $what "running " ":" "NO" | tee -a ${LOG}
else
echo "PRE stop" $what "running " ":" "YES" | tee -a ${LOG}
fi
elif [ $what = asm ] || [ $what = dbinst ] || [ $what = lsnr ]
then
if [ "$(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log)" = 0 ] || [ ! -s $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
echo "PRE stop" $what "running " ":" "NO" | tee -a ${LOG}
else
echo "PRE stop" $what "running " ":" $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) | tee -a ${LOG}
fi
fi
fi
elif [ $why = start ]
then
if [ $what = fgl ] || [ $what = agent ] || [ $what = mrp ] || [ $what = dbfs ] || [ $what = ogg ]
then
if [[ -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]]; then
if [ "$(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log)" = 0 ] || [ ! -s $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
echo "POST start" $what "running " ":" "NO" | tee -a ${LOG}
echo "" | tee -a ${LOG}
else
echo "POST start" $what "running " ":" "YES" | tee -a ${LOG}
echo "" | tee -a ${LOG}
fi
fi
elif [ $what = asm ] || [ $what = dbinst ] || [ $what = lsnr ]
then
if [ "$(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log)" = 0 ] || [ ! -s $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
echo "POST start" $what "running " ":" "NO" | tee -a ${LOG}
echo "" | tee -a ${LOG}
else
echo "POST start" $what "running " ":" $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) | tee -a ${LOG}
echo "" | tee -a ${LOG}
fi
fi
fi
}
# Code for starting the services
start_asm()
{
echo "***************************** ASM ************************" >> ${LOG}; echo "" >> ${LOG}
if [[ -f $OUTPUT_DIRECTORY/pre_stop_asm.log ]]; then
while read data
do
export ORACLE_SID=$data >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
echo "Checking for instance ${ORACLE_SID} "
if [ $(ps -ef | grep -v grep | grep pmon | grep "^.*${oraowner} " | grep $ORACLE_SID | wc -l) -eq 0 ]
then
echo "Starting instance ${ORACLE_SID} "
op=`$ORACLE_HOME/bin/sqlplus -s '/ as sysasm' << EOF
startup;
set echo off;
set linesize 200 pages 100;
select instance_name,host_name,startup_time from gv\\$instance;
EOF`
echo "$op" >> ${LOG}; echo "" >> ${LOG}
else
echo "ASM Instance ${ORACLE_SID} is already running "
echo "ASM Instance: $ORACLE_SID is already running .. moving on to databases ... " >> ${LOG}; echo "" >> ${LOG}
fi
echo "_____________________________________________________________________" >> ${LOG};echo "" >> ${LOG}
done < $OUTPUT_DIRECTORY/pre_stop_asm.log
fi
}
start_asm_10g()
{
echo "***************************** ASM ************************" >> ${LOG}; echo "" >> ${LOG}
while read data
do
export ORACLE_SID=$data >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
echo "Starting instance ${ORACLE_SID} "
if [ $(ps -ef | grep -v grep | grep pmon | grep "^.*${oraowner} " | grep $ORACLE_SID | wc -l) -eq 0 ]
then
op=`$ORACLE_HOME/bin/sqlplus -s '/ as sysdba' << EOF
startup;
set echo off;
set linesize 200 pages 100;
select instance_name,host_name,startup_time from gv\\$instance;
EOF`
echo "$op" >> ${LOG}; echo "" >> ${LOG}
fi
echo "_____________________________________________________________________" >> ${LOG};echo "" >> ${LOG}
done < $OUTPUT_DIRECTORY/pre_stop_asm.log
}
start_db_rac()
{
echo "************************** DATABASE & SERVICES *********************" >> ${LOG}; echo "" >> ${LOG}
# Start instance in OPEN mode
while read data
do
export ORACLE_DB=$(echo $data | awk 'BEGIN{FS=":"}{print $1}') >/dev/null
export ORACLE_SID=$(echo $data | awk 'BEGIN{FS=":"}{print $2}') >/dev/null
export RACONE_DB=$(echo $data | awk 'BEGIN{FS=":"}{print $3}') >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
echo "Starting instance ${ORACLE_SID} "
if [ $(ps -ef | grep -v grep | grep pmon | grep "^.*${oraowner} " | grep "pmon_${ORACLE_SID}\$" | wc -l) -eq 0 ]
then
if [ $ORACLE_DB = $ORACLE_SID ]
then
srvctl start database -d $ORACLE_DB >> ${LOG};echo "" >> ${LOG}
elif [[ ! -z $RACONE_DB ]]
then
srvctl start database -d $ORACLE_DB -n $RACONE_DB >> ${LOG};echo "" >> ${LOG}
else
srvctl start instance -d $ORACLE_DB -i $ORACLE_SID >> ${LOG};echo "" >> ${LOG}
fi
op=`$ORACLE_HOME/bin/sqlplus -s '/ as sysdba' << EOF
set linesize 200 pages 100;
set echo off;
select instance_name,host_name,startup_time from gv\\$instance;
select name,open_mode,database_role from gv\\$database;
EOF`
echo "$op" >> ${LOG}; echo "" >> ${LOG}
fi
srvctl status service -d $ORACLE_DB >> ${LOG}
echo "___________________________________________________________">> ${LOG};
done < $OUTPUT_DIRECTORY/pre_stop_dbopen.log
# Start instance in READ ONLY mode (should be defined as such in srvctl config)
while read data
do
export ORACLE_DB=$(echo $data | awk 'BEGIN{FS=":"}{print $1}') >/dev/null
export ORACLE_SID=$(echo $data | awk 'BEGIN{FS=":"}{print $2}') >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
echo "Starting instance ${ORACLE_SID} "
if [ $(ps -ef | grep -v grep | grep pmon | grep "^.*${oraowner} " | grep "pmon_${ORACLE_SID}\$" | wc -l) -eq 0 ]
then
if [ $ORACLE_DB = $ORACLE_SID ]
then
srvctl start database -d $ORACLE_DB >> ${LOG};echo "" >> ${LOG}
elif [[ ! -z $RACONE_DB ]]
then
srvctl start database -d $ORACLE_DB -n $RACONE_DB >> ${LOG};echo "" >> ${LOG}
else
srvctl start instance -d $ORACLE_DB -i $ORACLE_SID >> ${LOG};echo "" >> ${LOG}
fi
op=`$ORACLE_HOME/bin/sqlplus -s '/ as sysdba' << EOF
set linesize 200 pages 100;
set echo off;
select instance_name,host_name,startup_time from gv\\$instance;
select name,open_mode,database_role from gv\\$database;
EOF`
echo "$op" >> ${LOG}; echo "" >> ${LOG}
fi
srvctl status service -d $ORACLE_DB >> ${LOG}
echo "___________________________________________________________">> ${LOG};
done < $OUTPUT_DIRECTORY/pre_stop_dbopenronly.log
# Start instance in MOUNT mode
while read data
do
export ORACLE_DB=$(echo $data | awk 'BEGIN{FS=":"}{print $1}') >/dev/null
export ORACLE_SID=$(echo $data | awk 'BEGIN{FS=":"}{print $2}') >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
echo "Mounting instance ${ORACLE_SID} "
if [ $(ps -ef | grep -v grep | grep pmon | grep "^.*${oraowner} " | grep "pmon_${ORACLE_SID}\$" | wc -l) -eq 0 ]
then
if [ $ORACLE_DB = $ORACLE_SID ]
then
srvctl start database -d $ORACLE_DB -o mount >> ${LOG};echo "" >> ${LOG}
elif [[ ! -z $RACONE_DB ]]
then
srvctl start database -d $ORACLE_DB -n $RACONE_DB -o mount >> ${LOG};echo "" >> ${LOG}
else
srvctl start instance -d $ORACLE_DB -i $ORACLE_SID -o mount >> ${LOG};echo "" >> ${LOG}
fi
op=`$ORACLE_HOME/bin/sqlplus -s '/ as sysdba' << EOF
set linesize 200 pages 100;
set echo off;
select instance_name,host_name,startup_time from gv\\$instance;
select name,open_mode,database_role from gv\\$database;
EOF`
echo "$op" >> ${LOG}; echo "" >> ${LOG}
fi
echo "___________________________________________________________">> ${LOG};
done < $OUTPUT_DIRECTORY/pre_stop_dbmount.log
}
start_db_standalone()
{
echo "************************** DATABASE & SERVICES *********************" >> ${LOG}; echo "" >> ${LOG}
# Start instance in OPEN mode
while read data
do
export ORACLE_SID=$(echo $data | awk 'BEGIN{FS=":"}{print $2}') >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
echo "Starting instance ${ORACLE_SID} "
if [ $(ps -ef | grep -v grep | grep pmon | grep "^.*${oraowner} " | grep "pmon_${ORACLE_SID}\$" | wc -l) -eq 0 ]
then
op=`$ORACLE_HOME/bin/sqlplus -s '/ as sysdba' << EOF
startup;
set linesize 200 pages 100;
set echo off;
select instance_name,host_name,startup_time from v\\$instance;
select name,open_mode,database_role from v\\$database;
EOF`
echo "$op" >> ${LOG}; echo "" >> ${LOG}
fi
echo "___________________________________________________________">> ${LOG};
done < $OUTPUT_DIRECTORY/pre_stop_dbopen.log
# Start instance in READ ONLY mode
while read data
do
export ORACLE_SID=$(echo $data | awk 'BEGIN{FS=":"}{print $2}') >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
echo "Starting instance ${ORACLE_SID} "
if [ $(ps -ef | grep -v grep | grep pmon | grep "^.*${oraowner} " | grep "pmon_${ORACLE_SID}\$" | wc -l) -eq 0 ]
then
op=`$ORACLE_HOME/bin/sqlplus -s '/ as sysdba' << EOF
startup mount;
alter database open read only;
set linesize 200 pages 100;
set echo off;
select instance_name,host_name,startup_time from v\\$instance;
select name,open_mode,database_role from v\\$database;
EOF`
echo "$op" >> ${LOG}; echo "" >> ${LOG}
fi
echo "___________________________________________________________">> ${LOG};
done < $OUTPUT_DIRECTORY/pre_stop_dbopenronly.log
# Start instance in MOUNT mode
while read data
do
export ORACLE_SID=$(echo $data | awk 'BEGIN{FS=":"}{print $2}') >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
echo "Mounting instance ${ORACLE_SID} "
if [ $(ps -ef | grep -v grep | grep pmon | grep "^.*${oraowner} " | grep "pmon_${ORACLE_SID}\$" | wc -l) -eq 0 ]
then
op=`$ORACLE_HOME/bin/sqlplus -s '/ as sysdba' << EOF
startup mount;
set linesize 200 pages 100;
set echo off;
select instance_name,host_name,startup_time from v\\$instance;
select name,open_mode,database_role from v\\$database;
EOF`
echo "$op" >> ${LOG}; echo "" >> ${LOG}
fi
echo "___________________________________________________________">> ${LOG};
done < $OUTPUT_DIRECTORY/pre_stop_dbmount.log
}
start_mrp()
{
echo "******************************* MRP **************************" >> ${LOG}; echo "" >> ${LOG}
echo "Starting $what"
while read data
do
export ORACLE_SID=$data >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
echo "Starting MRP on ${ORACLE_SID}"
if [ $(ps -ef | grep -v grep | grep pmon | grep "^.*${oraowner} " | grep "pmon_${ORACLE_SID}\$" | wc -l) -ne 0 ]
then
op=`$ORACLE_HOME/bin/sqlplus -s '/ as sysdba' << EOF
set echo off;
set linesize 200 pages 100;
select name,open_mode,database_role from v\\$database;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
EOF`
echo "$op" >> ${LOG}; echo "" >> ${LOG}
fi
echo "_____________________________________________________________________" >> ${LOG};echo "" >> ${LOG}
done < $OUTPUT_DIRECTORY/pre_stop_mrp.log
}
start_lsnr()
{
echo "***************************** LISTENER ************************" >> ${LOG}; echo "" >> ${LOG}
if [[ $server_type = "rac_12c" ]] || [[ $server_type = "norac_asm12c" ]] || [[ $server_type = "rac_11g" ]] || [[ $server_type = "norac_asm11g" ]] || [[ $server_type = "rac_10g" ]] || [[ $server_type = "norac_asm10g" ]]
then
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}' | head -1`
else
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s | head -1`
fi
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
while read lsnr
do
echo "Starting listener ${lsnr}"
#if [ $(ps -ef | grep -v grep | grep pmon | grep "^.*${oraowner} " | grep $lsnr | wc -l) -eq 0 ]
if [ $(ps -ef | grep lsnr |grep -v grep | grep "^.*${oraowner} " | grep "tnslsnr $lsnr " | wc -l) -eq 0 ]
then
if [[ -f $OUTPUT_DIRECTORY/pre_config_lsnr.log ]]; then
LSNR_HOME=`cat $OUTPUT_DIRECTORY/pre_config_lsnr.log | grep "${lsnr}:" | cut -d":" -f2 -s |tail -1`
if [[ $ORACLE_HOME != $LSNR_HOME ]]; then
if [[ -f /etc/oratab ]]; then
ORACLE_SID=`grep "$LSNR_HOME" /etc/oratab | grep -v "^#" | cut -d":" -f1 -s |tail -1`
export ORAENV_ASK=NO >/dev/null
if [[ ! -z $ORACLE_SID ]]; then
. oraenv >/dev/null
fi
fi
fi
fi
echo "Starting listener ${lsnr}" >> ${LOG}
echo "" >> ${LOG}
lsnrctl start $lsnr >> ${LOG};echo "" >> ${LOG}
else
echo "" >> ${LOG}
echo "Listener: ${lsnr} already in Running state " >> ${LOG}
echo "" >> ${LOG}
fi
done < $OUTPUT_DIRECTORY/pre_stop_lsnr.log
sleep 5
}
start_agent()
{
echo "***************************** EMAGENT ************************" >> ${LOG}; echo "" >> ${LOG}
if [[ -f $OUTPUT_DIRECTORY/pre_stop_agent.log ]]; then
echo "Starting $what"
if [ "$(cat $OUTPUT_DIRECTORY/pre_stop_agent.log)" -eq 0 ]
then
echo "EMAgent was down even before the activity, so didn't bring it up" >> ${LOG}; echo "" >> ${LOG}
else
ORACLE_SID=`cat /etc/oratab | awk 'BEGIN{FS=":"}{print $1}' | grep OEM | grep -v "^#"`
export ORAENV_ASK=NO >/dev/null;
if [[ ! -z $ORACLE_SID ]]; then
. oraenv >/dev/null
if [[ -f $ORACLE_HOME/bin/emctl ]]; then
emctl start agent >/dev/null;
sleep 15
fi
fi
fi
else
echo "Note: pre_stop file Found: $OUTPUT_DIRECTORY/pre_stop_agent.log -> Skipping EMAGENT startup" >> ${LOG}
fi
}
start_fgl()
{
echo "**************************** FOGLIGHT ****************************" >> ${LOG}; echo "" >> ${LOG}
echo "Starting $what"
if [ "$(cat $OUTPUT_DIRECTORY/pre_stop_fgl.log)" -eq 0 ]
then
echo "Foglight was down even before the activity, so didn't bring it up" >> ${LOG}; echo "" >> ${LOG}
elif [ "$(ps -ef | grep -i foglight | grep "^.*${oraowner} " | grep -v grep | wc -l)" -ne 0 ]
then
echo "Foglight is already running" >> ${LOG}; echo "" >> ${LOG}
else
if [[ -f /oracle/dba/foglight/fgl_5/bin/fglam ]]; then
/oracle/dba/foglight/fgl_5/bin/fglam -d >/dev/null;
sleep 30
else
if [[ -f $OUTPUT_DIRECTORY/non_standard_fgl_start.cmd ]]; then
chmod 755 $OUTPUT_DIRECTORY/non_standard_fgl_start.cmd
$OUTPUT_DIRECTORY/non_standard_fgl_start.cmd >/dev/null;
sleep 30
fi
fi
fi
}
# OGG Support
##############
start_ogg()
{
echo "***************************** GOLDENGATE ************************" >> ${LOG}; echo "" >> ${LOG}
echo "Starting $what"
if [ "$(cat $OUTPUT_DIRECTORY/pre_stop_ogg.log)" = 0 ]
then
echo "OGG was down even before the activity, so didn't bring it up" >> ${LOG}; echo "" >> ${LOG}
else
# Set Ora env
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep -v grep | grep "+ASM" | grep "^.*${oraowner} " | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'`
export ORAENV_ASK=NO >/dev/null;
if [[ ! -z $ORACLE_SID ]]; then
. oraenv >/dev/null
else
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep "^.*${oraowner} " | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s| tail -1`
if [[ ! -z $ORACLE_SID ]]; then
. oraenv >/dev/null
fi
fi
if [[ -f ${OUTPUT_DIRECTORY}/gg_config.txt ]]; then
# Read gg start config on this host and act accordingly ..
cat ${OUTPUT_DIRECTORY}/gg_config.txt | sort -u | while read gg_config
do
CRS_RES_GG=`echo $gg_config | grep "GGCRS@" | cut -d ":" -f1 -s | cut -d"@" -f2 -s`
GG_HOME=`echo $gg_config | cut -d ":" -f2 -s`
LOCAL_NODE=`echo $gg_config | cut -d ":" -f3 -s`
if [[ ! -z $CRS_RES_GG ]]; then
if [[ -f ${ORACLE_HOME}/bin/crsctl ]]; then
CRS_STATE=`${ORACLE_HOME}/bin/crsctl stat res $CRS_RES_GG | grep "STATE=" | awk '{ print $1 }' | cut -d"=" -f2 -s`
if [[ "$CRS_STATE" != "ONLINE" ]]; then
echo "Starting Golden Gate via CRS Resource: $CRS_RES_GG" >> ${LOG}
if [[ "$server_type" == rac* ]]; then
echo "${ORACLE_HOME}/bin/crsctl start res $CRS_RES_GG -n $LOCAL_NODE -f" >> ${LOG}
${ORACLE_HOME}/bin/crsctl start res $CRS_RES_GG -n $LOCAL_NODE -f >> ${LOG}
sleep 30
else
echo "${ORACLE_HOME}/bin/crsctl start res $CRS_RES_GG" >> ${LOG}
${ORACLE_HOME}/bin/crsctl start res $CRS_RES_GG >> ${LOG}
sleep 30
fi
fi
fi
# display GG mgr output
#${GG_HOME}/ggsci << EOF >> ${LOG}
#info all
#exit
#EOF
else
if [[ -f ${OUTPUT_DIRECTORY}/pre_gg_inst.log ]]; then
ORACLE_GG_SID=`cat ${OUTPUT_DIRECTORY}/pre_gg_inst.log | grep "PRE_OGG_DBINST:" | cut -d":" -f3 -s | tail -1`
echo "Found a value for ORACLE_SID where GG was last running .. So will use: $ORACLE_GG_SID " >> ${LOG}
fi
if [[ ! -z $ORACLE_GG_SID ]]; then
ORACLE_SID=$ORACLE_GG_SID
. oraenv
else
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s | tail -1`
if [[ ! -z $ORACLE_SID ]]; then
echo "Did Not Find ORACLE_SID where GG was last running .. So will use a Random value: $ORACLE_SID" >> ${LOG}
. oraenv
fi
fi
echo "Starting Golden Gate (Non CRS Control) from GG_HOME=${GG_HOME}" >> ${LOG}
${GG_HOME}/ggsci << EOF >> ${LOG}
start mgr
shell sleep 10
exit
EOF
sleep 60
fi
done
fi
fi
##################################
# Post start OGG status in $LOG
##################################
echo "Collecting Post START GOLDENGATE information ..... "; echo ""
if [ "$(ps -ef | grep -v grep | grep "mgr PARAMFILE" | grep "^.*${oraowner} " | wc -l)" -eq 0 ]
then
echo "GoldenGate is not running on this host under osuser: ${oraowner}" >> ${LOG};echo "" >> ${LOG}
else
echo "" >> ${LOG}
echo "******************** POST START GOLDENGATE STATUS **************************" >> ${LOG}; echo "" >> ${LOG}
echo "GoldenGate is running on this host under osuser: ${oraowner}" >> ${LOG}
ps -ef | grep -v grep | grep "^.*${oraowner} " | grep "mgr PARAMFILE" >> ${LOG};echo "" >> ${LOG}
# Set Ora env
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'`
export ORAENV_ASK=NO >/dev/null;
if [[ ! -z $ORACLE_SID ]]; then
. oraenv >/dev/null
else
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s | tail -1`
. oraenv >/dev/null
fi
#ps -ef | grep -v grep | grep "mgr PARAMFILE" | grep "^.*${oraowner} " | sed -n 's/.*\(....................................................................mgr.prm \).*/\1/p' | awk '{ print $NF }' | sort | while read GG_MGRPROC
ps -ef | grep -v grep | grep "mgr PARAMFILE" | grep "^.*${oraowner} " | sed -n 's/.*\(...................................................................\/....prm \).*/\1/p' | awk '{ print $NF }' | sort | while read GG_MGRPROC
do
# Proceed only if Golden Gate Manager is running
if [[ ! -z $GG_MGRPROC ]]; then
#GG_HOME=`echo $GG_MGRPROC | sed 's/\/dirprm\/mgr.prm//g'`
GG_HOME=`echo $GG_MGRPROC | sed 's/\/dirprm\/mgr.prm//g' | sed 's/\/dirprm\/MGR.prm//g'`
sleep 60
if [[ -d $GG_HOME ]]; then
${GG_HOME}/ggsci << EOF >> ${LOG}
info all
exit
EOF
#echo "$op" >> ${LOG};echo "" >> ${LOG}
fi
fi
done
fi
}
# DBFS Support
##############
start_dbfs()
{
echo "***************************** DBFS ************************" >> ${LOG}; echo "" >> ${LOG}
echo "Starting $what"
if [ "$(cat $OUTPUT_DIRECTORY/pre_stop_dbfs.log)" = 0 ]
then
echo "DBFS was down even before the activity, so didn't bring it up" >> ${LOG}; echo "" >> ${LOG}
else
# Set Ora env
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep -v grep | grep "+ASM" | grep "^.*${oraowner} " | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'`
export ORAENV_ASK=NO >/dev/null;
if [[ ! -z $ORACLE_SID ]]; then
. oraenv >/dev/null
else
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep "^.*${oraowner} " | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s | tail -1`
if [[ ! -z $ORACLE_SID ]]; then
. oraenv >/dev/null
fi
fi
# Read gg start config on this host and act accordingly ..
if [[ -f ${OUTPUT_DIRECTORY}/dbfs_config.txt ]]; then
cat ${OUTPUT_DIRECTORY}/dbfs_config.txt | sort -u | while read dbfs_config
do
CRS_RES_DBFS=`echo $dbfs_config | grep "DBFSCRS@" | cut -d ":" -f1 -s | cut -d"@" -f2 -s`
DBFS_HOME=`echo $dbfs_config | cut -d ":" -f2 -s`
LOCAL_NODE=`echo $dbfs_config | cut -d ":" -f3 -s`
if [[ ! -z $CRS_RES_DBFS ]]; then
if [[ -f ${ORACLE_HOME}/bin/crsctl ]]; then
CRS_STATE=`${ORACLE_HOME}/bin/crsctl stat res $CRS_RES_DBFS | grep "STATE=" | awk '{ print $1 }' | cut -d"=" -f2 -s`
if [[ "$CRS_STATE" != "ONLINE" ]]; then
if [[ "$server_type" == rac* ]]; then
echo "${ORACLE_HOME}/bin/crsctl start res $CRS_RES_DBFS -n $LOCAL_NODE" >> ${LOG}
${ORACLE_HOME}/bin/crsctl start res $CRS_RES_DBFS -n $LOCAL_NODE >> ${LOG}
sleep 60
else
echo "${ORACLE_HOME}/bin/crsctl start res $CRS_RES_DBFS" >> ${LOG}
${ORACLE_HOME}/bin/crsctl start res $CRS_RES_DBFS >> ${LOG}
sleep 60
fi
else
echo "DBFS CRS Resource: $CRS_RES_DBFS is already ONLINE state ..." >> ${LOG}; echo "" >> ${LOG}
fi
fi
else
echo "" >> ${LOG}; echo "" >> ${LOG}
echo " INFO: For DBA .. DBFS process was detected on this host - As per config file: ${OUTPUT_DIRECTORY}/dbfs_config.txt " >> ${LOG}; echo "" >> ${LOG}
echo " But does not appear to be setup as a CRS Cluster Resource OR has failed to be stopped via CRS Cluster Resource " >> ${LOG}
echo " ... Please start manually if required ..." >> ${LOG}; echo "" >> ${LOG}
echo "" >> ${LOG}; echo "" >> ${LOG}
fi
#sleep 60
done
fi
fi
}
#INSERT INTO REPOSITORY DATABASE
#ASSIGNING THE OUTPUT VARIABLES
assign_log()
{
if [ -s $OUTPUT_DIRECTORY/post_start_crs.log ]
then
crs_output=`cat $OUTPUT_DIRECTORY/post_start_crs.log`
else
crs_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_asm.log ]
then
asm_output=`cat $OUTPUT_DIRECTORY/post_start_asm.log`
else
asm_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_esm.log ]
then
esm_agent_output=`cat $OUTPUT_DIRECTORY/post_start_esm.log`
else
esm_agent_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_dma.log ]
then
dma_agent_output=`cat $OUTPUT_DIRECTORY/post_start_dma.log`
else
dma_agent_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_lsnr.log ]
then
listener_output=`cat $OUTPUT_DIRECTORY/post_start_lsnr.log`
else
listener_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_dbinst.log ]
then
db_instance_output=`cat $OUTPUT_DIRECTORY/post_start_dbinst.log`
else
db_instance_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_dbopen.log ]
then
db_open_output=`cat $OUTPUT_DIRECTORY/post_start_dbopen.log`
else
db_open_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_dbopenro.log ]
then
db_openro_output=`cat $OUTPUT_DIRECTORY/post_start_dbopenro.log`
else
db_openro_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_dbmount.log ]
then
db_mount_output=`cat $OUTPUT_DIRECTORY/post_start_dbmount.log`
else
db_mount_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_dbservices.log ]
then
service_alignment_output=`cat $OUTPUT_DIRECTORY/post_start_dbservices.log`
else
service_alignment_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_mrp.log ]
then
mrp_output=`cat $OUTPUT_DIRECTORY/post_start_mrp.log`
else
mrp_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_agent.log ]
then
oem_agent_output=`cat $OUTPUT_DIRECTORY/post_start_agent.log`
else
oem_agent_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_portutil.log ]
then
port_utility_output=`cat $OUTPUT_DIRECTORY/post_start_portutil.log`
else
port_utility_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_fgl.log ]
then
foglight_output=`cat $OUTPUT_DIRECTORY/post_start_fgl.log`
else
foglight_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_osw.log ]
then
os_watcher_output=`cat $OUTPUT_DIRECTORY/post_start_osw.log`
else
os_watcher_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_usb.log ]
then
usb_output=`cat $OUTPUT_DIRECTORY/post_start_usb.log`
else
usb_output="no_status"
fi
if [ -s /oracle/dba/foglight/fgl_5/bin/fglam ]
then
fglam_output=`/oracle/dba/foglight/fgl_5/bin/fglam --check-connection`
else
fglam_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/server_type.log ]
then
instance_type=`cat $OUTPUT_DIRECTORY/server_type.log`
else
instance_type="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/version_executed_status.log ]
then
script_version=`cat $OUTPUT_DIRECTORY/version_executed_status.log`
else
script_version="no_status"
fi
}
insert_repdb()
{
for what in fgl osw agent portutil lsnr mrp dbinst asm
do
if [ -f $OUTPUT_DIRECTORY/stopped_$what.log ]
then
if [ "$(cat $OUTPUT_DIRECTORY/stopped_$what.log)" = yes ]
then
eval var_$what="success"
fi
if [ "$(cat $OUTPUT_DIRECTORY/stopped_$what.log)" = no ]
then
eval var_$what="failure"
fi
else
eval var_$what="no_status"
fi
done
var_dma="na"
var_esm="na"
var_crs="na"
if [[ $server_type = "rac_11g" ]] || [[ $server_type = "norac_asm11g" ]]
then
var_lsnr="na"
var_asm="na"
elif [[ $server_type = "norac_noasm" ]]
then
var_asm="na"
fi
#PREPARING THE INSERT STATEMENT
if [ $(cat /etc/oratab | grep oracle | grep -v -i asm | grep -v -i crs | grep -v -i oem | grep -v "#" | awk 'BEGIN{FS=":"}{print $1}' | head -1 | wc -l) = 1 ]
then
export ORACLE_SID=`cat /etc/oratab | grep oracle | grep -v -i asm | grep -v -i crs | grep -v -i oem | grep -v "#" | awk 'BEGIN{FS=":"}{print $1}' | head -1`
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
$ORACLE_HOME/bin/sqlplus -s OSH_SEH/dbaas_operations1@SUNDVD94 << EOFSTATUS
set echo off;
set head off;
set feedback off;
insert into OSH_SEH.dbss_log (DBSS_ID,
SCRIPT_VERSION,
INSTANCE_TYPE,
STOP_OR_START,
CRS_OR_DB,
SERVER_NAME,
SERVER_TIMESTAMP,
CRS,
ASM,
LISTENER,
DB_INSTANCE,
MRP_PROCESS,
ESM_AGENT,
DMA_AGENT,
OEM_AGENT,
PORT_UTILITY,
FOGLIGHT,
OS_WATCHER,
SENT_MAIL,
CRS_OUTPUT,
ASM_OUTPUT,
LISTENER_OUTPUT,
DB_INSTANCE_OUTPUT,
DB_OPEN_OUTPUT,
DB_OPENRO_OUTPUT,
DB_MOUNT_OUTPUT,
SERVICE_ALIGNMENT_OUTPUT,
MRP_OUTPUT,
ESM_AGENT_OUTPUT,
DMA_AGENT_OUTPUT,
OEM_AGENT_OUTPUT,
PORT_UTILITY_OUTPUT,
FOGLIGHT_OUTPUT,
OS_WATCHER_OUTPUT,
USB_OUTPUT,
FGLAM_OUTPUT)
values (DBSS_LOG_SEQ.nextval,
'$script_version',
'$instance_type',
'start',
'db',
'$(hostname -f)',
'$timevalue',
'$var_crs',
'$var_asm',
'$var_lsnr',
'$var_dbinst',
'$var_mrp',
'$var_esm',
'$var_dma',
'$var_agent',
'$var_portutil',
'$var_fgl',
'$var_osw',
0,
'$crs_output',
'$asm_output',
'$listener_output',
'$db_instance_output',
'$db_open_output',
'$db_openro_output',
'$db_mount_output',
'$service_alignment_output',
'$mrp_output',
'$esm_agent_output',
'$dma_agent_output',
'$oem_agent_output',
'$port_utility_output',
'$foglight_output',
'$os_watcher_output',
'$usb_output',
'$fglam_output');
commit;
EOFSTATUS
fi
}
# Start the appropriate services based on server type
echo "************************* START TIME : $(date) ************************" >> ${LOG}; echo "" >> ${LOG}
case $server_type in
"rac_12c")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "---------------------------> THIS IS A 12c CLUSTERWARE SYSTEM <------------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
when=pre; why=stop; what=dbinst; display_pre_post
start_db_rac;
when=post; why=start; what=dbinst; sleep 10; collect_$what; display_pre_post
collect_dbservices
service_alignment
for what in mrp agent fgl dbfs ogg
do
when=pre; why=stop; display_pre_post
start_$what
when=post; why=start; sleep 15; collect_$what; display_pre_post
done
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in dbinst mrp agent fgl dbfs ogg
do
started_status
done
assign_log
insert_repdb
echo "**************************************************"
;;
"rac_11g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "---------------------------> THIS IS A 11g CLUSTERWARE SYSTEM <------------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
when=pre; why=stop; what=dbinst; display_pre_post
start_db_rac;
when=post; why=start; what=dbinst; sleep 10; collect_$what; display_pre_post
collect_dbservices
service_alignment
for what in mrp agent fgl dbfs ogg
do
when=pre; why=stop; display_pre_post
start_$what
when=post; why=start; sleep 15; collect_$what; display_pre_post
done
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in dbinst mrp agent fgl dbfs ogg
do
started_status
done
assign_log
insert_repdb
echo "**************************************************"
;;
"rac_10g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "---------------------------> THIS IS A 10g CLUSTERWARE SYSTEM <------------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
when=pre; why=stop; what=dbinst; display_pre_post
start_asm_10g;
when=post; why=start; what=dbinst; sleep 10; collect_$what; display_pre_post
collect_dbservices
service_alignment
when=pre; why=stop; what=dbinst; display_pre_post
start_db_rac;
when=post; why=start; what=dbinst; sleep 10; collect_$what; display_pre_post
for what in mrp lsnr agent fgl ogg
do
when=pre; why=stop; display_pre_post
start_$what
when=post; why=start; sleep 10; collect_$what; display_pre_post
done
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in asm dbinst lsnr mrp agent fgl ogg
do
started_status
done
assign_log
insert_repdb
echo "**************************************************"
;;
"norac_asm12c")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "-------------------------> THIS IS A NON-RAC SYSTEM BUT WITH ASM 12c <----------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
#Check for ASM and start if needed
when=pre; why=stop; what=asm; display_pre_post
start_asm;
when=post; why=start; what=asm; sleep 10; collect_$what; display_pre_post
when=pre; why=stop; what=dbinst; display_pre_post
start_db_standalone
when=post; why=start; what=dbinst; sleep 10; collect_$what; display_pre_post
collect_dbservices
service_alignment
for what in lsnr mrp agent fgl dbfs ogg
do
when=pre; why=stop; display_pre_post
start_$what;
when=post; why=start; sleep 15; collect_$what; display_pre_post
done
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in asm dbinst mrp agent lsnr fgl dbfs ogg
do
started_status
done
assign_log
insert_repdb
echo "**************************************************"
;;
"norac_asm11g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "-------------------------> THIS IS A NON-RAC SYSTEM BUT WITH ASM 11g <----------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
#Check for ASM and start if needed
when=pre; why=stop; what=asm; display_pre_post
start_asm;
when=post; why=start; what=asm; sleep 10; collect_$what; display_pre_post
when=pre; why=stop; what=dbinst; display_pre_post
start_db_standalone
when=post; why=start; what=dbinst; sleep 10; collect_$what; display_pre_post
collect_dbservices
service_alignment
for what in lsnr mrp agent fgl dbfs ogg
do
when=pre; why=stop; display_pre_post
start_$what;
when=post; why=start; sleep 15; collect_$what; display_pre_post
done
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in asm dbinst mrp agent fgl lsnr dbfs ogg
do
started_status
done
assign_log
insert_repdb
echo "**************************************************"
;;
"norac_asm10g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "-------------------------> THIS IS A NON-RAC SYSTEM BUT WITH ASM 10g <----------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
when=post; why=start;
start_asm_10g; what=dbinst; collect_$what
start_db_standalone; what=dbinst; collect_$what
for what in mrp lsnr agent fgl ogg
do
start_$what; collect_$what
done
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in fgl agent lsnr dbinst mrp asm ogg
do
started_status
done
assign_log
insert_repdb
echo "**************************************************"
;;
"norac_noasm")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "--------------------------> THIS IS A NON-RAC & NON-ASM SYSTEM <----------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
when=pre; why=stop; what=dbinst; display_pre_post
start_db_standalone;
when=post; why=start; what=dbinst; sleep 10; collect_$what; display_pre_post
for what in mrp lsnr agent fgl ogg
do
when=pre; why=stop; display_pre_post
start_$what;
when=post; why=start; sleep 10; collect_$what; display_pre_post
done
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in dbinst mrp lsnr agent fgl ogg
do
started_status
done
assign_log
insert_repdb
echo "**************************************************"
;;
*)
echo "Invalid Selection : $server_type "
esac
chmod 755 $OUTPUT_DIRECTORY/pre_stop*.log 1> /dev/null 2>&1
chmod 755 $OUTPUT_DIRECTORY/post_start*.log 1> /dev/null 2>&1
chmod 755 $OUTPUT_DIRECTORY/started*.log 1> /dev/null 2>&1
chmod 755 $OUTPUT_DIRECTORY/bl_start*.log 1> /dev/null 2>&1
chown $oracred $OUTPUT_DIRECTORY/pre_stop*.log 1> /dev/null 2>&1
chown $oracred $OUTPUT_DIRECTORY/post_start*.log 1> /dev/null 2>&1
chown $oracred $OUTPUT_DIRECTORY/started*.log 1> /dev/null 2>&1
chown $oracred $OUTPUT_DIRECTORY/bl_start*.log 1> /dev/null 2>&1
filename=$(echo $(hostname) | cut -d. -f1)_$(date '+%m%d%Y_%H%M%S')
mv ${LOG} $OUTPUT_DIRECTORY/start_$filename.log
echo ""
echo ""
echo "************************************************************************************************************";
echo "Please check the detailed START report at $OUTPUT_DIRECTORY/start_$filename.log"
echo "************************************************************************************************************";
echo ""
#################################################################
# #
# Modified by EMEA OracleDBA Team for enhancements & automation #
# DEC 2016 #
# #
#################################################################
# #
# #
# USAGE : To be executed as oracle user #
# (pbrun to oracle or pboracle) #
# #
# Manual execution #
# sh bl_status.ksh #
# #
# Via job scheduler tools and by-passing the prompt #
# sh bl_status.ksh y #
# #
#---------------------------------------------------------------#
# #
# //Generic information about the batch of scripts developed// #
# bl_status.ksh #
# bl_stop.ksh #
# bl_stop_crs.ksh #
# bl_start_crs.ksh #
# bl_start.ksh #
# #
# Versions/Combinations Supported #
# Clustware 12c #
# Clustware 11g #
# Clustware 10g #
# NON-RAC with ASM 11g #
# NON-RAC with ASM 10g #
# NON-RAC & NON-ASM #
# #
# Components in scope #
# Clusterware #
# ASM Instance #
# Database Instance #
# Cluster Listener #
# Local Listener #
# Manager Recovery Process #
# GoldenGate Replication #
# Port Utility #
# Enterprise Manager Agent #
# OSWatcher Utility #
# Foglight Monitoring Agent #
# Filesystem #
# Rawdisk #
# #
#################################################################
export OS=`uname -a | awk '{ print $1 }'`
eval timevalue=`date '+%m%d%Y_%H%M%S'`
#Handle First Argument (oraowner:oragroup) if specified
if [[ ! -z $1 ]]; then
export oracred=$1
export oraowner=`echo $oracred | cut -d":" -f1 -s`
export oragroup=`echo $oracred | cut -d":" -f2 -s`
echo "Oracle Ownership Captured ARGUMENTS ...
oracred=$oracred
oraowner=$oraowner
oragroup=$oragroup
"
else
export oracred=oracle:dba
export oraowner=oracle
export oragroup=dba
fi
# CHECK IF THE USER IS as Arg#1 if specified
echo " "
if [ $(whoami) != "${oraowner}" ]
then
echo ' \t \t' "ATTENTION : Please execute this script as ${oraowner} user"
exit 0;
fi
# SCRIPT AND OUTPUT DIRECTORIES INITIALIZATION
SCRIPT_DIRECTORY=/efs/dist/gmrtdba/dbascripts/scripts/common
if [[ ${oraowner} = "oracle" ]]; then
if [[ -d /oracle/dba/output/generic ]]; then
OUTPUT_DIRECTORY=/oracle/dba/output/generic
else
OUTPUT_DIRECTORY=/var/bl_ora/log
if [[ ! -d $OUTPUT_DIRECTORY ]]; then
echo "OUTPUT_DIRECTORY: $OUTPUT_DIRECTORY was not found on this server ... Exiting"
exit 0
fi
fi
else
if [[ -d /oracle/dba/output/generic ]]; then
OUTPUT_DIRECTORY=/oracle/dba/output/generic/${oraowner}
else
OUTPUT_DIRECTORY=/var/bl_ora/log/${oraowner}
if [[ ! -d $OUTPUT_DIRECTORY ]]; then
echo "OUTPUT_DIRECTORY: $OUTPUT_DIRECTORY was not found on this server ... Exiting"
exit 0
fi
fi
fi
if [[ -f $OUTPUT_DIRECTORY/server_type.log ]]; then
#server_type=$(<$OUTPUT_DIRECTORY/server_type.log)
rm -f $OUTPUT_DIRECTORY/server_type.log
fi
if [ "$(ps -ef | grep crsd.bin | grep -v grep | wc -l)" -eq 1 ]
then
if [ "$(ps -ef | grep crsd.bin | grep -v grep | grep "12\." | wc -l)" -eq 1 ]
then
export server_type="rac_12c"
elif [ "$(ps -ef | grep crsd.bin | grep -v grep | grep "11\." | wc -l)" -eq 1 ]
then
export server_type="rac_11g"
else
export server_type="rac_10g"
fi
else
if [ "$(ps -ef | grep ohasd.bin | grep -v grep | grep "12\." | wc -l)" -eq 1 ]
then
export server_type="norac_asm12c"
elif [ "$(ps -ef | grep ohasd.bin | grep -v grep | grep "11\." | wc -l)" -eq 1 ]
then
export server_type="norac_asm11g"
elif [ "$(ps -ef | grep pmon | grep -v grep | grep "+ASM" | grep -v onitor | wc -l)" -eq 1 ]
then
export server_type="norac_asm10g"
else
export server_type="norac_noasm"
fi
fi
# Address rare issue seen where crsd.bin not picked up even though it is in fact a RAC system!
if [[ "$server_type" == norac_asm* ]] && [[ -f /etc/oratab ]]; then
ASM_LAST_CHAR=`grep "^\+ASM" /etc/oratab | cut -d":" -f1 -s | sed -e "s/.*\(.\)/\1/"`
echo $ASM_LAST_CHAR | egrep '^[0-9]+$'
if [ $? -eq 0 ]; then
#echo "$ASM_LAST_CHAR is a number .. So it's a RAC "
server_str_2=`echo $server_type | sed 's/asm//g' |cut -d"_" -f2 -s`
export server_type="rac_${server_str_2}"
fi
fi
echo $server_type > $OUTPUT_DIRECTORY/server_type.log
########################################################################
## Get standard pw for db connections ##################################
## Gen: echo "*****" | openssl enc -base64
export dba_ro_p=`echo "c2FmMzJ1c2UK" | openssl enc -base64 -d`
export gem_re_p=`echo "Z2Vtc19wYXNzdzByZAo=" | openssl enc -base64 -d`
########################################################################
status_ora_homes()
{
rm -f $OUTPUT_DIRECTORY/bl_ora_homes.tmp
rm -f $OUTPUT_DIRECTORY/bl_ora_homes.lst
#Get ORA HOME info from running instances
ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s | while read ORA_INST
do
if [[ ! -z $ORA_INST ]]; then
grep "^${ORA_INST}:" /etc/oratab | grep -v "^#" | cut -d":" -f2 -s | while read ORA_HOME
do
echo $ORA_HOME >> $OUTPUT_DIRECTORY/bl_ora_homes.tmp
done
fi
done
if [[ -f $OUTPUT_DIRECTORY/bl_ora_homes.tmp ]]; then
cat $OUTPUT_DIRECTORY/bl_ora_homes.tmp | sort -u > $OUTPUT_DIRECTORY/bl_ora_homes.lst
echo " Active Oracle Homes Found in /etc/oratab on this host: " >> ${LOG}
echo "`cat $OUTPUT_DIRECTORY/bl_ora_homes.lst`" >> ${LOG}
echo "" >> ${LOG}
else
echo "" >> ${LOG}
echo "No Oracle Home Information Found from /etc/oratab on this host " >> ${LOG}
echo "" >> ${LOG}
fi
}
status_has()
{
echo "Collecting CLUSTERWARE information ..... "; echo ""
echo "************************** CLUSTERWARE *********************" >> ${LOG}; echo "" >> ${LOG}
export ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'`
export ORAENV_ASK=NO >/dev/null;
. oraenv >/dev/null
crs_en_dis=`cat /etc/oracle/scls_scr/$(echo $(hostname) | cut -d. -f1)/root/crsstart | awk 'BEGIN{FS=":"}{print $1}'`
echo "CRS status : $crs_en_dis" >> ${LOG}; echo "" >> ${LOG}
crsctl check has >> ${LOG} ; echo "" >> ${LOG}
crsctl check crs >> ${LOG} ; echo "" >> ${LOG}
srvctl status asm -n $(hostname) >> ${LOG} ; >> ${LOG} ; echo "" >> ${LOG}
crs_stat -t >> ${LOG} ; >> ${LOG} ; echo "" >> ${LOG}
crsctl stat res -t >> ${LOG} ; >> ${LOG} ; echo "" >> ${LOG}
echo "CRS status : $crs_en_dis" >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
}
status_crs()
{
echo "Collecting CLUSTERWARE information ..... "; echo ""
echo "************************** CLUSTERWARE *********************" >> ${LOG}; echo "" >> ${LOG}
ORACLE_SID=`cat /etc/oratab | awk 'BEGIN{FS=":"}{print $1}' | grep CRS | grep -v "#"`
export ORAENV_ASK=NO >/dev/null;
. oraenv >/dev/null
crs_en_dis=`cat /etc/oracle/scls_scr/$(echo $(hostname) | cut -d. -f1)/root/crsstart | awk 'BEGIN{FS=":"}{print $1}'`
echo "CRS status : $crs_en_dis" >> ${LOG}; echo "" >> ${LOG}
crsctl check crs >> ${LOG} ; echo "" >> ${LOG}
crs_stat -t >> ${LOG} ; >> ${LOG} ; echo "" >> ${LOG}
if [ "$(ps -ef | grep crs | grep -v grep | awk 'BEGIN{FS=" "}{print $(NF)}' | grep "10\." | wc -l)" -eq 0 ]
then
crsctl stat res -t >> ${LOG} ; >> ${LOG} ; echo "" >> ${LOG}
crsctl stat res -t >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
#crsctl stat res -t >> ${LOG} ; >> ${LOG} ; echo "" >> ${LOG}
echo "";
fi
}
status_asm()
{
echo "Collecting ASM information ..... "; echo ""
echo "***************************** ASM ************************" >> ${LOG}; echo "" >> ${LOG}
ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep "+ASM" | grep -v onitor >> ${LOG} ; echo "" >> ${LOG}
ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'>$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
for SID in `ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'`
do
export ORACLE_SID=${SID} >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
op=`$ORACLE_HOME/bin/sqlplus -s '/ as sysdba'<< EOF
set echo off;
set linesize 200 pages 1000
col PATH for A40
col NAME for A30
select instance_name,host_name,startup_time from gv\\$instance;
select group_number gn,disk_number dn, mount_status, header_status,mode_status,state, total_mb, free_mb, path, name
from v\\$asm_disk order by group_number, disk_number;
set heading off;
select 'Use below ouput for comparing ASM DISK Status Pre and Post' from dual;
select 'ASMDISK_COMPARE_STRINGS:'||mount_status||':'||header_status||':'||mode_status||':'||name from v\\$asm_disk where NAME is not null order by name;
EOF`
echo "$op" >> ${LOG};echo "" >> ${LOG}
done
}
status_db()
{
echo "Collecting DATABASE & SERVICES information ..... "; echo ""
echo "************************** DATABASE & SERVICES *********************" >> ${LOG}; echo "" >> ${LOG}
ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s>$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
if [ "$(ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" |grep -v "\-MGMTDB" | grep -v onitor | wc -l)" != 0 ]
then
rm -f $OUTPUT_DIRECTORY/db:inst
rm -f $OUTPUT_DIRECTORY/db:inst.log
rm -f $OUTPUT_DIRECTORY/unidb:inst.log
rm -f $OUTPUT_DIRECTORY/dbopen:info.log
rm -f $OUTPUT_DIRECTORY/inst_info.log
rm -f $OUTPUT_DIRECTORY/db_stat_info.log
rm -f $OUTPUT_DIRECTORY/"$when"_"$why"_dbservices.log
# Grab unique name from each runing Instance
for SID in `ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" |grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s`
do
export ORACLE_SID=$SID
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
$ORACLE_HOME/bin/sqlplus -s '/ as sysdba'<< EOFUDB1 > $OUTPUT_DIRECTORY/inst_info.log
set echo off;
set heading off;
set linesize 200 pages 100;
select 'DBINST_ENTRY:'||d.DB_UNIQUE_NAME||':'||i.INSTANCE_NAME from v\$database d, v\$instance i;
select 'DBINST_OPEN_INFO:'||i.INSTANCE_NAME from v\$database d, v\$instance i where i.STATUS='OPEN' and d.DATABASE_ROLE='PRIMARY';
EOFUDB1
cat $OUTPUT_DIRECTORY/inst_info.log | grep "DBINST_ENTRY:" >> $OUTPUT_DIRECTORY/unidb:inst.log
cat $OUTPUT_DIRECTORY/inst_info.log | grep "DBINST_OPEN_INFO:" >> $OUTPUT_DIRECTORY/dbopen:info.log
done
# Display some db info in status log based on contents of $OUTPUT_DIRECTORY/dbopen:info.log
if [[ -f $OUTPUT_DIRECTORY/dbopen:info.log ]]; then
while read data
do
export ORACLE_SID=$(echo $data | awk 'BEGIN{FS=":"}{print $2}') >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
echo "" >> ${LOG}
echo "Collecting db info for instance: ${ORACLE_SID} " >> ${LOG}
echo "" >> ${LOG}
if [ $(ps -ef | grep -v grep | grep pmon | grep "^.*${oraowner} " | grep "pmon_${ORACLE_SID}\$" | wc -l) -ne 0 ]
then
$ORACLE_HOME/bin/sqlplus -s '/ as sysdba' << EOF > $OUTPUT_DIRECTORY/db_stat_info.log
set linesize 200 pages 100;
set heading off;
set echo off;
column COMP_ID format a15
column COMP_NAME format a40
column STATUS format a10
select '******* DB REGISTRY INFO *******' FROM DUAL;
select COMP_NAME, VERSION, STATUS, MODIFIED from dba_registry;
select '******* DB OBJECT VALID/INVALID COUNT *******' FROM DUAL;
select STATUS,COUNT(*) FROM DBA_OBJECTS GROUP BY STATUS;
select 'Checking any INVALID object counts ' FROM DUAL;
select owner,object_type,count(1) from dba_objects where status='INVALID' group by owner,object_type order by owner,object_type;
select '******* CONTROL FILE LOCATIONS *******' FROM DUAL;
select NAME from v\$controlfile;
select '******* DB SIZE TOTALS *******' FROM DUAL;
set heading on;
select (select sum(bytes/1048576) from dba_data_files) "Data Mb", (select NVL(sum(bytes/1048576),0) from dba_temp_files) "Temp Mb", (select sum(bytes/1048576)*max(members) from v\$log) "Redo Mb", (select sum(bytes/1048576) from dba_data_files) + (select NVL(sum(bytes/1048576),0) from dba_temp_files) + (select sum(bytes/1048576)*max(members) from v\$log) "Total Mb" from dual;
set heading off;
EOF
cat $OUTPUT_DIRECTORY/db_stat_info.log >> ${LOG}; echo "" >> ${LOG}
fi
echo "___________________________________________________________">> ${LOG};
done < $OUTPUT_DIRECTORY/dbopen:info.log
fi
if [[ $server_type = "rac_11g" ]] || [[ $server_type = "rac_12c" ]]
then
export ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'`
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
for SID in `ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" |grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d "_" -f3,4 -s`
do
R_DBNAME=` echo $SID | sed "s/[1-9]$//g"|sed "s/_$//g"`;ONENode_DB="";
if [ "$(srvctl config database -d $R_DBNAME |grep -w "RACOneNode" | wc -l)" -eq 1 ]
then
export LOCAL_NODE=`hostname -s`
export ONENode_DB=`echo ":$LOCAL_NODE"`
fi
UNIQUE_NAME=`echo $(crs_stat | grep "ora." | grep ".db$" | grep -i "$R_DBNAME" | tr "[:lower:]" "[:upper:]")`
if [[ -f $OUTPUT_DIRECTORY/unidb:inst.log ]] && [[ ! -z $UNIQUE_NAME ]]; then
UNIQUE_SID=`echo $UNIQUE_NAME | cut -d"." -f2 -s`
CHK_UNI_LOG=`grep ":${UNIQUE_SID}:" $OUTPUT_DIRECTORY/unidb:inst.log`
if [[ -z $CHK_UNI_LOG ]]; then
UNIQUE_NAME=""
fi
fi
if [[ ! -z $UNIQUE_NAME ]]; then
echo $(crs_stat | grep "ora." | grep ".db$" | grep -i $R_DBNAME | tr "[:lower:]" "[:upper:]" | awk 'BEGIN{FS="."}{print $2}')":"$SID$ONENode_DB >> $OUTPUT_DIRECTORY/db:inst
else
if [[ -f $OUTPUT_DIRECTORY/unidb:inst.log ]]; then
#Do lookup from status file to find correct Unique name
UNI_NAME=`grep "DBINST_ENTRY:" $OUTPUT_DIRECTORY/unidb:inst.log | grep ":${SID}$"| cut -d":" -f2 -s`
## if [[ ! -z $UNI_NAME ]]; then ## if unique name is have _tx matching with crs resource
if [[ "$(crs_stat | grep "ora." | grep ".db$" | grep -i ${UNI_NAME} | wc -l)" -eq 1 ]]; then
echo $(crs_stat | grep "ora." | grep ".db$" | grep -i ${UNI_NAME} | tr "[:lower:]" "[:upper:]" | awk 'BEGIN{FS="."}{print $2}')":"$SID >> $OUTPUT_DIRECTORY/db:inst
else
echo $(crs_stat | grep "ora." | grep ".db$" | grep -i ${R_DBNAME} | tr "[:lower:]" "[:upper:]" | awk 'BEGIN{FS="."}{print $2}')":"$SID >> $OUTPUT_DIRECTORY/db:inst
fi
else
echo $(crs_stat | grep "ora." | grep ".db$" | grep -i ${R_DBNAME} | tr "[:lower:]" "[:upper:]" | awk 'BEGIN{FS="."}{print $2}')":"$SID >> $OUTPUT_DIRECTORY/db:inst
fi
fi
done
elif [[ $server_type = "rac_10g" ]]
then
ORACLE_SID=`cat /etc/oratab | awk 'BEGIN{FS=":"}{print $1}' | grep CRS | grep -v "#"`
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
for SID in `ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s`
do
echo $(crs_stat | grep ora | grep db | grep -i ${SID%?} | tr "[:lower:]" "[:upper:]" | awk 'BEGIN{FS="."}{print $2}')":"$SID >> $OUTPUT_DIRECTORY/db:inst
done
else
for SID in `ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s`
do
echo $SID":"$SID >> $OUTPUT_DIRECTORY/db:inst
done
fi
cp $OUTPUT_DIRECTORY/db:inst $OUTPUT_DIRECTORY/db:inst.log
ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor >> ${LOG} ; echo "" >> ${LOG}
while read data
do
export ORACLE_DB=$(echo $data | awk 'BEGIN{FS=":"}{print $1}') >/dev/null
export ORACLE_SID=$(echo $data | awk 'BEGIN{FS=":"}{print $2}') >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
echo "Database Instance : "$ORACLE_SID >> ${LOG};
if [[ $server_type = "rac_11g" ]] || [[ $server_type = "rac_10g" ]] || [[ $server_type = "rac_12c" ]]
then
srvctl status database -d $ORACLE_DB >> ${LOG};echo "" >> ${LOG}
srvctl status service -d $ORACLE_DB >> ${LOG};echo "" >> ${LOG}
echo $ORACLE_DB:$ORACLE_SID":"$(srvctl status service -d $ORACLE_DB | grep $ORACLE_SID | grep -i "is running" | awk '{ print $2 }') >> $OUTPUT_DIRECTORY/"$when"_"$why"_dbservices.log
echo "_____________________________________________________________________" >> ${LOG}
sleep 3
else
op=`$ORACLE_HOME/bin/sqlplus -s '/ as sysdba'<< EOFDB2
set echo off;
set linesize 200 pages 100;
select instance_name,host_name,startup_time from gv\\$instance;
select name,open_mode,database_role from gv\\$database;
EOFDB2`
echo "$op" >> ${LOG};echo "" >> ${LOG}
if [[ "$server_type" == norac_asm* ]]; then
echo "" >> ${LOG}
echo "srvctl status database -d $ORACLE_DB" >> ${LOG}
srvctl status database -d $ORACLE_DB >> ${LOG}
echo "srvctl status service -d $ORACLE_DB" >> ${LOG}
srvctl status service -d $ORACLE_DB >> ${LOG}
echo "" >> ${LOG}
fi
echo "_____________________________________________________________________" >> ${LOG}
fi
done < $OUTPUT_DIRECTORY/db:inst.log
if [[ "$(cat $OUTPUT_DIRECTORY/db:inst.log | wc -l)" -gt 0 ]]; then
echo "yes" > $OUTPUT_DIRECTORY/"$why"_"$what".log
else
echo "no" > $OUTPUT_DIRECTORY/"$why"_"$what".log
fi
if [[ "$(cat $OUTPUT_DIRECTORY/dbopen:info.log | wc -l)" -gt 0 ]]; then
echo "yes" > $OUTPUT_DIRECTORY/"$why"_dbopenlog
else
echo "no" > $OUTPUT_DIRECTORY/"$why"_dbopen.log
fi
else
echo "All oracle instances are DOWN" >> ${LOG}; echo "" >> ${LOG}
fi
}
status_lsnr()
{
echo "Collecting LISTENER information ..... "; echo ""
echo "***************************** LISTENER ************************" >> ${LOG}; echo "" >> ${LOG}
ps -ef | grep lsnr | grep "^.*${oraowner} " | grep -v grep >> ${LOG} ; echo "" >> ${LOG}
ps -ef | grep lsnr | grep "^.*${oraowner} " | grep -v grep |sed -n 's/.*\(tnslsnr.*\).*/\1/p' | awk '{ print $2 }' | sed '/^\s*$/d' >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
if [[ $server_type = "rac_11g" ]] || [[ $server_type = "norac_asm11g" ]] || [[ $server_type = "rac_12c" ]] || [[ $server_type = "norac_asm12c" ]] || [[ $server_type = "rac_10g" ]] || [[ $server_type = "norac_asm10g" ]]
then
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}' | head -1`
else
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s | head -1`
fi
export ORAENV_ASK=NO >/dev/null
if [[ ! -z $ORACLE_SID ]]; then
. oraenv >/dev/null
fi
for lsnr in `ps -ef | grep lsnr | grep "^.*${oraowner} " | grep -v grep | sed -n 's/.*\(tnslsnr.*\).*/\1/p' | awk '{ print $2 }'`
do
LSNR_HOME=`ps -ef | grep lsnr | grep $lsnr | grep "^.*${oraowner} " | grep -v grep | sed -n 's/.*\(..........................................................tnslsnr\).*/\1/p' | awk '{ print $NF }' | sed 's/\/bin\/tnslsnr//g'`
if [[ $ORACLE_HOME != $LSNR_HOME ]]; then
if [[ -f /etc/oratab ]]; then
ORACLE_SID=`grep "$LSNR_HOME" /etc/oratab | grep -v "^#" | cut -d":" -f1 -s | tail -1`
export ORAENV_ASK=NO >/dev/null
if [[ ! -z $ORACLE_SID ]]; then
. oraenv >/dev/null
fi
fi
fi
lsnrctl status $lsnr >> ${LOG};echo "" >> ${LOG}
done
}
status_gg()
{
echo "Collecting GOLDENGATE information ..... "; echo ""
echo "***************************** GOLDENGATE **************************" >> ${LOG}; echo "" >> ${LOG}
ps -ef | grep -v grep | grep "mgr PARAMFILE" | grep "^.*${oraowner} " | sed -n 's/.*\(....................................................................\/....prm \).*/\1/p' | awk '{ print $NF }' | grep -v "\.\.\.\.mgr.prm" >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
if [ "$(ps -ef | grep -v grep | grep "mgr PARAMFILE" | grep "^.*${oraowner} " | wc -l)" -eq 0 ]
then
echo "GoldenGate is not running" >> ${LOG};echo "" >> ${LOG}
else
echo "GoldenGate is running" >> ${LOG};echo "" >> ${LOG}
#ps -ef | grep "/ggate/product/" | grep -v grep >> ${LOG};echo "" >> ${LOG}
ps -ef | grep -v grep | grep "^.*${oraowner} " | grep "mgr PARAMFILE" >> ${LOG};echo "" >> ${LOG}
# Set Ora env
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'`
export ORAENV_ASK=NO >/dev/null;
if [[ ! -z $ORACLE_SID ]]; then
. oraenv >/dev/null
else
ORACLE_SID=`ps -ef | grep pmon | sort -k9 | grep "^.*${oraowner} " | grep -v grep | grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | awk '{ print $NF }' | cut -d"_" -f3,4 -s | tail -1`
. oraenv >/dev/null
fi
ps -ef | grep -v grep | grep "mgr PARAMFILE" | grep "^.*${oraowner} " | sed -n 's/.*\(...................................................................\/....prm \).*/\1/p' | awk '{ print $NF }' | sort | while read GG_MGRPROC
do
# Proceed only if Golden Gate Manager is running
if [[ ! -z $GG_MGRPROC ]]; then
#GG_HOME=`echo $GG_MGRPROC | sed 's/\/dirprm\/mgr.prm//g'`
GG_HOME=`echo $GG_MGRPROC | sed 's/\/dirprm\/mgr.prm//g' | sed 's/\/dirprm\/MGR.prm//g'`
if [[ -d $GG_HOME ]]; then
${GG_HOME}/ggsci << EOF >> ${LOG}
info all
exit
EOF
#echo "$op" >> ${LOG};echo "" >> ${LOG}
fi
fi
done
fi
}
status_dbfs()
{
echo "Collecting DBFS information ..... "; echo ""
echo "***************************** DBFS **************************" >> ${LOG}; echo "" >> ${LOG}
ps -ef | grep -v grep | grep "dbfs_client" | grep "^.*${oraowner} " | sed -n 's/.*\(................................................................\/bin\/dbfs_client\).*/\1/p' | awk '{ print $NF }' | grep -v "\.\.\.\.dbfs_client" >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
if [ "$(ps -ef | grep -v grep | grep "dbfs_client" | grep "^.*${oraowner} " | wc -l)" -eq 0 ]
then
echo "DBFS is not running" >> ${LOG};echo "" >> ${LOG}
else
echo "DBFS is running" >> ${LOG};echo "" >> ${LOG}
ps -ef | grep -v grep | grep "^.*${oraowner} " | grep "dbfs_client" >> ${LOG};echo "" >> ${LOG}
fi
}
status_mrp()
{
echo "Collecting MRP information ..... "; echo ""
echo "******************************** MRP *****************************" >> ${LOG}; echo "" >> ${LOG}
ps -ef | grep mrp | sort -k9 | grep "^.*${oraowner} " | grep -v grep >> ${LOG} ; echo "" >> ${LOG}
ps -ef | grep mrp | sort -k9 | grep "^.*${oraowner} " | grep -v grep | awk '{ print $NF }' | cut -d"_" -f3,4 -s >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
if [ "$(ps -ef | grep mrp | grep "^.*${oraowner} " | grep -v grep | wc -l)" -eq 0 ]
then
echo "MRP is not running" >> ${LOG} ; echo "" >> ${LOG}
else
echo "MRP is running .. Collecting DG related Info" >> ${LOG} ; echo "" >> ${LOG}
#Pickup DG LAG STATUS from Primary db
DG_INST_1_LOG=$OUTPUT_DIRECTORY/pre_stop_dg_dbinst.log
DG_INST_2_LOG=$OUTPUT_DIRECTORY/pre_stop_dg_Primdbinst.log
rm -f ${DG_INST_1_LOG}
rm -f ${DG_INST_2_LOG}
while read data
do
export ORACLE_DB=$(echo $data | awk 'BEGIN{FS=":"}{print $1}') >/dev/null
export ORACLE_SID=$(echo $data | awk 'BEGIN{FS=":"}{print $2}') >/dev/null
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
echo "Checking Database Instance : "$ORACLE_SID >> ${LOG};
op=`$ORACLE_HOME/bin/sqlplus -s '/ as sysdba'<< EOFDB2
set heading off;
set echo off;
set linesize 200 pages 100;
select 'PRIMARY_DB_UNIQUE:'||PRIMARY_DB_UNIQUE_NAME||':STANDBY_DB_UNIQUE:'||DB_UNIQUE_NAME||':STANDBY_DB_INST:${ORACLE_SID}' from v\\$database where database_role like 'PHYSICAL STANDBY';
EOFDB2`
echo "$op" | grep "PRIMARY_DB_UNIQUE:" >> ${DG_INST_1_LOG}
done < $OUTPUT_DIRECTORY/db:inst.log
if [[ -f ${DG_INST_1_LOG} ]]; then
STANDBY_CNT=`cat ${DG_INST_1_LOG} | wc -l`
if [[ $STANDBY_CNT -ne 0 ]]; then
cat ${DG_INST_1_LOG} | while read dgline
do
PRIM_DB_SID=`echo $dgline | cut -d":" -f2 -s`
STANDBY_DB_SID=`echo $dgline | cut -d":" -f4 -s`
STANDBY_DB_INST=`echo $dgline | cut -d":" -f6 -s`
if [[ ! -z $PRIM_DB_SID ]]; then
op=`$ORACLE_HOME/bin/sqlplus -s '/ as sysdba' << EOFDB2
conn dba_ro/${dba_ro_p}@${PRIM_DB_SID}
set heading off;
set echo off;
set linesize 200 pages 100;
select d.name||':'||b.dest_id||':'||b.DRNAME||':'||max(a.Primary_sequence - b.DR_sequence)
from v\\$database d,(select thread#, SEQUENCE# Primary_sequence from v\\$log where status='CURRENT') a,
(select thread#,RESETLOGS_CHANGE#,max(sequence#) DR_sequence,dest_id,upper(name) DRNAME from v\\$archived_log where dest_id in (2,3) and applied in ('YES','IN-MEMORY') group by thread#,RESETLOGS_CHANGE#,dest_id,upper(name)) b
where d.RESETLOGS_CHANGE#=b.RESETLOGS_CHANGE#
and a.thread#=b.thread#
and b.DRNAME is not null
and b.DRNAME not like '%/%'
group by d.name,b.dest_id,b.DRNAME;
EOFDB2`
echo "${op}:${STANDBY_DB_INST}" >> ${DG_INST_2_LOG}
if [[ -f ${DG_INST_2_LOG} ]]; then
echo "" >> ${LOG};
echo "Active DG destinations detected on Primary db: $PRIM_DB_SID .. " >> ${LOG};
echo "" >> ${LOG};
echo "PRIMARY_DB:DEST_ID:STANDBY_DB:CURRENT_LAG:STANDBY_LOCAL_INST" >> ${LOG};
echo "============================================================" >> ${LOG};
echo "`cat ${DG_INST_2_LOG} | grep ":${STANDBY_DB_SID}:"`" >> ${LOG};
echo "" >> ${LOG};
echo "" >> ${LOG};
fi
fi
done
fi
fi
fi
}
status_em()
{
echo "Collecting EMAGENT information ..... "; echo ""
echo "***************************** EMAGENT ************************" >> ${LOG}; echo "" >> ${LOG}
if [ $(ps -ef | grep emagent | grep "^.*${oraowner} " | grep -v grep | wc -l) != 0 ]
then
ORACLE_SID=`cat /etc/oratab | awk 'BEGIN{FS=":"}{print $1}' | grep OEM | grep -v "^#"`
export ORAENV_ASK=NO >/dev/null;
if [[ ! -z $ORACLE_SID ]]; then
. oraenv >/dev/null
emctl status agent >> ${LOG} ; echo "" >> ${LOG}
fi
emctl status agent | grep "Agent is Running and Ready" > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
echo "EMAgent is not running" >> ${LOG} ; echo "" >> ${LOG}
fi
}
status_fgl()
{
echo "Collecting FOGLIGHT information ..... "; echo ""
echo "**************************** FOGLIGHT ****************************" >> ${LOG}; echo "" >> ${LOG}
ps -ef | grep -i foglight | grep "^.*${oraowner} " | grep -v grep >> ${LOG} ; echo "" >> ${LOG}
ps -ef | grep -i foglight | grep "^.*${oraowner} " | grep -v grep|head -1 > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
if [ "$(ps -ef | grep -i foglight | grep "^.*${oraowner} " | grep -v grep | wc -l)" -eq 0 ]
then
echo "Foglight is not running" >> ${LOG} ; echo "" >> ${LOG}
fi
}
status_osw()
{
echo "Collecting OSWATCHER information ..... "; echo ""
echo "**************************** OSWATCHER ****************************" >> ${LOG}; echo "" >> ${LOG}
ps -ef | grep -i OSW | grep "^.*${oraowner} " | grep -v grep >> ${LOG} ; echo "" >> ${LOG}
ps -ef | grep -i OSW | grep "^.*${oraowner} " | grep -v grep |head -1 > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
if [ "$(ps -ef | grep -i OSW | grep "^.*${oraowner} " | grep -v grep | wc -l)" -eq 0 ]
then
echo "OSWatcher is not running" >> ${LOG} ; echo "" >> ${LOG}
fi
}
status_portutil()
{
echo "Collecting PORT UTILITY information ..... "; echo ""
echo "**************************** PORT UTILITY ****************************" >> ${LOG}; echo "" >> ${LOG}
#ps -ef | grep 10101 | grep -v grep | grep port >> ${LOG} ; echo "" >> ${LOG}
ps -ef | grep "portdaemon.pl" | grep -v grep | grep port >> ${LOG} ; echo "" >> ${LOG}
ps -ef | grep "portdaemon.pl" | grep -v grep | grep port |head -2 > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
#if [ "$(ps -ef | grep 10101 | grep -v grep | grep port | wc -l)" -ge 1 ]
if [ "$(ps -ef | grep "portdaemon.pl" | grep -v grep | grep port | wc -l)" -ge 1 ]
then
echo "Port Utility is running" >> ${LOG} ; echo "" >> ${LOG}
else
echo "Port Utility is not running" >> ${LOG} ; echo "" >> ${LOG}
fi
}
status_tfa()
{
echo "Collecting TFA information ..... "; echo ""
echo "***************************** TFA **************************" >> ${LOG}; echo "" >> ${LOG}
ps -ef | grep -v grep | grep tfa_home |head -1 > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
if [ "$(ps -ef | grep -v grep | grep tfa_home | wc -l)" -eq 0 ]
then
echo "TFA is not running" >> ${LOG};echo "" >> ${LOG}
else
echo "TFA is running" >> ${LOG};echo "" >> ${LOG}
ps -ef | grep -v grep | grep "tfa_home" >> ${LOG};echo "" >> ${LOG}
fi
}
status_bda()
{
echo "Collecting BDA Agent information ..... "; echo ""
echo "***************************** BDA **************************" >> ${LOG}; echo "" >> ${LOG}
ps -ef | grep -v grep | grep dagent.conf |head -1 > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
BDA_AGT=$OUTPUT_DIRECTORY/pre_stop_bda.log
if [ "$(ps -ef | grep -v grep | grep dagent.conf | wc -l)" -eq 0 ]
then
echo "BDA Agent is not running" >> ${LOG};echo "" >> ${LOG}
echo "no" > $BDA_AGT
else
echo "BDA Agent is running" >> ${LOG};echo "" >> ${LOG}
ps -ef | grep -v grep | grep "dagent.conf" >> ${LOG};echo "" >> ${LOG}
echo "yes" > $BDA_AGT
fi
}
status_fs()
{
echo "Collecting FILESYSTEM information ..... "; echo ""
echo "**************************** FILESYSTEM ***************************" >> ${LOG}; echo "" >> ${LOG} ;
df -Pk > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
df -Pk >> ${LOG} ; echo "" >> ${LOG}
echo "OCFS Information... " >> ${LOG} ;
if [[ -f /etc/fstab ]]; then
grep ocfs /etc/fstab >> ${LOG} ; echo "" >> ${LOG}
fi
#Get Core FS Count
df -Pk | sed -n '1!p' | grep -v " /home" | grep -v " /.efs" | grep -v " /efs" | grep -v " /run" | grep -v " /apps/oracle" | grep -v " /tempmnt" | grep -v " /Net" | grep -v " /net" | grep -v " /dbacl" | wc -l > $OUTPUT_DIRECTORY/pre_disk_fs_mount.cnt
df -Pk | sed -n '1!p' | awk '{ print $NF }' | grep -v "^/home" | grep -v "^/.efs" | grep -v "^/efs" | grep -v "^/run" | grep -v "^/apps/oracle" | grep -v "^/tempmnt" | grep -v "^/Net" | grep -v "^/net" | grep -v "^/dbacl" > $OUTPUT_DIRECTORY/pre_disk_fs_mount.log
}
status_disk()
{
echo "Collecting DISK information ..... "; echo ""
echo "******************************* DISK ******************************" >> ${LOG}; echo "" >> ${LOG} ;
if [[ $OS != "AIX" ]]; then
ls -l /dev/mapper|egrep "asm.*p1|fra.*p1|gg.*p1"|while read line
do
named_disk=$(echo $line|xargs|cut -f9 -d" ")
dm_disk=$(echo $line|xargs|cut -f11 -d" "|cut -f2 -d"/")
echo "${named_disk}"
ls -l /dev/${dm_disk}
done > $OUTPUT_DIRECTORY/disk_info.lst
filename=$(date '+%m%d%Y_%H%M%S')
mv $OUTPUT_DIRECTORY/disk_info.lst $OUTPUT_DIRECTORY/disk_info_$filename.lst
echo "Disk ownership information is available at $OUTPUT_DIRECTORY/disk_info_$filename.lst" >> ${LOG} ; echo "" >> ${LOG}
fi
}
status_standalone_autostart()
{
echo "Collecting ORATAB and LSNRTAB information ..... "; echo ""
echo "******************************* STANDALONE AUTO-START INFO (/etc/oratab and /etc/lsnrtab contents) ******************************" >> ${LOG}; echo "" >> ${LOG} ;
if [[ -f /etc/oratab ]]; then
echo "" >> ${LOG}
echo "/etc/oratab =>" >> ${LOG}
echo "" >> ${LOG}
echo "`cat /etc/oratab`" >> ${LOG} ; echo "" >> ${LOG}
echo "" >> ${LOG}
else
echo "" >> ${LOG}
echo " NO /etc/oratab FOUND on this host!" >> ${LOG} ; echo "" >> ${LOG}
echo "" >> ${LOG}
fi
if [[ -f /etc/lsnrtab ]]; then
echo "" >> ${LOG}
echo "/etc/lsnrtab =>" >> ${LOG}
echo "" >> ${LOG}
echo "`cat /etc/lsnrtab`" >> ${LOG} ; echo "" >> ${LOG}
echo "" >> ${LOG}
else
echo "" >> ${LOG}
echo " NO /etc/lsnrtab FOUND on this host!" >> ${LOG} ; echo "" >> ${LOG}
echo "" >> ${LOG}
fi
}
status_status()
{
if [[ -f $OUTPUT_DIRECTORY/pre_"$why"_"$what".log ]]; then
if [[ "$(cat $OUTPUT_DIRECTORY/pre_"$why"_"$what".log | wc -l)" -gt 0 ]]; then
echo "yes" > $OUTPUT_DIRECTORY/"$why"_"$what".log
else
echo "no" > $OUTPUT_DIRECTORY/"$why"_"$what".log
fi
fi
}
# Remove the temporary log file
rm -f $OUTPUT_DIRECTORY/status.log
# Assign a new log file
LOG=$OUTPUT_DIRECTORY/status.log; echo "" >> ${LOG};
#ASSIGNING THE OUTPUT VARIABLES
assign_log()
{
if [ -s $OUTPUT_DIRECTORY/pre_status_crs.log ]
then
crs_output=`cat $OUTPUT_DIRECTORY/pre_status_crs.log`
else
crs_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_status_has.log ]
then
crs_output=`cat $OUTPUT_DIRECTORY/pre_status_has.log`
else
crs_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_status_asm.log ]
then
asm_output=`cat $OUTPUT_DIRECTORY/pre_status_asm.log`
else
asm_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_status_esm.log ]
then
esm_agent_output=`cat $OUTPUT_DIRECTORY/pre_status_esm.log`
else
esm_agent_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_status_dma.log ]
then
dma_agent_output=`cat $OUTPUT_DIRECTORY/pre_status_dma.log`
else
dma_agent_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_status_lsnr.log ]
then
listener_output=`cat $OUTPUT_DIRECTORY/pre_status_lsnr.log`
else
listener_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/db:inst ]
then
db_instance_output=`cat $OUTPUT_DIRECTORY/db:inst`
else
db_instance_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/dbopen:info.log ]
then
db_open_output=`cat $OUTPUT_DIRECTORY/dbopen:info.log`
else
db_open_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/unidb:inst.log ]
then
db_unique_output=`cat $OUTPUT_DIRECTORY/unidb:inst.log`
else
db_unique_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_status_dbmount.log ]
then
db_mount_output=`cat $OUTPUT_DIRECTORY/pre_status_dbmount.log`
else
db_mount_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_status_dbservices.log ]
then
service_alignment_output=`cat $OUTPUT_DIRECTORY/pre_status_dbservices.log`
else
service_alignment_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_status_mrp.log ]
then
mrp_output=`cat $OUTPUT_DIRECTORY/pre_status_mrp.log`
else
mrp_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_status_em.log ]
then
oem_agent_output=`cat $OUTPUT_DIRECTORY/pre_status_em.log`
else
oem_agent_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_status_portutil.log ]
then
port_utility_output=`cat $OUTPUT_DIRECTORY/pre_status_portutil.log`
else
port_utility_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_status_fgl.log ]
then
foglight_output=`cat $OUTPUT_DIRECTORY/pre_status_fgl.log`
else
foglight_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_status_osw.log ]
then
os_watcher_output=`cat $OUTPUT_DIRECTORY/pre_status_osw.log`
else
os_watcher_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/pre_status_usb.log ]
then
usb_output=`cat $OUTPUT_DIRECTORY/pre_status_usb.log`
else
usb_output="no_status"
fi
if [ -s /oracle/dba/foglight/fgl_5/bin/fglam ]
then
fglam_output=`/oracle/dba/foglight/fgl_5/bin/fglam --check-connection`
else
fglam_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/server_type.log ]
then
instance_type=`cat $OUTPUT_DIRECTORY/server_type.log`
else
instance_type="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/version_executed_status.log ]
then
script_version=`cat $OUTPUT_DIRECTORY/version_executed_status.log`
else
script_version="no_status"
fi
}
insert_repdb()
{ why=status;
for what in fgl osw agent portutil lsnr mrp db asm has em dma esm
do
status_status;
done
for what in fgl osw agent portutil lsnr mrp db asm has em
do
if [ -s $OUTPUT_DIRECTORY/status_$what.log ]
then
eval var_$what=`cat $OUTPUT_DIRECTORY/status_$what.log`
else
eval var_$what="no_status"
fi
done
var_esm=na;
var_dma=na;
#PREPARING THE INSERT STATEMENT
if [ $(cat /etc/oratab | grep oracle | grep -v -i asm | grep -v -i crs | grep -v -i oem | grep -v "#" | awk 'BEGIN{FS=":"}{print $1}' | head -1 | wc -l) = 1 ]
then
export ORACLE_SID=`cat /etc/oratab | grep oracle | grep -v -i asm | grep -v -i crs | grep -v -i oem | grep -v "#" | awk 'BEGIN{FS=":"}{print $1}' | head -1`
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
$ORACLE_HOME/bin/sqlplus -s OSH_SEH/dbaas_operations1@SUNDVD94 << EOFSTATUS
set echo off;
set head off;
set feedback off;
insert into OSH_SEH.dbss_log (DBSS_ID,
SCRIPT_VERSION,
INSTANCE_TYPE,
STOP_OR_START,
CRS_OR_DB,
SERVER_NAME,
SERVER_TIMESTAMP,
CRS,
ASM,
LISTENER,
DB_INSTANCE,
MRP_PROCESS,
ESM_AGENT,
DMA_AGENT,
OEM_AGENT,
PORT_UTILITY,
FOGLIGHT,
OS_WATCHER,
SENT_MAIL,
CRS_OUTPUT,
ASM_OUTPUT,
LISTENER_OUTPUT,
DB_INSTANCE_OUTPUT,
DB_OPEN_OUTPUT,
DB_OPENRO_OUTPUT,
DB_MOUNT_OUTPUT,
SERVICE_ALIGNMENT_OUTPUT,
MRP_OUTPUT,
ESM_AGENT_OUTPUT,
DMA_AGENT_OUTPUT,
OEM_AGENT_OUTPUT,
PORT_UTILITY_OUTPUT,
FOGLIGHT_OUTPUT,
OS_WATCHER_OUTPUT,
USB_OUTPUT,
FGLAM_OUTPUT,
DB_UNIQUE_OUTPUT)
values (DBSS_LOG_SEQ.nextval,
'$script_version',
'$instance_type',
'status',
'db',
'$(hostname -f)',
'$timevalue',
'$var_has',
'$var_asm',
'$var_lsnr',
'$var_db',
'$var_mrp',
'$var_esm',
'$var_dma',
'$var_em',
'$var_portutil',
'$var_fgl',
'$var_osw',
0,
'$crs_output',
'$asm_output',
'$listener_output',
'$db_instance_output',
'$db_open_output',
'$db_openro_output',
'$db_mount_output',
'$service_alignment_output',
'$mrp_output',
'$esm_agent_output',
'$dma_agent_output',
'$oem_agent_output',
'$port_utility_output',
'$foglight_output',
'$os_watcher_output',
'$usb_output',
'$fglam_output',
'$db_unique_output');
commit;
EOFSTATUS
fi
}
echo "************************* START TIME : $(date) ************************" >> ${LOG}; echo "" >> ${LOG}
case $server_type in
"rac_12c")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "---------------------------> THIS IS A 12c CLUSTERWARE SYSTEM <------------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG};
why=status; when=pre;
for what in has asm db mrp lsnr dbfs gg em fgl osw portutil fs disk tfa ora_homes bda
do
status_$what;
done
assign_log
insert_repdb
;;
"rac_11g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "---------------------------> THIS IS A 11g CLUSTERWARE SYSTEM <------------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG};
why=status; when=pre;
for what in has asm db mrp lsnr dbfs gg em fgl osw portutil fs disk tfa ora_homes bda
do
status_$what;
done
assign_log
insert_repdb
;;
"rac_10g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "---------------------------> THIS IS A 10g CLUSTERWARE SYSTEM <------------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG};
why=status; when=pre;
for what in crs asm db mrp lsnr gg em fgl osw portutil fs disk ora_homes bda
do
status_$what;
done
assign_log
insert_repdb
;;
"norac_asm12c")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "-------------------------> THIS IS A NON-RAC SYSTEM BUT WITH ASM 12c <----------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG};
why=status; when=pre;
for what in asm db mrp lsnr dbfs gg em fgl osw portutil fs disk tfa ora_homes bda
do
status_$what;
done
assign_log
insert_repdb
;;
"norac_asm11g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "-------------------------> THIS IS A NON-RAC SYSTEM BUT WITH ASM 11g <----------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG};
why=status; when=pre;
for what in asm db mrp lsnr dbfs gg em fgl osw portutil fs disk tfa ora_homes bda
do
status_$what;
done
assign_log
insert_repdb
;;
"norac_asm10g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "-------------------------> THIS IS A NON-RAC SYSTEM BUT WITH ASM 10g <----------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG};
why=status; when=pre;
for what in asm db mrp lsnr gg em fgl osw portutil fs disk tfa ora_homes bda
do
status_$what;
done
assign_log
insert_repdb
;;
"norac_noasm")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "--------------------------> THIS IS A NON-RAC & NON-ASM SYSTEM <----------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG};
why=status; when=pre;
for what in db mrp lsnr gg em fgl osw portutil fs disk ora_homes bda standalone_autostart
do
status_$what;
done
assign_log
insert_repdb
;;
*)
echo "Invalid Selection"
esac
filename=$(echo $(hostname) | cut -d. -f1)_$(date '+%m%d%Y_%H%M%S')
mv ${LOG} $OUTPUT_DIRECTORY/status_$filename.log
echo "" >> ${LOG};
echo "" >> ${LOG};
echo "******************************************************************************************************";
echo "Please check the detailed STATUS report at $OUTPUT_DIRECTORY/status_$filename.log"
echo "******************************************************************************************************";
echo "" >> ${LOG};
#################################################################
# #
#################################################################
# #
# Modified by EMEA OracleDBA Team for enhancements & automation #
# APRIL 2016 #
# #
#################################################################
# #
# USAGE : To be executed as root user #
# (pbrun to oracle or pboracle) #
# #
# Manual execution #
# sh bl_start_crs.ksh #
# #
# Via job scheduler tools and by-passing the prompt #
# sh bl_start_crs.ksh y #
# #
#---------------------------------------------------------------#
# #
# //Generic information about the batch of scripts developed// #
# bl_status.ksh #
# bl_stop.ksh #
# bl_stop_crs.ksh #
# bl_start_crs.ksh #
# bl_start.ksh #
# #
# Versions/Combinations Supported #
# Clustware 11g #
# Clustware 10g #
# NON-RAC with ASM 11g #
# NON-RAC with ASM 10g #
# NON-RAC & NON-ASM #
# #
# Components in scope #
# Clusterware #
# ASM Instance #
# Database Instance #
# Cluster Listener #
# Local Listener #
# Manager Recovery Process #
# GoldenGate Replication #
# Port Utility #
# Enterprise Manager Agent #
# OSWatcher Utility #
# Foglight Monitoring Agent #
# Filesystem #
# Rawdisk #
# #
#################################################################
export OS=`uname -a | awk '{ print $1 }'`
eval timevalue=`date '+%m%d%Y_%H%M%S'`
eval filename=$(echo $(hostname) | cut -d. -f1)_$timevalue
export PATH=$PATH:/usr/local/bin
if [[ -f /etc/redhat-release ]]; then
export RH_VER=`cat /etc/redhat-release | grep "Linux Server release" | sed -n 's/.*\(Linux Server release.*\).*/\1/p' | awk '{ print $4 }'`
else
export RH_VER=0
fi
if [ "$(ps -ef | grep -i mysql | grep -v grep | wc -l)" -ge 1 ]
then
echo "This is a MySQL Database Server"
exit 0
fi
# CHECK IF THE USER IS ROOT
echo " "
if [ $(whoami) != "root" ]
then
echo "ATTENTION : Please execute this script as root user"
exit 0;
fi
# SCRIPT AND OUTPUT DIRECTORIES INITIALIZATION
SCRIPT_DIRECTORY=/efs/dist/gmrtdba/dbascripts/scripts/common
if [[ -d /oracle/dba/output/generic ]]; then
OUTPUT_DIRECTORY=/oracle/dba/output/generic
else
OUTPUT_DIRECTORY=/var/bl_ora/log
if [[ ! -d $OUTPUT_DIRECTORY ]]; then
echo "OUTPUT_DIRECTORY: $OUTPUT_DIRECTORY was not found on this server ... Exiting"
exit 0
fi
fi
# Check if user really wants to START the services
if [ $# -eq 0 ]
then
read -r -p "Are you sure you want to START the Clusterware services ? [y/n] " response
if [ $response = y ]
then
echo ""; echo "Please wait while the services are started up... "; echo ""
else
exit; >/dev/null
fi
elif [ $1 == y ]
then
echo ""; echo "Please wait while the services are started up... "; echo ""
else
exit; >/dev/null
fi
export server_type=$(cat $OUTPUT_DIRECTORY/server_type.log)
collect_esm()
{
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep -i esm | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
elif [ $(( (`date +%s` - `stat -L --format %Y $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log`) > (2880*60) ) ) = 1 ]
then
rm -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep -i esm | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
if [ $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) -gt 0 ]
then
sleep 1
else
ps -ef | grep -i esm | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
fi
fi
elif [ $when = post ]
then
ps -ef | grep -i esm | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
sleep 0
fi
}
collect_dma()
{
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep opsware | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
elif [ $(( (`date +%s` - `stat -L --format %Y $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log`) > (2880*60) ) ) = 1 ]
then
rm -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep opsware | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
if [ $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) -gt 0 ]
then
sleep 1
else
ps -ef | grep opsware | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".lo g
fi
fi
elif [ $when = post ]
then
ps -ef | grep opsware | grep -v grep | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
sleep 0
fi
}
collect_lsnr()
{
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep lsnr |grep -v grep | sed -n 's/.*\(tnslsnr.*\).*/\1/p' | awk '{ print $2 }' | sed '/^\s*$/d' >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
#elif [ $(( (`date +%s` - `stat -L --format %Y $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log`) > (2880*60) )) -eq 1 ]
#then
#rm -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
#ps -ef | grep lsnr |grep -v grep | sed -n 's/.*\(tnslsnr.*\).*/\1/p' | awk '{ print $2 }' | sed '/^\s*$/d ' >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
for LSNR in `ps -ef | grep lsnr |grep -v grep | sed -n 's/.*\(tnslsnr.*\).*/\1/p' | awk '{ print $2 }' | s ed '/^\s*$/d'`
do
if [ $(grep -w "$LSNR" $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log | wc -l) -eq 1 ]
then
sleep 0
else
echo $LSNR >> $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
fi
done
fi
elif [ $when = post ]
then
ps -ef | grep lsnr |grep -v grep | sed -n 's/.*\(tnslsnr.*\).*/\1/p' | awk '{ print $2 }' | sed '/^\s*$/d' >$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
sleep 0
fi
}
collect_asm()
{
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep pmon | sort -k9 | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF }'>$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
#elif [ $(( (`date +%s` - `stat -L --format %Y $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log`) > (2880*60) )) -eq 1 ]
#then
#rm -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
#ps -ef | grep pmon | sort -k9 | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $N F}'>$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
for ASM in `ps -ef | grep pmon | sort -k9 | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF}'`
do
if [ $(grep -w "$ASM" $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log | wc -l) -eq 1 ]
then
sleep 1
else
echo $ASM >> $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
fi
done
fi
elif [ $when = post ]
then
ps -ef | grep pmon | sort -k9 | grep -v grep | grep "+ASM" | grep -v onitor | awk 'BEGIN{FS="_"}{print $NF }'>$OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
sleep 0
fi
}
collect_crs()
{
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep crs | grep -v grep | grep -v tfa | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what". log
#elif [ $(( (`date +%s` - `stat -L --format %Y $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log`) > (2880*60) )) -eq 1 ]
#then
#rm -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
#ps -ef | grep crs | grep -v grep | grep -v tfa | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what" .log
else
if [ $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) -gt 0 ]
then
sleep 1
else
ps -ef | grep crs | grep -v grep | grep -v tfa | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_ "$what".log
fi
fi
elif [ $when = post ]
then
ps -ef | grep crs | grep -v grep | grep -v tfa | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
else
sleep 0
fi
}
#Portdaemon detection
collect_portutil()
{
if [ $when = pre ]
then
if [ ! -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log ]
then
touch $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
ps -ef | grep "portdaemon.pl" | grep -v grep | grep port | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why "_"$what".log
#elif [ $(( (`date +%s` - `stat -L --format %Y $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log`) > (2880*60) )) -eq 1 ]
#then
#rm -f $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log
#ps -ef | grep "portdaemon.pl" | grep -v grep | grep port | wc -l > $OUTPUT_DIRECTORY/"$when"_"$wh y"_"$what".log
else
if [ $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) -gt 0 ]
then
sleep 1
else
ps -ef | grep "portdaemon.pl" | grep -v grep | grep port | wc -l > $OUTPUT_DIRECTORY/"$whe n"_"$why"_"$what".log
fi
fi
elif [ $when = post ]
then
ps -ef | grep "portdaemon.pl" | grep -v grep | grep port | wc -l > $OUTPUT_DIRECTORY/"$when"_"$why"_"$what ".log
else
sleep 0
fi
}
display_pre_post()
{
if [ $when = pre ]
then
if [ $what = asm ] || [ $what = lsnr ] || [ $what = portutil ]
then
if [ "$(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log)" = 0 ] || [ ! -s $OUTPUT_DIRECTORY/"$when"_"$why" _"$what".log ]
then
echo "PRE stop" $what "running " ":" "NO" | tee -a ${LOG}
else
echo "PRE stop" $what "running " ":" $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) | tee -a ${LO G}
fi
elif [ $what = crs ]
then
if [ "$(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log)" -lt 3 ]
then
echo "PRE stop" $what "running " ":" "NO" | tee -a ${LOG}
else
echo "PRE stop" $what "running " ":" "YES" | tee -a ${LOG}
fi
fi
elif [ $when = post ]
then
if [ $what = asm ] || [ $what = lsnr ] || [ $what = portutil ]
then
if [ "$(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log)" = 0 ] || [ ! -s $OUTPUT_DIRECTORY/"$when"_"$why" _"$what".log ]
then
echo "POST start" $what "running " ":" "NO" | tee -a ${LOG}
else
echo "POST start" $what "running " ":" $(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log) | tee -a ${ LOG}
fi
elif [ $what = crs ]
then
if [ "$(cat $OUTPUT_DIRECTORY/"$when"_"$why"_"$what".log)" -lt 3 ]
then
echo "POST start" $what "running " ":" "NO" | tee -a ${LOG}
else
echo "POST start" $what "running " ":" "YES" | tee -a ${LOG}
fi
fi
fi
}
started_status()
{
if [ $what = asm ] || [ $what = lsnr ] || [ $what = portutil ]
then
rm -f $OUTPUT_DIRECTORY/diff_file; rm -f $OUTPUT_DIRECTORY/diff_1; rm -f $OUTPUT_DIRECTORY/diff_2
cat $OUTPUT_DIRECTORY/pre_stop_$what.log | sort > $OUTPUT_DIRECTORY/diff_1;
cat $OUTPUT_DIRECTORY/post_start_$what.log | sort > $OUTPUT_DIRECTORY/diff_2;
diff -b -i -w $OUTPUT_DIRECTORY/diff_1 $OUTPUT_DIRECTORY/diff_2 > $OUTPUT_DIRECTORY/diff_file
#chown oracle:dba $OUTPUT_DIRECTORY/diff_file
chmod 777 $OUTPUT_DIRECTORY/diff_file
if [ ! -s $OUTPUT_DIRECTORY/diff_file ]
then
echo "yes" > $OUTPUT_DIRECTORY/started_$what.log | tee -a ${LOG}
echo "OK : pre-post status matches for $what"
else
echo "no" > $OUTPUT_DIRECTORY/started_$what.log | tee -a ${LOG}
echo "ATTENTION : $what didn't start. Please check"
fi
elif [ $what = crs ]
then
if [ "$(cat $OUTPUT_DIRECTORY/post_start_"$what".log)" -gt 5 ] || [ ! -s $OUTPUT_DIRECTORY/post_start_"$what".log ]
then
echo "yes" > $OUTPUT_DIRECTORY/started_$what.log
echo "OK : pre-post status matches for $what"
else
echo "no" > $OUTPUT_DIRECTORY/started_$what.log
echo "ATTENTION : $what didn't start. Please check"
fi
fi
}
start_esm()
{
if [ "$(cat $OUTPUT_DIRECTORY/pre_stop_esm.log)" = 0 ]
then
echo "ESM Agent was down even before the activity, so didn't bring it up" >> ${LOG}; echo -e "\n" > > ${LOG}
elif [ "$(ps -ef | grep esm | grep -v grep | wc -l)" != 0 ]
then
echo "ESM Agent is already running" >> ${LOG}; echo -e "\n" >> ${LOG}
else
/etc/init.d/esmrc start >/dev/null;
sleep 2
fi
}
start_dma()
{
if [ "$(cat $OUTPUT_DIRECTORY/pre_stop_dma.log)" = 0 ]
then
echo "DMA Agent was down even before the activity, so didn't bring it up" >> ${LOG}; echo -e "\n" > > ${LOG}
elif [ "$(ps -ef | grep opsware | grep -v grep | wc -l)" != 0 ]
then
echo "DMA Agent is already running" >> ${LOG}; echo -e "\n" >> ${LOG}
else
/etc/init.d/opsware-agent start >/dev/null;
sleep 15
fi
}
start_has()
{
ORACLE_SID=`cat /etc/oratab | awk 'BEGIN{FS=":"}{print $1}' | grep ASM | grep -v "#"`
export ORAENV_ASK=NO >/dev/null;
. oraenv >/dev/null
crsctl start has >> ${LOG} ; echo "" >> ${ LOG}
sleep 10
if [ "$(crsctl check has | grep online | wc -l)" -ne 0 ]
then
echo "Clusterware Services started" >> ${LOG}; echo "" >> ${LOG}
crsctl enable has >/dev/null
crs_en_dis=`cat /etc/oracle/scls_scr/$(echo $(hostname) | cut -d. -f1)/root/crsstart | awk 'BEGIN{ FS=":"}{print $1}'`
echo "HAS status : $crs_en_dis" >> ${LOG}; echo "" >> ${LO G}
echo "HAS is now enabled" >> ${LOG}
else
echo "ATTENTION : Clusterware services do not appear to have started properly" >> ${LOG} ; echo " " >> ${LOG}
echo "ATTENTION : CRS not enabled" >> ${LOG} ; echo "" >> ${L OG}
fi
}
start_crs()
{
ORACLE_SID=`cat /etc/oratab | awk 'BEGIN{FS=":"}{print $1}' | grep CRS | grep -v "#"`
export ORAENV_ASK=NO >/dev/null;
. oraenv >/dev/null
crsctl start crs >> ${LOG} ; echo "" >> ${ LOG}
sleep 10
if [ "$(crsctl check crs | grep online || crsctl check crs | grep healthy | wc -l)" -ne 0 ]
then
echo "Clusterware Services started" >> ${LOG}; echo "" >> ${LOG}
crsctl enable crs
crs_en_dis=`cat /etc/oracle/scls_scr/$(echo $(hostname) | cut -d. -f1)/root/crsstart | awk 'BEGIN{ FS=":"}{print $1}'`
echo "CRS status : $crs_en_dis" >> ${LOG}; echo "" >> ${LO G}
echo "CRS is now enabled" >> ${LOG}
else
echo "ATTENTION : Clusterware services do not appear to have started properly" >> ${LOG} ; echo " " >> ${LOG}
echo "ATTENTION : CRS not enabled" >> ${LOG} ; echo "" >> ${L OG}
fi
}
start_portutil()
{
# Initialise any previous Portdaemon start files
if [[ -f $OUTPUT_DIRECTORY/Portdaemon_start.sh ]]; then
rm $OUTPUT_DIRECTORY/Portdaemon_start.sh
fi
if [[ -f $OUTPUT_DIRECTORY/Portdaemon_config.txt ]]; then
cat $OUTPUT_DIRECTORY/Portdaemon_config.txt | while read PORT_CONFIG
do
PORT_USER=`echo $PORT_CONFIG | cut -d":" -f1 -s`
PORT_PROC=`echo $PORT_CONFIG | cut -d":" -f2 -s`
PORT_DIR=`dirname $PORT_PROC`
PORT_NUMB=`echo $PORT_CONFIG | cut -d":" -f3 -s`
# Gen Command for starting Portdaemon for this POrt ..
echo "su - $PORT_USER -c 'sh ${PORT_DIR}/start_port_daemon ${PORT_NUMB}'" >> $OUTPUT_DIRECTORY/Portdaemon_start .sh
done
# Loop through and stop all detected Portdaemon(s)
if [[ -f $OUTPUT_DIRECTORY/Portdaemon_start.sh ]]; then
chmod 744 $OUTPUT_DIRECTORY/Portdaemon_start.sh
sh $OUTPUT_DIRECTORY/Portdaemon_start.sh > /dev/null 2>&1
fi
else
echo "Portdaemon services not detected on this host" >> ${LOG}; echo "" >> ${LOG}
fi
}
enable_standalone_autostart()
{
DDMMYY=`date '+%m%d%y_%H:%M:%S'`
if [[ -f /etc/oratab_bl_backup ]]; then
if [[ -f /etc/oratab ]]; then
oracred=`ls -l /etc/oratab | awk '{ print $3":"$4 }'`
mv /etc/oratab $OUTPUT_DIRECTORY/oratab_no_autostart_${DDMMYY}
fi
mv /etc/oratab_bl_backup /etc/oratab
chown $oracred /etc/oratab
fi
if [[ -f /etc/lsnrtab_bl_backup ]]; then
if [[ -f /etc/lsnrtab ]]; then
oracred=`ls -l /etc/lsnrtab | awk '{ print $3":"$4 }'`
mv /etc/lsnrtab $OUTPUT_DIRECTORY/lsnrtab_no_autostart_${DDMMYY}
fi
mv /etc/lsnrtab_bl_backup /etc/lsnrtab
chown $oracred /etc/lsnrtab
fi
}
start_rh7_dbserv()
{
if [[ -f /etc/redhat-release ]] && [[ "$RH_VER" == 7.* ]]; then
export RH7_ORASTR=`systemctl status oracle_db.service | grep "Active: " | awk '{ print $1,$2,$3 }'`
if [[ "${RH7_ORASTR}" != "Active: active (running)" ]]; then
echo "" >> $LOG
echo "########################################################################" >> $LOG
echo "Note: RedHat7 service: oracle_db.service will be started here ... " >> $LOG
echo "" >> $LOG
echo "PRE Startup Status: " >> $LOG
systemctl status oracle_db.service | grep "Active: " >> $LOG
echo "" >> $LOG
echo " => Attempting to Start it ..." >> $LOG
echo "" >> $LOG
systemctl start oracle_db.service >> $LOG
sleep 2
echo "POST Startup Status: " >> $LOG
systemctl status oracle_db.service | grep "Active: " >> $LOG
echo "########################################################################" >> $LOG
echo "" >> $LOG
else
echo "" >> $LOG
echo "########################################################################" >> $LOG
echo "NO ACTION TAKEN: RedHat7 service: oracle_db.service was already found to be in ACTIVE state " >> $LOG
systemctl status oracle_db.service | grep "Active: " >> $LOG
echo "########################################################################" >> $LOG
echo "" >> $LOG
fi
fi
}
# Remove the temporary log file
rm -f $OUTPUT_DIRECTORY/start_crs.log
# Assign a new log file
LOG=$OUTPUT_DIRECTORY/start_crs.log; echo "" >> ${LOG};
#INSERT INTO REPOSITORY DATABASE
#ASSIGNING THE OUTPUT VARIABLES
assign_log()
{
if [ -s $OUTPUT_DIRECTORY/post_start_crs.log ]
then
crs_output=`cat $OUTPUT_DIRECTORY/post_start_crs.log`
else
crs_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_asm.log ]
then
asm_output=`cat $OUTPUT_DIRECTORY/post_start_asm.log`
else
asm_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_esm.log ]
then
esm_agent_output=`cat $OUTPUT_DIRECTORY/post_start_esm.log`
else
esm_agent_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_dma.log ]
then
dma_agent_output=`cat $OUTPUT_DIRECTORY/post_start_dma.log`
else
dma_agent_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_lsnr.log ]
then
listener_output=`cat $OUTPUT_DIRECTORY/post_start_lsnr.log`
else
listener_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_dbinst.log ]
then
db_instance_output=`cat $OUTPUT_DIRECTORY/post_start_dbinst.log`
else
db_instance_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_dbopen.log ]
then
db_open_output=`cat $OUTPUT_DIRECTORY/post_start_dbopen.log`
else
db_open_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_dbopenro.log ]
then
db_openro_output=`cat $OUTPUT_DIRECTORY/post_start_dbopenro.log`
else
db_openro_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_dbmount.log ]
then
db_mount_output=`cat $OUTPUT_DIRECTORY/post_start_dbmount.log`
else
db_mount_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_dbservices.log ]
then
service_alignment_output=`cat $OUTPUT_DIRECTORY/post_start_dbservices.log`
else
service_alignment_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_mrp.log ]
then
mrp_output=`cat $OUTPUT_DIRECTORY/post_start_mrp.log`
else
mrp_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_agent.log ]
then
oem_agent_output=`cat $OUTPUT_DIRECTORY/post_start_agent.log`
else
oem_agent_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_portutil.log ]
then
port_utility_output=`cat $OUTPUT_DIRECTORY/post_start_portutil.log`
else
port_utility_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_fgl.log ]
then
foglight_output=`cat $OUTPUT_DIRECTORY/post_start_fgl.log`
else
foglight_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_osw.log ]
then
os_watcher_output=`cat $OUTPUT_DIRECTORY/post_start_osw.log`
else
os_watcher_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/post_start_usb.log ]
then
usb_output=`cat $OUTPUT_DIRECTORY/post_start_usb.log`
else
usb_output="no_status"
fi
if [ -s /oracle/dba/foglight/fgl_5/bin/fglam ]
then
fglam_output=`/oracle/dba/foglight/fgl_5/bin/fglam --check-connection`
else
fglam_output="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/server_type.log ]
then
instance_type=`cat $OUTPUT_DIRECTORY/server_type.log`
else
instance_type="no_status"
fi
if [ -s $OUTPUT_DIRECTORY/version_executed_status.log ]
then
script_version=`cat $OUTPUT_DIRECTORY/version_executed_status.log`
else
script_version="no_status"
fi
}
insert_repdb()
{
for what in dma esm lsnr asm crs
do
if [ -f $OUTPUT_DIRECTORY/stopped_$what.log ]
then
if [ "$(cat $OUTPUT_DIRECTORY/stopped_$what.log)" = yes ]
then
eval var_$what="success"
fi
if [ "$(cat $OUTPUT_DIRECTORY/stopped_$what.log)" = no ]
then
eval var_$what="failure"
fi
else
eval var_$what="no_status"
fi
done
if [[ $server_type = "rac_10g" ]]
then
var_lsnr="na"
var_asm="na"
elif [[ $server_type = "norac_asm10" ]] || [[ $server_type = "norac_noasm" ]]
then
var_dma="na"
var_esm="na"
var_lsnr="na"
var_asm="na"
var_crs="na"
fi
for what in fgl osw agent portutil mrp dbinst
do
eval var_$what="na"
done
#PREPARING THE INSERT STATEMENT
if [ $(cat /etc/oratab | grep oracle | grep -v -i asm | grep -v -i crs | grep -v -i oem | grep -v "#" | awk 'BEGIN{FS=":"} {print $1}' | head -1 | wc -l) = 1 ]
then
export ORACLE_SID=`cat /etc/oratab | grep oracle | grep -v -i asm | grep -v -i crs | grep -v -i oem | grep -v "#" | awk 'B EGIN{FS=":"}{print $1}' | head -1`
export ORAENV_ASK=NO >/dev/null
. oraenv >/dev/null
$ORACLE_HOME/bin/sqlplus -s OSH_SEH/dbaas_operations1@SUNDVD94 << EOFSTATUS
set echo off;
set head off;
set feedback off;
insert into OSH_SEH.dbss_log (DBSS_ID,
SCRIPT_VERSION,
INSTANCE_TYPE,
STOP_OR_START,
CRS_OR_DB,
SERVER_NAME,
SERVER_TIMESTAMP,
CRS,
ASM,
LISTENER,
DB_INSTANCE,
MRP_PROCESS,
ESM_AGENT,
DMA_AGENT,
OEM_AGENT,
PORT_UTILITY,
FOGLIGHT,
OS_WATCHER,
SENT_MAIL,
CRS_OUTPUT,
ASM_OUTPUT,
LISTENER_OUTPUT,
DB_INSTANCE_OUTPUT,
DB_OPEN_OUTPUT,
DB_OPENRO_OUTPUT,
DB_MOUNT_OUTPUT,
SERVICE_ALIGNMENT_OUTPUT,
MRP_OUTPUT,
ESM_AGENT_OUTPUT,
DMA_AGENT_OUTPUT,
OEM_AGENT_OUTPUT,
PORT_UTILITY_OUTPUT,
FOGLIGHT_OUTPUT,
OS_WATCHER_OUTPUT,
USB_OUTPUT,
FGLAM_OUTPUT)
values (DBSS_LOG_SEQ.nextval,
'$script_version',
'$instance_type',
'start',
'crs',
'$(hostname -f)',
'$timevalue',
'$var_crs',
'$var_asm',
'$var_lsnr',
'$var_dbinst',
'$var_mrp',
'$var_esm',
'$var_dma',
'$var_agent',
'$var_portutil',
'$var_fgl',
'$var_osw',
0,
'$crs_output',
'$asm_output',
'$listener_output',
'$db_instance_output',
'$db_open_output',
'$db_openro_output',
'$db_mount_output',
'$service_alignment_output',
'$mrp_output',
'$esm_agent_output',
'$dma_agent_output',
'$oem_agent_output',
'$port_utility_output',
'$foglight_output',
'$os_watcher_output',
'$usb_output',
'$fglam_output');
commit;
EOFSTATUS
fi
}
case $server_type in
"rac_12c")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "---------------------------> THIS IS A 12c CLUSTERWARE SYSTEM <------------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
if [ "$(ps -ef | grep pmon | grep -v grep |grep -v "+ASM" |grep -v "\-MGMTDB" | grep -v onitor | wc -l)" -eq 0 ]
then
why=stop;
for what in esm dma asm lsnr crs portutil
do
when=pre; collect_$what; display_pre_post
done
echo "";
echo "Starting HAS"; echo "";
start_has
echo " "
echo "Starting Any Portdaemon Services if any "; echo "";
start_portutil
if [[ $OS != "AIX" ]]; then
echo "Waiting for 4 minutes to allow all the CRS processes to come up"
for i in {1..4}
do
echo -n -e ' '
for i in {1..60}
do
echo -n ".";sleep 1;
done
echo "";
done
else
echo "Waiting for 4 minutes to allow all the CRS processes to come up"
i=1
while [[ $i -le 120 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
echo ""
i=1
while [[ $i -le 120 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
fi
start_esm
start_dma
why=start;
for what in esm dma asm lsnr crs portutil
do
when=post; collect_$what; display_pre_post
done
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in esm dma lsnr asm crs portutil
do
started_status
done
echo ""
#Avoid error for SCAN lsnr
if [[ ! -f $OUTPUT_DIRECTORY/started_lsnr.log ]]; then
touch $OUTPUT_DIRECTORY/started_lsnr.log
fi
if [ "$(cat $OUTPUT_DIRECTORY/started_asm.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/started_lsnr .log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/started_crs.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/started_portutil.log) " = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_start_crs_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
echo ""
# Deal with lsnr check seperately due to SCAN lsnr
elif [ "$(cat $OUTPUT_DIRECTORY/started_asm.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/started_ls nr.log)" != yes ] && [ "$(cat $OUTPUT_DIRECTORY/started_crs.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/started_portutil.l og)" = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_start_crs_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
echo ""
else
echo "0" > $OUTPUT_DIRECTORY/bl_start_crs_flag.log
echo ""
echo "ATTENTION : Some services didn't start. Please check" | tee -a ${LOG}
echo ""
fi
else
echo "ATTENTION : CRS appears to be running already. Please check." | tee -a ${LOG}
echo "" | tee -a ${LOG}
fi
assign_log
insert_repdb
echo "**************************************************"
;;
"rac_11g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "---------------------------> THIS IS A 11g CLUSTERWARE SYSTEM <------------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
if [ "$(ps -ef | grep pmon | grep -v grep |grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | wc -l)" -eq 0 ]
then
why=stop;
for what in esm dma asm lsnr crs portutil
do
when=pre; collect_$what; display_pre_post
done
echo "";
echo "Starting HAS"; echo "";
start_has
echo " "
echo "Starting Any Portdaemon Services if any "; echo "";
start_portutil
if [[ $OS != "AIX" ]]; then
echo "Waiting for 4 minutes to allow all the CRS processes to come up"
for i in {1..4}
do
echo -n -e ' '
for i in {1..60}
do
echo -n ".";sleep 1;
done
echo "";
done
else
echo "Waiting for 4 minutes to allow all the CRS processes to come up"
i=1
while [[ $i -le 120 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
echo ""
i=1
while [[ $i -le 120 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
fi
start_esm
start_dma
why=start;
for what in esm dma asm lsnr crs portutil
do
when=post; collect_$what; display_pre_post
done
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in esm dma asm crs portutil
do
started_status
done
#Avoid error for SCAN lsnr
if [[ ! -f $OUTPUT_DIRECTORY/started_lsnr.log ]]; then
touch $OUTPUT_DIRECTORY/started_lsnr.log
fi
echo ""
if [ "$(cat $OUTPUT_DIRECTORY/started_asm.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/started_lsnr .log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/started_crs.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/started_portutil.log) " = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_start_crs_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
echo ""
# Deal with lsnr check seperately due to 11g SCAN
elif [ "$(cat $OUTPUT_DIRECTORY/started_asm.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/started_ls nr.log)" != yes ] && [ "$(cat $OUTPUT_DIRECTORY/started_crs.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/started_portutil.l og)" = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_start_crs_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
echo ""
else
echo "0" > $OUTPUT_DIRECTORY/bl_start_crs_flag.log
echo ""
echo "ATTENTION : Some services didn't start. Please check" | tee -a ${LOG}
echo ""
fi
else
echo "ATTENTION : CRS appears to be running already. Please check." | tee -a ${LOG}
echo "" | tee -a ${LOG}
fi
assign_log
insert_repdb
echo "**************************************************"
;;
"rac_10g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "---------------------------> THIS IS A 10g CLUSTERWARE SYSTEM <------------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
if [ "$(ps -ef | grep pmon | grep -v grep |grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | wc -l)" -eq 0 ]
then
why=stop;
for what in esm dma crs portutil
do
when=pre; collect_$what; display_pre_post
done
echo "";
echo "Starting CRS"; echo "";
start_crs
echo " "
echo "Starting Any Portdaemon Services if any "; echo "";
start_portutil
if [[ $OS != "AIX" ]]; then
echo "Waiting for 4 minutes to allow all the CRS processes to come up"
for i in {1..4}
do
echo -n -e ' '
for i in {1..60}
do
echo -n ".";sleep 1;
done
echo "";
done
else
echo "Waiting for 4 minutes to allow all the CRS processes to come up"
i=1
while [[ $i -le 120 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
echo ""
i=1
while [[ $i -le 120 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
fi
start_esm
start_dma
why=start;
for what in esm dma crs portutil
do
when=post; collect_$what; display_pre_post
done
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in esm dma crs portutil
do
started_status
done
echo ""
if [ "$(cat $OUTPUT_DIRECTORY/started_crs.log)" = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_start_crs_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
echo ""
else
echo "0" > $OUTPUT_DIRECTORY/bl_start_crs_flag.log
echo ""
echo "ATTENTION : Some services didn't start. Please check" | tee -a ${LOG}
echo ""
fi
else
echo "ATTENTION : CRS appears to be running already. Please check." | tee -a ${LOG}
echo "" | tee -a ${LOG}
fi
assign_log
insert_repdb
echo "**************************************************"
;;
"norac_asm12c")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "-------------------------> THIS IS A NON-RAC SYSTEM BUT WITH ASM 12c <----------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
if [ "$(ps -ef | grep pmon | grep -v grep |grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | wc -l)" -eq 0 ]
then
why=stop;
for what in esm dma asm lsnr crs portutil
do
when=pre; collect_$what; display_pre_post
done
echo "";
echo "Starting HAS"; echo "";
start_has
echo " "
echo "Starting Any Portdaemon Services if any "; echo "";
start_portutil
if [[ $OS != "AIX" ]]; then
echo "Waiting for 4 minutes to allow all the CRS processes to come up"
for i in {1..4}
do
echo -n -e ' '
for i in {1..60}
do
echo -n ".";sleep 1;
done
echo "";
done
else
echo "Waiting for 4 minutes to allow all the CRS processes to come up"
i=1
while [[ $i -le 120 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
echo ""
i=1
while [[ $i -le 120 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
fi
start_esm
start_dma
why=start;
for what in esm dma asm lsnr crs portutil
do
when=post; collect_$what; display_pre_post
done
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in esm dma asm lsnr crs portutil
do
started_status
done
echo ""
if [ "$(cat $OUTPUT_DIRECTORY/started_asm.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/started_lsnr .log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/started_crs.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/started_portutil.log) " = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_start_crs_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
echo ""
else
echo "0" > $OUTPUT_DIRECTORY/bl_start_crs_flag.log
echo ""
echo "ATTENTION : Some services didn't start. Please check" | tee -a ${LOG}
echo ""
fi
else
echo "ATTENTION : CRS appears to be running already. Please check." | tee -a ${LOG}
echo "" | tee -a ${LOG}
fi
assign_log
insert_repdb
echo "**************************************************"
;;
"norac_asm11g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "-------------------------> THIS IS A NON-RAC SYSTEM BUT WITH ASM 11g <----------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
if [ "$(ps -ef | grep pmon | grep -v grep |grep -v "+ASM" | grep -v "\-MGMTDB" | grep -v onitor | wc -l)" -eq 0 ]
then
why=stop;
for what in esm dma asm lsnr crs portutil
do
when=pre; collect_$what; display_pre_post
done
echo "";
echo "Starting HAS"; echo "";
start_has
echo " "
echo "Starting Any Portdaemon Services if any "; echo "";
start_portutil
if [[ $OS != "AIX" ]]; then
echo "Waiting for 4 minutes to allow all the CRS processes to come up"
for i in {1..4}
do
echo -n -e ' '
for i in {1..60}
do
echo -n ".";sleep 1;
done
echo "";
done
else
echo "Waiting for 4 minutes to allow all the CRS processes to come up"
i=1
while [[ $i -le 120 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
echo ""
i=1
while [[ $i -le 120 ]] ; do
echo ".\c";sleep 1;
i=$(expr $i + 1)
done
fi
start_esm
start_dma
why=start;
for what in esm dma asm lsnr crs portutil
do
when=post; collect_$what; display_pre_post
done
echo " "
echo "******************** SUMMARY ********************"
echo ""
for what in esm dma asm lsnr crs portutil
do
started_status
done
echo ""
if [ "$(cat $OUTPUT_DIRECTORY/started_asm.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/started_lsnr .log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/started_crs.log)" = yes ] && [ "$(cat $OUTPUT_DIRECTORY/started_portutil.log) " = yes ]
then
echo "1" > $OUTPUT_DIRECTORY/bl_start_crs_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
echo ""
else
echo "0" > $OUTPUT_DIRECTORY/bl_start_crs_flag.log
echo ""
echo "ATTENTION : Some services didn't start. Please check" | tee -a ${LOG}
echo ""
fi
else
echo "ATTENTION : CRS appears to be running already. Please check." | tee -a ${LOG}
echo "" | tee -a ${LOG}
fi
assign_log
insert_repdb
echo "**************************************************"
;;
"norac_asm10g")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "-------------------------> THIS IS A NON-RAC SYSTEM BUT WITH ASM 10g <---------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
echo " Checking the status of ESM & DMA agents" | tee -a ${LOG}; echo -e "\n" | tee -a ${ LOG}
why=stop;
for what in esm dma portutil
do
when=pre; collect_$what; display_pre_post
done
start_esm
start_dma
echo " "
echo "Starting Any Portdaemon Services if any "; echo "";
start_portutil
why=start;
for what in esm dma portutil
do
when=post; collect_$what; display_pre_post
done
echo -e ' \t ' "******************** SUMMARY ********************"
echo -e "\n"
for what in esm dma
do
started_status
done
echo "1" > $OUTPUT_DIRECTORY/bl_start_crs_flag.log
echo -e "\n"
echo -e ' \t ' "SUCCESS : Ready to move to next step" | tee -a ${LOG}
echo -e "\n"
assign_log
insert_repdb
;;
"norac_noasm")
echo "" ;
echo "---------------------------------------------------------------------------------------" >> ${LOG};
echo "--------------------------> THIS IS A NON-RAC & NON-ASM SYSTEM <----------------------- " >> ${LOG};
echo "---------------------------------------------------------------------------------------" >> ${LOG}; echo "" >> ${LOG}
echo " This script will check/start any Port daemons and Enable Autostart, If RH7 System it will strat Oracle Ser vice - otherwise it has no relevance to this server " | tee -a ${LOG}; echo "" | tee -a ${LOG}
why=stop;
for what in esm dma portutil
do
when=pre; collect_$what; display_pre_post
done
echo " "
echo "";
start_esm
start_dma
echo " "
echo "Starting Any Portdaemon Services if any "; echo "";
start_portutil
why=start;
for what in esm dma portutil
do
when=post; collect_$what; display_pre_post
done
for what in esm dma
do
started_status
done
echo "";
echo "Enabling Auto-start for this standalone host "; echo "";
enable_standalone_autostart
echo "Content of ORATAB on this host : "; echo "";
if [[ -f /etc/oratab ]]; then
echo "`cat /etc/oratab | grep -v "^#" | sort -u `"
fi
echo "";
echo "Content of LSNRTAB on this host : "; echo "";
if [[ -f /etc/lsnrtab ]]; then
echo "`cat /etc/lsnrtab | grep -v "^#" | sort -u `"
fi
if [[ "$RH_VER" == 7.* ]]; then
start_rh7_dbserv
fi
echo "";
echo "1" > $OUTPUT_DIRECTORY/bl_start_crs_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
echo ""
assign_log
insert_repdb
;;
*)
echo "Invalid Selection"
esac
chmod 777 $OUTPUT_DIRECTORY/pre_stop*.log 1> /dev/null 2>&1
chmod 777 $OUTPUT_DIRECTORY/post_start*.log 1> /dev/null 2>&1
chmod 777 $OUTPUT_DIRECTORY/started*.log 1> /dev/null 2>&1
chmod 777 $OUTPUT_DIRECTORY/start_crs*.log 1> /dev/null 2>&1
chmod 777 $OUTPUT_DIRECTORY/bl_start*.log 1> /dev/null 2>&1
#chown oracle:dba $OUTPUT_DIRECTORY/pre_stop*.log 1> /dev/null 2>&1
#chown oracle:dba $OUTPUT_DIRECTORY/post_start*.log 1> /dev/null 2>&1
#chown oracle:dba $OUTPUT_DIRECTORY/started*.log 1> /dev/null 2>&1
#chown oracle:dba $OUTPUT_DIRECTORY/start_crs*.log 1> /dev/null 2>&1
#chown oracle:dba $OUTPUT_DIRECTORY/bl_start*.log 1> /dev/null 2>&1
if ls $OUTPUT_DIRECTORY/Portdaemon* 1> /dev/null 2>&1; then
chmod 777 $OUTPUT_DIRECTORY/Portdaemon*
#chown oracle:dba $OUTPUT_DIRECTORY/Portdaemon*
fi
filename=$(echo $(hostname) | cut -d. -f1)_$(date '+%m%d%Y_%H%M%S')
mv ${LOG} $OUTPUT_DIRECTORY/start_crs_$filename.log
echo "************************************************************************************************************";
echo "Please check the detailed CRS START report at $OUTPUT_DIRECTORY/start_crs_$filename.log"
echo "************************************************************************************************************";
echo ""
echo ""
1419,1 Bot
echo "Content of LSNRTAB on this host : "; echo "";
if [[ -f /etc/lsnrtab ]]; then
echo "`cat /etc/lsnrtab | grep -v "^#" | sort -u `"
fi
if [[ "$RH_VER" == 7.* ]]; then
start_rh7_dbserv
fi
echo "";
echo "1" > $OUTPUT_DIRECTORY/bl_start_crs_flag.log
echo ""
echo "SUCCESS : Ready to move to next step" | tee -a ${LOG}
echo ""
assign_log
insert_repdb
;;
*)
echo "Invalid Selection"
esac
chmod 777 $OUTPUT_DIRECTORY/pre_stop*.log 1> /dev/null 2>&1
chmod 777 $OUTPUT_DIRECTORY/post_start*.log 1> /dev/null 2>&1
chmod 777 $OUTPUT_DIRECTORY/started*.log 1> /dev/null 2>&1
chmod 777 $OUTPUT_DIRECTORY/start_crs*.log 1> /dev/null 2>&1
chmod 777 $OUTPUT_DIRECTORY/bl_start*.log 1> /dev/null 2>&1
#chown oracle:dba $OUTPUT_DIRECTORY/pre_stop*.log 1> /dev/null 2>&1
#chown oracle:dba $OUTPUT_DIRECTORY/post_start*.log 1> /dev/null 2>&1
#chown oracle:dba $OUTPUT_DIRECTORY/started*.log 1> /dev/null 2>&1
#chown oracle:dba $OUTPUT_DIRECTORY/start_crs*.log 1> /dev/null 2>&1
#chown oracle:dba $OUTPUT_DIRECTORY/bl_start*.log 1> /dev/null 2>&1
if ls $OUTPUT_DIRECTORY/Portdaemon* 1> /dev/null 2>&1; then
chmod 777 $OUTPUT_DIRECTORY/Portdaemon*
#chown oracle:dba $OUTPUT_DIRECTORY/Portdaemon*
fi
filename=$(echo $(hostname) | cut -d. -f1)_$(date '+%m%d%Y_%H%M%S')
mv ${LOG} $OUTPUT_DIRECTORY/start_crs_$filename.log
echo "************************************************************************************************************";
echo "Please check the detailed CRS START report at $OUTPUT_DIRECTORY/start_crs_$filename.log"
echo "************************************************************************************************************";
echo ""
echo ""
Oracle ACS Priority Support Webinar
Oracle Database release 18c New features
AUDIENCE
Exclusively, Oracle ACS Priority Support customers are invited to attend.
Upcoming Priority Support Webinar
On Friday June 29th, 2018 the Priority Support program office will host a Priority Support webinar on Oracle Database release 18c New features.
Conference details
Date: June 29, 2018
Time: 7:00 AM PT /10:00 AM ET
Audio dial in: +1-866-682-4770
Conference Code: 3547314
Pass code: 12345
If you need Global access numbers, please contact your TAM at least 24 hours in advance.
Use the above call details for the webinar session. Please ignore any pop-ups you get with call details when you join the webinar.
-------------------------------------------------------
To join the online meeting click following link:
-------------------------------------------------------
When it's time, join the meeting
Meeting number: 592 086 160
"high watermark"
The database doesn't know what is on a block unless and until......
It goes to the block.
So, when you delete the information, the block is still "a block", it is just a block that once had active rows - but no longer does.
And when you full scan the table - we have to read all blocks that at any time contained data - because - they could contain data now. We won't know what is there until we read it.
Suppose you deleted all but ONE row - we have to look in every block (unless of course we use an index) to see if that row is on a given block.
<quote src=expert oracle database architecture>
High-water Mark
This is a term used with table segments stored in the database. If you envision a table, for example, as a 'flat' structure or as a series of blocks laid one after the other in a line from left to right, the high-water mark (HWM) would be the rightmost block that ever contained data, as illustrated in Figure 10-1.
+---- high water mark of newly created table
|
V
+--------------------------------------------------------+
| | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
high water mark after inserting 10,000 rows
|
v
+--------------------------------------------------------+
|x |x |x |x |x |x |x |x |x |x |x |x | | | | | | | |
|x |x |x |x |x |x |x |x |x |x |x |x | | | | | | | |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
high water mark after inserting 10,000 rows
|
v
+--------------------------------------------------------+
|x |x |x |x |x |x |x | | | | | | | | | | | | |
|x |x |x |x |x |x |x | | | | | | | | | | | | |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
Figure 10-1. Depiction of an HWM
Figure 10-1 shows that the HWM starts at the first block of a newly created table. As data is placed into the table over time and more blocks get used, the HWM rises. If we delete some (or even all) of the rows in the table, we might have many blocks that no longer contain data, but they are still under the HWM, and they will remain under the HWM until the object is rebuilt, truncated, or shrunk (shrinking of a segment is a new Oracle 10g feature that is supported only if the segment is in an ASSM tablespace).
The HWM is relevant since Oracle will scan all blocks under the HWM, even when they contain no data, during a full scan. This will impact the performance of a full scan¿especially if most of the blocks under the HWM are empty. To see this, just create a table with 1,000,000 rows (or create any table with a large number of rows), and then execute a SELECT COUNT(*) from this table. Now, DELETE every row in it and you will find that the SELECT COUNT(*) takes just as long (or longer, if you need to clean out the block! Refer to the 'Block Cleanout' section of Chapter 9) to count 0 rows as it did to count 1,000,000. This is because Oracle is busy reading all of the blocks below the HWM to see if they contain data. You should compare this to what happens if you used TRUNCATE on the table instead of deleting each individual row. TRUNCATE will reset the HWM of a table back to 'zero' and will truncate the associated indexes on the table as well. If you plan on deleting every row in a table, TRUNCATE¿if it can be used¿would be the method of choice for this reason.
In an MSSM tablespace, segments have a definite HWM. In an ASSM tablespace, however, there is an HWM and a low HWM. In MSSM, when the HWM is advanced (e.g., as rows are inserted), all of the blocks are formatted and valid, and Oracle can read them safely. With ASSM, however, when the HWM is advanced Oracle doesn¿t format all of the blocks immediately¿they are only formatted and made safe to read upon their first use. So, when full scanning a segment, we have to know if the blocks to be read are 'safe' or unformatted (meaning they contain nothing of interest and we do not process them). To make it so that not every block in the table need go through this safe/not safe check, Oracle maintains a low HWM and a HWM. Oracle will full scan the table up to the HWM¿and for all of the blocks below the low HWM, it will just read and process them. For blocks between the 'low HWM' and the HWM, it must be more careful and refer to the ASSM bitmap information used to manage these blocks in order to see which of them it should read and which it should just ignore.