oracle19c开机自启动

配置

bash 复制代码
cat > /etc/init.d/oracle19c <<'EOF'
#!/bin/bash
# Oracle startup and shutdown script

export ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
export ORACLE_SID=ORCLCDB
export LISTENER_NAME=LISTENER
# General exports and vars
export PATH=$ORACLE_HOME/bin:$PATH

case "$1" in
  start)
    echo "Starting Oracle Database and Listener..."
    sqlplus -s / as sysdba <<EOF1
    startup;
    alter pluggable database all open;
    exit;
EOF1
    lsnrctl start
    ;;
  stop)
    echo "Stopping Oracle Database and Listener..."
    lsnrctl stop
    sqlplus -s / as sysdba <<EOF2
    shutdown immediate;
    exit;
EOF2
    ;;
  *)
    echo "Usage: $0 {start|stop}"
    exit 1
    ;;
esac

exit 0
EOF

chmod 755 /etc/init.d/oracle19c
bash 复制代码
cat > /usr/lib/systemd/system/oracle.service <<"EOF"
[Unit]
Description=Oracle Database and Listener
After=network.target

[Service]
Type=forking
User=oracle
Group=oinstall
ExecStart=/etc/init.d/oracle19c start
ExecStop=/etc/init.d/oracle19c stop
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF
bash 复制代码
systemctl daemon-reload
systemctl enable --now oracle

参考连接

https://www.cnblogs.com/dll102/p/18454351
https://blog.csdn.net/Pepsiboy1/article/details/141718609?spm=1001.2101.3001.6650.3&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EYuanLiJiHua%7EPosition-3-141718609-blog-143025821.235%5Ev43%5Econtrol&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EYuanLiJiHua%7EPosition-3-141718609-blog-143025821.235%5Ev43%5Econtrol&utm_relevant_index=6

相关推荐
linweidong2 小时前
C++ 模块化编程(Modules)在大规模系统中的实践难点?
linux·前端·c++
invicinble6 小时前
对linux形成认识
linux·运维·服务器
小Pawn爷6 小时前
14.VMmare安装ubuntu
linux·运维·ubuntu
技术路上的探险家6 小时前
8 卡 V100 服务器:基于 vLLM 的 Qwen 大模型高效部署实战
运维·服务器·语言模型
有谁看见我的剑了?6 小时前
介绍一款 测试 DNS解析成功率的网站
运维
半桔7 小时前
【IO多路转接】高并发服务器实战:Reactor 框架与 Epoll 机制的封装与设计逻辑
linux·运维·服务器·c++·io
HABuo7 小时前
【linux文件系统】磁盘结构&文件系统详谈
linux·运维·服务器·c语言·c++·ubuntu·centos
Howrun7777 小时前
关于Linux服务器的协作问题
linux·运维·服务器
小白同学_C8 小时前
Lab3-page tables && MIT6.1810操作系统工程【持续更新】
linux·c/c++·操作系统os
十年磨一剑~9 小时前
Linux程序接收到sigpipe信号崩溃处理
linux