1. 安裝oracle
安裝必須組件
sudo apt-get install alien libaio1 unixodbc
新建管理服務(wù)chkconfig的腳本
sudo nano /sbin/chkconfig
粘貼以下內(nèi)容
#!/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
配置權(quán)限
sudo chmod 755 /sbin/chkconfig
設(shè)置內(nèi)核kernel參數(shù)
sudo nano /etc/sysctl.d/60-oracle.conf
粘貼以下內(nèi)容
# 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
使用下面命令通過加載內(nèi)核餐宿
sudo service procps start
檢查新的參數(shù)是否加載成功
sudo sysctl -q fs.file-max
設(shè)置/dev/shm掛載點(diǎn)
sudo nano /etc/rc2.d/S01shm_load
粘貼以下內(nèi)容
#!/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
添加文件權(quán)限
sudo chmod 755 /etc/rc2.d/S01shm_load
重啟服務(wù)器
reboot
下載deb, 并安裝
cd /tmp
wget https://github.com/duanzhichao/ubuntu2004-oracle11g/releases/download/deb/oracle-xe_11.2.0-2_amd64.deb
sudo dpkg --install oracle-xe_11.2.0-2_amd64.deb
按照以下內(nèi)容配置
Specify the HTTP port that will be used for Oracle Application Express [8080]:
# 定義HTTP網(wǎng)站管理的端口籍琳,默認(rèn)直接回車
Specify a port that will be used for the database listener [1521]:
# 定義數(shù)據(jù)庫監(jiān)聽的端口饱亮,默認(rèn)直接回車
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:
# 要求你設(shè)置系統(tǒng)賬號SYS的SYSTEM的密碼
Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:y
# 詢問是否設(shè)置數(shù)據(jù)庫開機(jī)啟動啟動羹令,默認(rèn)是開機(jī)啟動誉己,直接回車
# 成功的話終端輸出以下內(nèi)容
Starting Oracle Net Listener...Done
Configuring database...Done
Starting Oracle Database 11g Express Edition instance...Done
Installation completed successfully.
修改profile
sudo nano /etc/profile
粘貼以下內(nèi)容
# 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
啟動oracle服務(wù), 查看oracle運(yùn)行狀態(tài)
sudo systemctl start oracle-xe
sudo systemctl status oracle-xe
# 下面是正常運(yùn)行的結(jié)果
● 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
2. 修改字符集, 無需要可以跳過
sudo su oracle
sqlplus /as sysdba
SQL> shutdown immediate;
SQL> startup mount;
SQL> ALTER SESSION SET SQL_TRACE=TRUE;
SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;
SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
SQL> ALTER SYSTEM SET AQ_TM_PROCESSES=0;
SQL> ALTER DATABASE OPEN;
SQL> ALTER DATABASE character set INTERNAL_USE ZHS16GBK;
SQL> shutdown immediate;
SQL> startup
3. 升級apex 4.1或4.2, 無需要可跳過
cd /u01/app/oracle/product/11.2.0/xe/
wget https://github.com/duanzhichao/ubuntu2004-oracle11g/releases/download/apex41/apex_4.1.zip
# or
wget https://github.com/duanzhichao/ubuntu2004-oracle11g/releases/download/apex42/apex_4.2.2.zip
解壓apex
mv ./apex ./apex_old
unzip apex_xxx.zip
mv apex_xxx ./apex
安裝apex
cd apex
sqlplus / as sysdba
connect / as sysdba
SQL> @apexins SYSAUX SYSAUX TEMP /i/
設(shè)置靜態(tài)資源
sqlplus / as sysdba
connect / as sysdba
SQL> @apex_epg_config /u01/app/oracle/product/11.2.0/xe/
漢化apex
NLS_LANG=American_America.AL32UTF8
export NLS_LANG
echo $NLS_LANG
cd builder/zh-cn
sqlplus / as sysdba
connect / as sysdba
SQL> @load_zh-cn.sql
更新密碼
SQL> @apxchpwd
SQL> alter user apex_public_user account unlock;
SQL> alter user apex_public_user identified by 123;
# 如果4.1, APEX_040100; 如果4.2, APEX_040200
SQL> alter session set current_schema = APEX_040200;
4. 創(chuàng)建用戶,表空間,導(dǎo)入數(shù)據(jù)
sqlplus / as sysdba
connect / as sysdba
SQL> create user u1 identified by "123456";
SQL> create tablespace U1 logging datafile '/u01/app/oracle/oradata/XE/U1.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local;
命令行
imp hitb_pm/Hitb123456! file=/home/oracle/hitb_pm.dmp full=y ignore=y