|
报错的现象:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| [oracle@oracle11 ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 29-AUG-2016 10:38:59
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /opt/oracle/app/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /opt/oracle/app/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /opt/oracle/app/diag/tnslsnr/oracle11/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle11)(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
Listener failed to start. See the error message(s) above...
|
以上是报错信息.
开始查错,
查到了TNS-12545: Connect failed because target host or object does not exist
1
2
3
4
5
6
7
8
9
10
11
12
13
| [oracle@oracle11 ~]$ > /opt/oracle/app/diag/tnslsnr/oracle11/listener/alert/log.xml
[oracle@oracle11 ~]$ lsnrctl start
[oracle@oracle11 ~]$ grep txt /opt/oracle/app/diag/tnslsnr/oracle11/listener/alert/log.xml
<txt>System parameter file is /opt/oracle/app/product/11.2.0/dbhome_1/network/admin/listener.ora
<txt>Log messages written to /opt/oracle/app/diag/tnslsnr/oracle11/listener/alert/log.xml
<txt>Trace information written to /opt/oracle/app/diag/tnslsnr/oracle11/listener/trace/ora_3706_140351658579712.trc
<txt>Trace level is currently 0
<txt>Started with pid=3706
<txt>Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
<txt>Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle11)(PORT=1521)))
<txt>TNS-12545: Connect failed because target host or object does not exist
<txt>No longer listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
[oracle@oracle11 ~]$
|
网上查[TNS-12545: Connect failed] 找到tnsnames.ora文件
1
2
3
4
5
6
7
8
9
10
11
12
| cat /opt/oracle/app/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /opt/oracle/app/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle11)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
|
看到:HOST = oracle11
查看我的hosts文件,真的没有这个:
1
2
3
4
| [oracle@oracle11 ~]$ cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[oracle@oracle11 ~]$
|
添加一条:
1
2
3
4
5
6
7
8
| [oracle@oracle11 ~]$ su root
Password:
[iyunv@oracle11 oracle]# echo "127.0.0.1 oracle11 " >> /etc/hosts
[iyunv@oracle11 oracle]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 oracle11
[iyunv@oracle11 oracle]#
|
访问测试:,启动监听:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
| [oracle@oracle11 ~]$ ping oracle11
PING oracle11 (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.090 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.048 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.046 ms
[oracle@oracle11 ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 29-AUG-2016 10:47:44
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /opt/oracle/app/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /opt/oracle/app/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /opt/oracle/app/diag/tnslsnr/oracle11/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle11)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 29-AUG-2016 10:47:44
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/app/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /opt/oracle/app/diag/tnslsnr/oracle11/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle11)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@oracle11 ~]$
|
scott登陆上去试一试:
我的数据库服务已经启动
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| [oracle@oracle11 ~]$ sqlplus scott/11
SQL*Plus: Release 11.2.0.1.0 Production on Mon Aug 29 10:48:36 2016
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from dept;
DEPTNO DNAME LOC
---------- -------------- -------------
50 oracle England
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL>
SQL> exit;
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@oracle11 ~]$
|
|
|