Oracle的学习从安装开始,尤其是在Linux上的安装会相对复杂一些。连写了3篇Oracle的安装博客,也是没谁了。 :(
Step1:修改Hostname
[root@jmilkfan Desktop]# hostname
jmilk.fan.com
Step2:关闭Selinux
vim /etc/sysconfig/selinux
SELINUX=disabbled
Step3:修改网络配置
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
HWADDR="00:0C:29:8A:11:38"
NM_CONTROLLED="yes"
ONBOOT="yes"
IPADDR=10.100.100.130
NETMASK=255.0.0.0
Step4:修改Hosts文件
当然可以使用DNS Server,主要在Oracle Client使用Oracle监听程序连接到Oracle Server的时候可以进行IP、域名解析,不需要修改tnsnames.ora配置文件。
Vim /etc/hosts
10.100.100.130 jmilk.fan.com jmilk
Step5:关闭防火墙
service iptables stop
chkconfig iptables off
Step6:重启系统
[root@jmilk Desktop]# grep MemTotal /proc/meminfo
#官方要求内存大于512M
[root@jmilk Desktop]# grep SwapTotal /proc/meminfo
#官方给出了内存和Swap分区大小的配比,这里建议Swap给到内存的2倍
[root@jmilk Desktop]# df -m /tmp
#在安装Oracle过程中Tmp必须有400M的空余空间
Step1:配置YUM源,RHEL6.1安装光盘就能够满足
Step2:确定内核版本
[root@jmilk Desktop]# uname -a
Linux jmilk.fan.com 2.6.32-131.0.15.el6.x86_64 #1 SMP Tue May 10 15:42:40 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
Step3:检测软件包是否安装完整
这些软件包能够支撑,Oracle安装程序在安装的过程中对某些模块进行重新编译,然后再安装。我们可以Oracle官方文档在或者oraToolKit中找到。
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' binutils glibc glibc-common libaio libgcc libstdc++ make ksh libgomp sysstat kernel-headers libstdc++-devel elfutils-libelf-devel mpfr libXmu libXt libXxf86misc glibc-headers libXxf86vm glibc-headers libXxf86vm xorg-x11-xauth cpp libtool-ltdl unixODBC cloog-ppl ppl libmcpp mcpp xorg-x11-server-utils compat-db42 compat-db43 libdmx libXv libXxf86dga libIDL ORBit2 GConf2 libbonobo gtk2-engines shared-mime-info libdaemon avahi avahi-glib gnome-vfs2 xorg-x11-utils compat-libstdc++-33 celt051 libXp ConsoleKit-x11 xorg-x11-xinit glibc-devel gcc compat-gcc-34 ncurses-devel gcc-c++ libgnome readline-devel compat-db libaio-devel compat-gcc-34-c++
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' libgcc nss-softokn-freebl glibc libaio libstdc++ ncurses-libs readline libICE libtool-ltdl libSM libuuid unixODBC libXau libX11 libxcb libXext libXi compat-libstdc++-33 libXt libXtst libaio-devel unixODBC-devel glibc-devel
需要将没安装的rpm包都安装上之后,才能成功安装Oracle,当然我们也可以直接yum安装。
32位包:
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' libgcc nss-softokn-freebl glibc libaio libstdc++ ncurses-libs readline libICE libtool-ltdl libSM libuuid unixODBC libXau libX11 libxcb libXext libXi compat-libstdc++-33 libXt libXtst libaio-devel unixODBC-devel glibc-devel
64位包:
yum install -y celt051 libXp compat-gcc-34 libaio-devel unixODBC-devel compat-gcc-34-c++ libaio-0.3.107-10.el6.i686 ncurses-libs-5.7-3.20090208.el6.i686 readline-6.0-3.el6.i686 libICE-1.0.6-1.el6.i686 libtool-ltdl-2.2.6-15.5.el6.i686 libSM-1.1.0-7.1.el6.i686 libuuid unixODBC-2.2.14-11.el6.i686 libXau-1.0.5-1.el6.i686 libX11-1.3-2.el6.i686 libxcb-1.5-1.el6.i686 libXext-1.1-3.el6.i686 libXi-1.3-3.el6.i686 compat-libstdc++-33-3.2.3-69.el6.i686 libXt-1.0.7-1.el6.i686 libXtst-1.0.99.2-3.el6.i686 libaio-devel-0.3.107-10.el6.i686 unixODBC-devel-2.2.14-11.el6.i686 glibc-devel-2.12-1.25.el6.i686 ksh-20100621-6.el6.x86_64
进入到光盘挂载目录下的Package目录下,强制安装一个rpm包。这是一个BUG,明明没安装却告诉你安装了。
rpm -ivh libXp-1.0.0-15.1.el6.i686.rpm --force
rpm -ivh libXp-1.0.0-15.1.el6.x86_64.rpm --force
OraToolKit是一个辅助安装Oracle的工具,我们能通过它来检测我们的系统环境是否满足安装Oracle的需求。
[root@jmilk tmp]# rpm -ivh oratoolkit-1.0.2.1.5-1.noarch.rpm
Preparing... ########################################### [100%]
usermod: user oracle is currently logged in
1:oratoolkit ########################################### [100%]
usermod: user oracle is currently logged in
验证系统环境是否满足安装Oracle:
[root@jmilk otk]# pwd
/opt/oracle/otk/current/tools/
[root@jmilk tools]# /opt/oracle/otk/current/bin/installManager swReqCheck osSetup10gR2.cfg
如果最终检测结果出现了ERROR表示不满足安装条件,需要进一步的进行配置,一般是安装缺少的软件包。如果出现了Warning或Successfully表示可以安装Oracle。
在手动创建Oracle用户之前,其实我们在安装oraToolkit的时候就已经自动的创建了一个oracle用户和oinstall、dba这两个组,家目录默认为/opt/oracle/otk/home
。如果不希望使用默认用户的话,可以手动的删除他。
groupdel oinstall
groupdel dba
userdel oracle
groupadd oinstall #只有oinstall组内的用户才能够执行安装程序
groupadd dba #只有dba组内的用户才能够创建数据库
mkdir -p /u01/oracle
useradd -g oinstall -G dba -d /u01/oracle oracle
(echo fanguiju;echo fanguiju) | passwd --stdin oracle
chown -R oracle:oinstall /u01
more /etc/passwd|grep oracle
su - oracle
现在创建的oracle用户并没有.bash_profile
和.bashrc
个性化的环境配置文件,需要手动创建。
vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
unset USERNAME
#下面这些环境变量配置,会在运行Oracle安装程序的时候被加载
ORACLE_BASE=/u01
ORACLE_HOME=$ORACLE_BASE/oracle
ORACLE_SID=demo
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
alias sqlplus="rlwrap sqlplus"
alias rman="rlwrap rman"
alias lsnrctl="rlwrap lsnrctl"
export EDITOR=vi
stty erase ^h
vi .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
加载环境变量
source ./.bash_profile
source ./.bashrc
Step1:修改sysctl.conf配置文件
为了限定Oracle Instance所占用的内存。
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Controls IP packet forwarding
net.ipv4.ip_forward = 0
# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0
# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0
# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1
# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1
# Disable netfilter on bridges.
# net.bridge.bridge-nf-call-ip6tables = 0 在这行前加#
# net.bridge.bridge-nf-call-iptables = 0 在这行前加#
# net.bridge.bridge-nf-call-arptables = 0 在这行前加#
# Controls the maximum size of a message, in bytes
kernel.msgmnb = 65536
# Controls the default maxmimum size of a message queue
kernel.msgmax = 65536
# Controls the maximum shared segment size, in bytes
kernel.shmmax = 68719476736
# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 4294967296 删除这行并添加以下内容:
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144
#shmall 是全部允许使用的共享内存大小
#shmmax 是单个segment段允许使用的大小
#shmmni= 整个系统的内存segment的总个数
#sem =内核信号量
#修改这个配置文件的意义在于,限定Oracle数据库使用的共享内存池
重新加载配置文件
sysctl -p
Step2: 修改limits.conf配置文件
为了限定oracle用户能够启用的进程数量和能够打开的文件数量。
vim /etc/security/limits.conf
# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain> <type> <item> <value>
#
#Where:
#<domain> can be:
# - an user name
# - a group name, with @group syntax
# - the wildcard *, for default entry
# - the wildcard %, can be also used with %group syntax,
# for maxlogin limit
#
#<type> can have the two values:
# - "soft" for enforcing the soft limits
# - "hard" for enforcing hard limits
#
#<item> can be one of the following:
# - core - limits the core file size (KB)
# - data - max data size (KB)
# - fsize - maximum filesize (KB)
# - memlock - max locked-in-memory address space (KB)
# - nofile - max number of open files
# - rss - max resident set size (KB)
# - stack - max stack size (KB)
# - cpu - max CPU time (MIN)
# - nproc - max number of processes
# - as - address space limit (KB)
# - maxlogins - max number of logins for this user
# - maxsyslogins - max number of logins on the system
# - priority - the priority to run user process with
# - locks - max number of file locks the user can hold
# - sigpending - max number of pending signals
# - msgqueue - max memory used by POSIX message queues (bytes)
# - nice - max nice priority allowed to raise to values: [-20, 19]
# - rtprio - max realtime priority
#
#<domain> <type> <item> <value>
#
#* soft core 0
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#@student - maxlogins 4
# End of file 加入以下内容:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
#linux limits.conf 配置文件实际是 Linux PAM(插入式认证模块,Pluggable Authentication Modules)中 pam_limits.so 的配置文件
#这个配置文件限制oracle用户启动的最大进程数和能够打开的最大文件数
Step3:修改login配置文件
为了让oracle登陆的同时使limits.conf配置文件生效。
vi /etc/pam.d/login
#%PAM-1.0
auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
auth include system-auth
account required pam_nologin.so
account include system-auth
password include system-auth
# pam_selinux.so close should be the first session rule
session required pam_selinux.so close
session required pam_loginuid.so
session optional pam_console.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session required pam_selinux.so open
session required pam_namespace.so
session optional pam_keyinit.so force revoke
session include system-auth
-session optional pam_ck_connector.so 加入以下内容:
session required /lib/security/pam_limits.so
session required pam_limits.so
#在linux中执行有些程序时,这些程序在执行前首先要对启动它的用户进行认证,符合一定的要求之后才允许执行
#在linux中进行身份或是状态的验证程序是由PAM来进行的,PAM(Pluggable Authentication Modules)可动态加载验证模块
#因为可以按需要动态的对验证的内容进行变更,所以可以大大提高验证的灵活性。
#这个配置文件,就是让 limits.conf 的配置内容在oracle登陆的时候生效
Step4:修改profile配置文件
避免用户使用zsh,导致的进程数量过高,所以加入了一段Shell代码。当oracle是以zsh登陆的时候,也能够正确的限制启动进程数量。
vi /etc/profile
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}
if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`id -u`
UID=`id -ru`
fi
USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
pathmunge /sbin after
fi
HOSTNAME=`/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
umask 002
else
umask 022
fi
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null 2>&1
fi
fi
done
Unset i
unset pathmunge 加入以下内容:
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
#ulimit用于shell启动进程所占用的资源
#profile文件是系统整体的环境变量配置文件
su - root
cp /etc/redhat-release /etc/redhat-release.bak
vi /etc/redhat-release
Red Hat Enterprise Linux Server release 4
cd /tmp
mkdir -p oracle10gr2
cd oracle10gr2/
zcat 10201_database_linux_x86_64.cpio.gz | cpio -idmv
mv database/ /u01
cd /u01
chown -R oracle:oinstall database/
ls -l
init 6
重启并且以oracle用户登录:为了避免不能加载x11 window的错误
init 6
cd /u01/database/
./runInstaller
选择高级安装模式
选择一个存储目录和选择一个执行安装程序的组
选择安装企业版本
选择Oracle安装的家目录
忽略这个错误
安装环境检测,如果有没有通过检测项目,需要排查,或者手动勾选
等待安装结束
这里不能够着急点OK,点了就前功尽弃了。
先以登陆到root在执行这两个脚本
[root@jmilk ~]/u01/oracle/root.sh
[root@jmilk ~]/u01/oraInventory/orainstRoot.sh
执行完这两个脚本后,点击OK
测试
[oracle@jmilk ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Wed May 25 13:25:41 2016
Copyright (c) 1982, 2005, Oracle. All rights reserved.
在Linux下面使用sqlplus很不爽,上下键,退格键都不能用,严重降低生产效率。而rlwrap可以完美的解决这个问题。
[root@jmilk rlwrap]# pwd
/opt/oracle/otk/current/tools/rlwrap
[root@jmilk rlwrap]# ./configure && make && make install
[root@jmilk rlwrap]# rlwrap
Usage: rlwrap [options] command ...
Options:
-a[password:] --always-readline[=password:] -A --ansi-colour-aware -b <chars> --break-chars=<chars> -c --complete-filenames -C <name|N> --command-name=<name|N> -D <0|1|2> --history-no-dupes=<0|1|2> -f <completion list> --file=<completion list> -F <format string> --history-format=<format string> -h --help -H <file> --history-filename=<file> -i --case-insensitive -l <file> --logfile=<file> -n --no-warnings -p[ANSI colour spec] --prompt-colour[=ANSI colour spec] -P <input> --pre-given=<input> -q <chars> --quote-characters=<chars> -m[newline substitute] --multi-line[=newline substitute] -r --remember -v --version -s <N> --histsize=<N> (negative: readonly) -t <name> --set-term-name=<name>
bug reports, suggestions, updates:
http://utopia.knoware.nl/~hlub/uck/rlwrap/
这样我们的Oracle10gr2就在RHEL6.1上安装玩车个了,但是需要注意的是严格来说我们只是安装了RDBMS,而RDBMS是没有数据库的,所以我们还需要在额外的为RDBMS创建数据库并且创建监听程序。