我的sqlplus显示不正常:
[root@lunar ~]# su – oracle
[oracle@lunar ~]$ sqlplus / as sysdba
-bash: sqlplus: command not found
[oracle@lunar ~]$ . bb.env
[oracle@lunar ~]$ ss
SQL*Plus: Release 11.2.0.3.0 Production on Thu Oct 10 09:10:53 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
With the Partitioning and Real Application Testing options
SYS@bb>select * from dual;
X
SYS@bb>
检查glogin:
SYS@bb>exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
With the Partitioning and Real Application Testing options
[oracle@lunar ~]$ cd $ORACLE_HOME/sqlplus/admin
[oracle@lunar admin]$ ls
glogin.sql help libsqlplus.def plustrce.sql pupbld.sql
[oracle@lunar admin]$ tail glogin.sql
— Add any SQL*Plus commands here that are to be executed when a
— user starts SQL*Plus, or uses the SQL*Plus CONNECT command.
—
— USAGE
— This script is automatically run
—
#set pagesize 0
#set linesize 148
#SET SQLPROMPT ‘&_USER@&_CONNECT_IDENTIFIER>’
[oracle@lunar admin]$
检查环境变量:
[oracle@lunar ~]$ cat bb.env
umask 022
TMP=/tmp
TMPDIR=/tmp
export PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=bb
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/dbhome_1
export PATH=$ORACLE_HOME/OPatch:$ORACLE_HOME/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:$PATH
export LD_LIBRARY_PATH=/usr/lib:/usr/X11R6/lib
export ORACLE_PATH=/home/oracle/Scripts:$ORACLE_HOME/rdbms/admin
export NLS_LANG=American_America.ZHS16GBK
alias ss=”sqlplus / as sysdba”
[oracle@lunar ~]$
检查其他影响环境变量的配置文件:
[oracle@lunar ~]$ cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
[oracle@lunar ~]$
[oracle@lunar ~]$ cat .bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
[oracle@lunar ~]$
[oracle@lunar ~]$ cat /etc/profile
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
pathmunge () {
if ! echo $PATH | /bin/egrep -q “(^|:)$1($|:)” ; then
if [ “$2” = “after” ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
# ksh workaround
if [ -z “$EUID” -a -x /usr/bin/id ]; then
EUID=`id -u`
UID=`id -ru`
fi
# Path manipulation
if [ “$EUID” = “0” ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi
# No core files by default
ulimit -S -c 0 > /dev/null 2>&1
if [ -x /usr/bin/id ]; then
USER=”`id -un`”
LOGNAME=$USER
MAIL=”/var/spool/mail/$USER”
fi
HOSTNAME=`/bin/hostname`
HISTSIZE=1000
if [ -z “$INPUTRC” -a ! -f “$HOME/.inputrc” ]; then
INPUTRC=/etc/inputrc
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 99 ] && [ “`id -gn`” = “`id -un`” ]; then
umask 002
else
umask 022
fi
for i in /etc/profile.d/*.sh ; do
if [ -r “$i” ]; then
if [ “${-#*i}” != “$-” ]; then
. $i
else
. $i >/dev/null 2>&1
fi
fi
done
unset i
unset pathmunge
[oracle@lunar ~]$ cd /etc/profile.d
[oracle@lunar profile.d]$ ls
colorls.csh cvs.sh gnome-ssh-askpass.csh krb5-devel.sh lang.csh less.sh mpi-selector.csh vim.sh
colorls.sh glib2.csh gnome-ssh-askpass.sh krb5-workstation.csh lang.sh mc.csh mpi-selector.sh which-2.sh
cvs.csh glib2.sh krb5-devel.csh krb5-workstation.sh less.csh mc.sh vim.csh
[oracle@lunar profile.d]$
[root@lunar ~]# su – oracle
[oracle@lunar ~]$ env|grep SQLPATH
[oracle@lunar ~]$ . bb.env
[oracle@lunar ~]$ env|grep SQLPATH
[oracle@lunar ~]$
[oracle@lunar ~]$ ls -la
total 108
drwx—— 5 oracle oinstall 4096 Oct 10 09:13 .
drwxr-xr-x 3 root root 4096 Feb 8 2013 ..
-rw——- 1 oracle oinstall 10020 Oct 10 09:10 .bash_history
-rw-r–r– 1 oracle oinstall 33 Feb 8 2013 .bash_logout
-rw-r–r– 1 oracle oinstall 176 Feb 8 2013 .bash_profile
-rw-r–r– 1 oracle oinstall 124 Feb 8 2013 .bashrc
-rw-r–r– 1 oracle oinstall 529 Jun 23 12:20 bb.env
-rw-r–r– 1 oracle oinstall 515 Feb 8 2013 .emacs
-rw-r–r– 1 oracle oinstall 533 Jun 23 07:15 rac_dg.env
drwxr-xr-x 2 oracle oinstall 4096 Jun 19 07:08 Scripts
drwxr-xr-x 7 oracle oinstall 4096 Jun 23 12:23 test
-rw-r–r– 1 oracle oinstall 533 Jun 19 06:14 travel.env
-rw——- 1 oracle oinstall 9668 Oct 10 09:13 .viminfo
drwxr-xr-x 2 oracle oinstall 4096 Jun 23 09:29 .vnc
-rw——- 1 oracle oinstall 298 Jun 23 09:29 .Xauthority
-rw-r–r– 1 oracle oinstall 658 Feb 8 2013 .zshrc
[oracle@lunar ~]$ cat .zshrc
#
# .zshrc is sourced in interactive shells.
# It should contain commands to set up aliases,
# functions, options, key bindings, etc.
#
autoload -U compinit
compinit
#allow tab completion in the middle of a word
setopt COMPLETE_IN_WORD
## keep background processes at full speed
#setopt NOBGNICE
## restart running processes on exit
#setopt HUP
## history
#setopt APPEND_HISTORY
## for sharing history between zsh processes
#setopt INC_APPEND_HISTORY
#setopt SHARE_HISTORY
## never ever beep ever
#setopt NO_BEEP
## automatically decide when to page a list of completions
#LISTMAX=0
## disable mail checking
#MAILCHECK=0
# autoload -U colors
#colors
[oracle@lunar ~]$
一筹莫展中。。。。。。
忽然想起strace:
strace sqlplus / as sysdba 输出很多,相关的如下:
write(1, “Connected to:\n”, 14Connected to:
) = 14
write(1, “Oracle Database 11g Enterprise E”…, 77Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
) = 77
write(1, “With the Partitioning and Real A”…, 59With the Partitioning and Real Application Testing options
) = 59
write(1, “\n”, 1
) = 1 这里已经连接到oracle了,然后看它执行了什么
access(“/home/oracle/Scripts/login.sql”, F_OK) = -1 ENOENT (No such file or directory)
access(“/u01/app/oracle/product/11.2.0.3/dbhome_1/rdbms/admin/login.sql”, F_OK) = -1 ENOENT (No such file or directory)
access(“/home/oracle/Scripts/login.sql”, F_OK) = -1 ENOENT (No such file or directory)
access(“/u01/app/oracle/product/11.2.0.3/dbhome_1/rdbms/admin/login.sql”, F_OK) = -1 ENOENT (No such file or directory)
access(“/home/oracle/Scripts/login.sql”, F_OK) = -1 ENOENT (No such file or directory)
access(“/u01/app/oracle/product/11.2.0.3/dbhome_1/rdbms/admin/login.sql”, F_OK) = -1 ENOENT (No such file or directory)
access(“/home/oracle/Scripts/login.sql”, F_OK) = -1 ENOENT (No such file or directory)
access(“/u01/app/oracle/product/11.2.0.3/dbhome_1/rdbms/admin/login.sql”, F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 143360, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff3317ac000
munmap(0x7ff3317ac000, 143360) = 0
stat(“login.sql”, 0x7fff82d59450) = -1 ENOENT (No such file or directory)
access(“/home/oracle/Scripts/login.sql”, F_OK) = -1 ENOENT (No such file or directory)
access(“/u01/app/oracle/product/11.2.0.3/dbhome_1/rdbms/admin/login.sql”, F_OK) = -1 ENOENT (No such file or directory)
access(“/home/oracle/Scripts/login.sql”, F_OK) = -1 ENOENT (No such file or directory)
access(“/u01/app/oracle/product/11.2.0.3/dbhome_1/rdbms/admin/login.sql”, F_OK) = -1 ENOENT (No such file or directory)
brk(0x2135000) = 0x2135000
stat(“/u01/app/oracle/product/11.2.0.3/dbhome_1/sqlplus/admin/glogin.sql”, {st_mode=S_IFREG|0644, st_size=449, …}) = 0
access(“/u01/app/oracle/product/11.2.0.3/dbhome_1/sqlplus/admin/glogin.sql”, F_OK) = 0
statfs(“/u01/app/oracle/product/11.2.0.3/dbhome_1/sqlplus/admin/glogin.sql”, {f_type=”EXT2_SUPER_MAGIC”, f_bsize=4096, f_blocks=2666308, f_bfree=225670, f_bavail=88045, f_files=2752512, f_ffree=2535681, f_fsid={-2129888753, -1635635063}, f_namelen=255, f_frsize=4096}) = 0
open(“/u01/app/oracle/product/11.2.0.3/dbhome_1/sqlplus/admin/glogin.sql”, O_RDONLY) = 9
read(9, “–\n– Copyright (c) 1988, 2011, “…, 57344) = 449
read(9, “”, 57344) = 0
close(9) = 0
write(1, “SYS@bb>”, 7SYS@bb>) = 7
fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), …}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff3317ce000
read(0,
这里没有这个文件,正如上面strace的结果所示:
[oracle@lunar ~]$ cat /home/oracle/Scripts/login.sql
cat: /home/oracle/Scripts/login.sql: No such file or directory
[oracle@lunar ~]$
这里显示还是执行了/u01/app/oracle/product/11.2.0.3/dbhome_1/sqlplus/admin/glogin.sql,可是这个文件中唯一相关的几行我已经注释了:
[oracle@lunar ~]$ cat /u01/app/oracle/product/11.2.0.3/dbhome_1/sqlplus/admin/glogin.sql
—
— Copyright (c) 1988, 2011, Oracle and/or its affiliates.
— All rights reserved.
—
— NAME
— glogin.sql
—
— DESCRIPTION
— SQL*Plus global login “site profile” file
—
— Add any SQL*Plus commands here that are to be executed when a
— user starts SQL*Plus, or uses the SQL*Plus CONNECT command.
—
— USAGE
— This script is automatically run
—
#set pagesize 0
#set linesize 148
#SET SQLPROMPT ‘&_USER@&_CONNECT_IDENTIFIER>’
[oracle@lunar ~]$
怀疑是不是什么信息驻足留在某个我不知道的配置文件或者内存中了,看了下,貌似没有找到
[oracle@lunar ~]$ lsof /u01/app/oracle/product/11.2.0.3/dbhome_1/sqlplus/admin/glogin.sql
[oracle@lunar ~]$
于是我把这个文件mv成其他文件名,看看sqlplus什么样子:
[oracle@lunar ~]$ mv /u01/app/oracle/product/11.2.0.3/dbhome_1/sqlplus/admin/glogin.sql /u01/app/oracle/product/11.2.0.3/dbhome_1/sqlplus/admin/glogin.sql.bak
[oracle@lunar ~]$ ls -lrt /u01/app/oracle/product/11.2.0.3/dbhome_1/sqlplus/admin/glogin.sql
ls: /u01/app/oracle/product/11.2.0.3/dbhome_1/sqlplus/admin/glogin.sql: No such file or directory
[oracle@lunar ~]$ ss
SQL*Plus: Release 11.2.0.3.0 Production on Thu Oct 10 09:29:39 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
With the Partitioning and Real Application Testing options
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
With the Partitioning and Real Application Testing options
[oracle@lunar ~]$
可以看到这里已经正常了,那我再次move回去试试看:
[oracle@lunar ~]$ mv /u01/app/oracle/product/11.2.0.3/dbhome_1/sqlplus/admin/glogin.sql.bak /u01/app/oracle/product/11.2.0.3/dbhome_1/sqlplus/admin/glogin.sql
[oracle@lunar ~]$ ss
SQL*Plus: Release 11.2.0.3.0 Production on Thu Oct 10 09:30:03 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
With the Partitioning and Real Application Testing options
SYS@bb>select * from dual;
X
SYS@bb>exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
With the Partitioning and Real Application Testing options
[oracle@lunar ~]$ cat glogin.sql
cat: glogin.sql: No such file or directory
[oracle@lunar ~]$ cat /u01/app/oracle/product/11.2.0.3/dbhome_1/sqlplus/admin/glogin.sql
—
— Copyright (c) 1988, 2011, Oracle and/or its affiliates.
— All rights reserved.
—
— NAME
— glogin.sql
—
— DESCRIPTION
— SQL*Plus global login “site profile” file
—
— Add any SQL*Plus commands here that are to be executed when a
— user starts SQL*Plus, or uses the SQL*Plus CONNECT command.
—
— USAGE
— This script is automatically run
—
#set pagesize 0
#set linesize 148
#SET SQLPROMPT ‘&_USER@&_CONNECT_IDENTIFIER>’
[oracle@lunar ~]$
还是不行,一筹莫展中。。。。。。。。。。。。。。。
重启了主机,重启了数据库,一切未曾改变,仍然一筹莫展中。。。。。
然后我touch了一个空的glogin.sql(空白的),结果依旧
后来我在里面写入3行:
set pagesize 0
set linesize 148
SET SQLPROMPT ‘&_USER@&_CONNECT_IDENTIFIER>’
依旧不行。。。
再后来,我把pagesize设置为非零值,比如9999,问题就解决了:
SYS@bb>exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
With the Partitioning and Real Application Testing options
[oracle@lunar ~]$ ss
SQL*Plus: Release 11.2.0.3.0 Production on Thu Oct 10 10:00:11 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
With the Partitioning and Real Application Testing options
SYS@bb>select * from dual;
DU
—
X
SYS@bb>
查了下文档:
SET PAGESIZE
Sets the number of lines on each page of output.
Increase PAGESIZE to avoid printing headings frequently, or set it to 0 to prevent
headings being displayed.
好玩,lunar基础知识太不扎实了,O(∩_∩)O哈哈~