[20260915]斜杠引起的问题.txt
[20260915]斜杠引起的问题.txt
--//再次遇到斜杠引起的问题,只不过这次出现在开头.通过例子说明:
1.环境:
SYS@book> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
$ grep -v ^# /u01/app/oracle/product/11.2.0.4/db_1/network/admin/listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SDU=32767)
(GLOBAL_DBNAME = book)
(ORACLE_HOME = //u01/app/oracle/product/11.2.0.4/db_1)
(SID_NAME=book)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.56.102)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST =127.0.0.1)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
DIAG_ADR_ENABLED_LISTENER=OFF
--//ORACLE_HOME = //u01/app/oracle/product/11.2.0.4/db_1 出现2次斜线在开头。
--//主要原因是不熟悉linux下vim操作,拷贝和粘贴不小心导致的。
--//执行cd没有任何问题:
$ cd //u01/app/oracle/product/11.2.0.4/db_1;pwd
//u01/app/oracle/product/11.2.0.4/db_1
2.问题再现:
--//平时使用没有任何问题。问题在于配置静态监听,远程可以使用sys用户连接数据库关闭数据库并且重启数据库。
--//导致启动数据库ORACLE_HOME环境变量变成了//u01/app/oracle/product/11.2.0.4/db_1,这样本地连接的环境变量ORACLE_HOME还是
--// /u01/app/oracle/product/11.2.0.4/db_1,通过它计算共享内存段的key出现不一致,导致本机无法连接数据库.
$ ipcs -m
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 32768 oracle 640 12582912 26
0x00000000 65537 oracle 640 792723456 26
0x56c108b0 98306 oracle 640 2097152 26
$ ps -ef | grep pmo[n]
oracle 3120 1 0 09:06 ? 00:00:00 ora_pmon_book
$ cat /proc/3120/environ | tr '\0' '\n' | grep ORACLE_HOME
ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1
--//远程sys用户连接数据库关闭并且重启数据库。
D:\tmp\study> sqlplus sys/oracle@192.168.56.102:1521/book as sysdba
sqlplus sys/oracle@192.168.56.102:1521/book as sysdba
SQL*Plus: Release 21.0.0.0.0 - Production on Tue Sep 15 09:27:51 2026
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS@192.168.56.102:1521/book> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@192.168.56.102:1521/book> startup
ORACLE instance started.
Total System Global Area 801701888 bytes
Fixed Size 2257520 bytes
Variable Size 285216144 bytes
Database Buffers 507510784 bytes
Redo Buffers 6717440 bytes
Database mounted.
Database opened.
$ ipcs -m
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 163840 oracle 640 12582912 24
0x00000000 196609 oracle 640 792723456 24
0xbfc32dfc 229378 oracle 640 2097152 24
--//启动后检查发现key发生了变化,前面是0x56c108b0。
--//这样远程连接使用数据库不存在任何问题,本地使用出现问题。
$ sqlplus -l -s scott/book
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Process ID: 0
Session ID: 0 Serial number: 0
SP2-0751: Unable to connect to Oracle. Exiting SQL*Plus
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Tue Sep 15 09:32:15 2026
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SYS@book>
--//可以发现连接到空闲实例上。
$ ps -ef | grep pmo[n]
oracle 3729 1 0 09:28 ? 00:00:00 ora_pmon_book
$ cat /proc/3729/environ | tr '\0' '\n' | grep ORACLE_HOME
ORACLE_HOME=//u01/app/oracle/product/11.2.0.4/db_1
--//可以启动数据库进程的环境变量ORACLE_HOME=//u01/app/oracle/product/11.2.0.4/db_1。
--//修改环境变量如下就可以连接数据库:
$ export ORACLE_HOME=//u01/app/oracle/product/11.2.0.4/db_1
$ rlsql -s -l scott/book <<<'select sysdate from dual ;'
SYSDATE
-------------------
2026-09-15 09:36:21
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Tue Sep 15 09:35:27 2026
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS@book> oradebug setmypid
Statement processed.
SYS@book> oradebug ipc
IPC information written to the trace file
--//查看跟踪文件:
*** 2026-09-15 09:37:37.438
Processing Oradebug command 'ipc'
Dump of unix-generic skgm context
areaflags 000000f7
realmflags 0000001f
mapsize 00000800
protectsize 00001000
lcmsize 00001000
seglen 00200000
largestsize 0000004000000000
smallestsize 0000000000400000
stacklimit 0x7fff4617c970
stackdir -1
mode 640
magic acc01ade
Handle: 0x7f44faed9100 `//u01/app/oracle/product/11.2.0.4/db_1book'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dump of unix-generic realm handle `//u01/app/oracle/product/11.2.0.4/db_1book', flags = 00000000
Area #0 `Fixed Size' containing Subareas 0-0
Total size 0000000000227270 Minimum Subarea size 00000000
Area Subarea Shmid Stable Addr Actual Addr
0 0 163840 0x00000060000000 0x00000060000000
Subarea size Segment size
0000000000228000 0000000000c00000
Area #1 `Variable Size' containing Subareas 4-4
Total size 000000002f400000 Minimum Subarea size 00400000
Area Subarea Shmid Stable Addr Actual Addr
1 4 196609 0x00000060c00000 0x00000060c00000
Subarea size Segment size
000000002f400000 000000002f400000
Area #2 `Redo Buffers' containing Subareas 1-1
Total size 0000000000668000 Minimum Subarea size 00000000
Area Subarea Shmid Stable Addr Actual Addr
2 1 163840 0x00000060228000 0x00000060228000
Subarea size Segment size
0000000000668000 0000000000c00000
Area #3 `Base Allocator Control' containing Subareas 3-3
Total size 0000000000002000 Minimum Subarea size 00000000
Area Subarea Shmid Stable Addr Actual Addr
3 3 163840 0x00000060bfe000 0x00000060bfe000
Subarea size Segment size
0000000000002000 0000000000c00000
Area #4 `Slab Allocator Control' containing Subareas 2-2
Total size 000000000036e000 Minimum Subarea size 00000000
Area Subarea Shmid Stable Addr Actual Addr
4 2 163840 0x00000060890000 0x00000060890000
Subarea size Segment size
000000000036e000 0000000000c00000
Area #5 `skgm overhead' containing Subareas 5-5
Total size 0000000000003000 Minimum Subarea size 00000000
Area Subarea Shmid Stable Addr Actual Addr
5 5 229378 0x00000090000000 0x00000090000000
Subarea size Segment size
0000000000003000 0000000000200000
--//注意看下划线handle信息发生变化,包含2部分,ORACLE_HOME和ORACLE_SID.也就是启动参与计算共享内存段的key的信息发生变化。
--//另外提示如果斜线出现在结尾,export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1/,
--//oracle 11.2.0.4以后版本已经不存在类似问题,可以自行测试。
3.知道原因解决就很简单了。
--//修改环境变量export ORACLE_HOME=//u01/app/oracle/product/11.2.0.4/db_1的情况下,关闭数据库。
--//修改监听配置文件,删除多余的斜线,并重新启动监听。
--//再修改回来环境变量export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1,启动数据库。
$ ipcs -m
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 294912 oracle 640 12582912 22
0x00000000 327681 oracle 640 792723456 22
0x56c108b0 360450 oracle 640 2097152 22
4.补充:
--//本想在21c重复测试,发现21c采用Read-Only Oracle Homes,参数文件位置发生了变化,也许在早期很容易发现类似错误。
$ export ORACLE_HOME=//u01/app/oracle/product/21.0.0/dbhome_1
--//前面出现2个/在开头
$ rlsql
SQL*Plus: Release 21.0.0.0.0 - Production on Mon Sep 14 15:59:27 2026
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Connected to an idle instance.
SYS@book> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/21.0.0/dbhome_1/dbs/initbook.ora'
--//21c采用Read-Only Oracle Homes,参数文件放在$ORACLE_BASE/dbs目录也就是/u01/app/oracle/dbs目录。
--//而修改环境变量export ORACLE_HOME=//u01/app/oracle/product/21.0.0/dbhome_1的情况下读取参数文件是
--// /u01/app/oracle/product/21.0.0/dbhome_1/dbs/目录,也许在早期很容易发现类似错误。
--//再次遇到斜杠引起的问题,只不过这次出现在开头.通过例子说明:
1.环境:
SYS@book> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
$ grep -v ^# /u01/app/oracle/product/11.2.0.4/db_1/network/admin/listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SDU=32767)
(GLOBAL_DBNAME = book)
(ORACLE_HOME = //u01/app/oracle/product/11.2.0.4/db_1)
(SID_NAME=book)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.56.102)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST =127.0.0.1)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
DIAG_ADR_ENABLED_LISTENER=OFF
--//ORACLE_HOME = //u01/app/oracle/product/11.2.0.4/db_1 出现2次斜线在开头。
--//主要原因是不熟悉linux下vim操作,拷贝和粘贴不小心导致的。
--//执行cd没有任何问题:
$ cd //u01/app/oracle/product/11.2.0.4/db_1;pwd
//u01/app/oracle/product/11.2.0.4/db_1
2.问题再现:
--//平时使用没有任何问题。问题在于配置静态监听,远程可以使用sys用户连接数据库关闭数据库并且重启数据库。
--//导致启动数据库ORACLE_HOME环境变量变成了//u01/app/oracle/product/11.2.0.4/db_1,这样本地连接的环境变量ORACLE_HOME还是
--// /u01/app/oracle/product/11.2.0.4/db_1,通过它计算共享内存段的key出现不一致,导致本机无法连接数据库.
$ ipcs -m
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 32768 oracle 640 12582912 26
0x00000000 65537 oracle 640 792723456 26
0x56c108b0 98306 oracle 640 2097152 26
$ ps -ef | grep pmo[n]
oracle 3120 1 0 09:06 ? 00:00:00 ora_pmon_book
$ cat /proc/3120/environ | tr '\0' '\n' | grep ORACLE_HOME
ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1
--//远程sys用户连接数据库关闭并且重启数据库。
D:\tmp\study> sqlplus sys/oracle@192.168.56.102:1521/book as sysdba
sqlplus sys/oracle@192.168.56.102:1521/book as sysdba
SQL*Plus: Release 21.0.0.0.0 - Production on Tue Sep 15 09:27:51 2026
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS@192.168.56.102:1521/book> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@192.168.56.102:1521/book> startup
ORACLE instance started.
Total System Global Area 801701888 bytes
Fixed Size 2257520 bytes
Variable Size 285216144 bytes
Database Buffers 507510784 bytes
Redo Buffers 6717440 bytes
Database mounted.
Database opened.
$ ipcs -m
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 163840 oracle 640 12582912 24
0x00000000 196609 oracle 640 792723456 24
0xbfc32dfc 229378 oracle 640 2097152 24
--//启动后检查发现key发生了变化,前面是0x56c108b0。
--//这样远程连接使用数据库不存在任何问题,本地使用出现问题。
$ sqlplus -l -s scott/book
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Process ID: 0
Session ID: 0 Serial number: 0
SP2-0751: Unable to connect to Oracle. Exiting SQL*Plus
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Tue Sep 15 09:32:15 2026
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SYS@book>
--//可以发现连接到空闲实例上。
$ ps -ef | grep pmo[n]
oracle 3729 1 0 09:28 ? 00:00:00 ora_pmon_book
$ cat /proc/3729/environ | tr '\0' '\n' | grep ORACLE_HOME
ORACLE_HOME=//u01/app/oracle/product/11.2.0.4/db_1
--//可以启动数据库进程的环境变量ORACLE_HOME=//u01/app/oracle/product/11.2.0.4/db_1。
--//修改环境变量如下就可以连接数据库:
$ export ORACLE_HOME=//u01/app/oracle/product/11.2.0.4/db_1
$ rlsql -s -l scott/book <<<'select sysdate from dual ;'
SYSDATE
-------------------
2026-09-15 09:36:21
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Tue Sep 15 09:35:27 2026
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS@book> oradebug setmypid
Statement processed.
SYS@book> oradebug ipc
IPC information written to the trace file
--//查看跟踪文件:
*** 2026-09-15 09:37:37.438
Processing Oradebug command 'ipc'
Dump of unix-generic skgm context
areaflags 000000f7
realmflags 0000001f
mapsize 00000800
protectsize 00001000
lcmsize 00001000
seglen 00200000
largestsize 0000004000000000
smallestsize 0000000000400000
stacklimit 0x7fff4617c970
stackdir -1
mode 640
magic acc01ade
Handle: 0x7f44faed9100 `//u01/app/oracle/product/11.2.0.4/db_1book'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dump of unix-generic realm handle `//u01/app/oracle/product/11.2.0.4/db_1book', flags = 00000000
Area #0 `Fixed Size' containing Subareas 0-0
Total size 0000000000227270 Minimum Subarea size 00000000
Area Subarea Shmid Stable Addr Actual Addr
0 0 163840 0x00000060000000 0x00000060000000
Subarea size Segment size
0000000000228000 0000000000c00000
Area #1 `Variable Size' containing Subareas 4-4
Total size 000000002f400000 Minimum Subarea size 00400000
Area Subarea Shmid Stable Addr Actual Addr
1 4 196609 0x00000060c00000 0x00000060c00000
Subarea size Segment size
000000002f400000 000000002f400000
Area #2 `Redo Buffers' containing Subareas 1-1
Total size 0000000000668000 Minimum Subarea size 00000000
Area Subarea Shmid Stable Addr Actual Addr
2 1 163840 0x00000060228000 0x00000060228000
Subarea size Segment size
0000000000668000 0000000000c00000
Area #3 `Base Allocator Control' containing Subareas 3-3
Total size 0000000000002000 Minimum Subarea size 00000000
Area Subarea Shmid Stable Addr Actual Addr
3 3 163840 0x00000060bfe000 0x00000060bfe000
Subarea size Segment size
0000000000002000 0000000000c00000
Area #4 `Slab Allocator Control' containing Subareas 2-2
Total size 000000000036e000 Minimum Subarea size 00000000
Area Subarea Shmid Stable Addr Actual Addr
4 2 163840 0x00000060890000 0x00000060890000
Subarea size Segment size
000000000036e000 0000000000c00000
Area #5 `skgm overhead' containing Subareas 5-5
Total size 0000000000003000 Minimum Subarea size 00000000
Area Subarea Shmid Stable Addr Actual Addr
5 5 229378 0x00000090000000 0x00000090000000
Subarea size Segment size
0000000000003000 0000000000200000
--//注意看下划线handle信息发生变化,包含2部分,ORACLE_HOME和ORACLE_SID.也就是启动参与计算共享内存段的key的信息发生变化。
--//另外提示如果斜线出现在结尾,export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1/,
--//oracle 11.2.0.4以后版本已经不存在类似问题,可以自行测试。
3.知道原因解决就很简单了。
--//修改环境变量export ORACLE_HOME=//u01/app/oracle/product/11.2.0.4/db_1的情况下,关闭数据库。
--//修改监听配置文件,删除多余的斜线,并重新启动监听。
--//再修改回来环境变量export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1,启动数据库。
$ ipcs -m
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 294912 oracle 640 12582912 22
0x00000000 327681 oracle 640 792723456 22
0x56c108b0 360450 oracle 640 2097152 22
4.补充:
--//本想在21c重复测试,发现21c采用Read-Only Oracle Homes,参数文件位置发生了变化,也许在早期很容易发现类似错误。
$ export ORACLE_HOME=//u01/app/oracle/product/21.0.0/dbhome_1
--//前面出现2个/在开头
$ rlsql
SQL*Plus: Release 21.0.0.0.0 - Production on Mon Sep 14 15:59:27 2026
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Connected to an idle instance.
SYS@book> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/21.0.0/dbhome_1/dbs/initbook.ora'
--//21c采用Read-Only Oracle Homes,参数文件放在$ORACLE_BASE/dbs目录也就是/u01/app/oracle/dbs目录。
--//而修改环境变量export ORACLE_HOME=//u01/app/oracle/product/21.0.0/dbhome_1的情况下读取参数文件是
--// /u01/app/oracle/product/21.0.0/dbhome_1/dbs/目录,也许在早期很容易发现类似错误。
浙公网安备 33010602011771号