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

相关推荐
岚天start25 分钟前
Linux内核coredump分析方案
linux·运维·服务器·gdb·coredump·堆栈·内存快照
屁股割了还要学1 小时前
【Linux入门】常用工具:yum、vim
linux·运维·服务器·c语言·c++·学习·考研
云计算练习生1 小时前
linux shell编程实战 03 数组:批量处理数据
linux·运维·服务器·数组·shell编程
王道长服务器 | 亚马逊云1 小时前
AWS Elemental MediaConvert:视频转码不再难
linux·服务器·网络·云计算·音视频·aws
Jm_洋洋1 小时前
【Linux系统编程】程序替换:execve(execl、execlp、execle、execv、execvp、execvpe)
linux·运维·c语言·开发语言·程序人生
HIT_Weston1 小时前
14、【Ubuntu】【VSCode】VSCode 断联问题分析:hostname(二)
linux·vscode·ubuntu
冲上云霄的Jayden2 小时前
bash执行脚本 CondaError: Run ‘conda init‘ before ‘conda activate‘
linux·ubuntu·conda·bash·init·activate
驱动探索者2 小时前
影石Insta360发展史:从深圳公寓到全球影像创新标杆
linux
Wang's Blog2 小时前
Linux小课堂: SSH 免密登录原理与实现之基于公钥认证的安全连接机制
linux·安全·ssh
戴草帽的大z3 小时前
交叉编译FFmpeg:从x264到RK3588部署实战
linux·ffmpeg·rk3588·h.264·aarch64