Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
416 views
in Technique[技术] by (71.8m points)

linux - 如何自动重新安装Azure Linux OS磁盘以进行读写以启用Oracle DB自动启动(How to automatically remount Azure Linux OS disk for read-write to enable Oracle DB auto-startup)

I have a Linux VM in Azure, with Oracle Database installed.

(我在Azure中安装了Linux VM,并安装了Oracle数据库。)

In order to get the database up and running, I have to run the following commands in sequence:

(为了启动和运行数据库,我必须依次运行以下命令:)

  1. sudo su - followed by password entry (the user I have access to is not an admin user)

    (sudo su -输入密码(我有权访问的用户不是管理员用户))

  2. mount -orw,remount /; exit
  3. sudo su - oracle (password entry not required at this point)

    (sudo su - oracle (此时无需输入密码))

  4. lsnrctl start
  5. sqlplus /nolog
  6. CONNECT / AS SYSDBA;
  7. STARTUP;
  8. DISCONNECT;
  9. CONNECT; followed by entering user id/password

    (然后输入用户ID /密码)

This makeshift routine is a result of my (probably) botching the OS disk expansion.

(这个临时例程是我(可能)修改了OS磁盘扩展的结果。)

While I somehow managed to successfully complete the disk expansion, the database became unable to start up automatically like it did before my disk expansion efforts.

(尽管我设法成功完成了磁盘扩展,但数据库却无法像我进行磁盘扩展之前一样自动启动。)

Ideally I would like to configure the database to startup automatically like before;

(理想情况下,我想将数据库配置为像以前一样自动启动;)

failing which, any way to automate/shortcut this routine would be appreciated (I have this committed to muscle memory, but any amount of time saved would be great).

(否则,将以任何方式使该例程自动化/捷径将不胜感激(我致力于肌肉记忆,但是节省的时间量将是巨大的)。)

  ask by user10931326 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You could you a script to do all routine on startup.

(您可以使用脚本在启动时执行所有例程。)

Create script like this and call it startDB.sh (do not forget to make it executable - chmod +x startDB.sh):

(像这样创建脚本并将其命名为startDB.sh(不要忘记使其可执行-chmod + x startDB.sh):)

#!/bin/sh
mount -orw,remount /; exit
lsnrctl start
sqlplus /nolog <<EOF
connect user/pass
STARTUP;
DISCONNECT;
EOF

Add script to startup:

(将脚本添加到启动:)

    #crontab -e
    @reboot su - user -c "/home/user/startDB.sh"

If you don't have access to crontab, you can run startDB.sh script manually, this should help you to save some time :)

(如果您无权访问crontab,则可以手动运行startDB.sh脚本,这应该可以帮助您节省一些时间:))

It's not tested, so there can be errors or mistypes, please run some test before using it in production.

(它未经测试,因此可能存在错误或类型错误,请在生产中使用它之前进行一些测试。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...