背景:
今天有个开发员A找到我说“连接oracle standby database的account locked了”,于是我习惯地查了数据库用户表状态,发现没有问题。也排查了他的程序在连接过程中没有错误连接到一些不匹配的数据库中。但是为什么会报这个错呢?
分析:
1. 检查primary和standyb数据库用户状态表dba_users user$,看到account_status为open
2. 使用该用户尝试登录standby database ,果然报“ORA-28000: the account is locked”
3. 使用该用户尝试登录primary database ,正常。
4. 那为什么这个用户被锁呢?那里输错了密码,原来小A,在昨天那数据库用户密码串(加密后)的放在另一个配置文件上,然后通过JAVA读出,结果由于密码串有些特殊字符,结果读出来后被转义了。
行动:
1. 在standby database 中执行alter user XX account unlock; 《〈〈〈〈〈〈〈解决
2. 禁用配置文件保存密码串再读出的方式,直到解决转义问题后再启用。
原因:standby database是在内存中把用户锁定,但由于是read only状态,所以并没有更改用户表中的状态信息。具体说明如下:
ORA-28000 “the account is locked” in the standby database, even after the account was unlocked in the primary. (Doc ID 1600401.1)
==>
CAUSE
A
privileged user
(
a
database
administrator
)
must unlock account
in
the standby
database
.
It
is
not
enough
to
unlock the same
account
in
the primary
database
.
This
is
because the standby
is
open
read
-
only
and
cannot update any
tables
.
When
a
user's
account has
to
be locked on the standby
database
,
it
is
locked only
in
memory
there
.
==>
SOLUTION
A
privileged user
(
sysdba
,
the database
administrator
)
must logon
to
the standby
and
unlock the account
there
.
A
message
ORA
-
28015
"Account unlocked, but the database is open for read-only access"
confirms that the account
is
now unlocked
in
the standby
database
.
From
then
on
,
the user can logon
to
the standby database without getting any
error
.
备注:网上有人说,有的standby database 的版本是不能直接解锁的,要重启standby database.