oracle 11g创建数据库教程
cd /oracle/app/oracle/product/11.2.0/dbhome_1/bin ./dbca
自定义用户表空间大小。
安装过程半个小时是需要的。
2.配置oracle系统用户环境变量
使用vi等文本编缉器在~/.bash_profile中追加以下内容。
不要使用cat来添加,因为cat会将全部变量替换为当前值再写入文件,而像ORACLE_BASE这些变量是我们刚要声明的,去取值只能取回空。
alias ls="ls -FA"
ORACLE_SID=lsdb; export ORACLE_SID
ORACLE_UNQNAME=lsdb; export ORACLE_UNQNAME
ORACLE_BASE=/oracle/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME
DB_HOME=$ORACLE_HOME; export DB_HOME
GI_HOME=/oracle/app/11.2.0/grid; export GI_HOME
ORA_NLS11=$DB_HOME/nls/data; export ORA_NLS11
TNS_ADMIN=$DB_HOME/network/admin; export TNS_ADMIN
NLS_DATE_FORMAT="DD-MON-YYYY HH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG="AMERICAN_AMERICA.AL32UTF8"; export NLS_LANG
#ORACLE_TERM=xterm; export ORACLE_TERM
#THREADS_FLAG=native; export THREADS_FLAG
#JAVA_HOME=/usr/local/java; export JAVA_HOME
#SQLPATH=/oracle/app/common/oracle/sql; export SQLPATH
#ORACLE_PATH=/oracle/app/common/oracle/sql; export ORACLE_PATH
PATH=$DB_HOME/bin:$DB_HOME/OPatch:$GI_HOME/bin:$PATH
PATH=$PATH:/bin:/usr/bin:/usr/bin/X11:/usr/local/bin
export PATH
LD_LIBRARY_PATH=$DB_HOME/lib:$LD_LIBRARY_PATH
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DB_HOME/oracm/lib
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$DB_HOME/JRE:$CLASSPATH
CLASSPATH=$CLASSPATH:$DB_HOME/jlib
CLASSPATH=$CLASSPATH:$DB_HOME/rdbms/jlib
CLASSPATH=$CLASSPATH:$DB_HOME/network/jlib
export CLASSPATH
TEMP=/tmp
TMPDIR=/tmp
export TEMP TMPDIR
source ~/.bash_profile
3.创建表空间和用户
sqlplus / as sysdba
create tablespace lsdb_data datafile size 1G;
create user lsdb identified by lsdb123#
default tablespace lsdb_data
temporary tablespace temp;
grant connect to lsdb;
grant resource to lsdb;
grant unlimited tablespace to lsdb;
grant execute on dbms_stats to lsdb;
grant select any dictionary to lsdb;
grant create public synonym to lsdb;
grant debug connect session to lsdb;
grant create session to lsdb;
grant create procedure to lsdb;
grant create view to lsdb;
grant create synonym to lsdb;
grant create job to lsdb;
grant create table to lsdb;
grant create user to lsdb;
grant create indextype to lsdb;
grant analyze any to lsdb;
grant create database link to lsdb;
grant create cluster to lsdb;
grant create operator to lsdb;
grant create type to lsdb;
grant create trigger to lsdb;
grant create sequence to lsdb;
4.配置连接文件和监听文件并
cd $TNS_ADMIN cat >> listener.ora <<EOF LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = ls) (PORT = 1521)) ) ) ) INBOUND_CONNECT_TIMEOUT_LISTENER = 0 EOF cat >> tnsnanes.ora <<EOF LSDB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = ls)(PORT = 1521)) ) (CONNECT_DATA = (SID = lsdb) (SERVER = DEDICATED) ) ) EOF
5.启动监听和数据库
lsnrctl start lsnrctl stop sqlplus / as sysdba startup shutdown immediate