新手oracle重启、监听

本文详细介绍了在Linux环境下切换到Oracle用户,重启Oracle数据库及监听器的具体步骤,包括使用sqlplus关闭和启动数据库,以及lsnrctl命令的使用。同时,文章还提到了当IP地址变更时,如何修改listener.ora文件以解决监听器启动失败的问题。
摘要由CSDN通过智能技术生成

有一次遇到了记录下。

 

#su到oracle用户下

[root@localhost ~]# su - oracle

 

 

 

 #重启数据库:
[oracle@localhost ~]$  sqlplus /nolog 
SQL>  conn /as sysdba 
SQL>  shutdown immediate       关闭数据库
SQL>  startup               数据库启动
SQL>  exit 

[oracle@localhost ~]$  lsnrctl start       启用监听

 

 

停掉lsnrctl 
[oracle@localhost ~]$ lsnrctl stop

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 22-JAN-2018 08:00:14

Copyright (c) 1991, 2009, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
The command completed successfully

 

 

启动lsnrctl 
[oracle@localhost ~]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 22-JAN-2018 08:00:23

Copyright (c) 1991, 2009, Oracle. All rights reserved.

Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.241.155)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 22-JAN-2018 08:00:23
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.241.155)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

 

这个命令会列出Oracle Net Listener的进程
[oracle@localhost ~]$ netstat -antp | grep tnslsnr
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 192.168.241.155:1521 0.0.0.0:* LISTEN 6407/tnslsnr
[oracle@localhost ~]$

 

#退出oracle用户

[oracle@localhost ~]$ exit
logout
[root@localhost ~]#

 

 用plsql连接到数据库,tnsnames.ora增加配置

TEST_DB155 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.241.155)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORCL)
)
)

 

 

 有一次Linux的ip变了以后,出现了这个

[root@localhost ~]# su - oracle
[oracle@localhost ~]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 01-SEP-2018 03:38:08

Copyright (c) 1991, 2009, Oracle. All rights reserved.

Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.241.155)(PORT=1521)))
TNS-12545: Connect failed because target host or object does not exist
TNS-12560: TNS:protocol adapter error
TNS-00515: Connect failed because target host or object does not exist
Linux Error: 99: Cannot assign requested address

Listener failed to start. See the error message(s) above...

进去改了下ip就好了

[oracle@localhost ~]$ vim /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora

 

============================================================== 

 

select * from dba_users; 查看数据库里面所有用户,前提是你是有dba权限的帐号,如sys,system
select * from all_users;  查看你能管理的所有用户!
select * from user_users; 查看当前用户信息 !

 

用system用户查看到SCOTT用户过期 ,TEST用户还没过期,所以SCOTT用户上不去。

 

转载于:https://www.cnblogs.com/baofengc/p/9791266.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值