在LINUX平台上手动创建数据库(oracle 10g)(在一个oracle服务器上启动两个实例)
1.首先设置要创建的ORACLE的SID,如果在.bash_profile文件里设置里该变量,就不用设置了。
$echo $ORACEL_SID
mdy
如果没有设置,就手动设置,如果一个服务器上要运行多个ORACLE实例,也需要手动设置。
export ORACLE_SID=gcm
2. 创建需要的诊断目录,这些目录都是ORACLE进程遇到错误或用户手动TRACE时需要的。
mkdir -p $ORACLE_BASE/admin/gcm/adump
mkdir -p $ORACLE_BASE/admin/gcm/bdump
mkdir -p $ORACLE_BASE/admin/gcm/cdump
mkdir -p $ORACLE_BASE/admin/gcm/udump
mkdir -p $ORACLE_BASE/admin/gcm/pfile
创建oracle的数据文件目录
mkdir -p $ORACLE_BASE/oradata/gcm
3. 创建ORACLE的参数文件$ORACLE_HOME/dbs/initgcm.ora 内容如下:
aq_tm_processes=0
audit_file_dest=/oracle/admin/gcm/adump
background_dump_dest=/oracle/admin/gcm/bdump
compatible=10.2.0.1.0
control_files=/oracle/oradata/gcm/control01.ctl, /oracle/oradata/gcm/control02.ctl, /oracle/oradata/gcm/control03.ctl
core_dump_dest=/oracle/admin/gcm/cdump
db_block_size=8192
db_domain=""
db_file_multiblock_read_count=16
db_name=gcm
instance_name=gcm
dispatchers="(PROTOCOL=TCP) (SERVICE=gcmXDB)"
job_queue_processes=10
nls_length_semantics=BYTE
open_cursors=300
pga_aggregate_target=94371840
processes=150
remote_login_passwordfile=EXCLUSIVE
resource_manager_plan=""
sessions=170
sga_target=285212672
undo_management=AUTO
undo_retention=900
undo_tablespace=UNDOTBS1
user_dump_dest=/oracle/admin/gcm/udump
4.创建密码文件
orapwd file=$ORACLE_HOME/dbs/orapwgcm password=admin entries=5 force=y
5.创建oracle的建库脚本 createdb.sql,内容如下:
create database gcm
MAXINSTANCES 1
MAXLOGHISTORY 1
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXDATAFILES 100
DATAFILE
'/oracle/oradata/gcm/system01.dbf' size 100m reuse autoextend on next 1m maxsize unlimited extent management local
sysaux datafile
'/oracle/oradata/gcm/sysaux01.dbf' size 100m reuse autoextend on next 1m maxsize unlimited
default temporary tablespace TEMP tempfile
'/oracle/oradata/gcm/temp01.dbf' size 20m reuse autoextend on next 640k maxsize unlimited
undo tablespace UNDOTBS1 datafile
'/oracle/oradata/gcm/undo01.dbf' size 20m reuse autoextend on next 5M maxsize unlimited
logfile
GROUP 1 ('/oracle/oradata/gcm/redo1.dbf') size 10m,
GROUP 2 ('/oracle/oradata/gcm/redo2.dbf') size 10m,
GROUP 3 ('/oracle/oradata/gcm/redo3.dbf') size 10m
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
;
6.数据库创建完成后,再创建ORACLE的数据字典。
SQL>@/oracle/product/10g/rdbms/admin/catalog.sql
SQL>@/oracle/product/10g/rdbms/admin/catproc.sql
SQL>@/oracle/product/10g/rdbms/admin/catexp.sql
到此ORACLE手动创建过程就完成了
7.创建(新)用户:
create user gcm identified by onewavegcm;
username:新用户名的用户名
password: 新用户的密码
也可以不创建新用户,而仍然用以前的用户,如:继续利用scott用户
8.创建表空间:
create tablespace gcm datafile 'd:\data.dbf' size 300m;
tablespacename:表空间的名字
d:\data.dbf':表空间的存储位置
xxx表空间的大小,m单位为兆(M)
9.将空间分配给用户:
alter user gcm default tablespace gcm;
将名字为tablespacename的表空间分配给username
10.给用户授权:
grant connect,resource,dba to gcm;
11.然后再以楼主自己创建的用户登录,登录之后创建表即可。
conn username/password;
创建表用create table.
SELECT host_name, instance_name, version FROM v$instance;
select distinct username from v$session ;
imp gcm/onewavegcm file=gcmtable.dmp full=y
12.修改监听配置文件listener.ora
gcm =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 219.141.133.x)(PORT = 1522))
)
)
)
SID_LIST_gcm =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = gcm)
(ORACLE_HOME = /oracle/product/10g)
(SID_NAME = gcm)
)
)
13.启动实例
su oracle
export ORACLE_SID=boss
sqlplus>startup
exit
su oracle
export ORACLE_SID=gcm
sqlplus / as sysdba
>startup
14.启动监听
su oracle
#lsnrctl start #listener1
#lsnrctl start gcm #listener2
阅读(10756) | 评论(0) | 转发(0) |