oracle数据库自动启动配置

前言

Oracle数据库默认情况下是不会随系统启动而启动的。在某些特殊情况下,有些用户希望可以自动启动,那么就需要手工编写相关的脚本来实现了。如下借鉴网络上的信息整理测试如下,经过测试可以正常运行。

Su -root 
1.
mkdir /home/oracle/scripts

2.
cat > /home/oracle/scripts/setEnv.sh <<EOF
# Oracle Settings
export TMP=/tmp
export TMPDIR=\$TMP

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/12.2.0.1/db_1
export ORACLE_SID=betadb

export PATH=/usr/sbin:/usr/local/bin:\$PATH
export PATH=\$ORACLE_HOME/bin:\$PATH

export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlib
EOF


3.
echo ". /home/oracle/scripts/setEnv.sh" >> /home/oracle/.bash_profile

4.

cat > /home/oracle/scripts/start_all.sh <<EOF
#!/bin/bash
. /home/oracle/scripts/setEnv.sh

export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES

dbstart \$ORACLE_HOME
EOF


cat > /home/oracle/scripts/stop_all.sh <<EOF
#!/bin/bash
. /home/oracle/scripts/setEnv.sh

export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES

dbshut \$ORACLE_HOME
EOF

chown -R oracle.oinstall /home/oracle/scripts
chmod u+x /home/oracle/scripts/*.sh


5.
You should be able to start/stop the database with the following scripts run from the "oracle" user.


$ ~/scripts/start_all.sh
$ ~/scripts/stop_all.sh




创建服务:
Create the service file called "/lib/systemd/system/dbora.service".

[Unit]
Description=The Oracle Database Service
After=syslog.target network.target

[Service]
# systemd ignores PAM limits, so set any necessary limits in the service.
# Not really a bug, but a feature.
# https://bugzilla.redhat.com/show_bug.cgi?id=754285
LimitMEMLOCK=infinity
LimitNOFILE=65535

#Type=simple
# idle: similar to simple, the actual execution of the service binary is delayed
#       until all jobs are finished, which avoids mixing the status output with shell output of services.
RemainAfterExit=yes
User=oracle
Group=oinstall
Restart=no
ExecStart=/bin/bash -c '/home/oracle/scripts/start_all.sh'
ExecStop=/bin/bash -c '/home/oracle/scripts/stop_all.sh'

[Install]
WantedBy=multi-user.target



If you are using NFS storage, you need to define the dependency between Oracle and NFS.

[Unit]
Description=The Oracle Database Service
Requires=rpc-statd.service network.target nfs.service nfs-mountd.service local-fs.target remote-fs.target
After=syslog.target network.target nfs.service nfs-mountd.service local-fs.target rpc-statd.service remote-fs.target

[Service]
# systemd ignores PAM limits, so set any necessary limits in the service.
# Not really a bug, but a feature.
# https://bugzilla.redhat.com/show_bug.cgi?id=754285
LimitMEMLOCK=infinity
LimitNOFILE=65535

#Type=simple
# idle: similar to simple, the actual execution of the service binary is delayed
#       until all jobs are finished, which avoids mixing the status output with shell output of services.
Type=idle
RemainAfterExit=yes
User=oracle
Group=oinstall
Restart=no
ExecStart=/bin/bash -c '/home/oracle/scripts/start_all.sh'
ExecStop=/bin/bash -c '/home/oracle/scripts/stop_all.sh'

[Install]
WantedBy=multi-user.target



# systemctl daemon-reload


# systemctl start dbora.service
# systemctl enable dbora.service
ln -s '/usr/lib/systemd/system/dbora.service' '/etc/systemd/system/multi-user.target.wants/dbora.service'
# systemctl status dbora.service
dbora.service - The Oracle Database Service
   Loaded: loaded (/lib/systemd/system/dbora.service; linked)
   Active: active (exited) since Tue 2015-03-24 10:55:28 GMT; 5min ago
  Process: 6145 ExecStart=/home/oracle/scripts/start_all.sh (code=exited, status=0/SUCCESS)
 Main PID: 6145 (code=exited, status=0/SUCCESS)

Mar 24 10:56:27 ol7-121.localdomain startup.sh[6145]: SQL> ORACLE instance started.
Mar 24 10:56:27 ol7-121.localdomain startup.sh[6145]: Total System Global Area 1140850688 bytes
Mar 24 10:56:27 ol7-121.localdomain startup.sh[6145]: Fixed Size                    2923584 bytes
Mar 24 10:56:27 ol7-121.localdomain startup.sh[6145]: Variable Size                  419431360 bytes
Mar 24 10:56:27 ol7-121.localdomain startup.sh[6145]: Database Buffers          704643072 bytes
Mar 24 10:56:27 ol7-121.localdomain startup.sh[6145]: Redo Buffers                   13852672 bytes
Mar 24 10:56:31 ol7-121.localdomain startup.sh[6145]: Database mounted.
Mar 24 10:56:33 ol7-121.localdomain startup.sh[6145]: Database opened.
Mar 24 10:56:33 ol7-121.localdomain startup.sh[6145]: SQL> Disconnected from Oracle Database 12c Enterprise Edition Re...ction
Mar 24 10:56:33 ol7-121.localdomain startup.sh[6145]: With the Partitioning, OLAP, Advanced Analytics and Real Applica...tions
Hint: Some lines were ellipsized, use -l to show in full.
#
  • 7
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
(一)客户端组件和服务器端组件 2 (二)Oracle Database 的体系架构 2 1. 什么是数据库?什么是实例? 3 2. 存储结构 3 数据文件(data file) 4 联机日志文件(online redo log file) 4 控制文件(control file) 5 归档模式:冷备份,离线备份,热备份,联机备份 6 Spfile:二进制,9i 之后 Pfile:文本,9i 之前 6 可以将 spfile 转换为 pfile 6 注意:scope 的取值有三个:memory、spfile、both 7 一个表空间(tablespace)由一组段组成 8 Tablespaces(表空间) 8 system sysaux temp undo 8 Segments (段) 8 extents (区) 8 Data Block (数据块) 8 3. 进程结构 9 日志写进程(LGWR) 检查点进程(CKPT) 9 归档进程(ARCn) 恢复器进程(RECO) 9 2日志写进程(LGWR) 10 3检查点进程(CKPT) 10 6归档进程(ARCn) 10 7恢复器进程(RECO) 11 4. 内存结构 11 1共享池:shared pool 12 3重做日志缓冲区:log buffer 12 (三)自动内存管理和自动共享内存管理 13 (四)管理方案对象 13 (五)数据字典 15 (一)安装 Oracle Linux 7.3 64 位操作系统 17 (二)安装 Oracle Database 12cR2 19 (三)使用 DBCA 创建 Oracle 数据库 21 (四)验证 Oracle Database 12cR2 环境 25 (五)使用 oracle-database-server-12cR2-preinstall 包 25 三、管理数据库实例 27 (一)管理工具 27 (二)初始化参数 27 (三)数据库启动的过程 29 (四)数据库的关闭 29 四、配置 Oracle 的网络环境 31 (一)连接建立的过程 31 (二)使用 lsnrctl 命令 31 (三)如何配置监听器 33 (四)注册数据库的服务 34 (五)建立连接的方法 36 (六)共享服务器模式 38 (七)分布式数据库基础 40 五、管理用户和权限 42 (一)用户 42 (二)权限 46 (三)角色 51 (四)概要文件:Profile 54 六、管理数据库存储结构 57 (一)存储结构 57 (二)数据块的结构 57 (三)表空间和数据文件 57 (四)什么是自动存储管理 58 七、数据的并发处理 60 (一)锁定的机制 60 (三)锁的队列 60 (四)死锁 62 (五)手动加锁 64 (方式一)lock 语句 64 八、管理还原数据 65 (一)什么是还原数据? 65 (二)还原数据的作用 66 (三)还原数据的工作原理 66 (四)还原数据与重做数据 67 (五)管理还原数据 67 (六)还原保留期和确保还原保留期 67 九、数据库审计 68 (一)什么是数据库审计 68 (二)审计的参数设置 69 (三)强制审计 69 (四)标准审计 69 (五)基于值的审计 71 (六)细粒度审计(FGA) 71 (七)DBA 审计 73 (八)12c 审计的新特性 73 十、移动数据 76 (一)移动数据的整体架构 76 (二)目录对象 76 (三)使用 SQL*Loader 77 (四)数据泵 78 (五)外部表 80 十一、性能管理基础 82 (一)性能监视 82 (二)性能监视 82 (三)管理内存组件 83 (四)使用内存指导 83 (五)使用动态性能视图 84 (六)故障排除和优化视图 85 (七)无效和不可用对象 85 =======第二篇:备份与恢复======= 86 一、备份和恢复的基本概念 86 (一)衡量数据库可恢复性的两个指标 86 (二)数据库故障的类型 86 (三)配置数据库的可恢复性 88 (四)归档日志文件 88 (五)启用 ARCHIVELOG(归档)模式 89 (六)Oracle 数据库备份的解决方案 89 二、闪回 90 (一)什么是闪回 Flashback? 90 (五)闪回查询:Flashback Query 91 (六)闪回版本查询:Flashback Version Query 92 (七)闪回表:Flashback Table 93 (八)闪回数据库:Flashback Database 94 (九)闪回删除:Flashback Drop 95 (十)闪回事务查询:Flashback Transaction Qu

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值