推荐于2016-10-01 · 知道合伙人数码行家
关注
展开全部
操作顺序如下:
1.创建实例启动用的参数文件。在程序默认的参数文件里修改即可:重命名规则 initSID.ora
/u01/oracle/product/11.2.0/db_1/dbs/ 下,目录尽量使用绝对路径,采用ORACLE_BASE等环境变量有可能报错。
例 initcrm.ora
db_name='crm' --修改
#memory_target=500m --注释掉
sga_target=200m --添加
pga_aggregate_target=60m --添加
processes = 150
audit_file_dest='/u01/oracle/admin/crm/adump' --建立目录
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/u01/oracle/flash_recovery_area' --建立目录
db_recovery_file_dest_size=2G
diagnostic_dest='/u01/oracle' ---修改
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
2.创建相应目录:
mkdir -p /u01/oracle/admin/ora11g/adump
mkdir -p /u01/oracle/admin/ora11g/dpdump
mkdir -p /u01/oracle/flash_recovery_area
3.创建密码文件:命名规则 orapwSID,目录依旧是 /u01/oracle/product/11.2.0/db_1/dbs/
Linux下orapw+实例名
Windows下pwd+实例名
$ orapwd file=orapwora11g password=oracle
4.创建数据库实例
设置环境变量 export ORACLE_SID=crm
执行以下命令
sqlplus /nolog
conn / as sysdba
注意:本处可能报错需要可能的原因: a)glibc-devel-2.5-58.el5_6.4、libaio-0.3.106-5包是否已安装,命令分别为rpm -q glibc-devel、rpm -q libaio
b)oracle目录权限不足或属组不对,chmod 6751 oracle 授权、chown -R oracle.oinstall /u01/oracle 修改属组
执行建库脚本:
startup nomount pfile="/u01/oracle/product/11.2.0.1/db1/dbs/initcrm.ora";
CREATE DATABASE "crm"
MAXINSTANCES 8
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
DATAFILE '/u01/oracle/oradata/system01.dbf' SIZE 1024M REUSE
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/u01/oracle/oradata/sysaux01.dbf' SIZE 500M REUSE
SMALLFILE DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/u01/oracle/oradata/temp01.dbf' SIZE 20M REUSE
SMALLFILE UNDO TABLESPACE "UNDOTBS1" DATAFILE '/u01/oracle/oradata/undo01.dbf' SIZE 300M REUSE
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
LOGFILE GROUP 1 ('/u01/oracle/oradata/log01.dbf') SIZE 50M,
GROUP 2 ('/u01/oracle/oradata/log02.dbf') SIZE 50M,
GROUP 3 ('/u01/oracle/oradata/log03.dbf') SIZE 50M;
创建USERS表空间
CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/u01/app/oradata/user01.dbf' SIZE 1000M REUSE EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
ALTER DATABASE DEFAULT TABLESPACE "USERS";
------------------------------------------
SQL> create spfile from pfile;
File created.
-----------------------------------------
sqlplus / as sysdba
SQL> show user;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/catalog.sql;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/catblock.sql;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/catproc.sql;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/catoctk.sql;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/owminst.plb;
使用system用户编译
@/u01/oracle/product/11.2.0.1/db1/sqlplus/admin/pupbld.sql;
@/u01/oracle/product/11.2.0.1/db1/sqlplus/admin/help/hlpbld.sql helpus.sql;
使用sys用户编译
@/u01/oracle/product/11.2.0.1/db1/javavm/install/initjvm.sql;
@/u01/oracle/product/11.2.0.1/db1/xdk/admin/initxml.sql;
@/u01/oracle/product/11.2.0.1/db1/xdk/admin/xmlja.sql;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/catjava.sql;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/catexf.sql;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/catqm.sql change_on_install SYSAUX TEMP YES;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/catxdbj.sql;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/catrul.sql;
spool /oracle/admin/edidb/scripts/ordinst.log append
@/u01/oracle/product/11.2.0.1/db1/ord/admin/ordinst.sql SYSAUX SYSAUX;
spool off
spool /u01/oracle/admin/ora11g/scripts/interMedia.log append
@/u01/oracle/product/11.2.0.1/db1/ord/im/admin/iminst.sql;
spool off
set echo on
spool /oracle/admin/edidb/scripts/lockAccount.log append
BEGIN
FOR item IN ( SELECT USERNAME FROM DBA_USERS WHERE ACCOUNT_STATUS IN ('OPEN', 'LOCKED', 'EXPIRED') AND USERNAME NOT IN (
'SYS','SYSTEM') )
LOOP
dbms_output.put_line('Locking and Expiring: ' || item.USERNAME);
execute immediate 'alter user ' ||
sys.dbms_assert.enquote_name(
sys.dbms_assert.schema_name(
item.USERNAME),false) || ' password expire account lock' ;
END LOOP;
END;
/
spool off
到此,数据库实例建立完毕。
1.创建实例启动用的参数文件。在程序默认的参数文件里修改即可:重命名规则 initSID.ora
/u01/oracle/product/11.2.0/db_1/dbs/ 下,目录尽量使用绝对路径,采用ORACLE_BASE等环境变量有可能报错。
例 initcrm.ora
db_name='crm' --修改
#memory_target=500m --注释掉
sga_target=200m --添加
pga_aggregate_target=60m --添加
processes = 150
audit_file_dest='/u01/oracle/admin/crm/adump' --建立目录
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/u01/oracle/flash_recovery_area' --建立目录
db_recovery_file_dest_size=2G
diagnostic_dest='/u01/oracle' ---修改
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
2.创建相应目录:
mkdir -p /u01/oracle/admin/ora11g/adump
mkdir -p /u01/oracle/admin/ora11g/dpdump
mkdir -p /u01/oracle/flash_recovery_area
3.创建密码文件:命名规则 orapwSID,目录依旧是 /u01/oracle/product/11.2.0/db_1/dbs/
Linux下orapw+实例名
Windows下pwd+实例名
$ orapwd file=orapwora11g password=oracle
4.创建数据库实例
设置环境变量 export ORACLE_SID=crm
执行以下命令
sqlplus /nolog
conn / as sysdba
注意:本处可能报错需要可能的原因: a)glibc-devel-2.5-58.el5_6.4、libaio-0.3.106-5包是否已安装,命令分别为rpm -q glibc-devel、rpm -q libaio
b)oracle目录权限不足或属组不对,chmod 6751 oracle 授权、chown -R oracle.oinstall /u01/oracle 修改属组
执行建库脚本:
startup nomount pfile="/u01/oracle/product/11.2.0.1/db1/dbs/initcrm.ora";
CREATE DATABASE "crm"
MAXINSTANCES 8
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
DATAFILE '/u01/oracle/oradata/system01.dbf' SIZE 1024M REUSE
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/u01/oracle/oradata/sysaux01.dbf' SIZE 500M REUSE
SMALLFILE DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/u01/oracle/oradata/temp01.dbf' SIZE 20M REUSE
SMALLFILE UNDO TABLESPACE "UNDOTBS1" DATAFILE '/u01/oracle/oradata/undo01.dbf' SIZE 300M REUSE
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
LOGFILE GROUP 1 ('/u01/oracle/oradata/log01.dbf') SIZE 50M,
GROUP 2 ('/u01/oracle/oradata/log02.dbf') SIZE 50M,
GROUP 3 ('/u01/oracle/oradata/log03.dbf') SIZE 50M;
创建USERS表空间
CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/u01/app/oradata/user01.dbf' SIZE 1000M REUSE EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
ALTER DATABASE DEFAULT TABLESPACE "USERS";
------------------------------------------
SQL> create spfile from pfile;
File created.
-----------------------------------------
sqlplus / as sysdba
SQL> show user;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/catalog.sql;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/catblock.sql;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/catproc.sql;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/catoctk.sql;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/owminst.plb;
使用system用户编译
@/u01/oracle/product/11.2.0.1/db1/sqlplus/admin/pupbld.sql;
@/u01/oracle/product/11.2.0.1/db1/sqlplus/admin/help/hlpbld.sql helpus.sql;
使用sys用户编译
@/u01/oracle/product/11.2.0.1/db1/javavm/install/initjvm.sql;
@/u01/oracle/product/11.2.0.1/db1/xdk/admin/initxml.sql;
@/u01/oracle/product/11.2.0.1/db1/xdk/admin/xmlja.sql;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/catjava.sql;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/catexf.sql;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/catqm.sql change_on_install SYSAUX TEMP YES;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/catxdbj.sql;
@/u01/oracle/product/11.2.0.1/db1/rdbms/admin/catrul.sql;
spool /oracle/admin/edidb/scripts/ordinst.log append
@/u01/oracle/product/11.2.0.1/db1/ord/admin/ordinst.sql SYSAUX SYSAUX;
spool off
spool /u01/oracle/admin/ora11g/scripts/interMedia.log append
@/u01/oracle/product/11.2.0.1/db1/ord/im/admin/iminst.sql;
spool off
set echo on
spool /oracle/admin/edidb/scripts/lockAccount.log append
BEGIN
FOR item IN ( SELECT USERNAME FROM DBA_USERS WHERE ACCOUNT_STATUS IN ('OPEN', 'LOCKED', 'EXPIRED') AND USERNAME NOT IN (
'SYS','SYSTEM') )
LOOP
dbms_output.put_line('Locking and Expiring: ' || item.USERNAME);
execute immediate 'alter user ' ||
sys.dbms_assert.enquote_name(
sys.dbms_assert.schema_name(
item.USERNAME),false) || ' password expire account lock' ;
END LOOP;
END;
/
spool off
到此,数据库实例建立完毕。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询