Installing Java, Oracle 11g R2 Express Edition and SQL Developer on Ubuntu 64-bi

本文介绍如何在Linux环境下安装配置Oracle 11g R2 Express Edition及SQL Developer,包括安装Java JDK、设置环境变量、安装所需依赖包、配置内核参数等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

Installing Java

We start with installing Java on the machine. My personal preference is to use Oracle Java JDK. Installing this JDK could be done easily by performing the following statements.

1sudo add-apt-repository ppa:webupd8team/java
2sudo apt-get update
3sudo apt-get install oracle-java7-installer

The screen in figure 1 will appear in the terminal, hit enter to proceed. After this, the screen in figure 2 will be shown. Navigate to <Yes> using the left arrow on your keyboard and hit enter. Oracle JDK 7 will be installed.

Binary Code license Figure 1: Binary Code license JDK License AgreementFigure 2: JDK License Agreement

To validate the Java installation, execute the following command:

1java -version

This should result in the following (or something similar).

1java version “1.7.0_51”
2Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
3Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

The next next step is to set the JAVA_HOME environment variable. To do this, open the /etc/bash.bashrc file by executing the following statement.

1sudo gedit /etc/bash.bashrc

Scroll to the bottom of the file and add the following lines.

1export JAVA_HOME=/usr/lib/jvm/java-7-oracle
2export PATH=$JAVA_HOME/bin:$PATH

Save the file and close the editor. To load the changes, execute the following statement.

1source /etc/bash.bashrc

To validate the changes you can execute the following statement.

1echo $JAVA_HOME

The result of this statement should be the following.

1/usr/lib/jvm/java-7-oracle

Installing Oracle 11g R2 Express Edition

For the installation of Oracle 11g R2 Express Edition (XE), a couple of additional Linux packages are required. These packages can be installed by executing the following statement.

1sudo apt-get install alien libaio1 unixodbc

The next step is to download the Oracle 11g R2 Express Edition from the Oracle website. Make sure you select the Linux x64 version from http://www.oracle.com/technetwork/products/express-edition/downloads/index.html. After the download is completed, open the terminal and navigate to the download directory. In my case this can be done by executing the following statement.

1cd Downloads

The next step step is to unzip the downloaded file. To do this, execute the following command.

1unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip

A new directory (Disk1) is added to the Download directory. Navigate to this directory:

1cd Disk1

Now we have to convert the Red Hat package (rpm) to a Debian package. This may be done using the alien command. The -d parameter is used to inform alien that a Debian package should be generated. When the -scripts parameter is toggled, alien will try to convert the scripts that are meant to be run when the package is installed and removed.

1sudo alien --scripts -d oracle-xe-11.2.0-1.0.x86_64.rpm

This step may take a while, while this statement is executing we can do the following steps. Open a new terminal window for these steps.

The Red Hat package, relies on the /sbin/chkconfig file, which is not used in Ubuntu. To successfully install Oracle XE we use a simple trick. Start by creating a custom /sbin/chkconfig file by executing the following statement.

1sudo gedit /sbin/chkconfig

Copy and paste the following into the editor:

01#!/bin/bash
02# Oracle 11gR2 XE installer chkconfig hack for Ubuntu
03file=/etc/init.d/oracle-xe
04if [[ ! `tail -n1 $file | grep INIT` ]]; then
05echo >> $file
06echo '### BEGIN INIT INFO' >> $file
07echo '# Provides: OracleXE' >> $file
08echo '# Required-Start: $remote_fs $syslog' >> $file
09echo '# Required-Stop: $remote_fs $syslog' >> $file
10echo '# Default-Start: 2 3 4 5' >> $file
11echo '# Default-Stop: 0 1 6' >> $file
12echo '# Short-Description: Oracle 11g Express Edition' >> $file
13echo '### END INIT INFO' >> $file
14fi
15update-rc.d oracle-xe defaults 80 01
16#EOF

Save the file and close the editor. Now we have to provide the file with the appropriate execution privileges.

1sudo chmod 755 /sbin/chkconfig

After this, we have to create the file /etc/sysctl.d/60-oracle.conf to set the additional kernel parameters. Open the file by executing the following statement.

1sudo gedit /etc/sysctl.d/60-oracle.conf

Copy and paste the following into the file. Kernel.shmmax is the maximum possible value of physical RAM in bytes. 536870912 / 1024 /1024 = 512 MB.

1# Oracle 11g XE kernel parameters
2fs.file-max=6815744
3net.ipv4.ip_local_port_range=9000 65000
4kernel.sem=250 32000 100 128
5kernel.shmmax=536870912

Save the file. The changes in this file may be verified by executing:

1sudo cat /etc/sysctl.d/60-oracle.conf

Load the kernel parameters:

1sudo service procps start

The changes may be verified again by executing:

1sudo sysctl -q fs.file-max

This method should return the following:

1fs.file-max = 6815744

After this, execute the following statements to make some more required changes:

1sudo ln -s /usr/bin/awk /bin/awk
2mkdir /var/lock/subsys
3touch /var/lock/subsys/listener

Close the second terminal window and return to the first terminal window. The rpm package should be converted and a new file called oracle-xe-11.2.0-2_amd64.deb have been generated. To run this file, execute the following command:

1sudo dpkg --install oracle-xe_11.2.0-2_amd64.deb

Execute the following to avoid getting a ORA-00845: MEMORY_TARGET error. Note: replace “size=4096m” with the size of your (virtual) machine’s RAM in MBs.

1sudo rm -rf /dev/shm
2sudo mkdir /dev/shm
3sudo mount -t tmpfs shmfs -o size=4096m /dev/shm

Create the file /etc/rc2.d/S01shm_load.

1sudo gedit /etc/rc2.d/S01shm_load

Copy and paste the following in the file. Note: replace “size=4096m” with the size of your machine’s RAM in MBs.

01#!/bin/sh
02case "$1" in
03start) mkdir /var/lock/subsys 2>/dev/null
04touch /var/lock/subsys/listener
05rm /dev/shm 2>/dev/null
06mkdir /dev/shm 2>/dev/null
07mount -t tmpfs shmfs -o size=4096m /dev/shm ;;
08*) echo error
09exit 1 ;;
10esac

Save the file, close the editor and provide the appropriate execution privileges.

1sudo chmod 755 /etc/rc2.d/S01shm_load

Configuring Oracle 11g R2 Express Edition

If you have successfully installed to Oracle 11g R2 Express Edition server, it’s time to configure the server. To start the configuration of the server, execute the following command and follow the “wizard” in the terminal. Default values are shown between brackets for each question.

1sudo /etc/init.d/oracle-xe configure

Now it is time to set-up some environmental variables. Open the /etc/bash.bashrc file by executing the following statement:

1sudo gedit /etc/bash.bashrc

Scroll to the bottom of the file and add the following lines.

1export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
2export ORACLE_SID=XE
3export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
4export ORACLE_BASE=/u01/app/oracle
5export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
6export PATH=$ORACLE_HOME/bin:$PATH

Save the file and close the editor. To load the changes, execute the following statement:

1source /etc/bash.bashrc

To validate the changes you can execute the following statement.

1echo $ORACLE_HOME

This statement should result in the following output.

1/u01/app/oracle/product/11.2.0/xe

After this step it is recommended to reboot the machine. After the reboot is completed, you should be able to start the Oracle server using the following command:

1sudo service oracle-xe start

A file named oraclexe-gettingstarted.desktop is placed on your desktop. To make this file executable, navigate to you desktop.

1cd ~/Desktop

To make the file executable, execute the following statement.

1sudo chmod a+x oraclexe-gettingstarted.desktop

Installing SQL Developer

Finally, after the installation of Oracle 11g R2 Express Edition and Java, SQL Developer could be installed. This is done by performing the following steps.

Download Oracle SQL Developer from the Oracle site. Select the Linux RPM package: http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html. Open a terminal window and navigate to the Download directory:

1cd Downloads

Convert the Red Hat package to a Ubuntu package. Note: this may take a while.

1sudo alien --scripts -d sqldeveloper-4.0.0.13.80-1.noarch.rpm

A file named sqldeveloper_4.0.0.13.80-2_all.deb will be generated. To run this file, execute the following statement:

1sudo dpkg --install sqldeveloper_4.0.0.13.80-2_all.deb

Create a .sqldeveloper directory in your home folder:

1sudo mkdir /home/.sqldeveloper/

Run SQL Developer from the terminal.

1sudo /opt/sqldeveloper/sqldeveloper.sh

Now enter the full Java path. In my case this is done as follows:

1/usr/lib/jvm/java-7-oracle

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值