一.数据库的打开与关闭

 

linux下启动oracle

su - oracle

sqlplus /nolog

conn /as sysdba

startup

exit

lsnrctl start

exit

 

linux下关闭oracle

su - oracle

sqlplus /nolog

conn /as sysdba

shutdown immediate

exit

lsnrctlk stop

exit

启动监听器

lsnrctl start

停止监听器

lsnrctl stop

查看监听器状态

lsnrctl

status

exit

                        实例

 

[root@www ~]# su - oracle

[oracle@www ~]$ sqlplus

SQL*Plus: Release 10.2.0.1.0 - Production on Thu May 24 11:18:12 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Enter user-name: sys as sysdba

Enter password: 

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area  285212672 bytes

Fixed Size                  1218992 bytes

Variable Size             117442128 bytes

Database Buffers          163577856 bytes

Redo Buffers                2973696 bytes

Database mounted.

Database opened.

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

[oracle@www ~]$ lsnrctl start

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 24-MAY-2012 11:21:31

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

[oracle@www ~]$  emctl start dbconsole
TZ set to PRC
Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0  
Copyright (c) 1996, 2005 Oracle Corporation.  All rights reserved.
 
[oracle@www ~]$ isqlplusctl start
iSQL*Plus 10.2.0.1.0
Copyright (c) 2003, 2005, Oracle.  All rights reserved.
getnameinfo failed
Starting iSQL*Plus ...
iSQL*Plus started.
 

 

  二.em中网页的内容正常,但按钮是乱码。

http://192.168.2.100:1158/em

 

下面是解决办法:

 

1.修改jdk 下面的字体。

[oracle@rac2 db_1]$ cd $ORACLE_HOME/jdk/jre/lib/

[oracle@rac2 lib]$ mv font.properties font.properties_bak

[oracle@rac2 lib]$

[oracle@rac2 lib]$ cp font.properties.zh_CN.Redhat font.properties

[oracle@rac2 lib]$

 

2.修改jre 下面的字体

[oracle@rac2 lib]$ cd $ORACLE_HOME/jre/1.4.2/lib

[oracle@rac2 lib]$ mv font.properties font.properties_bak

[oracle@rac2 lib]$ cp font.properties.zh_CN.Redhat font.properties

 

3.清除emcache

[oracle@rac2 lib]$ cd $ORACLE_HOME/oc4j/j2ee/oc4j_applications/applications/em/em/cabo/p_w_picpaths/cache/zhs

[oracle@rac2 zhs]$ rm *.gif

 

 

另外,还需要注意font.properties最后一行的设置字体文件,如果不存在需要指定已经存在的字体文件,还要注意字体文件必须有操作的权限,下面是我的centos5的设置

cd $ORACLE_HOME/jdk/jre/lib/

[oracle@localhost lib]$ tail -n 3 font.properties(使最下面一行为以下内容)

filename.-misc-zysong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1=/usr/share/fonts/chinese/TrueType/uming.ttf

 

 

4. 重新启动em

[oracle@rac2 zhs]$ emctl stop dbconsole

[oracle@rac2 zhs]$ emctl start dbconsole

 

三.isqlplus中网页的内容正常,但按钮是乱码

http://192.168.2.100:5560/isqlplus

如果此页央按钮上中文仍乱码,则:

cd $ORACLE_HOME/oc4j/j2ee/oc4j_applications/applications/isqlplus/isqlplus/cabo/p_w_picpaths/cache/zhs

rm *.gif

然后重启isqlplus服务:

isqlplusctl stop

isqlplusctl start

 

四.将数据库模式变为归档模式

 

SQL> archive log list;

Database log mode              No Archive Mode

Automatic archival             Disabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     4

Current log sequence           6

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount;

ORACLE instance started.

 

Total System Global Area  285212672 bytes

Fixed Size                  1218992 bytes

Variable Size             113247824 bytes

Database Buffers          167772160 bytes

Redo Buffers                2973696 bytes

Database mounted.

SQL> alter database archivelog;

 

Database altered.

 

SQL> alter database open;

 

Database altered.

 

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     4

Next log sequence to archive   6

Current log sequence           6

SQL> 

 

 五.设置iSQL*Plus以DBA或者OPER登录

  从Oracle9i开始,Oracle提供了Web方式的sqlplus界面,通过iSQL*Plus,用户可以不需要安装任何Oracle客户端,就能够通过浏览器方式的sqlplus进行数据操作与数据库管理。一般用户登录iSQL*Plus的网址http://ip:port/isqlplus,进入该网址后会直接进入数据库用户登录界面,使用数据库中的普通用户即可登录。当我们以sys用户登录iSQL*Plus,则会提示需要以SYSDBA或者SYSOPER身份登录,可登录界面里并没有这个选项。DBA用户登录iSQL*Plus的网址http://ip:port/isqlplus/dba,进入该网址后首先会弹出一个登录框,要求先输入iSQL*Plus DBA的用户和密码。注意这里不是数据库用户,而是iSQL*Plus应用服务器要求的用户和密码。所以要以DBA身份登录iSQL*Plus,必须先配置好oc4j用户。

 

(sys用户使用http://ip:port/isqlplus登录)


 
   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 user / List user / Grant the webDba role / Remove users / Revoke the webDba role / Change user passwords。上述任务既可以先进入JAZN命令环境后再执行,也可以直接直接在命令行中实现。
 
  
 
   通过如下步骤实现:

 

 vim  .bash_profile(最后几行)

PATH=$PATH:$HOME/bin
export PATH

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=/u01/app/oracle/product/10.2.0

export ORACLE_SID=liuwei 连接标识符

export PATH=$ORACLE_HOME/bin:$PATH

export JAVA_HOME=$ORACLE_HOME/jdk

  1.切换到正确的目录
     [oracle@RHEL ~]$  cd $ORACLE_HOME/oc4j/j2ee/isqlplus/\
     >application-deployments/isqlplus
2.运行JAZN shell
     [oracle@RHEL isqlplus]$  $JAVA_HOME /bin/ 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
    或者
     [oracle@RHEL isqlplus]$  $JAVA_HOME/bin/java -Djava.security.properties=$ORACLE_HOME/oc4j/j2ee/home/config/jazn.security.props -jar $ORACLE_HOME/oc4j/j2ee/home/jazn.jar -user "iSQL*Plus DBA/admin" -password welcome -shell

3.创建用户
     JAZN:>  adduser "iSQL*Plus DBA" oracle oracle
    示例中创建用户oracle,密码也是oracle。语法是: adduser "iSQL*Plus DBA" username password
4.授予webDba role给用户
     JAZN:>  grantrole webDba "iSQL*Plus DBA" oracle
5.退出JAZN shell
     JAZN:>  exit

    重新启动iSQL*Plus。
[oracle@RHEL isqlplus]$  isqlplusctl start
iSQL*Plus 10.2.0.1.0
Copyright (c) 2003, 2005, Oracle.  All rights reserved.
Starting iSQL*Plus ...
iSQL*Plus started.

    再次登录iSQL*Plus,输入之前创建的用户oracle以及密码后,出现DBA登录界面。

 

     用http://ip:port/isqlplus/dba登录)

 

 

 

六.出现临时文件为空的提示错误

一.删除原有的临时文件

可用sys登录select * from v$datafile;查看路径

二.重建临时文件

 

 附 . linux下mysql密码忘记

 

mysqld --skip-grant-tables

mysql -uroot

update mysql.user set password=password('456') where user='root';

 

 

安装Oracle 10g忘记sys密码

window
sqlplus / as sysdba
alter user sys identified by password;

linux   
切换到Oracle用户   
su Oracle   
sqlplus / as sysdba   
alter user sys identified by password; 

执行完以上命令之后Oracle 10g中的sys密码就被更改为password了,我们可以使用sqlplus登录Oracle了,执行命令:

sqlplus sys/password as sysdba
注意: sys用户必须以sysdba的身份登录,否则无法登录的说!