摘要:
oracle故障模拟;自启动流程;应用进程日志文件位置
1、在Oracle中切换账户可以通过ALTER SESSION和CONNECT语句来实现。ALTER SESSION语句可以在不断开会话的情况下切换账户(需要具有ALTER SESSION系统权限),而CONNECT语句将会话断开并重新连接到新账户。
//两套数据库:服务名分别是dbms和fdp
sqlplus usrdba/password@dbms
sqlplus twr00/ca2804@dbms
sqlplus app00/ca2804@dbms
sqlplus plan/ca2804@fdp1a
sqlplus sup/ca2804@fdp1a
SQL> SELECT username FROM dba_users;
SQL> connect PLAN/ca2804 //切换账户
SQL> SELECT USER FROM DUAL; //查询当前用户
SQL> show user; //查询当前用户
SQL> select t.table_name from user_tables t; //查询登录用户所有表名
SQL> SELECT table_name, tablespace_name FROM user_tables WHERE table_name = 'T_CPDLCTIMER';
SQL> select t.column_name from user_col_comments t where t.table_name ='SP_SECT';//查询指定表的所有字段名
SQL> desc DBA_TABLES
SQL> SELECT OWNER,TABLE_NAME,TABLESPACE_NAME,CLUSTER_NAME,INSTANCES FROM DBA_TABLES WHERE TABLE_NAME='SP_MTCA_SWITCH';
oracle用户与表空间关系:( Oracle数据库、实例、用户、表空间、表之间的关系)
- 用户=商家
- 表=商品
- 表空间=仓库
实例->用户->表(用户属于数据库实例,表属于某个用户)
一个数据库可以有n个实例;用户是在实例下建立的,不同实例可以建相同名字的用户。
2、模拟故障1:(模拟磁盘/home/oracle/oradata/fdp1位置读写异常)
[root@host3 fdp1]# mount /dev/sda2 /home/oracle/oradata/fdp1
# ps -ef | grep oracle //查看oracle进程运行正常
$sqlplus / as sysdba
SQL> SELECT host_name FROM V$INSTANCE;
host3.a28.com
SQL> select * from STC_PLAN;
ERROR at line 1:
ORA-01116: error in opening database file 5
ORA-01110: data file 5: '/home/oracle/oradata/fdp1/atc01.dbf'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
[root@host3 db_log]# tailf 20230707-DBH.log
host:[3] 20230707031508 get state:[1] <GOOD:1 BAD:0 net:2>
host:[3] 20230707031508 get state:[1] <GOOD:1 BAD:0 net:1>
host:[3] 20230707031509 send state:[1] [14400-526] <GOOD:1 BAD:0 net:1>
host:[3] 20230707031509 send state:[1] [14400-526] <GOOD:1 BAD:0 net:2>
//测试:在FDOP上操作删除用户name='bbb'
[root@host205 fdop_log]# tailf 2023070712fdop.log
======stmt=delete from hz_user where name='bbb';
Database rollback(-1) to close For DB Error!
error sql:delete from hz_user where name='bbb';
error function code:9;
error desc:ORA-01116: error in opening database file 3
ORA-01110: data file 3: '/home/oracle/oradata/fdp1/undotbs01.dbf'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
====current is 0 0:ATC 1:SIM ====
buf[0]:1 msflag===[1]
a1使用服务名[fdp1a]连接库失败!
b1使用服务名[fdp1a][fdp1b]连接库失败!
connect MASTER[plan/1] FAIL!*******************
//SMP监控RUN-LOG报错“FDP1:DBSY on FDP1 Report OP DB ERR[ORA-01116]”
ORA-01116: 打开数据库文件时出错
--------------------umount后恢复OK---------------------
[root@host3 db_log]# umount /home/oracle/oradata/fdp1
SQL> select count(*) from T_CITYROUTE;
COUNT(*)
10031
[root@host205 fdop_log]# tailf 2023070713fdop.log
====current is 0 0:ATC 1:SIM ====
buf[0]:1 msflag===[1]
1已连接到系统库<fdp1a>
====pid:11549==pidName:CETC_FDOP====
=====msflag:1 connect [fdp1a]=====
connect MASTER[plan/1] OK!*******************
-------ClickOnButtonAction
======stmt=delete from hz_user where name='aaa';
sendsql_log====/home/atc/log/db_log/20230707-FDOP_sendsql.log
***:这种情况下,读表报错“No such file or directory”,ora进程运行正常,但是SMP监控FDP1-DB状态OK,而且还是主态(SMP监控RUN-LOG报错“FDP1:DBSY on FDP1 Report OP DB ERR[ORA-01116]”——问题是该报错没有改变SMP上FDP1-DB的状态)。umount后,读表恢复。
模拟故障2:(模拟磁盘/home/oracle位置读写异常)
[root@host3 oracle]# mount /dev/sda2 /home/oracle
SQL> SELECT OWNER FROM DBA_TABLES WHERE TABLE_NAME='T_CPDLCTIMER';
ERROR at line 1:
Error while trying to retrieve text for error ORA-03135
separator not found in message(3144)separator not found in message(3142)
[root@host3 oracle]# ps -aux |grep ora //进程宕
*:这种情况下SMP监控FDP1-DB状态变为Error,而且自动切为Slave态
3、莱斯rhel7.8自启动配置( xinit启动X Window System过程初探)
TWPLC1 <atc>[/home/atc]$ ps -aux |grep xinit
root 2211 0.0 0.0 193972 2412 ? S 5月30 0:00 /bin/su - atc -c xinit /home/atc/.xinitrc -- /usr/bin/X :0 -s 0
atc 2212 0.0 0.0 14024 836 ? Ss 5月30 0:00 xinit
atc 2307 0.0 0.0 113288 1416 ? Ss 5月30 0:00 /bin/sh /home/atc/.xinitrc
//运行/home/atc/shell/start_pre
[root@host206 shell]# more /etc/rc.local
touch /var/lock/subsys/local
sh /home/atc/shell/start_pre
//运行bin/su - $USER -c xinit /home/${USER}/.xinitrc -- /usr/bin/X :0 -s 0
[root@host206 ~]# more /home/atc/shell/autologin
#!/bin/sh
USER=atc
rm -f /var/run/console/console.lock /var/run/console/$USER
echo -n $USER > /var/run/console/console.lock
#touch /var/run/console/$USER
echo -n 1 > /var/run/console/$USER
/sbin/pam_console_apply
PATH=/sbin:/usr/sbin:/bin:/usr/bin
/bin/su - $USER -c xinit /home/${USER}/.xinitrc -- /usr/bin/X :0 -s 0
#echo "rm /var/run/console/"
#rm -f /var/run/console/console.lock /var/run/console/$USER
#/sbin/pam_console_apply -r
//startx启动Xwindows服务时读取.xinitrc,启动程序 sh /home/atc/shell/start_CETC &
TWPLC1 <atc>[/home/atc]$ more /home/atc/.xinitrc
TIME=`date "+%Y%m%d%H"`
LOG="/home/atc/log/zl_log/startx_$TIME.log"
#Disable the screen-saver
date >> $LOG
xset s 0
xset -dpms
echo " xset" >> $LOG
#Set the background
xsetroot -solid grey25
echo " xsetroot" >> $LOG
#allow access form any computer
xhost +
echo " xhost +" >> $LOG
#Start the window manager
xterm &
echo " xterm" >> $LOG
sh /home/atc/shell/start_CETC &
echo " start_CETC" >> $LOG
/bin/mwm
echo " mwm" >> $LOG
//start_CETC运行进程/home/atc/bin/CETC_SDD、CETC_SDD等
TWPLC1 <atc>[/home/atc]$ more /home/atc/shell/start_CETC
#start software for atc
. /home/atc/.profile
ATC_EXECPATH=/home/atc/bin/
ATCEXE_NONE()
99 {
100 _EXENAME=$1
101 export TERM=xterm
102 exec "$ATC_EXECPATH""$_EXENAME" > /dev/null 2>&1 &
103 }
start_SDD()
{
ATCEXE_NONE "CETC_SDD"
ATCEXE_NONE "CETC_SDDH"
ATCEXE_NONE "CETC_POST"
ATCEXE_NONE "CETC_FDD"
ATCEXE_NONE "CETC_PRT"
ATCEXE_NONE "CETC_CFLCA"
sleep 30
ATCEXE_NONE "CETC_FBF"
#exec /home/atc/bin/CETC_FBF > /tmp/fpf.log &
cd /home/atc/shell
sh pid-fbf.sh &
}
***: /etc/rc.local——>/home/atc/shell/start_pre——>(sh "$ATC_SHELLPATH"autologin &)/home/atc/shell/autologin——>/home/${USER}/.xinitrc——>/home/atc/shell/start_CETC——>/home/atc/shell/start_zl(启动CETC_ZLD;CETC_DBH;CETC_NET;CETC_NETC等)
[root@host206 ~]# ll /etc/rc.local
lrwxrwxrwx. 1 root root 13 4月 12 06:44 /etc/rc.local -> rc.d/rc.local
4、/home/atc/shell/start_zl调用sh /home/atc/shell/mywatch.sh &;这里可知zl_log/top_$time.log(zlsem_$time.log)日志(top/zlsem)的来源。
[root@host206 ~]# more /home/atc/shell/mywatch.sh
#export TERM=xterm
pid=`/bin/ps -ef|grep -v grep|grep -w mywatch.sh|awk '{print 2}'|grep -v $$`
echo pid=$pid
kill -9 $pid
while :
do
time=`date "+%Y%m%d%H"`
date >>/home/atc/log/zl_log/zlsem_$time.log
date >>/home/atc/log/zl_log/top_$time.log
/home/atc/bin/zlsem >>/home/atc/log/zl_log/zlsem_$time.log
top -bn 1 >>/home/atc/log/zl_log/top_$time.log &
echo " " >>/home/atc/log/zl_log/top_$time.log
sleep 1
done
5、从/home/atc/shell/start_pre脚本可见:LGP实现使用elk(elasticsearch-7.12.0;logstash-7.12.0;kibana-7.12.0-linux-x86_64;filebeat-7.12.0-linux-x86_64)
if [ "$typename" = "LGP" ]
then
nohup /home/leslas/elkmgr/elk/logstash-7.12.0/bin/logstash >/dev/null 2>&1 &
su - elk_user -c "nohup /home/leslas/elkmgr/elk/elasticsearch-7.12.0/bin/elasticsearch >/dev/null 2>&1 &"
su - elk_user -c "nohup /home/leslas/elkmgr/elk/kibana-7.12.0-linux-x86_64/bin/kibana >/dev/null 2>&1 &"
nohup java -jar /home/atc/bin/las-log-new.jar >/dev/null 2>&1 &
fi
nohup /home/leslas/elkmgr/bmgr/filebeat-7.12.0-linux-x86_64/filebeat -strict.perms=false -e -c /home/leslas/elkmgr/bmgr/filebeat-7.12.0-linux-x86_64/filebeat.yml >/dev/null 2>&1 &
6、CETC_FDOP进程的日志文件:/home/atc/log/fdop_log/2023070711fdop.log;/home/atc/log/db_log/20230707-FDOP_sendsql.log
CETC_FBF进程的日志文件:/home/atc/log/db_log/20230707-CETC_FBF_conndb.log但是这个日志只记录数据量connect信息;connect [fdp1a]
CETC_FDD进程设计为查询时连库,进程日志文件:/home/version/current/atc_3.4/log/fdd_log/20230707-FDD-DbConnect.log和20230707-FDD-FPW.log)