ubuntu12.04下安装oracle实战记录
今天经过9个多小时的实战终于把oracle在ubuntu上安装成功了
在这里记录一下
1、下载oracle express的安装介质
http://www.oracle.com/technetwork/products/express-edition/downloads/index.html
Oracle Database Express Edition 11g Release 2 for Linux x64
2、转换为deb包
由于下载的是rpm包ubuntu无法直接使用所以需要alien来转换
1 |
sudo apt-get install alien |
2 |
sudo alien -d --scripts oracle-xe-11.2.0-1.0.x86_64.rpm |
成功转换后得到oracle-xe_11.2.0-2_amd64.deb安装文件
3、安装deb
双击deb安装这个包,这时包安装成功但是我们会得到一个错误说/sbin/chkconfig不存在。
我们要修改/var/lib/dpkg/info/oracle-xe.postinst脚本
1 |
if [ -f /etc/SuSE-release ] |
2 |
then |
3 |
cp -f /u01/app/oracle/product/11.2.0/xe/config/scripts/oracle-xe.sles /etc/init.d/oracle-xe |
4 |
/usr/lib/lsb/install_initd /etc/init.d/oracle-xe > /dev/null 2>&1 |
5 |
/sbin/insserv /etc/init.d/oracle-xe > /dev/null 2>&1 |
6 |
/sbin/SuSEconfig > /dev/null 2>&1 |
7 |
#else |
8 |
# /sbin/chkconfig --add oracle-xe |
9 |
fi |
把else与/sbin/chkconfig --add oracle-xe注释掉,然后再执行
1 |
sudo /var/lib/dpkg/info/oracle-xe.postinst |
会提示你运行/etc/init.d/oracle-xe configure进行配置。但别急,我们还需要一些步骤再执行。
4、安装依赖包
1 |
sudo apt-get install libaio1 |
5、解决ORA-00845: MEMORY_TARGET问题
用root登录
1 |
sudo su - |
粘贴下载的代码到命令行,来创建oracle-shm
01 |
cat > /etc/init.d/oracle-shm <<-EOF |
02 |
#! /bin/sh |
03 |
# /etc/init.d/oracle-shm |
04 |
# |
05 |
# |
06 |
case "\$1" in |
07 |
start) |
08 |
echo "Starting script /etc/init.d/oracle-shm" |
09 |
# Run only once at system startup |
10 |
if [ -e /dev/shm/.oracle-shm ]; then |
11 |
echo "/dev/shm is already mounted, nothing to do" |
12 |
else |
13 |
rm -f /dev/shm |
14 |
mkdir /dev/shm |
15 |
#mount -B /run/shm /dev/shm |
16 |
mount -t tmpfs shmfs -o size=2048m /dev/shm |
17 |
touch /dev/shm/.oracle-shm |
18 |
fi |
19 |
;; |
20 |
stop) |
21 |
echo "Stopping script /etc/init.d/oracle-shm" |
22 |
echo "Nothing to do" |
23 |
;; |
24 |
*) |
25 |
echo "Usage: /etc/init.d/oracle-shm {start|stop}" |
26 |
exit 1 |
27 |
;; |
28 |
esac |
29 |
# |
30 |
### BEGIN INIT INFO |
31 |
# Provides: oracle-shm |
32 |
# Required-Start: $remote_fs $syslog |
33 |
# Required-Stop: $remote_fs $syslog |
34 |
# Default-Start: 2 3 4 5 |
35 |
# Default-Stop: 0 1 6 |
36 |
# Short-Description: Bind /run/shm to /dev/shm at system startup. |
37 |
# Description: Fix to allow Oracle 11g use AMM. |
38 |
### END INIT INFO |
39 |
EOF |
安装oracle-shm
1 |
chmod 755 /etc/init.d/oracle-shm |
2 |
update-rc.d oracle-shm defaults 01 99 |
重启
1 |
reboot |
6、配置oracle xe
1 |
sudo /etc/init.d/oracle-xe configure |
选择web管理端口默认8080
选择监听端口默认1521
输入管理员密码与确认密码(sys密码)
最后询问你是否自动启动默认y
7、进行web管理台
从菜单中选择Other->Get Started with Oracle Database 11g Express Edition
总体上可按照上面来进行安装,特别是问题00845
然后这里面有环境变量,远程登录配置,以及上面所说的chkconfig
Step-by-Step Installing Oracle Database Express Edition 11gR2 on Ubuntu Server 12.04 LTS
Step 1. Managing Swap partition. Oracle Database Express Edition 11gR2 may require up to a 2GB (2095100 KB) swap partition, Enter the following command in terminal to verify your swap space:
cat /proc/meminfo | grep -i swap
If you don’t have enough swap space, you can increase available swap space by the following guide to create and enable swap partiton, in this case I’ll create 1 GB swap file and loaded at startup, located in the /home directory
Login as root:
sudo -i
Create swap file on /home directory with following commands:
dd if=/dev/zero of=/home/swapfile bs=1024 count=1048576 mkswap /home/swapfile swapon /home/swapfile swapon -a
Create a backup of the original “fstab” file and add the new swap file:
cp /etc/fstab /etc/fstab.backup_`date +%N` echo '/home/swapfile swap swap defaults 0 0' >> /etc/fstab
Logout from root and verify the new swap space:
exit swapon -s
Step 1. Install additional software thats require Oracle 11g Express Edition
sudo apt-get install alien libaio1
Step 2. Download Oracle Database Express Edition 11gR2 via Oracle Official website, it require registration before downloading.
Step 3. unzip the downloaded file, then convert the Oracle Database Express Edition 11gR2 package installer to debian package
unzip oracle-xe-11.2.0.1.0.x86_64.rpm.zip
cd Disk1/
sudo alien --to-deb --scripts oracle-xe-11.2.0-1.0.x86_64.rpm
Step 4. Configure Awk and Chkconfig, The following needs to be set for compatibility:
sudo ln -s /usr/bin/awk /bin/awk sudo mkdir /var/lock/subsys
Ubuntu uses different tools to manage services and system startup scripts. The “chkconfig” tool required by the Oracle installer is not available in Ubuntu. The following will create a file to simulate the “chkconfig” tool.
Login as root:
sudo -i
Copy and paste the following Script directly into the terminal to create a file chkconfig:
cat > /sbin/chkconfig <<-EOF #!/bin/bash # Oracle 11gR2 XE installer chkconfig, Only run once. echo "Simulating /sbin/chkconfig..." if [[ ! `tail -n1 /etc/init.d/oracle-xe | grep INIT` ]]; then cat >> /etc/init.d/oracle-xe <<-EOM # ### BEGIN INIT INFO # Provides: OracleXE # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Oracle 11g Express Edition ### END INIT INFO EOM fi update-rc.d oracle-xe defaults 80 01 EOF
Logout form root:
exit
Set the file /sbin/chkconfig executable :
sudo chmod 755 /sbin/chkconfig
Step 5. Install Oracle Database Express Edition 11gR2 with the following commands:
cd ~/Downloads/Disk1 sudo dpkg -i oracle-xe-11.2.0-1.0.x86_64.deb
Run the following configuration script to create (clone) the database. Accept the default answers, including “y” to startup the database automatically, or modify as required.
sudo /etc/init.d/oracle-xe configure
To verify success, the procedure should end showing:
Starting Oracle Net Listener...Done
Configuring database...Done
Starting Oracle Database 11g Express Edition instance...Done
Installation completed successfully.
Step 6. Set a password for the Oracle account:
sudo passwd oracle
Step 7. Post-Installation, In order to use sqlplus and other tools, the Oracle account requires specific environment variables. The following will set these variables automatically at every Oracle login:
Login as the Oracle user:
su - oracle
Copy the default account skeleton files and add the Oracle env script to .profile:
cp /etc/skel/.bash_logout ./ cp /etc/skel/.bashrc ./ cp /etc/skel/.profile ./ echo "" >>./.profile echo '. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh' >>./.profile
Step 7. Configure remote login. By default, the Oracle Database XE graphical user interface is only available at the local server, but not remotely. The following will enable remote logins:
Login as the Oracle user, then login as SYSDBA and run the following commands:
su - oracle sqlplus / as sysdba SQL> EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE); exit
基本上按照上面的就可以正常安装成功了