斑竹网络专注为中小企业客户提供以管理服务为核心的IT全方位服务 https://www.sysadm.cn
分类: Oracle
2013-11-28 09:43:26
建立多个实例和数据库
(整理时间:2008-06-06)
(系统环境:oracle 9i)
RedHat AS4)
1、 将原来的/opt/oracle/product/9.2.0.4/dbs/spfilejsunicom.ora 复制成新的,以便新建立netplat实例使用
$ cd /opt/oracle/product/9.2.0.4/dbs/
$ cp spfilejsunicom.ora spfilenewplat.ora
然后编译spfilenewplat.ora文件,将以下行修改成以下内容:
*.instance_name='newplat'
*.db_name='newplat'
即实例名和数据库名都换成新实例名
然后su – oracle
$ sqlplus “/as sysdba”
SQL> create pfile from spfile;
2、 建立初始化文件
$ cd /$ORACLE_HOME/dbs
$ cp initjsunicom.ora initnewplat.ora
然后编辑initnewplat.ora文件,修改以下行的内容(红色部分)
*.aq_tm_processes=1
*.background_dump_dest='/opt/oracle/admin/newplat/bdump'
*.compatible='9.2.0.0.0'
*.control_files='/oradata/newplat/control01.ctl','/oradata/newplat/control02.ctl','/oradata/newplat/control03.ctl'
*.core_dump_dest='/opt/oracle/admin/newplat/cdump'
*.db_block_size=8192
*.db_cache_size=612368384
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='newplat'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=newplatXDB)'
*.fast_start_mttr_target=300
*.hash_join_enabled=TRUE
*.instance_name='newplat'
*.java_pool_size=20971520
*.job_queue_processes=10
*.large_pool_size=120586240
*.log_archive_dest_1='LOCATION=/oradata/archive'
*.log_archive_dest_state_1='enable'
*.log_archive_format='%t_%s.dbf'
*.log_archive_start=true
*.open_cursors=300
*.pga_aggregate_target=271581184
*.processes=150
*.query_rewrite_enabled='FALSE'
*.remote_login_passwordfile='EXCLUSIVE'
*.shared_pool_size=203423744
*.sort_area_size=524288
*.star_transformation_enabled='FALSE'
*.timed_statistics=TRUE
*.user_dump_dest='/opt/oracle/admin/newplat/udump'
3、 建立相应的目录,记住用oracle业建立
$ mkdir /arch_log/newplat
$ mkdir /oradata/newplat
$ mkdir /opt/oracle/admin/newplat
$ mkdir /opt/oracle/admin/newplat/create
$ mkdir /opt/oracle/admin/newplat/bdump
$ mkdir /opt/oracle/admin/newplat/cdump
$ mkdir /opt/oracle/admin/newplat/pfile
$ mkdir /opt/oracle/admin/newplat/udump
$ mkdir /opt/oracle/admin/newplat/scripts
4、 生成密码文件
$ export ORACLE_SID='newplat'
编辑/etc/oratab文件,添加入下面这一行
$ vi /etc/oratab
newplat:/opt/oracle/product/9.2.0.4:Y
$ /opt/oracle/product/9.2.0.4/bin/orapwd file=/opt/oracle/product/9.2.0.4/dbs/orapwnewplat password=bwyy1679
注意:
如果之前已经试图创建一个数据库没有成功之后,可能需要要密码文件删除掉重新生成,否则有可以出现如下错误
ORA-01501: CREATE DATABASE failed
ORA-01991: invalid password file '/opt/oracle/product/9.2.0.4/dbs/orapwnewplat'
5、 创建数据库
$ sqlplus /nolog
SQL> connect SYS/change_on_install as SYSDBA
SQL> startup nomount pfile="/opt/oracle/product/9.2.0.4/dbs/initnewplat.ora";
显示信息如下:
ORACLE instance started.
Total System Global Area 1024530448 bytes
Fixed Size 452624 bytes
Variable Size 402653184 bytes
Database Buffers 620756992 bytes
Redo Buffers 667648 bytes
然后执行下列语句子
CREATE DATABASE newplat
LOGFILE group 1 ('/oradata/newplat/redo01.log') SIZE 100M,
group 2 ('/oradata/newplat/redo02.log') SIZE 100M,
group 3 ('/oradata/newplat/redo03.log') SIZE 100M
DATAFILE '/oradata/newplat/system.dbf' SIZE 300M
CHARACTER SET ZHS16GBK
national character set utf8
EXTENT MANAGEMENT LOCAL
default temporary tablespace ts_temp
tempfile '/oradata/newplat/temp01.dbf' size 50M autoextend on next 50M maxsize 300M;
系统显示下列信息,表示数据库已经创建完成
6、 建立表空间文件
a. 建立索引表空间
SQL> CREATE TABLESPACE "INDX" LOGGING DATAFILE ' /oradata/newplat/indx01.dbf' SIZE 20M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;
b. 建立tools表空间
CREATE TABLESPACE "TOOLS" LOGGING DATAFILE '/oradata/newplat/tools01.dbf' SIZE 10M REUSE AUTOEXTEND ON NEXT 320K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;
c. 建立用户表空间
SQL> CREATE TABLESPACE "USERS" LOGGING DATAFILE '/oradata/newplat/users01.dbf' SIZE 20M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;
7、 创建数据字典及其它相关包
SQL> @/opt/oracle/product/9.2.0.4/rdbms/admin/catalog.sql;
SQL> @/opt/oracle/product/9.2.0.4/rdbms/admin/catexp7.sql
SQL> @/opt/oracle/product/9.2.0.4/rdbms/admin/catblock.sql;
SQL> @/opt/oracle/product/9.2.0.4/rdbms/admin/catproc.sql
SQL> @/opt/oracle/product/9.2.0.4/rdbms/admin/catoctk.sql;
SQL> @/opt/oracle/product/9.2.0.4/rdbms/admin/owminst.plb;