oracle安装还是比较简单的,不过需要的空间太大了,害我删除了vc2005 和 csdn 空间才够用!
路径:
Oracle9i 官方下载地址
http://www.oracle.com/technology/global/cn/software/products/oracle9i/index.html
10G和11G的
http://www.oracle.com/technology/software/products/database/index.html
oracle 的默认用户为scott
scott,oracle原始自带的一个用户
密码为tiger
只是为了用户除system管理帐户外方便使用的一个用户
没什么太大的意义
平时也就用来做一些功能的测试之类的
以删除不用 。
使用sql plus登陆时 遇到最多的问题是:
error: the account is locked
至于 scott 用户为什么被锁定,可能是下面几个原因。
1. 尝试多次登录未成功(可能密码不正确);
2. 此用户被管理员手工锁定;
3. 用户密码到期、未按时修改密码,等等。
看来 scott 这个用户肯定是登陆不了了,然后我用尝试着用 system 这个用户登录,我记得在安装 Oracle 11g 的时候曾提示输入密码,然后我自己输了一个,结果我用自己原先设定的密码试了一下果然连接上了。可见来在 oracle 11g 的 system 这个用户的密码并不是默认的,而是安装的时候自己设定的。
用 system 登录进去之后,执行下面的命令:
SQL> alter user scott account unlock;
用户已更改。
这样就完成解锁的操作。接下来,你还可以重新给 scott 这个用户设定密码。
修改scott的登录密码:
SQL> alter user scott identified by tiger;
用户已更改。
大功告成,此时你再拿 scott 和 tiger 来登录就可以了!
SQL> conn scott/tiger
已连接。
学习 Oracle 数据库的几点经验:
1. 在Dos命令下输入 sqlplus 可以打开 Oracle 自带的 SQL Plus 并出现登录提示,而输入 sqlplus/nolog 则打开 SQL Plus 后不出现登陆提示;
2. 在 SQL Plus 中输入 conn 可以连接数据库,其中的一种格式为:
SQL> conn 用户名/密码 如: conn scott/tiger
3. Oracle 中给用户加锁与解锁的代码:
SQL> alter user 用户名 account lock; (加锁)
SQL> alter user 用户名 account unlock; (解锁)
oracle:端口查看, isqlplus 命令行启动与关闭,DBA访问
如果通过浏览器方式访问Oracle的em,isqlplus等,需要知道各个服务的端口,此时可以查看:
$ORACLE_HOME/product/10.1.0/Db_1/install目录下的portlist.ini文件或readme.txt文件
修改服务端口号:
$ORACLE_HOME/product/10.1.0/Db_1/oc4j/j2ee/isqlplus/config目录中的http-web-site.xml文件,其他服务类似。
----------------------------------------------------------------------------------------------------
可以通过以下命令启动和停止isqlplus服务:
isqlplusctl start
isqlplusctl stop
----------------------------------------------------------------------------------------------------
em管理器访问URL URL: http://address:5513/em/ (具体端口查看不同数据库)
普通用户访问isqlplus URL:http://address:5560/isqlplus/
DBA用户访问isqlplus URL: http://address:5560/isqlplus/dba/
----------------------------------------------------------------------------------------------------
如何以DBA身份登陆isqlplus:
一般用户登陆isqlplus的网址http://ip:port/isqlplus,进入该网址后会直接进入数据库用户登陆界面,使用数据库中的普通用户即可登陆。
DBA用户登陆isqlpus的网址http://ip:port/isqlplus/dba,进入该网址后首先会弹出一个登陆框,要求先输入iSQL*Plus DBA的用户和密码,注意这里不是数据库用户,而是isqlplus应用服务器要求的用户和密码。
要以DBA身份登陆isqlplus,必须先配置好oc4j用户。oc4j可以使用两种身份认证方式:
基于xml配置文件(jazn-data.xml)
基于LDAP(Oracle Internet Directory)
本文只涉及第一种方式,也就是采用xml配置文件认证的方式。该配置文件位于$ORACLE_HOME/oc4j/j2ee/isqlplus/application-deployments/isqlplus/config。
但是该配置文件中的密码是加密过的,所以我们不能手动修改该文件,而是通过JAZN(Java AuthoriZatioN)来配置。JAZN是oracle提供的一个JASS(Java Authentication and Authorization Service)工具。通过JAZN,可以完成以下任务
Create users
List users
Grant the webDba role
Remove users
Revoke the webDba role
Change user passwords
以上任务,可以先进入JAZN命令环境后再执行,也可以直接通过一条完整的命令行实现。完整的命令行其实就是在进入JAZN的命令后面直接加上对应的任务选项即可,本文只以JAZN命令环境为例。
如何进入JAZN命令环境
1.进入到目录$ORACLE_HOME/oc4j/j2ee/isqlplus/application-deployments/isqlplus/
2.确保JAVA_HOME环境变量指向了正确的jdk(需要1.4以上)路径,可以使用oracle自带的jdk,位于$ORACLE_HOME/jdk
3.执行以下命令
java -Djava.security.properties=$ORACLE_HOME/sqlplus/admin/iplus/provider -jar $ORACLE_HOME/oc4j/j2ee/home/jazn.jar -user “iSQL*Plus DBA/admin” -password welcome -shell
windows:
java -Djava.security.properties=D:/oracle/product/10.2.0/db_1/sqlplus/admin/iplus/provider -jar D:/oracle/product/10.2.0/db_1/oc4j/j2ee/home/jazn.jar -user "iSQL*Plus DBA/admin" -password welcome -shell
其中realm=iSQL*Plus DBA,user=admin,这些可以从xml配置文件中看到,admin的默认密码是welcome,但是admin用户默认没有webDba权限,不能直接用于登陆isqlplus。
注意该命令一定要先进入第一步的目录后再执行,否则会报错
oracle.security.jazn.JAZNRuntimeException: Configuration file “configjazn.xml” does not exist. Check your JAAS configuration settings.
或者
Realm [iSQL*Plus DBA] does not exist in system.
如果报以上的错误,请仔细检查你的当前目录是否和第一步中给出的目录完全一致
进入JAZN命令环境后,可以执行所有的任务:
1.新建用户ning,密码pass
JAZN:> adduser “iSQL*Plus DBA” ning pass
2.列出用户
JAZN:> listusers
iSQL*Plus DBA/admin
iSQL*Plus DBA/ning
JAZN:> listusers “iSQL*Plus DBA”
admin
ning
3.授予用户登陆isqlplus DBA的权限
JAZN:> grantrole webDba “iSQL*Plus DBA” ning
4.撤销用户登陆isqlplus DBA的权限
JAZN:> revokerole webDba “iSQL*Plus DBA” ning
5.删除用户
JAZN:> remuser “iSQL*Plus DBA” ning
6.修改用户密码
JAZN:> setpasswd “iSQL*Plus DBA” ning pass newpass
7.退出JAZN命令环境
JAZN:> exit
假设上面我们创建了一个用户ning,密码为pass,并且已经授予webDba权限。
接下来重新启动isqlplus应用服务器
isqlplusctl stop
isqlplusctl start
再进入网址http://ip:port/isqlplus/dba,在弹出的对话框中输入ning和pass,就可以进入到数据库登陆界面了,选择以sysdba或sysoper身份登陆了。
注意windows下 符号的区别
adduser "iSQL*Plus DBA" oracle oracle
grantrole webDba "iSQL*Plus DBA" oracle
grantrole webDba "iSQL*Plus DBA" admin
如何查看Oracle的端口号
Configuration and Migration Tools---->Net Manager----->服务命名----->找到对应的sid查看端口号!
客户端默认的端口号一般都是1521
服务端默认的端口号一般是389
XP Oracle Enterprise Manager 没法启动
C:/Documents and Settings/Administrator>emctl status dbconsole
Environment variable ORACLE_SID not defined. Please define it.
C:/Documents and Settings/Administrator>set oracle_sid=testdb
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.
C:/Documents and Settings/Administrator>emctl start dbconsole
Unable to determine local host from URL REPOSITORY_URL=http://10.10.10.84:%EM_UP
LOAD_PORT%/em/upload/
.
C:/Documents and Settings/Administrator>emctl config
Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0
Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved.
Usage ::
emctl config console <fileloc> [<EM loc>]
where <fileloc> contains config entries.
emctl config [agent] addtarget [-f|-force] <fileloc> [<EM loc>]
where <fileloc> contains a definition of target to add,
and where -f or -force allows to overwrite an existing target.
If -f or -force is not specified, existing targets cannot be overwritten.
emctl config [agent] addtargets [-f|-force] <fileloc> [<EM loc>]
where <fileloc> contains a definition of targets to add
and where -f or -force allows to overwrite existing targets.
If -f or -force is not specified, existing targets cannot be overwritten.
emctl config [agent] modifytarget <fileloc> [<EM loc>]
where <fileloc> contains a new definition of target to modify
emctl config [agent] deletetarget <type> <name> [<EM loc>]
where <type>,<name> specify target type and name to delete
emctl config [agent] listtargets [<EM loc>]
lists all targets present in targets.xml
emctl config [agent] listcentralagents [<EM loc>]
lists the central agents this home is associated with
emctl config [agent] addcentralagent <centralAgentHomePath> [<EM loc>]
associates this home with a new central agent
emctl config [agent] removecentralagent <centralAgentHomePath> [<EM loc>]
removes the association of this home with a central agent
emctl config [agent] setcentralagents <centralAgent1> [<centralAgent2> ...]
sets the list of central agents this home is associated with
emctl config agent addTargetsToRepository <uploadFile> <update_on_dup (true |
false)>
uploadFile contains definition for targets
update_on_dup decides whether updating duplicate targets
This function is for central agent
<EM loc> is optional and can be used to operate on a different Oracle Home.
The centralagent commands do not apply in a agent-only home.
C:/Documents and Settings/Administrator>emctl config dbconsole
Unable to determine local host from URL REPOSITORY_URL=http://10.10.10.84:%EM_UP
LOAD_PORT%/em/upload/
.
C:/Documents and Settings/Administrator>emctl config dbconsole
Unable to determine local host from URL REPOSITORY_URL=http://10.10.10.84:%EM_UP
LOAD_PORT%/em/upload/
.
C:/Documents and Settings/Administrator>emca -config dbcontrol db
EMCA 开始于 2008-7-4 11:43:43
EM Configuration Assistant 10.2.0.1.0 正式版
版权所有 (c) 2003, 2005, Oracle。保留所有权利。
输入以下信息:
数据库 SID: testdb
已为数据库 testdb 配置了 Database Control
您已选择配置 Database Control, 以便管理数据库 testdb
此操作将移去现有配置和默认设置, 并重新执行配置
是否继续? [yes(Y)/no(N)]: y
监听程序端口号: 1521
SYS 用户的口令:
DBSNMP 用户的口令:
SYSMAN 用户的口令:
SYSMAN 用户的口令: 通知的电子邮件地址 (可选):
通知的发件 (SMTP) 服务器 (可选):
-----------------------------------------------------------------
已指定以下设置
数据库 ORACLE_HOME ................ D:/oracle/product/10.2.0/db_1
数据库主机名 ................ 10.10.10.84
监听程序端口号 ................ 1521
数据库 SID ................ testdb
通知的电子邮件地址 ...............
通知的发件 (SMTP) 服务器 ...............
-----------------------------------------------------------------
是否继续? [yes(Y)/no(N)]: y
2008-7-4 11:44:29 oracle.sysman.emcp.EMConfig perform
信息: 正在将此操作记录到 D:/oracle/product/10.2.0/db_1/cfgtoollogs/emca/testdb/e
mca_2008-07-04_11-43-42-上午.log。
2008-7-4 11:44:31 oracle.sysman.emcp.util.DBControlUtil stopOMS
信息: 正在停止 Database Control (此操作可能需要一段时间)...
2008-7-4 11:44:41 oracle.sysman.emcp.util.DBControlUtil startOMS
信息: 正在启动 Database Control (此操作可能需要一段时间)...
2008-7-4 11:45:21 oracle.sysman.emcp.EMDBPostConfig performConfiguration
信息: 已成功启动 Database Control
2008-7-4 11:45:21 oracle.sysman.emcp.EMDBPostConfig performConfiguration
警告: 无法创建 Database Control 快捷方式
2008-7-4 11:45:21 oracle.sysman.emcp.EMDBPostConfig performConfiguration
信息: >>>>>>>>>>> Database Control URL 为http://10.10.10.84:5500/em<<<<<<<<<<<
已成功完成 Enterprise Manager 的配置
EMCA 结束于 2008-7-4 11:45:21
C:/Documents and Settings/Administrator>emctl start dbconsole
Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0
Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved.
http://10.10.10.84:5500/em/console/aboutApplication
Starting Oracle Enterprise Manager 10g Database Control ...请求的服务已经启动。