Oracle记录-开启与关闭数据库
1.配置tnsnames.ora/listener.ora
#cd /usr/oracle/oracle/product/11.2.0/db_1/network/admin ---切换到安装目录 #vim tnsnames.ora # tnsnames.ora Network Configuration File: D:\app\xinfang\product\11.2.0\dbhome_1\network\admin\tnsnames.ora # Generated by Oracle configuration tools. ORACLR_CONNECTION_DATA = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) (CONNECT_DATA = (SID = CLRExtProc) (PRESENTATION = RO) ) ) BIT = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST=10.2.1.169)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME =BIT) ) ) #vim listener.ora SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = BIT) (ORACLE_HOME = /usr/oracle/oracle/product/11.2.0/db_1) (SID_NAME = BIT) ) ) LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =10.2.1.169)(PORT = 1521)) )
2.启动监听
#lsnrctl start ---开启监听 #lsnrctl status ---查看监听状态
3.启动与停止
#sqlplus / as sysdba
SQL>startup
SQL>exit
startup
a.启动实例:包括读取参数文件、分配SGA、启动后台进程
b.装载数据库:将数据库与已启动的实例相联系,装载后,数据库保持关闭状态
c.打开数据库:打开控制文件、数据文件、日志文件,可以进行正常的操作处理
startup nomount只启动实例,不装载数据库
startup mount 启动实例,装载数据库但不打开数据库
alter database open read only(只读)
Alter database open read write(可读可写)
Alter database open 打开数据库
Startup restrict 以受限方式打开
Startup pfile=文件名 启动指定参数文件
Startup pfile=文件名 open restrict force 以强制方式启动指定参数文件
shutdown关闭数据库
A.关闭数据库-卸载数据库-关闭数据库实例
B.shutdown normal 默认方式,需要等待所有用户断开连接、执行后不允许新的连接
C.shutdown immediate 执行完正在执行的语句就断开连接
D.shutdown transactional 执行完当前事务后断开连接
E.shutdown abort 直接关闭数据库