一. EM(Enterprise Manager)
9I提供的是OEM JAVA写的图形很丑陋 速度也慢 到10g后改名为EM
oracle10G提供的EM基于WEB的企业管理器
功能强大 但不是DBA日常维护的主要接口 辅助而已
安装完成后数据库和OEM都处于启动状态
ps -ef | grep ^oracle
访问路径:
通过主机名或IP访问 单机没DNS时/etc/hosts里要有域名解析
http://dba.up.com:1158/em 10.1版本是5500 10.2后1158
如果多个EM在同一台主机上 第一个端口1158 第二个5500 第三个5501 ...
端口文件:
[oracle@dba install]$ cat $ORACLE_HOME/install/portlist.ini
iSQL*Plus HTTP 端口号 =5560
Enterprise Manager Console HTTP 端口 (ora10g) = 1158
Enterprise Manager 代理端口 (ora10g) = 3938
[oracle@dba install]$
使用超级管理员sys登录 连接身份sysdba 选择登录后要同意使用协议版权
EM的启动和关闭
EM是通过数据库监听器连接到数据库的 所以启动EM前应该把监听启动起来(默认端口TCP1521)
数据监听程序的关闭启动
[oracle@dba log]$ lsnrctl status
[oracle@dba log]$ lsnrctl stop
[oracle@dba log]$ lsnrctl start
启动和关闭EM
[oracle@dba log]$ emctl status dbconsole
[oracle@dba log]$ emctl stop dbconsole
[oracle@dba log]$ emctl start dbconsole
二. ISQLPLUS
WEB模式的数据库用户接口
默认接口有两个
普通用户
http://dba.up.com:5560/isqlplus/ 超级管理员
http://dba.up.com:5560/isqlplus/dba 默认情况下管理员是不允许从这个接口登录的
开启的方法
1.要安装JDK 使用系统中的java就可以 但要1.6.0的版本才可以 如果安装了1.4.0 先卸掉
[root@dba Server]# rpm -ivh jpackage-utils-1.7.3-1jpp.2.el5.noarch.rpm
[root@dba Server]# rpm -ivh java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5.i386.rpm
2.切换到oracle用户配置
配置文件目录
[oracle@dba ~]$ cd $ORACLE_HOME/oc4j/j2ee/isqlplus/application-deployments/isqlplus/
默认的isqlplus认证用户admin 密码welcome 授予 iSQL*Plus DBA 权限
[oracle@dba isqlplus]$ 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
JAZN:> listusers
iSQL*Plus DBA/admin
JAZN:> grantrole webDba "iSQL*Plus DBA" admin
JAZN:> exit
注意是 区分大小写
3.重新启动isqlplus 使更改生效
[oracle@dba isqlplus]$ isqlplusctl stop
[oracle@dba isqlplus]$ isqlplusctl start
4.再通过
http://dba.up.com:5560/isqlplus/dba 地址访问
三. sqlplus 这是DBA管理数据库的常用接口 命令行接口
但这个环境过于简单 没有上下键翻查历史命令的功能
安装软件添加翻查历史功能
[root@dba ~]# rpm -ivh rlwrap-0.30-1.el5.i386.rpm
切换到oracle用户 添加命令别名
vim .bashrc
alias sql='rlwrap sqlplus'
alias sqlplus='rlwrap sqlplus'
alias lsnrctl='rlwrap lsnrctl'
alias rman='rlwrap rman'
:wq
加载 source .bash_profile
连接oracle的方法:
[oracle@dba ~]$ sql /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Feb 25 05:24:37 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected.
SQL> show user
USER is "SYS"
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@dba ~]$
四. 数据库的启动和关闭
启动
[oracle@dba ~]$ sql /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Feb 25 07:03:34 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> show user
USER is "SYS"
SQL> startup
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 83887696 bytes
Database Buffers 197132288 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
SQL>
关闭
[oracle@dba ~]$ sql / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Feb 25 07:04:30 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> show user
USER is "SYS"
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
五. 添加oracle随系统启动的脚本
启动脚本已随安装的软件安装到系统 不需要自己编写
脚本位置:
$ORACLE_HOME/bin/dbstart
$ORACLE_HOME/bin/dbshut
启动脚本中有一个路径变量值设置错误 要手动修正
[oracle@dba ~]$ sed -n '78p' $ORACLE_HOME/bin/dbstart
ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle
[oracle@dba ~]$ sed -i 's!/ade/vikrkuma_new/oracle!$ORACLE_HOME!' $ORACLE_HOME/bin/dbstart
[oracle@dba ~]$ sed -n '78p' $ORACLE_HOME/bin/dbstart
ORACLE_HOME_LISTNER=$ORACLE_HOME
[oracle@dba ~]$
要想使dbstart命令生效 还需要修改/etc/oratab里的内容
[oracle@dba ~]$ grep $ORACLE_SID /etc/oratab
ora10g:/u01/oracle/product/10.2.0:N
[oracle@dba ~]$
改成
ora10g:/u01/oracle/product/10.2.0:Y
之后就可以使用dbstart和dbshut来启停数据库了
[oracle@dba ~]$ ps -ef | grep ora_ | grep -v grep
[oracle@dba ~]$ dbstart
Processing Database instance "ora10g": log file /u01/oracle/product/10.2.0/startup.log
[oracle@dba ~]$ ps -ef | grep ora_ | grep -v grep
oracle 12359 1 0 07:24 ? 00:00:00 ora_pmon_ora10g
oracle 12361 1 0 07:24 ? 00:00:00 ora_psp0_ora10g
oracle 12363 1 1 07:24 ? 00:00:00 ora_mman_ora10g
oracle 12365 1 0 07:24 ? 00:00:00 ora_dbw0_ora10g
oracle 12367 1 1 07:24 ? 00:00:00 ora_lgwr_ora10g
oracle 12369 1 0 07:24 ? 00:00:00 ora_ckpt_ora10g
oracle 12371 1 3 07:24 ? 00:00:00 ora_smon_ora10g
oracle 12373 1 0 07:24 ? 00:00:00 ora_reco_ora10g
oracle 12375 1 1 07:24 ? 00:00:00 ora_cjq0_ora10g
oracle 12377 1 7 07:24 ? 00:00:00 ora_mmon_ora10g
oracle 12379 1 0 07:24 ? 00:00:00 ora_mmnl_ora10g
oracle 12381 1 0 07:24 ? 00:00:00 ora_d000_ora10g
oracle 12383 1 0 07:24 ? 00:00:00 ora_s000_ora10g
oracle 12388 1 1 07:24 ? 00:00:00 ora_qmnc_ora10g
oracle 12394 1 12 07:24 ? 00:00:00 ora_j000_ora10g
[oracle@dba ~]$ dbshut
[oracle@dba ~]$ ps -ef | grep ora_ | grep -v grep
[oracle@dba ~]$
借助这两个命令结合shell_script写个自己的脚本
[oracle@dba ~]$ cat /etc/rc.d/init.d/dbora
#!/bin/bash
# chkconfig: 35 85 90
# description: Oracle auto start-stop script.
# AUTH:seker
. /etc/init.d/functions
start(){
if ps aux | grep ora_ | grep -v grep &>/dev/null
then
echo -n $"cannot start database: database is already running."
failure $"cannot start database: database is already running."
echo
exit 1
else
echo -n $"Starting Database: "
daemon su - $ORA_OWNER -c "dbstart" && touch /var/lock/subsys/`basename $0`
echo
fi
}
stop(){
if ps aux | grep ora_ | grep -v grep &>/dev/null
then
echo -n $"Stoping Database: "
daemon su - $ORA_OWNER -c "dbshut" && rm -f /var/lock/subsys/`basename $0`
echo
else
echo -n $"cannot stop database:Database is not already running."
failure $"cannot stop database:Database is not already running."
echo
exit 1
fi
}
ORA_OWNER=oracle
case "$1" in
start)
start
;;
stop)
stop
;;
emstart)
su - $ORA_OWNER -c 'emctl status dbconsole &>/dev/null && echo "OEM is already running" || emctl start dbconsole'
;;
emstop)
su - $ORA_OWNER -c 'emctl status dbconsole &>/dev/null && emctl stop dbconsole || echo "OEM is not running"'
;;
isqlstart)
su - $ORA_OWNER -c 'ps aux | grep 'isqlplus/config/server.xml' | grep -v grep &>/dev/null || isqlplusctl start'
;;
isqlstop)
su - $ORA_OWNER -c 'ps aux | grep 'isqlplus/config/server.xml' | grep -v grep &>/dev/null && isqlplusctl stop || echo "isqlplus is not running"'
;;
lsnstart)
su - $ORA_OWNER -c 'lsnrctl status &>/dev/null && echo "listen is already running" || lsnrctl start &>/dev/null'
;;
lsnstop)
su - $ORA_OWNER -c 'lsnrctl status &>/dev/null && lsnrctl stop &>/dev/null || echo "lsnrctl is not already running"'
;;
*)
echo "USAGE: $0 {start|stop|lsnstart|lsnstop|emstart|emstop|isqlstart|isqlstop}"
echo -e "\tstart : database start"
echo -e "\tstop : database stop"
echo -e "\tlsnstart : listen start"
echo -e "\tlsnstop : listen stop"
echo -e "\temstart : OEM start"
echo -e "\temstop : OEM stop"
echo -e "\tisqlstart : isqlplus start"
echo -e "\tisqlstop : isqlplus stop"
esac
[oracle@dba ~]$
添加到启动脚本目录
[root@dba ~]# chmod +x /etc/rc.d/init.d/dbora
[root@dba ~]# chkconfig --add dbora
也可以使用service调用
[root@dba ~]# service dbora stop
[root@dba ~]# service dbora start
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24756465/viewspace-717601/
,如需转载,请注明出处,否则将追究法律责任。