ubuntu 安装 oracle 11g数据库,亲测有用

Instructions for Installing Oracle DBMS in Ubuntu VM


These install instructions are adapted from Me and My Ubuntu blog.

1. Download VirtualBox

Download the VirtualBox application for your host machine type from the virtual box download site.

2. Install VirtualBox

Doubleclick on the downloaded installer and follow the instructions.

3. Download Ubuntu

Download Ubuntu Desktop Edition (14.04 64 bit version). Note the directory where you downloaded it.

4. Start the VirtualBox application

5. Create a virtual machine (VM) and install Ubuntu

Make sure that you set the memory of the VM to be greater than 2GB and the storage of the VM to be at least 10GB. See screencast

6. Clone backups of your Ubuntu VM

See screencast

7. Download Oracle Database Express Edition

Download Oracle Database Express Edition 11g Release 2 for Linux x64.

See screencast

8. Follow pre-install instructions

See screencast, but note that the screencast did not include the last step before REBOOT listed below. You should execute the commands in the last step.

  1. Unzip using the command:
    unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip 
  2. Install required packages using the command:
    sudo apt-get install alien libaio1 unixodbc
  3. Convert RPM package format to DEB package format (that is used by Ubuntu) using the command:
    sudo alien --scripts -d oracle-xe-11.2.0-1.0.x86_64.rpm
  4. Create the required chkconfig script using the command::
    sudo vim /sbin/chkconfig
    The pico text editor is started and the commands are shown at the bottom of the screen. Now copy and paste the following into the file and save:
    
    #!/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
    
  5. Change the permission of the chkconfig file using the command:
    sudo chmod 755 /sbin/chkconfig  
  6. Set kernel parameters. Oracle 11gR2 XE requires additional kernel parameters which you need to set using the command:
    sudo vim /etc/sysctl.d/60-oracle.conf
    Copy the following into the file and save:
    # 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 
    
    Verify the change using the command:
    sudo cat /etc/sysctl.d/60-oracle.conf 
    
    You should see what you entered earlier. Now load the kernel parameters:
    sudo service procps start
    
    Verify the new parameters are loaded using:
    sudo sysctl -q fs.file-max
    
    You should see the file-max value that you entered earlier.
  7. Set up /dev/shm mount point for Oracle. Create the following file using the command:
    sudo vim /etc/rc2.d/S01shm_load
    
    Copy the following into the file and save.
    #!/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 
    
    Change the permissions of the file using the command:
    sudo chmod 755 /etc/rc2.d/S01shm_load
    
  8. [This step was not included in the screencast, but you should do it.] Execute the following commands:
    sudo ln -s /usr/bin/awk /bin/awk 
    sudo mkdir /var/lock/subsys 
    sudo touch /var/lock/subsys/listener 
    
  9. REBOOT your Ubuntu VM.

9. Install Oracle

See screencast for a recording of the following steps.

  1. Install the oracle DBMS using the command:
    sudo dpkg --install oracle-xe_11.2.0-2_amd64.deb
    
  2. Configure Oracle using the command:
    sudo /etc/init.d/oracle-xe configure 
    
    Enter the following information:
    • A valid HTTP port for the Oracle Application Express (the default is 8080)
    • A valid port for the Oracle database listener (the default is 1521)
    • A password for the SYS and SYSTEM administrative user accounts
    • Confirm password for SYS and SYSTEM administrative user accounts
    • Whether you want the database to start automatically when the computer starts (next reboot).

if error,line: CONFIGURATION="/etc/sysconfig/$CONFIG_NAME" change this to: CONFIGURATION="/etc/default/$CONFIG_NAME"

  1. Setup environment variables by editting your .bashrc file:
    vim ~/.bashrc
    
    Add the following lines to the end of the file:
    export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
    export ORACLE_SID=XE
    export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
    export ORACLE_BASE=/u01/app/oracle
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
    export PATH=$ORACLE_HOME/bin:$PATH
    
    Load the changes by executing your profile:
    . ~/.profile
    
  2. Start the Oracle 11gR2 XE:
    sudo service oracle-xe start
    
  3. Add user YOURUSERNAME to group dba using the command
    sudo usermod -a -G dba YOURUSERNAME
    

10. Using the Oracle XE Command Shell

See screencast for a recording of the following steps.

  1. Start the Oracle XE 11gR2 server using the command:
    sudo service oracle-xe start
    
    This step is most likely not necessary, but I am documenting the command here anyway.
  2. Start command line shell as the system admin using the command:
    sqlplus sys as sysdba
    
    Enter the password that you gave while configuring Oracle earlier. You will now be placed in a SQL environment that only understands SQL commands.
  3. Create a regular user account in Oracle using the SQL command:
    create user USERNAME identified by PASSWORD;
    
    Replace USERNAME and PASSWORD with the username and password of your choice. Please remember this username and password. If you had error executing the above with a message about resetlogs, then execute the following SQL command and try again:
    alter database open resetlogs
    
  4. Grant privileges to the user account using the SQL command:
    grant connect, resource to USERNAME;
    
    Replace USERNAME and PASSWORD with the username and password of your choice. Please remember this username and password.
  5. Exit the sys admin shell using the SQL command:
    exit;
    
  6. Start the commandline shell as a regular user using the command:
    sqlplus
    
    You will be prompted for a username and password. Once authenticated, you will be able to type in the standard SQL commands learned in class.
  7. USE it

create table products(id int,name char(10));

insert into products values(1,'ipad');
insert into produncts values(2,'samsung s3');

select * from products;

8.delete user

drop user barry2

 

11. Clone your VM if everything was successful!

 

service name,SID:

oracle查看service name,SID:

service name:

使用sqlplus / as sysdba登录后,

SQL> show parameter service

 

查看SID:

用户命令窗口输入如下命令可以看到sid。

lsnrctl status

创建表空间

CREATE TABLESPACE tbs1 DATAFILE 'tbs1_data.dbf' SIZE 1m;

删除表空间 

 drop tablespace tablespacename including contents and datafiles 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值