Installing Oracle9i on RedHat Linux

Introduction

This version of Oracle is easier to install than many of the previous ones. However there are still some traps and issues to get around. if you just need a database with transaction support, get Postgresql (www.postgresql.org) - it is very easy to install.

Before You Get Oracle

This release recommends 512 Mb of RAM, 1 GB of swap and 3 GB of disk ! You can get away with 320 MB, 750 Mb and 2.5 Gb respectively - provided you do not attempt to create a database at install time (wait until later !)

Do not attempt to install at all if you have less than 200 Mb of RAM as the installer will crash at link time ! (If you are an Oracle install pro then you can link manually to complete the process, but its a bit of a pest).

This release requires a 2.4.4 Kernel and Glibc 2.2.2. However you can install with 2.4.2 (Redhat 7.1) or 2.4.3 (Mandrake 8.0) Kernels.

There is an undocumented dependency on Binutils. The version that comes with Redhat 7.1 causes Oracle to be unlinkable. The solution is to use the version that comes with Redhat 7.0 (binutils-2.10.0.18) or Mandrake 8.0 (binutils-2.10.1.0.2).

The tested combinations were :

  1. Redhat 7.0 with binutils-2.10.0.18
  2. Mandrake 8.0 with binutils-2.10.1.0.2.

Getting Oracle

Visit www.oracle.com and click on "Oracle technology Network". The current URL for downloads is here. Select "9i Database" and then pick the "Linux" entry. You must then agree to the license before the actual download page appears.

There are three big files :

  1. Linux9i_Disk1.cpio.gz (400Mb)
  2. Linux9i_Disk2.cpio.gz (620 Mb)
  3. Linux9i_Disk3.cpio.gz (80 Mb)
They are actually cpio archives ( not gzipped cpio archives ! ). You need fast internet access...or a friend with fast internet access.

Once downloaded then expand the archives somewhere where you have 2 GB of space :

  #  cd /var/bigspace
  #  cpio -idmv Linux9i_Disk1.cpio.gz
  #  cpio -idmv Linux9i_Disk2.cpio.gz
  #  cpio -idmv Linux9i_Disk3.cpio.gz
These expanded archives can be burned to three CDs to provide a convenient and professional looking installation.

Preparation

Decide where you want Oracle to be installed and create a directory for it ( I use /usr/oracle/[version] but its up to you). In addition create a group and user for Oracle (login as root for this) :
  #  groupadd dba
  #  useradd oracle
  #  mkdir /usr/oracle
  #  mkdir /usr/oracle/9.0
  #  chown -R oracle:dba /usr/oracle
Remember you need 3 GB or so !

In addition I usually create the file /etc/oratab used to record databases :

  #  touch /etc/oratab
  #  chown oracle:dba /etc/oratab
There is some folklore about setting a plethora of environment variables and a thing called "Optimal Flexible Architecture". This business is best summed up by saying : The procedure is neither optimal, flexible nor an architecture... but a way of laying out files that some Oracle folk like.

Ensure that you have installed X on your machine, as there is no longer a character mode installer.

Oracle, like most databases, needs to use IPC to create shared memory. Typically the default amount configured on most Linux distributions is minimal. To sort this out : ( as root here )

  # sysctl -w kernel.shmmax=100000000
  # echo "kernel.shmmax = 100000000" >> /etc/sysctl.conf
This enables a shared memory segment to be 100 Mb ( probably enough to start you off...)

Installation

Login as oracle and proceed to install :
  $  cd /var/bigspace
  $  cd Disk1
  $  export ORACLE_HOME=/usr/oracle/9.0
  $  ./runInstaller
The Java Gui installer will start and guide you through the process.

This part is now fairly easy - just pick "9i Database", then either of "Enterprise" or "Standard Edition" depending whether you want all the fancy bits or not ( bitmap indexes, partitions, transportable tablespaces etc require Enterprise Edition).

The next step asks about what database you want, I usually say "Software Only" and do the database later.

You will be asked where JDK is... if you don't have a JDK it does not matter ( unless you wish to do Java development of course).

Then click on install and wait for a while.

At some point you will be asked about the "other locations" for the remaining software archives.. its fairly straightforward what to be there ( if you have cut CDs, ensure your terminal window is not still cd'ed into the cdrom mount directory... )

Post Installation

Now comes creating a database. There is a reasonable Gui tool for this :
  $ export PATH=$PATH:$ORACLE_HOME/bin
  $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
  $ dbca &
Additionally there is a network configuration tool with a similar UI :
  $ netca &
However I will detail a command line creation and configuration of a database so that some understanding of what is happening can be gained:

Set up configuration for a database called db1 :

  $ cat "db1:/usr/oracle/9.0:Y >> /etc/oratab"
  $ cd $ORACLE_HOME/dbs
  $ cat initdw.ora |sed s/"#db_name = MY_DB_NAME"/"db_name = db1"/|sed s/#control_files/control_files/ > initdb1.ora
Start and create database :
  $ export PATH=$PATH:$ORACLE_HOME/bin
  $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
  $ export ORACLE_SID=db1
  $ sqlplus /nolog <<!
  connect / as sysdba
  startup nomount
  create database db1;
  !
This creates a default database with files in $ORACLE_HOME/dbs

Now add the database meta data to actually make it useful :

$ sqlplus /nolog <<!
  connect / as sysdba
  @?/rdbms/admin/catalog
  @?/rdbms/admin/catproc
  !
Now create a user and give it wide ranging permissions :
  $ sqlplus /nolog <<!
  connect / as sysdba
  create user myuser identified by password;
  grant create session,create any table to myuser;
  grant unlimited tablespace to myuser;
  !
Now the usual sort of database stuff can be done :
  $ sqlplus myuser/password <<!
  create table mytable(id integer, val varchar2(100));
  insert into mytables values(1,'xxxxx');
  select * from mytable;
  !
You can shut down the database with :
  $ sqlplus /nolog <<!
  connect / as sysdba
  shutdown 
  !
And start it again with :
  $ sqlplus /nolog <<!
  connect / as sysdba
  startup 
  !
Simple command line versions of these are provided :
  $ dbshut
  $ dbstart
The thing that is unusual about Oracle is that there is a one to one correspondence between database server (ORACLE_SID) and database (db_name in init$ORACLE_SID.ora) - i.e : one server manages one and only one database. Compare this to Mysql or Postgresql where one server manages many databases. If you want another database, then you must go through the above steps again with ORACLE_SID set differently and a new initialization file with a new db_name in it.

Networking

It is nice if remote clients can see your database, so here is the story :
  $ echo " LISTENER = (ADDRESS_LIST= (ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)) (ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))" > $ORACLE_HOME/network/admin/listener.ora
  $ lnsrctl start
  $ echo "DB1 =  (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = < your host >)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = db1)))" > $ORACLE_HOME/network/admin/tnsnames.ora
These two commands tell the network listener where to listen, and clients were to send connection requests to. This can be tested by :
  $ tnsping db1 1
This should return (ok) [number]

Housekeeping

It is easy to make Oracle start automatically. Create a script called oracle in /etc/init.d that is like : ( you need to be root here )
  #!/bin/sh
  #
  # oracle        This shell script takes care of starting and stopping
  #               the oracle services.
  #
  # chkconfig: 345 90 10
  # description: Oracle server
  #   
  # probe: true
  
  # Source function library.
  . /etc/rc.d/init.d/functions

  # Source networking configuration.
  if [ ! -f /etc/sysconfig/network ]; then
      exit 0
  fi

  # Check for echo -n vs echo /c
  if echo '/c' | grep -s c > /dev/null 2 > &1 ; then
      ECHO_N="echo -n"
      ECHO_C=""
  else
      ECHO_N="echo"
      ECHO_C='/c'
  fi



  # See how we were called.
  case "$1" in
    start)
        # Start server.
        $ECHO_N "Starting Oracle: "$ECHO_C
        su -l oracle  -c sqlplus /nolog >/dev/null <<!
                          connect / as sysdba
                          startup
  !
          su -l oracle -c "lsnrctl start > /dev/null"
        ;;
    stop)
        # Stop server.
        $ECHO_N "Stopping Oracle: "$ECHO_C
        su -l oracle  -c sqlplus /nolog > /dev/null <<!
                          connect / as sysdba
                          shutdown abort
  !
          su -l oracle -c "lsnrctl stop > /dev/null"
        ;;
    *)
        echo $"Usage: $0 {start|stop}"
        exit 1
        ;;
  esac

  exit 0
Then tell the system to run it : ( as root again )
  #  chkconfig --add oracle
It is nice to set up the Oracle .bash_profile to get ORACLE_SID and PATH working by default :
  # .bash_profile

  # Get the aliases and functions
  if [ -f ~/.bashrc ]; then
    . ~/.bashrc
  fi
  
  export BASH_ENV=$HOME/.bashrc

  export ORAENV_ASK=NO
  export ORACLE_SID=db1
  if [ -f /usr/local/bin/oraenv ];then
    . /usr/local/bin/oraenv
  fi
  ORAENV_ASK=YES
  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
Finally a more sophisticated script to create a database in /var/oradata ( for example ) : ( as oracle )
  #!/bin/bash
  #  ---------------------------------------------------------------------------
  #  file         : createdb1.sql
  #  ---------------------------------------------------------------------------
  
  DB=db1
  DBPATH=/var/oradata
  ORACLE_SID=$DB
  
  
  mkinit()
  {
  export ORACLE_SID=$DB
  export ORAENV_ASK=NO
  . /usr/local/bin/oraenv
  cp init$DB.ora $ORACLE_HOME/dbs
  }
  
  mkdb()
  {
  sqlplus /nolog <<!
  CONNECT / AS SYSDBA
  STARTUP NOMOUNT
  CREATE DATABASE $DB 
  DATAFILE '$DBPATH/$DB/sys.dat' SIZE 200M
  AUTOEXTEND ON
  NEXT 10M
  LOGFILE GROUP 1 '$DBPATH/$DB/log01.dat' SIZE 50M,
          GROUP 2 '$DBPATH/$DB/log02.dat' SIZE 50M
  ;
  !
  }
  
  scdb()
  {
  sqlplus /nolog  <<!
  CONNECT / AS SYSDBA
  @?/rdbms/admin/catalog
  @?/rdbms/admin/catproc
  !
  }
  
  mktb()
  {
  sqlplus /nolog  <<!
  CONNECT / AS SYSDBA
  CREATE TABLESPACE rollback
  DATAFILE '$DBPATH/$DB/rollback.dat' SIZE 100M
  AUTOEXTEND ON
  NEXT 100M
  DEFAULT STORAGE ( INITIAL 10M NEXT 10M PCTINCREASE 0)
  ;
  CREATE TABLESPACE temp
  DATAFILE '$DBPATH/$DB/temp.dat' SIZE 100M
  AUTOEXTEND ON
  NEXT 100M
  DEFAULT STORAGE ( INITIAL 10M NEXT 10M PCTINCREASE 0)
  TEMPORARY
  ;
  CREATE TABLESPACE data
  DATAFILE '$DBPATH/$DB/data.dat' SIZE 200M
  AUTOEXTEND ON
  NEXT 100M
  EXTENT MANAGEMENT LOCAL 
  SEGMENT SPACE MANAGEMENT AUTO
  ;
  !
  }
  
  
  mkoj()
  {
  sqlplus /nolog  <<!
  CONNECT / AS SYSDBA
  CREATE ROLLBACK SEGMENt t0 ;
  ALTER ROLLBACK SEGMENT t0 ONLINE;
  SET TRANSACTION USE ROLLBACK SEGMENT t0;
  CREATE ROLLBACK SEGMENT r0 TABLESPACE rollback;
  CREATE ROLLBACK SEGMENT r1 TABLESPACE rollback;
  ALTER ROLLBACK SEGMENT t0 OFFLINE;
  DROP ROLLBACK SEGMENT t0;
  !
  echo "rollback_segments = (r0,r1)" >> $ORACLE_HOME/dbs/init$DB.ora
  }
  
  resp=n
  echo -n "Create initial files ?"
  read resp
  case $resp in
    y) echo "Creating initialization files"
       mkinit
       ;;
  esac
  
  
  resp=n
  echo -n "Create database ?"
  read resp
  case $resp in
    y) echo "Creating $DB"
       mkdb
       ;;
  esac
  
  
  resp=n
  echo -n "Run database scripts ?"
  read resp
  case $resp in
    y) echo "Running scripts for $DB"
       scdb
       ;;
  esac
  
  
  resp=n
  echo -n "Create tablespaces ?"
  read resp
  case $resp in
    y) echo "Creating tablespaces for $DB"
       mktb
       ;;
  esac
  
  
  resp=n
  echo -n "Create objects ?"
  read resp
  case $resp in
    y) echo "Creating some objects for $DB"
     mkoj
     ;;
esac
<think>好的,我现在需要帮助用户解决在基于RPM的Linux发行版上安装软件的问题。用户提到了RedHat Enterprise Linux、CentOS、Fedora和openSUSE这些系统。首先,我应该回想一下这些系统常用的包管理工具。记得RPM是这些系统的包管理基础,主要工具包括Yum和DNF,还有zypper在openSUSE中使用。 接下来,我需要整理安装软件的几种方法。通常,用户可以通过官方仓库直接安装,这是最方便的方式。比如使用yum install或者dnf install命令。另外,有时候软件可能不在官方仓库里,这时候可能需要添加第三方仓库,比如EPEL或者RPM Fusion,这些仓库提供了额外的软件包。用户可能需要先安装epel-release或者启用RPM Fusion仓库,然后再用yum或dnf安装。 第三种情况是用户直接下载了RPM包,这时候可以用rpm -i命令来安装,但需要注意依赖问题。如果依赖较多,手动处理会很麻烦,所以可能的话还是建议通过仓库安装。 还有一种方法是使用第三方提供的自动安装脚本,比如像GitLab提供的脚本,不过要提醒用户注意安全,确保来源可信。 然后,我需要结合用户提供的引用内容。引用[2]提到可以通过Yum仓库安装RabbitMQ,引用[3]提到了使用Yum仓库安装GitLab的例子。这些可以作为具体例子来说明如何添加仓库并安装软件。 此外,用户可能想知道不同发行版之间的差异。例如,openSUSE使用zypper而不是yum/dnf,所以需要单独说明。同时,收费和免费版本在稳定性上的区别,如引用[4]提到的收费版更稳定,可能影响软件安装时的选择。 还需要注意一些常见问题,比如依赖解决、GPG密钥的导入,以及更新缓存的重要性。比如在添加新仓库后,需要运行yum makecache或者dnf makecache来更新元数据。 最后,生成相关问题时要覆盖用户可能进一步关心的方面,比如如何解决依赖、第三方仓库推荐、手动安装与仓库安装的优劣比较,以及特定发行版如openSUSE的注意事项。</think>在基于RPM的Linux发行版(如Red Hat Enterprise Linux、CentOS、Fedora、openSUSE)中安装软件主要有以下方法: ### 一、通过包管理器安装 1. **Yum/DNF(RHEL/CentOS/Fedora)** - 基础命令:`sudo yum install package_name`(CentOS 7及以下) 或`sudo dnf install package_name`(Fedora/CentOS 8+) 例如安装Erlang RPM包: ```bash sudo yum install erlang # 通过预设仓库安装[^2] ``` - 添加第三方仓库(如EPEL/RPM Fusion): ```bash sudo yum install epel-release # 安装EPEL仓库 sudo yum install package_name ``` 2. **Zypper(openSUSE)** ```bash sudo zypper refresh # 更新仓库元数据 sudo zypper install package_name ``` ### 二、直接安装RPM包 1. 下载RPM文件后安装: ```bash sudo rpm -ivh package.rpm # 安装单个包 ``` 2. 自动解决依赖(需配置仓库): ```bash sudo yum localinstall package.rpm # 自动处理依赖[^3] ``` ### 三、通过第三方仓库安装 - **示例:GitLab CE安装** ```bash curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash sudo yum install gitlab-ce # 自动配置仓库并安装[^3] ``` ### 四、源码编译安装(较少用) 需安装编译工具链: ```bash sudo yum groupinstall "Development Tools" ./configure && make && sudo make install ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值