Oracle 11g 安装成功后在Linux开机利用chkconfig自动启动设置
指出3,4,5级别启动这个服务,99是在相应的/etc/rc.d/rcN.d(N为前面指定的级别, 这里是345)目录下生成的链接文件的序号(启动优
注:开始首先需要修改Oracle与root用户的环境变量
vi ~/.bash_profle
添加如下内容:
umask 022
export ORACLE_BASE=/home/oracle/app
export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
一、使用root用户修改/etc/oratab 文件:
$ vi /etc/oratab
orcl:/home/oracle/app/oracle/product/11.2.0/dbhome_1:N
改为:
orcl:/home/oracle/app/oracle/product/11.2.0/dbhome_1:Y
也就是将最后的N改为Y
二、使用oracle用户修改$ORACLE_HOME/bin/dbstart文件:
# su - oracle
$ cd $ORACLE_HOME/bin
$ vi dbstart
找到 ORACLE_HOME_LISTNER=.....这行, 修改成
ORACLE_HOME_LISTNER=$ORACLE_HOME
同样修改dbshut
vi dbshut
ORACLE_HOME_LISTNER=$ORACLE_HOME
注意:是修改,,不是增加,可是使用vi的查找功能查找:
ORACLE_HOME_LISTNER,然后进行修改,修改后保存
三、测试运行 dbshut, dbstart 看能否启动oracle 服务及listener服务:
关闭,或者启动时可能会报错,提示dbstart或dbshut权限不足.
1.修改dbstart和dbshut的日志文件的权限:
$su - root
#cd $ORACLE_HOME
#chown oracle:oinstall $ORACLE_HOME/startup.log
#chown oracle:oinstall $ORACLE_HOME/shutdown.log
#chown oracle:oinstall $ORACLE_HOME/listener.log
2.执行相应的脚本进行测试 (可选)
#su - oracle
$cd $ORACLE_HOME/bin
$./dbstart (./dbshut)
$ ps -efw | grep ora_
$ lsnrctl status
$ ps -efw | grep LISTEN | grep -v grep
四:创建服务
$su - root
# cd /etc/rc.d/init.d/
# vi oracle
-----脚本-----
#!/bin/bash
# chkconfig: 345 99 10
# description: Startup Script for Oracle Databases
# /etc/rc.d/init.d/oracle
export ORACLE_BASE=/home/oracle/app
export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
ORA_OWNR="oracle"
# if the executables do not exist -- display error
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi
# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display
case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
touch /var/lock/Oracle
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"
#su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctrl start"
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"
#su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctrl stop"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
rm -f /var/lock/Oracle
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: `basename $0` start|stop|restart|reload"
exit 1
esac
exit 0
----若启动成功以下可以略过----
五.检查:
根据上面的运行结果,当相应的运行级别为on时(例如:5:on),在对应的/etc/rc.d/rcN.d(例如:和5:on对应的是:/etc /rc.d/rc5.d)下面会生成一个文件:S99oradbstart,使用vi S99oradbstart打开该文件,可以看到该文件的内容和/etc/rc.d/init.d/oradbstart内容相同,表示配置成功,其实,S99oradbstart是一个到/etc/rc.d/init.d/oradbstart的链接,我们可以使用file命令来查看:
$file /etc/rc.d/rc5.d/S99oradbstart
S99oradbstart:symbolic link to '../init.d/oradbstart
六.一点说明:
脚本文件中的:# chkconfig: 345 99 10
指出3,4,5级别启动这个服务,99是在相应的/etc/rc.d/rcN.d(N为前面指定的级别, 这里是345)目录下生成的链接文件的序号(启动优先级别)S99oradbstart, 10为在除前面指出的级别对应的/etc/rc.d/rcN.d(N为除345之外的级别) 目录生成的链接文件的序号(服务停止的优先级别)K10oradbstart。

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











Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

MySQL is suitable for beginners because it is simple to install, powerful and easy to manage data. 1. Simple installation and configuration, suitable for a variety of operating systems. 2. Support basic operations such as creating databases and tables, inserting, querying, updating and deleting data. 3. Provide advanced functions such as JOIN operations and subqueries. 4. Performance can be improved through indexing, query optimization and table partitioning. 5. Support backup, recovery and security measures to ensure data security and consistency.

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.
