十、用dbca建立RAC集群数据库
由oracle用户,执行dbca来建立RAC集群数据库。先说明一下,建库时先不配置企业管理器(Enterprise Manager),等建库成功后,执行脚本配置EM,原因是在安装过程中配置EM导致建库时间很长,如果RAC节点的主机性能不好,可能导致安装程序的界面停止响应;SGA也不要设置太大,本次安装为400M。我发现当EM启动后,占用的系统资源很大,做管理还是使用sqlplus命令行更为快捷。
1.建立RAC集群数据库 (不配置EM)
-bash-3.00# export DISPLAY=192.168.1.130:0.0
-bash-3.00# /usr/openwin/bin/xhost +
-bash-3.00# su – oracle
(启用用户等效性,如果设置密钥时密码为空,就不用执行这两个命令了)
-bash-3.00$ exec /usr/bin/ssh-agent $SHELL
-bash-3.00$ /usr/bin/ssh-add
(启用图形功能)
-bash-3.00$ export DISPLAY=192.168.1.130:0.0
-bash-3.00$ /usr/openwin/bin/xhost + 192.168.1.130
-bash-3.00$ dbca
显示出图形配置界面,开始进行安装
建立RAC集群数据库 | ||
步骤 | 操作说明 | 屏幕截图 |
1.选择操作 | 选择创建数据库,下一步 | |
2.选择数据库模板 | 按默认设置,下一步 | |
3.创建数据库标识 | Global Database Name: racdb.racnode.com SID: racdb 选择配置所有节点,下一步 | |
4.管理选项 | 注意:这一步不配置EM,建立RAC数据库之后再执行emca配置 | |
5.数据库认证 | 选择使用相同的密码,下一步 | |
6.数据库文件存储路径 | 存储类型:ASM自动存储 存储路径:+RACDB_DATA | |
7.回复配置 | 闪回区:+FRA 闪回区大小:8G | |
8.数据库内容 | 选择安装示例scheme,下一步 | |
9.初始化参数 | SGA指定为400M,先不要下一步,再切换到“Character Sets”页面 | |
字符集设置,选择 Unicode(AL32UTF8) | ||
10.数据库存储 | 按默认设置,下一步 | |
11.创建数据库选项 | 选中创建数据库,点击“Finish”按钮,开始建库 (可以选择同时生成安装脚本,默认路径$ORACLE_BASE/admin/racdb/scripts) | |
12.总结 | 给出一个总结,点击“OK”,继续 | |
13.dbca创建RAC数据库 | 建库过程比较慢,大约1小时 | |
13.建库成功 | 建库成功后,dbca给出提示 全局名称:racdb.racnode.com SID: racdb SPFILE: +RACDB_DATA/racdb/spfileracdb.ora | |
2.在建库成功后,使用emca配置企业管理器
以oracle用户执行以下命令来配置EM
-bash-3.00$ emca -config dbcontrol db -silent -cluster -ASM_USER_ROLE SYSDBA -ASM_USER_NAME ASMSNMP -CLUSTER_NAME racnode-cluster -SID racdb -ASM_SID +ASM1 -DB_UNIQUE_NAME racdb -EM_HOME /u01/app/oracle/product/11.2.0/dbhome_1 -SERVICE_NAME racdb.racnode.com -ASM_PORT 1521 -PORT 1521 -LISTENER_OH /u01/app/11.2.0/grid -LISTENER LISTENER -ORACLE_HOME /u01/app/oracle/product/11.2.0/dbhome_1 -HOST racnode1 -ASM_OH /u01/app/11.2.0/grid;
STARTED EMCA at Feb 25, 2010 11:49:59 PM
EM Configuration Assistant, Version 11.2.0.0.2 Production
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Password for SYS user:
Password for DBSNMP user:
Password for SYSMAN user:
ASM user password:
-----------------------------------------------------------------
You have specified the following settings
Database ORACLE_HOME ................ /u01/app/oracle/product/11.2.0/dbhome_1
Database instance hostname ................ racnode1
Listener ORACLE_HOME ................ /u01/app/11.2.0/grid
Listener port number ................ 1521
Cluster name ................ racnode-cluster
Database unique name ................ racdb
Email address for notifications ............... null
Outgoing Mail (SMTP) server for notifications ............... null
ASM ORACLE_HOME ................ /u01/app/11.2.0/grid
ASM port ................ 1521
ASM user role ................ SYSDBA
ASM username ................ ASMSNMP
-----------------------------------------------------------------
Feb 25, 2010 11:50:20 PM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /u01/app/oracle/cfgtoollogs/emca/racdb/emca_2010_02_25_23_49_58.log.
Feb 25, 2010 11:50:37 PM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepository
INFO: Uploading configuration data to EM repository (this may take a while) ...
Feb 25, 2010 11:54:03 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Uploaded configuration data successfully
Feb 25, 2010 11:54:04 PM oracle.sysman.emcp.EMDBCConfig instantiateOC4JConfigFiles
INFO: Propagating /u01/app/oracle/product/11.2.0/dbhome_1/oc4j/j2ee/OC4J_DBConsole_racnode1_racdb to remote nodes ...
Feb 25, 2010 11:54:09 PM oracle.sysman.emcp.EMDBCConfig instantiateOC4JConfigFiles
INFO: Propagating /u01/app/oracle/product/11.2.0/dbhome_1/oc4j/j2ee/OC4J_DBConsole_racnode2_racdb to remote nodes ...
Feb 25, 2010 11:54:19 PM oracle.sysman.emcp.EMAgentConfig deployStateDirs
INFO: Propagating /u01/app/oracle/product/11.2.0/dbhome_1/racnode1_racdb to remote nodes ...
Feb 25, 2010 11:54:24 PM oracle.sysman.emcp.EMAgentConfig deployStateDirs
INFO: Propagating /u01/app/oracle/product/11.2.0/dbhome_1/racnode2_racdb to remote nodes ...
Feb 25, 2010 11:54:32 PM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibrary
INFO: Location /u01/app/oracle/product/11.2.0/dbhome_1/EMStagePatches_racdb is not shared. Software library could not be configured. Provisioning archives will not be deployed. Please configure it manually.
Feb 25, 2010 11:54:32 PM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Securing Database Control (this may take a while) ...
Feb 25, 2010 11:54:59 PM oracle.sysman.emcp.util.DBControlUtil startOMS
INFO: Starting Database Control (this may take a while) ...
Feb 26, 2010 12:25:28 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: Database Control started successfully
Feb 26, 2010 12:25:32 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: >>>>>>>>>>> The Database Control URL is https://racnode1:1158/em <<<<<<<<<<<
卸载EM
-bash-3.00$ emca -deconfig all db -cluster
STARTED EMCA at Feb 25, 2010 11:45:09 PM
EM Configuration Assistant, Version 11.2.0.0.2 Production
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Enter the following information:
Database unique name: racdb
Service name: racdb.racnode.com
Listener ORACLE_HOME [ /u01/app/11.2.0/grid ]: (回车)
Password for SYS user: *******
Central agent home: /u01/app/oracle/product/11.2.0/dbhome_1
Do you wish to continue? [yes(Y)/no(N)]: Y
3.启动和关闭集群系统的命令
(1) 启动集群件和集群数据库
集群系统默认是自动启动的,手工启动集群件的命令是:
-bash-3.00# cd /u01/app/11.2.0/grid/bin (root用户)
-bash-3.00# ./crsctl start cluster
也可以以下命令(在11.2版本中不建议使用),以grid用户执行
-bash-3.00# su - grid
-bash-3.00$ crs_start -all
启动集群数据库
-bash-3.00$ su - oracle
-bash-3.00$ srvctl start database -d racdb (启动全部实例节点)
-bash-3.00$ srvctl start instance -d racdb -n racdb1 (节点1上启动数据库实例)
-bash-3.00$ srvctl start instance -d racdb -n racdb2 (节点2上启动数据库实例)
(2) 关闭RAC集群数据库和集群件
先关闭集群数据库
-bash-3.00$ su - oracle
-bash-3.00$ srvctl stop database -d racdb
再关闭集群件(root用户)
-bash-3.00$ su -
-bash-3.00# cd /u01/app/11.2.0/grid/bin
-bash-3.00# ./crsctl stop cluster
4.RAC集群系统日常维护命令
集群系统的维护主要使用srvctl命令就可以完成,我们可以使用帮助命令来查看其使用,在oracle用户下执行 srvctl -help 来查看帮助信息
-bash-3.00# su - oracle
-bash-3.00$ srvctl -help
Usage: srvctl []
commands: enable|disable|start|stop|relocate|status|add|remove|modify|getenv|setenv|unsetenv|config
objects: database|instance|service|nodeapps|vip|asm|diskgroup|listener|srvpool|server|scan|scan_listener|oc4j|home|filesystem|gns
For detailed help on each command and object and its options use:
srvctl -h or
srvctl -h
该命令的格式和用法都列出来了,继续查看具体用法就在命令和对象的后面加 -h 参数,这样一层一层的查看帮助就可以得到全部的使用方法而不用查看其它的资料。
-bash-3.00$ srvctl add -h (给集群添加对象,比较重要的如:service, srvpool等等)
-bash-3.00$ srvctl remove -h (删除集群的对象)
-bash-3.00$ srvctl modify -h (修改集群的对象)
-bash-3.00$ srvctl config -h (查看集群内对象的配置信息)
-bash-3.00$ srvctl status -h (查看集群内对象的状态信息)
-bash-3.00$ srvctl relocate -h (把集群的对象重定位到其它实例节点,如oc4j, gns只在一个实例节点上有效,使用该命令可以把对象转移到其它实例节点)
-bash-3.00$ srvctl enable -h (把集群内已经存在的对象置于可用状态)
-bash-3.00$ srvctl disable -h (把集群内已经存在的对象置于不可用状态)
-bash-3.00$ srvctl start -h (启动集群内已经存在的对象)
-bash-3.00$ srvctl stop -h (停止集群内已经存在的对象)
常用的比如:
◆查看全部安装集群数据库名称
-bash-3.00$ srvctl config database
racdb
◆查看指定的集群数据库的配置信息
-bash-3.00$ srvctl config database -d racdb
Database unique name: racdb
Database name: racdb
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +RACDB_DATA/racdb/spfileracdb.ora
Domain: racnode.com
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: racdb
Database instances: racdb1,racdb2
Disk Groups: RACDB_DATA,FRA
Services: MYRAC
Database is administrator managed
◆显示节点应用程序的配置
-bash-3.00$ srvctl config nodeapps -a -g -s -e
VIP exists.:racnode1
VIP exists.: /192.168.1.201/192.168.1.201/255.255.255.0/e1000g0
VIP exists.:racnode2
VIP exists.: /192.168.1.205/192.168.1.205/255.255.255.0/e1000g0
GSD exists.
ONS daemon exists. Local port 6100, remote port 6200
eONS daemon exists. Multicast port 16717, multicast IP address 234.92.69.133, listening port 2016
◆列出集群中所有运行的实例
-bash-3.00$ sqlplus / as sysdba
SQL> col host format a10
SQL> col db_status format a8
SQL> col inst_name format a8
SQL> SELECT inst_id, instance_number inst_no, instance_name inst_name,
2 parallel, status, database_status db_status, active_state state,
3 host_name host
4 FROM gv$instance
5 Order By inst_id;
INST_ID INST_NO INST_NAM PAR STATUS DB_STATU STATE HOST
---------- ---------- -------- --- ------------ -------- --------- ----------
1 1 racdb1 YES OPEN ACTIVE NORMAL racnode1
2 2 racdb2 YES OPEN ACTIVE NORMAL racnode2
◆列出所有数据文件、临时数据文件、日志文件、控制文件
SQL> set pagesize 100; (设置sqlplus的显示行数,可以一次显示100行记录)
SQL> set linesize 100; (设置sqlplus的显示总宽度, 默认80,设置成100或者更宽都可以)
SQL> col file_size format a9;
SQL> col file# format 99999; (格式化数值类型的字段)
SQL>
SQL> SELECT 'data_file' as file_type, file#, creation_time, status, name, to_char(bytes/(1024*1024) || 'M') as file_size FROM v$datafile
2 union
3 SELECT 'temp_file' as file_type, file#, creation_time, status, name, to_char(bytes/(1024*1024) || 'M') as file_size FROM v$tempfile
4 union
5 SELECT 'log_file' as file_type, group#, null as creation_time, type, member, null as file_size FROM v$logfile
6 union
7 SELECT 'control_file' as file_type, null as file#, null as creation_time, status, name, null as file_size FROM v$controlfile;
FILE_TYPE FILE# CREATION_ STATUS NAME FILE_SIZE
------------ ------ --------- ------- ---------------------------------------------------- ---------
control_file +FRA/racdb/controlfile/current.256.711918025
control_file +RACDB_DATA/racdb/controlfile/current.260.711918019
data_file 1 20-NOV-09 SYSTEM +RACDB_DATA/racdb/datafile/system.256.711917577 <
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26712/viewspace-1031708/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26712/viewspace-1031708/