这两天在linux中给已有的oracle添加新实例,其中涉及数据库服务、监听配置,oracle服务是否正常、监听是否成功等操作,特此记录存档,以备后用。
- oracle服务启动操作命令
1、查看oracle服务是否启动
ps -ef|grep ora
2、重启数据库命令
dbstart
要直接执行dbstartt必须在/etc/profile中对oracle配置环境变量,内容如下
export ORACLE_HOME=/usr/oracle/app/oracle/product/11.2.0/dbhome1 export PATH=$PATH:$ORACLE_HOME/bin
另外dbstart只能在oracle账户中使用。但/etc/profile文件修改需要在root下操作
3、在sqlplus中启动多个数据库实例
以下这些操作需要在oracle账户中进行操作
a、启动默认的数据库实例
#sqlplus / as sysdba #startup #quit
b、启动第二个数据库实例
#export ORACLE_SID=数据库实例名 #sqlplus / as sysdba #startup #quit
- oracle监听查看和启动命令
监听的命令都必须在oracle账户下才能执行,这是因为只对oracle账户配置环境变量
1、查看监听状态
lsnrctl status
2、添加监听数据库
lsnrctl start pujinet
3、重启监听
a、先停止监听
lsnrctl stop
b、启动监听
lsnrctl start
- oracle单监听多实例的监听文件的配置
打开listener.ora文件,不同人安装,路径有所不同
vi /usr/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.31.20)(PORT = 1521)) ) ) ADR_BASE_LISTENER = /usr/oracle/app SID_LIST_LISTENER = ( SID_LIST = (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = /usr/oracle/app/oracle/product/11.2.0/dbhome_1) (SID_NAME = orcl) ) (SID_DESC = (GLOBAL_DBNAME = dev) (ORACLE_HOME = /usr/oracle/app/oracle/product/11.2.0/dbhome_1) (SID_NAME = dev) ) (SID_DESC = (GLOBAL_DBNAME = pujinet) (ORACLE_HOME = /usr/oracle/app/oracle/product/11.2.0/dbhome_1) (SID_NAME = pujinet) ) )
- oracle客户端软件连接不同实例配置文件
打开tnsnames.ora,新增需要的实例连接配置
SID_LIST_LISTENER = ( SID_LIST = ( (SID_NAME = PLSExtProc) (ORACLE_HOME = /usr/oracle/app/oracle/product/11.2.0/dbhome_1) (PROGRAM = extproc) ) #setting orcl (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = /usr/oracle/app/oracle/product/11.2.0/dbhome_1) (SID_NAME = orcl) ) #setting dev (SID_DESC = (GLOBAL_DBNAME = dev) (ORACLE_HOME = /usr/oracle/app/oracle/product/11.2.0/dbhome_1) (SID_NAME = dev) ) #setting pujinet (SID_DESC = (GLOBAL_DBNAME = pujinet) (ORACLE_HOME = /usr/oracle/app/oracle/product/11.2.0/dbhome_1) (SID_NAME = pujinet) ) ) )
查看端口号
netstat -nltp |grep svn
查看环境变量
env
实现自动监听
Oracle监听器帮助
1.查看所有的监听器命令
lsnrctl hep命令可以显示所有可用的监听器命令。在oracle11g中其输出如下:
- start - Start the Oracle listener
- stop - Stop the Oracle listener
- status - Display the current status of the Oracle listener
- services - Retrieve the listener services information
- version - Display the oracle listener version information
- reload - This will reload the oracle listener SID and parameter files. This is equivalent to lsnrctl stop and lsnrctl start.
- save_config - This will save the current settings to the listener.ora file and also take a backup of the listener.ora file before overwriting it. If there are no changes, it will display the message “No changes to save for LISTENER”
- trace - Enable the tracing at the listener level. The available options are ‘trace OFF’, ‘trace USER’, ‘trace ADMIN’ or ‘trace SUPPORT’
- spawn - Spawns a new with the program with the spawn_alias mentioned in the listener.ora file
- change_password - Set the new password to the oracle listener (or) change the existing listener password.
- show - Display log files and other relevant listener information.