Linux版本 CentOS 6.3 OS环境 VMware® Workstation 9.0.0 build-812388 oracle安装文件位置: G:\Program Files\Red Hat Enterprise Linux 4\Exchange Data\ORACLE\oracle-xe-10.2.0.1-1.0.i386.rpm
Preparing
查询删除原有oracle服务 [root@localhost Desktop]# rpm -qa|grep oracle oracle-xe-10.2.0.1-1.0.i386 [root@localhost Desktop]# rpm -e oracle-xe-10.2.0.1-1.0.i386
创建用户和组
1 创建组
groupadd dba
2 查询组
cat /etc/group
3 创建用户
先删除 userdel -r oracle
useradd -g 组名 用户名
useradd -g -dba oracle
4 查询用户
ls /home
5 创建密码
[root@localhost Oracle]# passwd oracle
Changing password for user oracle.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
1 Down Load RPM from following location
http://www.oracle.com/technetwork/products/express-edition/downloads/index.html
2 Installing oracle rpm package
以oracle用户身份登陆,执行如下命令:
rpm -ivh oracle-xe-10.2.0.1-1.0.i386.rpm
3 Configuring Oracle DB
#su root #/etc/init.d/oracle-xe configure
set up as following (set up port listener and so on)
Oracle Database 10g Express Edition Configuration ------------------------------------------------- This will configure on-boot properties of Oracle Database 10g Express Edition. The following questions will determine whether the database should be starting upon system boot, the ports it will use, and the passwords that will be used for database accounts. Press <Enter> to accept the defaults. Ctrl-C will abort. Specify the HTTP port that will be used for Oracle Application Express [8080]:7070 Specify a port that will be used for the database listener [1521]: Specify a password to be used for database accounts. Note that the same password will be used for SYS and SYSTEM. Oracle recommends the use of different passwords for each database account. This can be done after initial configuration: Password can't be null. Enter password: Confirm the password: Do you want Oracle Database 10g Express Edition to be started on boot (y/n) [y]: Starting Oracle Net Listener...Done Configuring Database...Done Starting Oracle Database 10g Express Edition Instance...Done Installation Completed Successfully. To access the Database Home Page go to "http://127.0.0.1:7070/apex"
Oracle basic info:
ORACLE_BASE=/usr/lib/oracle/xe/app/oracle; ORACLE_HOME=$ORACLE_BASE/product/10.2.0/server;
--------------------------------------------
data文件位置
/usr/lib/oracle/xe/oradata/XE
-rw-r----- 1 oracle dba 7061504 Feb 16 12:42 control.dbf
-rw-r----- 1 oracle dba 230694912 Feb 16 12:29 sysaux.dbf
-rw-r----- 1 oracle dba 356524032 Feb 16 12:34 system.dbf
-rw-r----- 1 oracle dba 20979712 Feb 16 05:03 temp.dbf
-rw-r----- 1 oracle dba 220209152 Feb 16 12:39 undo.dbf
-rw-r----- 1 oracle dba 104865792 Feb 16 04:30 users.dbf
把个人用户home目录下的.bashrc 和.bash_profile拷贝到ORACLE_BASE目录下
cp /root/.bashrc /usr/lib/oracle/xe/app/oracle/.bashrc
cp /root/.bash_profile /usr/lib/oracle/xe/app/oracle/.bash_profile
改变文件所属
# chown oracle .bash_profile # chown oracle .bashrc # chmod 755 .bash_profile # chmod 755 .bashrc
设置环境变量
#vi /etc/profile # Oracle Settings TMP=/tmp; export TMP TMPDIR=$TMP; export TMPDIR ORACLE_BASE=/usr/lib/oracle/xe/app/oracle; export ORACLE_BASE ORACLE_HOME=$ORACLE_BASE/product/10.2.0/server/bin/oracle; export ORACLE_HOME ORACLE_SID=XE; export ORACLE_SID ORACLE_TERM=xterm; export ORACLE_TERM PATH=/usr/sbin:$PATH; export PATH PATH=$ORACLE_HOME/bin:$PATH; export PATH TNS_ADMIN=$ORACLE_HOME/network/admin LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH if [ $USER = "oracle" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi fi
初始化数据库:
# su oracle cd /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/dbs/ cp init.ora initXE.ora vi initXE.ora
db_name='XE' memory_target=1G processes = 150 audit_file_dest='/usr/lib/oracle/xe/app/oracle/admin/XE/adump' audit_trail ='db' db_block_size=8192 db_domain='' #db_recovery_file_dest='/u01/app/oracle/fast_recovery_area' #db_recovery_file_dest_size=2G diagnostic_dest='/usr/lib/oracle/xe/app/oracle' dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)' open_cursors=300 remote_login_passwordfile='EXCLUSIVE' undo_tablespace='UNDOTBS1' # You may want to ensure that control files are created on separate physical # devices control_files = ('/usr/lib/oracle/xe/oradata', '/usr/lib/oracle/xe/oradata') compatible ='10.2.0'
#su oracle sqlplus /nolog
SQL> connect sys/cici123love as sysdba
SQL> startup mount
10g xe版本已经内置了一个设置好的数据库 XE, 因此不许要手动创建数据库,但是需要初始化数据库结构
运行一下两行代码:
sql> alter database open
SQL> @/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/rdbms/admin/catalog.sql SQL> @/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/rdbms/admin/catproc.sql
接下来创建用户,初始数据库中应当已经存在users表,因此直接插入数据就可以了:
SQL> create user cici identified by "xxxx"; SQL> grant dba to cici;
以该用户身份登录
SQL>exist SQL>conn cici/cici123love
插表以及数据并且测试:
SQL> create table test_table (txt varchar2(100) not null); SQL> insert into test_table values('Hello world !'); SQL> select * from test_table;
=====================Potential Issue==========================
1 database didn‘t open
则需要重新启动并装载数据库
参见 http://www.cnblogs.com/cici-new/archive/2013/02/16/2913697.html
2 ora-01033 oracle initialization or shutdown in progressreferences
http://www.cnblogs.com/cici-new/archive/2013/02/16/2913689.html
====================参考文章==================================
http://blog.csdn.net/reda0821/article/details/7816562