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

相关推荐
未济14 小时前
linux 配置环境变量
linux
傲世仙尊14 小时前
目录即文件-Ext文件系统收尾篇
linux·c语言
虎头金猫14 小时前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
_艾伦 耶格尔.16 小时前
进程间通信
linux
AI职业加油站16 小时前
AI智能体应用工程师证书:政策红利下的职业新风口
大数据·运维·人工智能·学习·职场发展
Liuqy-0516 小时前
Linux IO编程——静态库、动态库
linux
此冬歌咏17 小时前
K8s 节点故障实战:优雅驱逐 31 秒,硬故障 331 秒,以及那个永远 Pending 的 Pod
运维·k8s
彧azz17 小时前
Linux 环境下 Redis 学习总结:数据类型、持久化、锁、事务、主从与缓存问题
linux·redis·笔记·学习·面试
-梅18 小时前
linux(8) 软硬链接
linux·运维·服务器
AIgorithmGEEK18 小时前
[Linux]线程三部曲(上):一个执行流的诞生——从操作系统一路拆到 pthread_create
linux·线程·pid