新手oracle重啓、監聽

有一次遇到了記錄下。sql

 

#su到oracle用戶下數據庫

[root@localhost ~]# su - oraclevim

 

 

 

 #重啓數據庫:
[oracle@localhost ~]$  sqlplus /nolog 
SQL>  conn /as sysdba 
SQL>  shutdown immediate       關閉數據庫
SQL>  startup               數據庫啓動
SQL>  exit 

[oracle@localhost ~]$  lsnrctl start       啓用監聽

 

 

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

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

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

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

 

 

啓動lsnrctl 
[oracle@localhost ~]$ lsnrctl startthis

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

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

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用戶上不去。

相關文章
相關標籤/搜索