暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

实战oracle数据库和ogg随系统自动启动

原创 jieguo 2023-07-07
414

为了减少由于系统意外宕机重启需人工启动所花费的时间,我们有必要制定策略让数据库和ogg等应用随系统自动启动。

如下以oracle数据库和ogg为例,举一反三,其它应用均可参考如下方法实现:

1.配置ogg启动信息:

准备启动参数文件:

vi /home/oracle/info.txt
sh date
start mgr

配置启动命令:

vi /home/oracle/startmgr.sh
/ogg/19c/ggsci paramfile /home/oracle/info.txt >> /home/oracle/oggstartoutput.txt

ogg的抽取和推送进程如果需要自动启动,则在view param mgr参数中添加

AUTOSTART ER * --调试期间不要开启,上生产后开启即可

2.配置数据库和ogg启动脚本:

vi /home/oracle/start.sh

#start db
source /home/oracle/.bash_profile
lsnrctl start
export ORACLE_SID=mid
sqlplus / as sysdba <<EOF
startup
exit;
EOF
#start ogg
/home/oracle/startmgr.sh

3.配置随系统启动脚本:

vi /etc/rc.local
文件末尾添加一行:
su - oracle -s /bin/bash /home/oracle/start.sh
赋予执行权限:
chmod +x /etc/rc.d/rc.local

4.手动测试脚本及重启操作系统验证:

手动测试:
oracle下停监听,库,ogg,然后执行脚本测
root下执行:
su - oracle -c /home/oracle/startmgr.sh
su - oracle -s /bin/bash /home/oracle/start.sh

重启系统测试:
reboot
验证:
ps -ef|grep ora_smon
lsnrctl status
/ogg/19c/ggsci
info all

tips:centos7.x配置postgresql随系统启动:

[root@localhost ~]# ll /home/postgres/startup.sh 
-rwxrwxr-x. 1 postgres postgres 71 11月  2 09:26 /home/postgres/startup.sh
[root@localhost ~]# more /home/postgres/startup.sh
/home/postgresql/bin/pg_ctl -D /home/postgresql/data/ -l logfile start
[root@localhost ~]# cat /etc/rc.local 
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
su - postgres -s /bin/bash /home/postgres/startup.sh
[root@localhost ~]# ll /etc/rc.local 
lrwxrwxrwx. 1 root root 13 2月  17 2023 /etc/rc.local -> rc.d/rc.local
[root@localhost ~]# ll /etc/rc.d/rc.local 
-rwxr-xr-x. 1 root root 526 11月  2 09:26 /etc/rc.d/rc.local
[root@localhost ~]# netstat -tunlp|grep post
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      1385/postgres       
tcp6       0      0 :::5432                 :::*                    LISTEN      1385/postgres 

最后修改时间:2023-11-02 09:30:04
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论