sys用戶權限不足,本地登錄失敗 |ORA-01031 insufficient privileges|
機器總喜歡挑放假的時候出問題,“雙節”(中秋、國慶)快到了,對于搞系統運維的工程師來說其實并不輕松,于是今天趕緊裝起一臺數據庫備用服務器以備半夜“機”叫。
安裝OS就沒什么好說的了,從模板機中托一個出來改改IP和HostName就完事了,安裝Oracle數據庫也不是第一次了,找了一個靜默安裝的響應文件改一下把數據庫裝起來,雖然計劃是搭建DataGuard的,但是為了測試安裝是否成功,還是選擇了建庫,一切裝完后,例行登錄數據庫發現出了狀況:
[oracle@wz_oracle2 dbs]$ sqlplus system/oracle as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on Tue Sep 21 16:41:01 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved. ERROR: ORA-01031: insufficient privileges Enter user-name:
一般來說,ORA-01031都是出現在忘記輸入as sysdba
的時候出現的,這是為什么呢?
試一下其他方式登錄:
[oracle@wz_oracle2 dbs]$ [oracle@wz_oracle2 dbs]$ [oracle@wz_oracle2 dbs]$ sqlplus system/oracle SQL*Plus: Release 10.2.0.1.0 - Production on Tue Sep 21 16:41:05 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production With the Partitioning, OLAP and Data Mining options SQL> exit Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production With the Partitioning, OLAP and Data Mining options [oracle@wz_oracle2 dbs] [oracle@wz_oracle2 dbs] [oracle@wz_oracle2 dbs]$ sqlplus sys/oracle as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on Tue Sep 21 16:41:16 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production With the Partitioning, OLAP and Data Mining options SQL> exit Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production With the Partitioning, OLAP and Data Mining options
system 可以登錄,由于是新裝的數據庫,所以system用戶不會具有sysdba的權限,可以判斷system用的是密碼認證方式,密碼登錄沒有問題證明數據庫沒有問題;
sys用戶默認是sysdba,可以通過操作系統認證登錄(dba組中的用戶自動視為認證通過)或者使用密碼文件進行認證的方式登錄(常見于遠程登錄),修改密碼文件的名字再登錄:
[oracle@wz_oracle2 dbs]$ mv orapwora8i orapwora8i--- [oracle@wz_oracle2 dbs]$ sqlplus sys/oracle as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on Tue Sep 21 20:34:28 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved. ERROR: ORA-01031: insufficient privileges Enter user-name:
登錄失敗,可以判斷 sys 使用了密碼文件進行登錄認證。
現在可以基本認為 sys 用戶在操作系統認證這一關過不去了。由于這次安裝是使用響應文件進行靜默安裝的,估計問題就出在這個響應文件上,于是再次仔細審查響應文件的每一個選項,特別是涉及“組”的選項:
[oracle@wz_oracle2 ~]$ id uid=500(oracle) gid=500(dba) groups=500(dba) [oracle@wz_oracle2 ~]$ cat enterprise.rsp | egrep -i "grp|group" UNIX_GROUP_NAME="dba" s_nameForDBAGrp="oracle" s_nameForOPERGrp="oracle" [oracle@wz_oracle2 ~]$
果然,指定的DBA組合Oper組不對,大意啦~~~~~~。
這個問題應該如何解決呢,當然全部推倒重來也是可以的,但是有沒有“成本”更小的方法呢?求助于萬能的google輕易地找到了解決方案,就是修改 $ORACLE_HOME/rdbms/lib/config.c 這個文件:
[oracle@wz_oracle2 ~]$ cat $ORACLE_HOME/rdbms/lib/config.c
/* SS_DBA_GRP defines the UNIX group ID for adminstrative access. */
/* Refer to the Installation and User's Guide for further information. */
#define SS_DBA_GRP "oracle" /* 改成 dba */
#define SS_OPER_GRP "oracle" /* 改成 dba */
char *ss_dba_grp[] = {SS_DBA_GRP, SS_OPER_GRP};
再執行 relink all 就可以了:
[oracle@wz_oracle2 ~]$ cat $ORACLE_HOME/rdbms/lib/config.c
/* SS_DBA_GRP defines the UNIX group ID for adminstrative access. */
/* Refer to the Installation and User's Guide for further information. */
#define SS_DBA_GRP "dba"
#define SS_OPER_GRP "dba"
char *ss_dba_grp[] = {SS_DBA_GRP, SS_OPER_GRP};
[oracle@wz_oracle2 ~]$ relink all
.................
.................
.................
.................
.................
[oracle@wz_oracle2 ~]$
[oracle@wz_oracle2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Sep 21 20:48:03 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup ;
ORACLE instance started.
Total System Global Area 599785472 bytes
Fixed Size 2022600 bytes
Variable Size 171967288 bytes
Database Buffers 419430400 bytes
Redo Buffers 6365184 bytes
Database mounted.
Database opened.
SQL>
問題解決,使用響應文件靜默安裝的方式看起來很酷,但是一定要小心謹慎。
浙公網安備 33010602011771號