[20160310]神奇的斜线.txt

简介: [20160310]神奇的斜线.txt --今天发现同事配置的数据库服务器,没有配置NLS_DATE_FORMAT环境变量,当打开.bash_profile时发现同事配置的-ORACLE_HOME环境变 --量结尾带有/,忍不住想说一番,还好我测试以下,发现11.

[20160310]神奇的斜线.txt

--今天发现同事配置的数据库服务器,没有配置NLS_DATE_FORMAT环境变量,当打开.bash_profile时发现同事配置的-ORACLE_HOME环境变
--量结尾带有/,忍不住想说一番,还好我测试以下,发现11.2.0.4版本,ORACLE_HOME最后有没有/都可以正常进入连上数据库(当执行
--sqlplus / as sysdba).

--相关链接可以看我以前写的blog:

[20140513]ORACLE_HOME环境变量结尾的斜杠
http://blog.itpub.net/267265/viewspace-1160328/
[20150911]关于远程启动数据库问题.txt
http://blog.itpub.net/267265/viewspace-1797866/

1.测试1:

$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1/
$ rlsql
SQL*Plus: Release 11.2.0.4.0 Production on Thu Mar 10 14:57:44 2016
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> @ &r/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

--正常,可以登录。

2.测试2:
[oracle@gxqyydg4 IP=100.78 ~/gdul 6]$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1
[oracle@gxqyydg4 IP=100.78 ~/gdul 7]$ rlsql
SQL*Plus: Release 11.2.0.4.0 Production on Thu Mar 10 14:58:48 2016
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> @ &r/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

--正常,可以登录。也就是将从11.2.0.4,环境变量ORACLE_HOME无论后面有没有/,都不影响进入数据库。

3.我启动数据库是设置ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1(没有斜线的)。
--设置ORACLE_HOME结尾带斜线。
$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1/
SYS@book> @ &r/spid

       SID    SERIAL# SPID       PID  P_SERIAL# C50
---------- ---------- ------ ------- ---------- --------------------------------------------------
       112        519 1030        34        244 alter system kill session '112,519' immediate;

$ cat /proc/1030/environ | tr '=' '\n'|strings | grep -A1 ORACLE_HOME
ORACLE_HOME
/u01/app/oracle/product/11.2.0.4/dbhome_1/

$ ps -ef | grep ora_pmo[n]
oracle   53188     1  0 Mar08 ?        00:00:22 ora_pmon_book

$ cat /proc/53188/environ | tr '=' '\n'|strings | grep -A1 ORACLE_HOME
ORACLE_HOME
/u01/app/oracle/product/11.2.0.4/dbhome_1

--可以发现ORACLE_HOME不一样,但是都可以正常连接数据库。

4.看看ipc信息:

SYS@book> oradebug setmypid
Statement processed.
SYS@book> oradebug ipc
IPC information written to the trace file
*** 2016-03-10 15:10:31.001
Processing Oradebug command 'ipc'
Dump of unix-generic skgm context
areaflags            000000f7
realmflags           0000001f
mapsize              00000800
protectsize          00001000
lcmsize              00001000
seglen               00200000
largestsize  0000000480000000
smallestsize 0000000000400000
stacklimit     0x7fff5659d250
stackdir                   -1
mode                      640
magic                acc01ade
Handle:        0x7fd033e7e0b0 `/u01/app/oracle/product/11.2.0.4/dbhome_1book'

--注意看Handle:        0x7fd033e7e0b0 `/u01/app/oracle/product/11.2.0.4/dbhome_1book'。

5.设置ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1/
SYS@book> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@book> exit

$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1/
SYS@book> startup
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.
Database opened.

SYS@book> oradebug setmypid
Statement processed.
SYS@book> oradebug ipc
IPC information written to the trace file

Processing Oradebug command 'ipc'
Dump of unix-generic skgm context
areaflags            000000f7
realmflags           0000001f
mapsize              00000800
protectsize          00001000
lcmsize              00001000
seglen               00200000
largestsize  0000000480000000
smallestsize 0000000000400000
stacklimit     0x7fff6e19ad40
stackdir                   -1
mode                      640
magic                acc01ade
Handle:        0x7f51a90520b0 `/u01/app/oracle/product/11.2.0.4/dbhome_1book'
--可以发现无论设置ORACLE_HOME带与不带结尾的斜线,ipc看到的Handle 都是一样的。

5.再看看看监听:
--注当前设置的 ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1/

$ ps -ef | grep tnslsn[r]
oracle   53211     1  0 Feb28 ?        00:00:21 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit

$ cat /proc/53211/environ | tr '=' '\n'|strings | grep -A1 ORACLE_HOME
ORACLE_HOME
/u01/app/oracle/product/11.2.0.4/dbhome_1

--可以发现监听的ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1

--从远程使用sys用户连上数据库

d:\tools\rlwrap>sqlplus sys/xxxxxx@78 as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Thu Mar 10 15:25:24 2016
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@78> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.

SYS@78> startup
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.
Database opened.

--注要远程连接关闭后启动数据库一定要配置静态监听。注意这个时候实际上因为监听进程的ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1
--这样远程启动的数据库环境变量ORACLE=/u01/app/oracle/product/11.2.0.4/dbhome_1,在服务器上看看。

$ ps -ef | grep dbw[0]
oracle    1559     1  0 15:35 ?        00:00:00 ora_dbw0_book

$ cat /proc/1559/environ | tr '=' '\n'|strings | grep -A1 ORACLE_HOME
ORACLE_HOME
/u01/app/oracle/product/11.2.0.4/dbhome_1

--可以发现ORACLE启动的进程已经是环境变量ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1.

$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1/

[oracle@gxqyydg4 IP=100.78 ~/gdul 19]$ rlsql
SQL*Plus: Release 11.2.0.4.0 Production on Thu Mar 10 15:39:50 2016
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> @ &r/spid

       SID    SERIAL# SPID       PID  P_SERIAL# C50
---------- ---------- ------ ------- ---------- --------------------------------------------------
        80          3 1638        31          2 alter system kill session '80,3' immediate;

SYS@book> host  cat /proc/1638/environ | tr '=' '\n'|strings | grep -A1 ORACLE_HOME
ORACLE_HOME
/u01/app/oracle/product/11.2.0.4/dbhome_1/

--可以发现现在ORACLE_HOME已经没有任何影响。换一句话讲从11.2.0.4开始,无论ORACLE_HOME结尾是否带/.

--ipc 看到的handle都是Handle:        0x7f51a90520b0 `/u01/app/oracle/product/11.2.0.4/dbhome_1book'.
--也就是 最后的连接就是没有斜线的。

6.补充11.2.0.3情况看看:

$ export ORACLE_HOME=/u01/app/oracle11g/product/11.2.0/db_2/

SYS@test> startup
ORACLE instance started.

Total System Global Area 1603411968 bytes
Fixed Size                  2228784 bytes
Variable Size             973082064 bytes
Database Buffers          620756992 bytes
Redo Buffers                7344128 bytes
Database mounted.
Database opened.
SYS@test> oradebug setmypid
Statement processed.
SYS@test> oradebug ipc
Information written to trace file.

*** 2016-03-10 15:47:35.443
Processing Oradebug command 'ipc'
Dump of unix-generic skgm context
areaflags            000000f7
realmflags           0000001f
mapsize              00000800
protectsize          00001000
lcmsize              00001000
seglen               00200000
largestsize  0000000080000000
smallestsize 0000000001000000
stacklimit       0x7fbe07e840
stackdir                   -1
mode                      640
magic                acc01ade
Handle:          0x2a970040b0 `/u01/app/oracle11g/product/11.2.0/db_2/test'

--最后的连接存在斜线。如果这个时候设置ORACLE_HOME没有斜线.

$ export ORACLE_HOME=/u01/app/oracle11g/product/11.2.0/db_2
$ rlsql
SQL*Plus: Release 11.2.0.3.0 Production on Thu Mar 10 15:51:00 2016
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to an idle instance.

--无法连接上打开的数据库。如果启动数据库:

SYS@test> startup
ORACLE instance started.
Total System Global Area 1603411968 bytes
Fixed Size                  2228784 bytes
Variable Size             973082064 bytes
Database Buffers          620756992 bytes
Redo Buffers                7344128 bytes
ORA-01102: cannot mount database in EXCLUSIVE mode

SYS@test> shutdown immediate ;
ORA-01507: database not mounted

总结:
当然从这些小细节,可以看出oracle一直不断的改进进步。从管理角度讲最好不要结尾的斜线。

相关实践学习
数据库实验室挑战任务-初级任务
本场景介绍如何开通属于你的免费云数据库,在RDS-MySQL中完成对学生成绩的详情查询,执行指定类型SQL。
阿里云云原生数据仓库AnalyticDB MySQL版 使用教程
云原生数据仓库AnalyticDB MySQL版是一种支持高并发低延时查询的新一代云原生数据仓库,高度兼容MySQL协议以及SQL:92、SQL:99、SQL:2003标准,可以对海量数据进行即时的多维分析透视和业务探索,快速构建企业云上数据仓库。 了解产品 https://www.aliyun.com/product/ApsaraDB/ads
目录
相关文章
|
5月前
|
Perl
解决sed替换文本,里面含有“/“、“#”等特殊字符的问题
解决sed替换文本,里面含有“/“、“#”等特殊字符的问题
62 0
|
Linux Perl
LINUX使用sed,字串中包含特殊字符怎么办?
LINUX使用sed,字串中包含特殊字符怎么办?
114 0
|
存储 Unix Linux
路径中的斜杠/反斜杠\双斜杠以及常用绝对路径与相对路径知识
路径中的斜杠/反斜杠\双斜杠以及常用绝对路径与相对路径知识
404 0
路径中的斜杠/反斜杠\双斜杠以及常用绝对路径与相对路径知识
编写一个程序,将a.txt文件中的单词与b.txt文件中的单词交替合并到c.txt文件中,a.txt文件中的单词用回车符分隔,b.txt文件中用回车或空格进行分隔
编写一个程序,将a.txt文件中的单词与b.txt文件中的单词交替合并到c.txt文件中,a.txt文件中的单词用回车符分隔,b.txt文件中用回车或空格进行分隔
目录字串最后都不要带目录分隔符
目录字串最后都不要带目录分隔符
106 0
|
C# Windows
C# 不能用于文件名的字符
原文:C# 不能用于文件名的字符 在 Windows 有一些字符是不能作为文件名,尝试重命名一个文件,输入/ 就可以看到windows 提示的不能作为文件名的字符 那么具体是包括哪些符号不能...
916 0
|
Shell 数据库
[20180503]珅与分隔符.txt
[20180503]珅与分隔符.txt --//今天再次遇到分隔符问题,以前也遇到过做一次,链接.http://blog.itpub.net/267265/viewspace-763696/ --//这个"珅"还是许多人喜欢作为名字使用.
1109 0
|
索引 关系型数据库 Oracle
[20180329]删除带斜线的索引.txt
[20180329]删除带斜线的索引.txt --//上午看链接:http://www.itpub.net/thread-2100824-1-1.html --//开始没仔细看,实际上已经恢复了,索引名带斜线,看看如何删除.
946 0
|
Oracle 关系型数据库 Linux
[20171124]xxd与通配符.txt
[20171124]xxd与通配符.txt --//linux 上许多命令都支持通配符,比如 $ ls -l *.txt -rw-r--r-- 1 oracle oinstall 44801024 2017-11-24 09:16:38 c01.
804 0