背景:之前安装的oracle 11.2.0.4.0版本,有一天修改了主机名,再次重启的时候就报错:
[oracle@rsync_server ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Jul 18 23:12:23 2019
Copyright © 1982, 2013, Oracle. All rights reserved.
Connected.
SQL> startup
ORA-00119: invalid specification for system parameter LOCAL_LISTENER
ORA-00130: invalid listener address ‘(ADDRESS=(PROTOCOL=TCP)(HOST=rsync_server)(PORT=1521))’
查看listener.ora文件和tnsnames.ora文件,文件中并没有hostname。
[oracle@rsync_server admin]$ cat listener.bak_20190718
# listener.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora # Generated by Oracle configuration tools.
PASSWORDS_LISTENER= (76CC275A9805B912)
#--------------------------------------------
#----ADDED BY TNSLSNR 13-DEC-2018 15:53:22—
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = orcl)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.16.66)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /home/oracle/app
[oracle@rsync_server admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
OGG2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.106)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = test)
)
)
查看/etc/hosts文件配置:
[root@rsync_server etc]# cat hosts
#127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
#192.168.2.105 linux_64 localhost
192.168.16.66 linux_64 localhost
192.168.2.106 linux_64_clone
修改/etc/hosts文件:
[oracle@rsync_server ~]$ cat /etc/hosts
#127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
#192.168.2.105 linux_64 localhost
192.168.16.66 rsync_server
192.168.2.106 linux_64_clone
再次启动oracle数据库:
[oracle@rsync_server ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 18-JUL-2019 23:17:00
Copyright © 1991, 2013, Oracle. All rights reserved.
Starting /home/oracle/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait…
TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /home/oracle/app/diag/tnslsnr/rsync_server/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.16.66)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.16.66)(PORT=1521)))
STATUS of the LISTENER
-------------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 18-JUL-2019 23:17:02
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Password or Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /home/oracle/app/diag/tnslsnr/rsync_server/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.16.66)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary…
Service “orcl” has 1 instance(s).
Instance “orcl”, status UNKNOWN, has 1 handler(s) for this service…
The command completed successfully
[oracle@rsync_server ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Jul 18 23:17:08 2019
Copyright © 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 622149632 bytes
Fixed Size 2255792 bytes
Variable Size 398459984 bytes
Database Buffers 218103808 bytes
Redo Buffers 3330048 bytes
Database mounted.
Database opened.
SQL> select status from v$instance;
STATUS
------------
OPEN
查看数据库中用户信息:
SQL> conn user1
Enter password:
ERROR:
ORA-28002: the password will expire within 7 days
Connected.
SQL> select table_name from user_tables;
TABLE_NAME
------------------------------
TAB2
TAB3
TAB4
TAB5
TAB6
TAB7
TAB1