Ubuntu 22.04上安装Oracle 11g Express Edition的过程,因为oracle没有提供Ubuntu系统deb格式安装包,我这里是转换得到文件。鉴于oralce官网不再提供oracle 11g xe的安装包下载,需要的朋友可以评论留下邮箱,我会在看到后回复给大家。
一、系统环境
操作系统:Ubuntu 22.04.4 LTS
数据库版本:Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
安装方式:deb安装包
二、预安装软件
1.先通过unzip命令解压
如果没有命令,请通过apt install unzip安装
unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
**2.安装预先安装的包和依赖程序 **
sudo apt-get install alien libaio1 unixodbc
**3.将RPM安装包转换成DEB格式 **
这里正常的rpm文件路径在DISK下面
cd ./oracle-xe-11.2.0-1.0.x86_64.rpm/Disk1/
sudo alien --scripts -d oracle-xe-11.2.0-1.0.x86_64.rpm
4.创建管理服务chkconfig的脚本
sudo vim /sbin/chkconfig
添加下面的内容并保存
#!/bin/bash
# Oracle 11gR2 XE installer chkconfig hack for Ubuntu
file=/etc/init.d/oracle-xe
if [[ ! `tail -n1 $file | grep INIT` ]]; then
echo >> $file
echo '### BEGIN INIT INFO' >> $file
echo '# Provides: OracleXE' >> $file
echo '# Required-Start: $remote_fs $syslog' >> $file
echo '# Required-Stop: $remote_fs $syslog' >> $file
echo '# Default-Start: 2 3 4 5' >> $file
echo '# Default-Stop: 0 1 6' >> $file
echo '# Short-Description: Oracle 11g Express Edition' >> $file
echo '### END INIT INFO' >> $file
fi
update-rc.d oracle-xe defaults 80 01
4.修改chkconfig文件权限
sudo chmod 755 /sbin/chkconfig
5.设置内核kernel参数
(这是oracle 11g R2 XE安装要求)
sudo vim /etc/sysctl.d/60-oracle.conf
添加下面的内容并保存
# Oracle 11g XE kernel parameters
fs.file-max=6815744
net.ipv4.ip_local_port_range=9000 65000
kernel.sem=250 32000 100 128
kernel.shmmax=536870912
使用下面命令通过加载内核餐宿
sudo service procps start
检查新的参数是否加载成功
sudo sysctl -q fs.file-max
6.设置/dev/shm挂载点
sudo vim /etc/rc2.d/S01shm_load
添加下面的内容并保存
#!/bin/sh
case "$1" in
start) mkdir /var/lock/subsys 2>/dev/null
touch /var/lock/subsys/listener
rm /dev/shm 2>/dev/null
mkdir /dev/shm 2>/dev/null
mount -t tmpfs shmfs -o size=2048m /dev/shm ;;
*) echo error
exit 1 ;;
esac
添加文件权限
sudo chmod 755 /etc/rc2.d/S01shm_load
**9.重启服务器 **
reboot
三、安装Oracle
1.使用下面命令安装oracle
sudo dpkg --install oracle-xe_11.2.0-2_amd64.deb
**2.使用下面命令开始配置oracle **
sudo /etc/init.d/oracle-xe configure
中途会询问你下面的问题
Specify the HTTP port that will be used for Oracle Application Express [8080]:
# 定义HTTP网站管理的端口,默认直接回车
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:
# 要求你设置系统账号SYS的SYSTEM的密码
Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:y
# 询问是否设置数据库开机启动启动,默认是开机启动,直接回车
正常安装成功的过程日志
root@oracle_01:/# sudo /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 <Enter> to accept the defaults.
Ctrl-C will abort.
Specify the HTTP port that will be used for Oracle Application Express [8080]:
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.
root@oracle_01:/
3.设置系统环境变量
sudo vim /etc/profile
在最末尾添加下面的内容并保存
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/xe; 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
使用下面命令刷新使其生效
sudo source /etc/profile
4.启动oracle服务
sudo systemctl start oracle-xe
5.查看oracle运行状态
sudo systemctl status oracle-xe
**下面是正常运行的结果 **
root@oracle_01:/# sudo systemctl status oracle-xe
● oracle-xe.service - LSB: Oracle 11g Express Edition
Loaded: loaded (/etc/init.d/oracle-xe; generated)
Active: active (exited) since Sun 2024-04-28 16:02:02 CST; 27min ago
Docs: man:systemd-sysv-generator(8)
Process: 803 ExecStart=/etc/init.d/oracle-xe start (code=exited, status=0/SUCCESS)
CPU: 61ms
Apr 28 16:01:52 oracle_01 systemd[1]: Starting LSB: Oracle 11g Express Edition...
Apr 28 16:01:53 oracle_01 oracle-xe[803]: Starting Oracle Net Listener.
Apr 28 16:01:53 oracle_01 su[899]: (to oracle) root on none
Apr 28 16:01:53 oracle_01 su[899]: pam_unix(su:session): session opened for user oracle(uid=1002) by (uid=0)
Apr 28 16:01:55 oracle_01 oracle-xe[803]: Starting Oracle Database 11g Express Edition instance.
Apr 28 16:01:55 oracle_01 su[940]: (to oracle) root on none
Apr 28 16:01:55 oracle_01 su[940]: pam_unix(su:session): session opened for user oracle(uid=1002) by (uid=0)
Apr 28 16:02:02 oracle_01 systemd[1]: Started LSB: Oracle 11g Express Edition.
root@oracle_01:/#
四、登录数据库
1.使用下面命令用system账号登录
sqlplus system/123456Ab as sysdba;
2.登录后执行SQL语句查询数据库版本
select * from v$version;
下面是完整登录操作记录
root@oracle_01:/# sqlplus sys/123456Ab as sysdba;
SQL*Plus: Release 11.2.0.2.0 Production on Sun Apr 28 15:59:18 2024
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
SQL> exit
Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
到此完结!
版权归原作者 风行無痕 所有, 如有侵权,请联系我们删除。