LINUX下ORACLE自动启动
本文通过使用python脚本来启动oracle数据库,实现oracle数据库的开机启动(主要启动监听和数据库,不包含dbconsole): STEP1:关闭数据库,关闭监听 /prepre name=code class=sql[oracle@REDHAT6 ~]$ lsnrctl stopSQL shutdown immediate STEP2:查看是否有
本文通过使用python脚本来启动oracle数据库,实现oracle数据库的开机启动(主要启动监听和数据库,不包含dbconsole):
STEP1:关闭数据库,关闭监听
[oracle@REDHAT6 ~]$ lsnrctl stop SQL> shutdown immediate

STEP2:查看是否有python相关的包是否已经安装(若没有安装,就需要安装相关的包)
[root@REDHAT6 ~]# which python /usr/bin/python
STEP3:编写启动相关服务的 python 脚本
-- 先新建两个文件,一个是python脚本,一个是记录日志 [oracle@REDHAT6 ~]$ touch oracle.py [oracle@REDHAT6 ~]$ touch oracle.log [oracle@REDHAT6 ~]$ chmod -R 755 oracle.py
python脚本
import commands; import sys; import time; dtime=time.strftime('%Y-%m-%d %H:%I:%M:%S',time.localtime(time.time())); file_append=open('/home/oracle/oracle.log','a+') print>>file_append,dtime,'\n' print>>file_append,'============START LISTENER================\n' (status,output)=commands.getstatusoutput("su - oracle -c '/u01/app/oracle/bin/lsnrctl start' ") print>>file_append,output+'\n' if(status==0): print>>file_append,'============OK: LISTENER START OK=============\n' else: print>>file_append,'============ERROR: LISTENER START ERROR=============\n' print>>file_append,'============START DATABASE================\n' (status,output)=commands.getstatusoutput("su - oracle -c '/u01/app/oracle/bin/dbstart' ") print>>file_append,output,'\n' if(status==0): print>>file_append,'============OK: DATABASE START OK=============\n' else: print>>file_append,'============ERROR: DATABASE START ERROR=======\n' print>>file_append,'\n','\n' file_append.close()
脚本先启动lsnrctl, 再启动 dbstart, 在dbstart启动时,会自动启动lsnrctl,由于本人在环境变量中没有配置,所以在启动dbstart时,监听无法启动,所以就在python中先启动了监听
STEP4:将脚本执行命令添加到开机启动中
[oracle@REDHAT6 ~]$ vi /etc/rc.d/rc.local

下次启动机器,就会发现监听程序和数据库程序已经启动
最后,我们看看日志文件
[oracle@REDHAT6 ~]$ tail -200 /home/oracle/oracle.log

下面是启动数据库的日志,里面会报监听错误,但是监听我们先已经启动了,所以可以不必理会。也可以通过配置环境变量来启动
参考网址:
http://blog.csdn.net/my2010sam/article/details/18315785
http://biancheng.dnbcw.info/python/242105.html

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

Visual Studio Code (VSCode) is a cross-platform, open source and free code editor developed by Microsoft. It is known for its lightweight, scalability and support for a wide range of programming languages. To install VSCode, please visit the official website to download and run the installer. When using VSCode, you can create new projects, edit code, debug code, navigate projects, expand VSCode, and manage settings. VSCode is available for Windows, macOS, and Linux, supports multiple programming languages and provides various extensions through Marketplace. Its advantages include lightweight, scalability, extensive language support, rich features and version

VS Code To switch Chinese mode: Open the settings interface (Windows/Linux: Ctrl, macOS: Cmd,) Search for "Editor: Language" settings Select "Chinese" in the drop-down menu Save settings and restart VS Code

MongoDB is suitable for handling large-scale unstructured data, and Oracle is suitable for enterprise-level applications that require transaction consistency. 1.MongoDB provides flexibility and high performance, suitable for processing user behavior data. 2. Oracle is known for its stability and powerful functions and is suitable for financial systems. 3.MongoDB uses document models, and Oracle uses relational models. 4.MongoDB is suitable for social media applications, while Oracle is suitable for enterprise-level applications.
