時間:2015-06-28 00:00:00 來源:IT貓撲網(wǎng) 作者:網(wǎng)管聯(lián)盟 我要評論(0)
在服務器端配置listener.ora和tnsnames.ora
修改lisnter.ora和tnsnames.ora文件,以增加listener.
這一部分,RAC環(huán)境和非RAC環(huán)境沒有區(qū)別,可以參考oracle的文檔.
可以一個listener給三個instance服務,也可以啟動三個listener給三個instance服務.
我啟動了三個listener.
Listener.ora
LSNR1 =
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=your_ip_or_name)(PORT=1521)))
LSNR2 =
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=your_ip_or_name)(PORT=1522)))
LSNR3 =
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=your_ip_or_name)(PORT=1523)))
tnsnames.ora
lsnr1=(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=your_ip_or_name)(PORT=1521)))
lsnr2=(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=your_ip_or_name)(PORT=1522)))
lsnr3=(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=your_ip_or_name)(PORT=1523)))
將your_ip_or_name替換為你的IP地址或者hostname.
Rac.test.com替換為你init.ora文件中設置的db_name.db_domain
啟動三個listener.
$ lsnrctl start lsnr1
$ lsnrctl start lsnr2
$ lsnrctl start lsnr3
創(chuàng)建數(shù)據(jù)庫
可以運行dbca用圖形界面來創(chuàng)建,也可以用命令行來創(chuàng)建.
因為以前沒有創(chuàng)建過集群下的數(shù)據(jù)庫,因此我用圖形界面來創(chuàng)建腳本,修改后用命令行來創(chuàng)建.
先確認ORACM和GSD已經(jīng)啟動:
$ ps -ef | grep oracm
root 3056 1 0 10:50 pts/1 00:00:00 oracm
root 3057 3056 0 10:50 pts/1 00:00:00 oracm
root 3059 3057 0 10:50 pts/1 00:00:00 oracm
root 3060 3057 0 10:50 pts/1 00:00:00 oracm
root 3061 3057 0 10:50 pts/1 00:00:00 oracm
root 3062 3057 0 10:50 pts/1 00:00:00 oracm
root 3063 3057 0 10:50 pts/1 00:00:00 oracm
root 3064 3057 0 10:50 pts/1 00:00:00 oracm
root 3065 3057 0 10:50 pts/1 00:00:00 oracm
root 3338 3057 0 11:36 pts/1 00:00:00 oracm
root 3362 3057 0 11:36 pts/1 00:00:00 oracm
oracle 3482 2932 0 11:38 pts/1 00:00:00 grep oracm
$ gsdctl stat
GSD is running on the local node
然后運行dbca啟動數(shù)據(jù)庫配置助手.
在歡迎畫面中,選擇Oracle cluster database, 然后一路繼續(xù)就可以了.
在最后的總結畫面上,可以選擇創(chuàng)建數(shù)據(jù)庫,也可以選擇創(chuàng)建腳本.我選擇了創(chuàng)建腳本.
手工修改腳本為自己想要的樣子,然后跟非集群環(huán)境一樣手工創(chuàng)建數(shù)據(jù)庫.數(shù)據(jù)文件使用本地管理,不用數(shù)據(jù)字典管理.并創(chuàng)建缺省的撤消表空間(undo tablespace)和臨時表空間.
注意:
根據(jù)我的經(jīng)驗,SGA太小,在創(chuàng)建數(shù)據(jù)字典的時候會失敗,因此SGA可以大一些.但因為是集群,需要啟動多個instance,所以在數(shù)據(jù)字典創(chuàng)建完以后,即catalog.sql,catproc.sql,catclust.sql運行完以后,需要將SGA改小一點.
修改init.ora文件,并拷貝到$ORACLE_HOME/dbs下,改名字為initrac.ora.
我是一個instance對應一個listener.也可以一個listener響應多個instnce.
其余參數(shù)可以自己根據(jù)自己的情況進行設置,以下是cluster的參數(shù):
undo_management=AUTO
undo_retention=10800
cluster_database=true
cluster_database_instances=5
rac1.instance_name=rac1
rac1.instance_number=1
rac1.local_listener=lsnr1
rac1.thread=1
rac1.undo_tablespace=UNDOTBS1
rac2.instance_name=rac2
rac2.instance_number=2
rac2.local_listener=lsnr2
rac2.thread=2
rac2.undo_tablespace=UNDOTBS2
rac3.instance_name=rac3
rac3.instance_number=3
rac3.local_listener=lsnr3
rac3.thread=3
rac3.undo_tablespace=UNDOTBS3
如果要多個instance都由一個listener來響應,則改以下兩行:
rac2.local_listener=lsnr1
rac3.local_listener=lsnr1
注意:
盡管數(shù)據(jù)庫名字叫rac,但啟動的實例名字不能叫rac.我將ORACLE_SID分別設置成了rac1,rac2,rac3.
然后啟動第一個實例,創(chuàng)建數(shù)據(jù)庫:
$ export ORACLE_SID=rac1
$ sqlplus /nolog
SQL*Plus: Release 9.2.0.4.0????j? - Production on Fri Nov 21 13:43:22 2003
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> conn / as sysdba;
Connected to an idle instance.
SQL> startup pfile=/u01/app/oracle/product/9.2.0.4.0/dbs/initrac.ora;
ORACLE instance started.
Total System Global Area 38867968 bytes
Fixed Size 451584 bytes
Variable Size 33554432 bytes
Database Buffers 4194304 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL>
創(chuàng)建數(shù)據(jù)庫的命令:
CREATE DATABASE rac
MAXINSTANCES 32
MAXLOGHISTORY 100
MAXLOGFILES 192
MAXLOGMEMBERS 3
MAXDATAFILES 1024
DATAFILE '/u02/oradata/rac/rac/system01.dbf' SIZE 100M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE 1000M
EXTENT MANAGEMENT LOCAL
DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/u02/oradata/rac/rac/temp01.dbf' SIZE 40M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE 1000M
UNDO TABLESPACE "UNDOTBS1" DATAFILE '/u02/oradata/rac/rac/undotbs01.dbf' SIZE 50M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE 1000M
CHARACTER SET ZHS16GBK
LOGFILE GROUP 1 ('/u02/oradata/rac/rac/redo01.log') SIZE 10M REUSE,
GROUP 2 ('/u02/oradata/rac/rac/redo02.log') SIZE 10M REUSE,
GROUP 3 ('/u02/oradata/rac/rac/redo03.log') SIZE 10M REUSE;
然后創(chuàng)建數(shù)據(jù)字典.
以sysdba身份運行:
SQL> @?/rdbms/admin/catalog.sql;
SQL> @?/rdbms/admin/catproc.sql;
SQL> @?/rdbms/admin/catclust.sql;
以system身份運行:
SQL> @?/sqlplus/admin/pupbld.sql;
創(chuàng)建并啟動多個instance
在啟動多個instance前,需要為每個instance增加一個undo tablespace, 并增加一組 redo logfile.
SQL>CREATE UNDO TABLESPACE UNDOTBS2 DATAFILE '/u02/oradata/rac/rac/undotbs02.dbf' SIZE 50M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE 1000M;
SQL>CREATE UNDO TABLESPACE UNDOTBS3 DATAFILE '/u02/oradata/rac/rac/undotbs03.dbf' SIZE 50M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE 1000M;
SQL> ALTER DATABASE ADD LOGFILE THREAD 2 '/u02/oradata/rac/rac/redo2_1.log' SIZE 10M;
SQL> ALTER DATABASE ADD LOGFILE THREAD 2 '/u02/oradata/rac/rac/redo2_2.log' SIZE 10M;
SQL> ALTER DATABASE ADD LOGFILE THREAD 3 '/u02/oradata/rac/rac/redo3_1.log' SIZE 10M;
SQL> ALTER DATABASE ADD LOGFILE THREAD 3 '/u02/oradata/rac/rac/redo3_1.log' SIZE 10M;
SQL>
然后就可以啟動多個instance了.
$ export ORACLE_SID=rac2
$ sqlplus /nolog
SQL*Plus: Release 9.2.0.4.0 - Production on Fri Nov 21 15:11:16 2003
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> conn / as sysdba;
Connected to an idle instance.
SQL> startup pfile=/u01/app/oracle/product/9.2.0.4.0/dbs/initrac.ora
ORACLE instance started.
Total System Global Area 38867968 bytes
Fixed Size 451584 bytes
Variable Size 33554432 bytes
Database Buffers 4194304 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL>
然后再啟動rac3.
注意:
如果SGA配置太大,啟動多個instan
關鍵詞標簽:詳解,過程,安裝,SQL&g
相關閱讀
熱門文章 Oracle中使用alter table來增加,刪除,修改列的語法 oracle中使用SQL語句修改字段類型-oracle修改SQL語句案例 誤刪Oracle數(shù)據(jù)庫實例的控制文件 為UNIX服務器設置Oracle全文檢索
人氣排行 oracle中使用SQL語句修改字段類型-oracle修改SQL語句案例 Oracle中使用alter table來增加,刪除,修改列的語法 ORACLE SQL 判斷字符串是否為數(shù)字的語句 ORACLE和SQL語法區(qū)別歸納(1) oracle grant 授權語句 ORACLE修改IP地址后如何能夠使用 如何加速Oracle大批量數(shù)據(jù)處理 Oracle刪除表的幾種方法