Mục đích: Hướng dẫn bật/tắt Oracle Grid (Cluster+ASM), Oracle RAC 11g, 12c, 19c đảm bảo an toàn, tránh rủi ro bật tắt nhầm làm chết cả cluster 2 node.
I. Thực hiện tắt/bật Grid node 2 trước:
1. Tắt Grid và instance trên node 2
1.1. Stop oracle instance
(oracle)# sqlplus / as sysdba;
SQL> shutdown immediate
(nếu lâu quá thì shutdown abort)
1.2. Kiểm tra đường dẫn GRID_HOME
(root)# ps -ef |grep grid
Giả dụ là /u01/app/12.2.0/grid
1.3. Shutdown các dịch vụ cluster (gsd, ons, vip, lsnr sẽ offline) (có thẻ bỏ qua bước này)
(root)# cd /u01/app/12.2.0/grid
(root)# srvctl stop nodeapps -n <node_name>
Kiểm tra lại trạng thái các service của cluster:
(root)#./crsctl status resource -t
1.4. Stop grid
(root)# ./crsctl stop crs
2. Bật Grid và instance trên node 2
2.1. Kiểm tra đường dẫn GRID_HOME
(root)# ps -ef |grep grid
Giả dụ là /u01/app/12.2.0/grid
2.2. Start grid
(root)# ./crsctl start crs
(Check alert log grid trong quá trình bật crs)
Kiểm tra lại trạng thái các service của cluster:
(root)#./crsctl status resource -t
(root)#./crsctl check crs
(root)#./crsctl check css
(root)#./crsctl query vss votediks
(root)# .ocrcheck
2.3. Stop oracle instance node 2
(oracle)# sqlplus / as sysdba;
SQL> startup
(Check alert log trong quá trình startup)
2.4. Kiểm tra lại đảm bảo instance và service đã ONLINE hết
(root)#./crsctl status resource -t
II. Sau khi node 2 lên thì thực hiện tương tự trên node 1
III. Kiểm tra lại đảm bảo instance và service đã ONLINE hết
(root)#./crsctl status resource -t
== File init.ohasd ==
more /etc//init.ohasd
#!/bin/sh
#
# Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
#
# init.ohasd - Control script for the Oracle HA services daemon
# This script is invoked by the init system
#
# Note:
# For security reason, all cli tools shipped with Clusterware should be
# executed as HAS_USER in init.ohasd and ohasd rc script for SIHA. (See bug
# 9216334 for more details)
######### Shell functions #########
tolower_host()
{
#If the hostname is an IP address, let hostname
#remain as IP address
H1=`$HOSTN`
len1=`$EXPRN "$H1" : '.*'`
len2=`$EXPRN match $H1 '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'`
# Strip off domain name in case /bin/hostname returns
# FQDN hostname
if [ $len1 != $len2 ]; then
H1=`$ECHO $H1 | $CUT -d'.' -f1`
fi
$ECHO $H1 | $TR '[:upper:]' '[:lower:]'
}
# Invoke crsctl as root in case of clusterware, and HAS_USER in case of SIHA.
# Note: Argument with space might be problemactic (my_crsctl 'hello world')
my_crsctl()
{
if [ root = "root" ]; then
$CRSCTL $*
else
$SU root -c "$CRSCTL $*"
fi
}
# Invoke clsecho as root in case of clusterware, and HAS_USER in case of SIHA.
# Note: Argument with space might be problemactic (my_clsecho 'hello world')
my_clsecho()
{
if [ root = "root" ]; then
$CLSECHO $*
else
$SU root -c "$CLSECHO $*"
fi
}
# Invoke clsecho as root in case of clusterware, and HAS_USER in case of SIHA.
# Note: Argument with space might be problemactic (my_logsys 'hello world')
my_logsys()
{
if [ root = "root" ]; then
$LOGSYS
PREV_RESTART_TIME=0
RESTART_COUNTER=0
# How long to wait (in seconds) before rechecking a dependency,
# and printing out messages about it.
DEP_CHECK_WAIT=60
NAMEDPIPE=/var/tmp/.oracle/npohasd
### CLI tools
BASENAME=/bin/basename
HOSTN=/bin/hostname
SU=/bin/su
CHOWN=/bin/chown
ECHO=/bin/echo
SLEEP=/bin/sleep
EXPRN=/usr/bin/expr
CUT=/usr/bin/cut
CAT=/bin/cat
GREP=/bin/grep
# Location to TR differs in diff. platforms.
TR=/bin/tr
#solaris location (for both SPARC and amd)
[ 'SunOS' = `/bin/uname` ] && TR=/usr/xpg4/bin/tr
#on linux tr is at /usr/bin/tr
[ 'Linux' = `/bin/uname` ] && TR=/usr/bin/tr
CLSECHO="/u01/app/11.2.0/grid/bin/clsecho"
LOGSYS="$CLSECHO -s $0:"
PERL="/u01/app/11.2.0/grid/perl/bin/perl -I${ORA_CRS_HOME}/perl/lib"
CRSCTL=/u01/app/11.2.0/grid/bin/crsctl
### Main ###
# Retrieve name of the platform
PLATFORM=`/bin/uname`
MY_HOST=`tolower_host`
# Default path for SCR control files.
AUTORUNFILE=/etc/oracle/scls_scr/$MY_HOST/root/ohasdrun
LOGMSG="/bin/logger -puser.err"
LOGERR="/bin/logger -puser.alert"
OSF1)
;;
esac
case $1 in
'run')
# we set the hard and soft limit here as root
# these limits will be reset in ohasd wrapper.
# Nevertheless, we need to set them here in the
# case of SIHA since the wrapper will not get
# called as root
case $PLATFORM in
Linux)
# MEMLOCK limit is for Bug 9136459
ulimit -l unlimited
ulimit -c unlimited
ulimit -n 65536
;;
*)
ulimit -c unlimited
ulimit -n 65536
;;
esac
# Handle reboot of system or restarted init script
STARTUP_LOOP="true"
while ($STARTUP_LOOP)
do
if [ -r $AUTORUNFILE ]
then
case `$CAT $AUTORUNFILE` in
restart*)
OUTPUT=`my_crsctl check has | $GREP 4638`
case "$OUTPUT" in
CRS*)
# Sync with ohasd and restart after crash
read junk < $NAMEDPIPE
STARTUP_LOOP="false"
;;
*)
# Stale restart at boot time, wait for restart
$SLEEP 10
;;
esac
;;
*)
STARTUP_LOOP="false"
;;
esac
else
STARTUP_LOOP="false"
fi
done
# Wait until clusterware home is mounted.
while [ ! -r $CLSECHO ]
do
$LOGMSG "Waiting for filesystem containing $CLSECHO."
$SLEEP $DEP_CHECK_WAIT
done
# Try to create named pipe.
if [ root = "root" ]; then
OUTPUT=`mkfifo $NAMEDPIPE 2>&1`
else
OUTPUT=`$SU root -c "mkfifo $NAMEDPIPE" 2>&1`
fi
if [ ! -p $NAMEDPIPE ]; then
# Print an alert entry regarding failure to create named pipe.
# Note: Cannot use my_clsecho since OUTPUT has newline and white spaces
if [ root = "root" ]; then
$CLSECHO -l -p has -f crs -m 10131 $NAMEDPIPE "$OUTPUT"
else
$SU root -c "$CLSECHO -l -p has -f crs -m 10131 $NAMEDPIPE '$OUTPUT'"
fi
# Stop ohasd restart.
$ECHO "stop" > $AUTORUNFILE
fi
# Main loop
while (true)
do
$SLEEP 10
;;
esac
;;
*)
STARTUP_LOOP="false"
;;
esac
else
STARTUP_LOOP="false"
fi
done
# Wait until clusterware home is mounted.
while [ ! -r $CLSECHO ]
do
$LOGMSG "Waiting for filesystem containing $CLSECHO."
$SLEEP $DEP_CHECK_WAIT
done
# Try to create named pipe.
if [ root = "root" ]; then
OUTPUT=`mkfifo $NAMEDPIPE 2>&1`
else
OUTPUT=`$SU root -c "mkfifo $NAMEDPIPE" 2>&1`
fi
if [ ! -p $NAMEDPIPE ]; then
# Print an alert entry regarding failure to create named pipe.
# Note: Cannot use my_clsecho since OUTPUT has newline and white spaces
if [ root = "root" ]; then
$CLSECHO -l -p has -f crs -m 10131 $NAMEDPIPE "$OUTPUT"
else
$SU root -c "$CLSECHO -l -p has -f crs -m 10131 $NAMEDPIPE '$OUTPUT'"
fi
# Stop ohasd restart.
$ECHO "stop" > $AUTORUNFILE
fi
# Main loop
while (true)
do
continue
else
# Reset the counter if ohasd does not restart more than
# RESTART_LIMIT times in the last RESTART_TIME_WINDOW secs.
RESTART_COUNTER=1
my_logsys "Resetting RESTART_COUNTER to 1."
fi
PREV_RESTART_TIME=$CURR_TIME
else
# Let ohasd restart if failed to obtain current time.
my_logsys "Unable to obtain current time. $PERL -e 'print time' failed."
fi
fi
############################################
my_logsys "ohasd is restarting $RESTART_COUNTER/$RESTART_LIMIT."
# Restart ohasd and sync with it
if [ root = "root" ]; then
/u01/app/11.2.0/grid/bin/ohasd restart &
else
$SU root -c "/u01/app/11.2.0/grid/bin/ohasd restart &"
fi
read junk < $NAMEDPIPE
;;
stop*)
$SLEEP 10
;;
*)
$LOGERR 'autorun file for ohasd has unknown value'
$SLEEP 10
;;
esac
else
$LOGERR 'autorun file for ohasd is missing'
$SLEEP 10
fi
done
;;
esac
* KHOÁ HỌC ORACLE DATABASE A-Z ENTERPRISE trực tiếp từ tôi giúp bạn bước đầu trở thành những chuyên gia DBA, đủ kinh nghiệm đi thi chứng chỉ OA/OCP, đặc biệt là rất nhiều kinh nghiệm, bí kíp thực chiến trên các hệ thống Core tại VN chỉ sau 1 khoá học.
* CÁCH ĐĂNG KÝ: Gõ (.) hoặc để lại số điện thoại hoặc inbox https://m.me/tranvanbinh.vn hoặc Hotline/Zalo 090.29.12.888
* Chi tiết tham khảo:
https://bit.ly/oaz_w
hoặc
https://bit.ly/oaz_fp
=============================
KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH:
📧 Mail: binhoracle@gmail.com
☎️ Mobile: 0902912888
⚡️ Skype: tranbinh48ca
👨 Facebook: https://www.facebook.com/BinhOracleMaster
👨 Inbox Messenger: https://m.me/101036604657441 (profile)
👨 Fanpage: https://www.facebook.com/tranvanbinh.vn
👨 Inbox Fanpage: https://m.me/tranvanbinh.vn
👨👩 Group FB: https://www.facebook.com/groups/DBAVietNam
👨 Website: https://www.tranvanbinh.vn
👨 Blogger: https://tranvanbinhmaster.blogspot.com
🎬 Youtube: http://bit.ly/ytb_binhoraclemaster
👨 Tiktok: https://www.tiktok.com/@binhoraclemaster?lang=vi
👨 Linkin: https://www.linkedin.com/in/binhoracle
👨 Twitter: https://twitter.com/binhoracle
👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội
=============================
học oracle database, Tự học Oracle, Tài liệu Oracle 12c tiếng Việt, Hướng dẫn sử dụng Oracle Database, Oracle SQL cơ bản, Oracle SQL là gì, Khóa học Oracle Hà Nội, Học chứng chỉ Oracle ở đầu, Khóa học Oracle online,khóa học pl/sql, học dba, học dba ở việt nam, khóa học dba, khóa học dba sql, tài liệu học dba oracle, Khóa học Oracle online, học oracle sql, học oracle ở đâu tphcm, học oracle bắt đầu từ đâu, học oracle ở hà nội, oracle database tutorial, oracle database 12c, oracle database là gì, oracle database 11g, oracle download, oracle database 19c, oracle dba tutorial, oracle tunning, sql tunning , oracle 12c, oracle dataguard, oracle goldengate, oracle weblogic, oracle exadata, hoc solaris, hoc linux, hoc aix