环境:RHEL 6.5 + Oracle Database XE 11gR2
下载地址:
http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html。
选择linux版本:oracle-xe-11.2.0-1.0.x86_64.rpm.zip。
安装步骤如下:
1. 解压:unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
Archive: oracle-xe-11.2.0-1.0.x86_64.rpm.zip
creating: Disk1/
creating: Disk1/upgrade/
inflating: Disk1/upgrade/gen_inst.sql
creating: Disk1/response/
inflating: Disk1/response/xe.rsp
inflating: Disk1/oracle-xe-11.2.0-1.0.x86_64.rpm
2. 安装:
(1)cd Disk1
(2)rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
Preparing... ########################################### [100%]
1:oracle-xe ########################################### [100%]
Executing post-install steps...
You must run '/etc/init.d/oracle-xe configure' as the root user to configure the database.
(3)/etc/init.d/oracle-xe configure
Oracle Database 11g Express Edition Configuration
-------------------------------------------------
This will configure on-boot properties of Oracle Database 11g 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 to accept the defaults.
Ctrl-C will abort.
Specify the HTTP port that will be used for Oracle Application Express [8080]:8686
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:
Confirm the password:
Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:y
Starting Oracle Net Listener...Done
Configuring database...Done
Starting Oracle Database 11g Express Edition instance...Done
Installation completed successfully.
3. 配置
安装成功后,会创建一个名为oracle的用户,主目录在:/u01/app/oracle/。
为了使用方便,我从其他用户目录下把 .bashrc 和 .bash_profile 文件拷贝到oracle用户主目录下。
# chown oracle:dba .bash_profile
# chown oracle:dba .bashrc
# chmod 755 .bashrc
# chmod 755 .bash_profile
修改.bashrc(新打开一个shell)或 .bash_profile(每次登录)文件,增加一行内容如下:
. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
允许远程用户访问:
$ sqlplus system
SQL> EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);
4. 解锁HR用户,并增加数据库连接数
(1)以DBA身份连接数据库
connect sys/welcome1 as sysdba;
(2)然后给HR Schema解锁,做有关HR Schema的实验需要设置此项。
alter user hr identified by hr account unlock;
(3)修改允许的数据库连接数
alter system set processes=500 scope=spfile;
5. 启动与停止
(1)/etc/init.d/oracle-xe start
6. 卸载
# rpm -e oracle-xe
7. 远程无法访问的问题
开始以为是防火墙和SELinux的问题,再确认防火墙和SELinux都关闭的情况下,依然无法远程访问,只能在本机访问。
经过进一步检查,这是因为使用DHCP动态获取了IP地址和主机名导致的问题。
使用hostname可以检查机器的主机名,或者从Shell Prompt中也可以看出来。
解决方法如下:
(1)修改文件:/u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
把 HOST = localhost.localdomain改成IP地址即可。
# listener.ora Network Configuration File:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/xe)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
)
)
(2)修改文件:/u01/app/oracle/product/11.2.0/xe/network/admin/tnsnames.ora
把 HOST = localhost.localdomain改成IP地址即可。
# tnsnames.ora Network Configuration File:
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
参考文献:
1. http://www.linuxidc.com/Linux/2012-08/66974.htm
下载地址:
http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html。
选择linux版本:oracle-xe-11.2.0-1.0.x86_64.rpm.zip。
安装步骤如下:
1. 解压:unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
Archive: oracle-xe-11.2.0-1.0.x86_64.rpm.zip
creating: Disk1/
creating: Disk1/upgrade/
inflating: Disk1/upgrade/gen_inst.sql
creating: Disk1/response/
inflating: Disk1/response/xe.rsp
inflating: Disk1/oracle-xe-11.2.0-1.0.x86_64.rpm
2. 安装:
(1)cd Disk1
(2)rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
Preparing... ########################################### [100%]
1:oracle-xe ########################################### [100%]
Executing post-install steps...
You must run '/etc/init.d/oracle-xe configure' as the root user to configure the database.
(3)/etc/init.d/oracle-xe configure
Oracle Database 11g Express Edition Configuration
-------------------------------------------------
This will configure on-boot properties of Oracle Database 11g 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
Ctrl-C will abort.
Specify the HTTP port that will be used for Oracle Application Express [8080]:8686
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:
Confirm the password:
Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:y
Starting Oracle Net Listener...Done
Configuring database...Done
Starting Oracle Database 11g Express Edition instance...Done
Installation completed successfully.
3. 配置
安装成功后,会创建一个名为oracle的用户,主目录在:/u01/app/oracle/。
为了使用方便,我从其他用户目录下把 .bashrc 和 .bash_profile 文件拷贝到oracle用户主目录下。
# chown oracle:dba .bash_profile
# chown oracle:dba .bashrc
# chmod 755 .bashrc
# chmod 755 .bash_profile
修改.bashrc(新打开一个shell)或 .bash_profile(每次登录)文件,增加一行内容如下:
. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
允许远程用户访问:
$ sqlplus system
SQL> EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);
4. 解锁HR用户,并增加数据库连接数
(1)以DBA身份连接数据库
connect sys/welcome1 as sysdba;
(2)然后给HR Schema解锁,做有关HR Schema的实验需要设置此项。
alter user hr identified by hr account unlock;
(3)修改允许的数据库连接数
alter system set processes=500 scope=spfile;
5. 启动与停止
(1)/etc/init.d/oracle-xe start
(2)/etc/init.d/oracle-xe stop
更多命令参数可以敲入:service oracle-xe,回车会显示如下信息:
Usage: /etc/init.d/oracle-xe {start|stop|restart|force-reload|configure|status|enable|disable}
更多命令参数可以敲入:service oracle-xe,回车会显示如下信息:
Usage: /etc/init.d/oracle-xe {start|stop|restart|force-reload|configure|status|enable|disable}
6. 卸载
# rpm -e oracle-xe
7. 远程无法访问的问题
开始以为是防火墙和SELinux的问题,再确认防火墙和SELinux都关闭的情况下,依然无法远程访问,只能在本机访问。
经过进一步检查,这是因为使用DHCP动态获取了IP地址和主机名导致的问题。
使用hostname可以检查机器的主机名,或者从Shell Prompt中也可以看出来。
解决方法如下:
(1)修改文件:/u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
把 HOST = localhost.localdomain改成IP地址即可。
# listener.ora Network Configuration File:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/xe)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
)
)
(2)修改文件:/u01/app/oracle/product/11.2.0/xe/network/admin/tnsnames.ora
把 HOST = localhost.localdomain改成IP地址即可。
# tnsnames.ora Network Configuration File:
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
参考文献:
没有评论:
发表评论