到官網下載軟體包,要先註冊一個帳號,下載完是一個壓縮包,解壓出oracle-xe-11.2.0-1.0.x86_64.rpm。Linux下只有64位版本。
1、安裝依賴包
yum install libaio libaio-devel bc -y
2、安裝Oracle Express Edition
使用root使用者操作。
cd ~
wget http://download.oracle.com/otn/linux/oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip?AuthParam=1409379226_d26581af452e67b3a2b04fe09ee28749 -O oracle-xe-11.2.0-1.0.x86_64.rpm.zip
unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
cd Disk1
rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
安裝時會對系統進行檢測,最好記憶體有1G,SWAP要求是記憶體的2倍。
[root@server01 Disk1]# 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、將tmpfs擴充為2G
tmpfs小於2G,在下一步執行設定命令會報錯:
Database Configuration failed. Look into /u01/app/oracle/product/11.2.0/xe/config/log for details
1)修改/etc/fstab檔案
vim /etc/fstab
將:
tmpfs /dev/shm tmpfs defaults 0 0
改為:
tmpfs /dev/shm tmpfs defaults,size=2048M 0 0
2)重新載入tmpfs
umount /dev/shm
mount /dev/shm
3)檢查
df -h /dev/shm
Filesystem Size Used Avail Use% Mounted on
none 2.0G 243M 1.8G 12% /dev/shm
4、按照提示進行設定
/etc/init.d/oracle-xe configure
[root@server01 Disk1]# /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]:8081
Specify a port that will be used for the database listener [1521]: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.
輸入的四項內容是:http訪問時的連接埠、資料庫的監聽連接埠、SYS和SYSTEM使用者的密碼、是否開機啟動(並沒有開機啟動,可能還有地方要設定)。
安裝完成後,會自動建立一個名為oracle的使用者,家目錄/u01/app/oracle。
會建立dba組,oracle使用者屬於這個組。
會自動產生一個資料庫執行個體,名為XE。/u01/app/oracle/product/11.2.0/xe/dbs/spfileXE.ora
HTTP管理地址:
http://伺服器IP:8081/
用SYS或SYSTEM使用者登入。
5、設定oracle的環境變數
vim /etc/profile
加入:
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=XE
設定後登出使用者重新登入,就可以用sqlplus了。
6、進入sqlplus控制台
sqlplus /nolog
SQL> connect as sysdba
Enter user-name: sys
Enter password:
Connected.
SQL>
之後可以做其它操作。
啟動命令:
startup
關閉命令:
shutdown