新手oracle重启、监听、报错

有一次遇到了记录下。

 

#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

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

 

 

 

 

 

有一次,PL/SQL连不上虚拟机的oracle。报错是ORA-12154: TNS: 无法解析指定的连接标识符。

重启oraclelsnrctl后都无效,

最后找到问题,是windows上要【新建】一个环境变量TNS_ADMIN,值就是tnsnames.ora所在的目录(我的是E:\Program Files\Oracle\Instant Client\network\admin\tnsnames.ora)。

保存,重启PL/SQL后,连上了。

------------------------------------------------------------------------------------------------

变量名:TNS_ADMIN

       E:\Program Files\Oracle\Instant Client\network\admin\

------------------------------------------------------------------------------------------------

 

 

 

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

 一些查询

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

 

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

 

posted @ 2018-10-15 15:29  暴风城  阅读(22705)  评论(0编辑  收藏  举报