oracle 数据库 安装 和优化

文档说明:以#开始命令表示root用户执行,$开始命令以oracle/grid执行(前面都有切换用户的动作)
==================================================
一.基础环境准备
==================================================
--------------------------------------------------
1.1.操作系统检查(录屏:<nodename>_os_check.log)
--------------------------------------------------
1).内存及交换分区
====================
a).内存大小要求至少:1GB
--------------------
# grep MemTotal /proc/meminfo

--------------------
b).交换空间大小
--------------------
Available RAM Swap Space Required
Between 1 GB and 2 GB 1.5 times the size of RAM
Between 2 GB and 16 GB Equal to the size of RAM
More than 16 GB 16 GB

# free -m

--------------------
c).共享内存段
--------------------
至少要大于MEMORY_MAX_TARGET and MEMORY_TARGET
# df -m /dev/shm/

--系统默认共享内存段为内存大小一半,可以通过以下方式调整(建议不要超过内存)
# mount -t tmpfs shmfs -o size=<7g> /dev/shm

--永久生效则在/etc/fstab里面加入:
shmfs /dev/shm tmpfs size=7g 0

====================
2).文件系统
====================
a)./tmp至少1g
--------------------
# df -h /tmp
--安装或者卸载都需要确保oracle用户在/tmp下有执行权限;

--------------------
b).安装目录40g
--------------------
# df -h

====================
3).操作系统版本
====================
--------------------
a).系统详细信息
--------------------
# cat /proc/version
--确认内核版本

--------------------
b).发行版本
--------------------
# lsb_release -id

====================
4).补丁包安装
====================
binutils-2.23.52.0.1-12.el7.x86_64
compat-libcap1-1.10-3.el7.x86_64
compat-libstdc++-33-3.2.3-71.el7.i686
compat-libstdc++-33-3.2.3-71.el7.x86_64
gcc-4.8.2-3.el7.x86_64
gcc-c++-4.8.2-3.el7.x86_64
glibc-2.17-36.el7.i686
glibc-2.17-36.el7.x86_64
glibc-devel-2.17-36.el7.i686
glibc-devel-2.17-36.el7.x86_64
ksh
libaio-0.3.109-9.el7.i686
libaio-0.3.109-9.el7.x86_64
libaio-devel-0.3.109-9.el7.i686
libaio-devel-0.3.109-9.el7.x86_64
libgcc-4.8.2-3.el7.i686
libgcc-4.8.2-3.el7.x86_64
libstdc++-4.8.2-3.el7.i686
libstdc++-4.8.2-3.el7.x86_64
libstdc++-devel-4.8.2-3.el7.i686
libstdc++-devel-4.8.2-3.el7.x86_64
libXi-1.7.2-1.el7.i686
libXi-1.7.2-1.el7.x86_64
libXtst-1.2.2-1.el7.i686
libXtst-1.2.2-1.el7.x86_64
make-3.82-19.el7.x86_64
sysstat-10.1.5-1.el7.x86_64
elfutils-libelf-devel-*

yum -y install binutils-*.x86_64 \
compat-libcap1-*.x86_64 \
compat-libstdc++-*.x86_64 \
compat-libstdc++-*.i?86 \
gcc-*.x86_64 \
gcc-c++-*.x86_64 \
glibc-*.i?86 \
glibc-*.x86_64 \
glibc-devel-*.x86_64 \
glibc-devel-*.i?86 \
ksh \
libaio-*.x86_64 \
libaio-*.i?86 \
libaio-devel-*.x86_64 \
libaio-devel-*.i?86 \
libgcc-*.i?86 \
libgcc-*.x86_64 \
libstdc++-*.x86_64 \
libstdc++-*.i?86 \
libstdc++-devel-*.x86_64 \
libstdc++-devel-*.i?86 \
libXi-*.i?86 \
libXi-*.x86_64 \
libXtst-*.i?86 \
libXtst-*.x86_64 \
make-* \
sysstat-*.x86_64 \
unixODBC-*.x86_64 \
unixODBC-*.i?86 \
elfutils-libelf-devel-*.i?86 \
elfutils-libelf-devel-*.x86_64 \
unixODBC-devel-*.x86_64

--rlwrap
yum -y install rlwrap-0.37-1.el5.x86_64.rpm

====================
5).调整系统资源限制
====================
a).内核参数
--------------------
# vi /etc/sysctl.conf
--加入以下内容
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4294967295
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576

--下次启动读取
# chkconfig boot.sysctl on
--当前生效
# sysctl -p

--------------------
b).资源限制
--------------------
# vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768


--------------------------------------------------
1.2.配置IP地址解析(录屏:<node_name>_pre-install.log)
--------------------------------------------------
# vi /etc/hosts
保留回环地址之外加入:
#public
192.168.100.111 node111
192.168.100.112 node112

#private
172.16.100.111 node111-priv
172.16.100.112 node112-priv

#vip
192.168.100.211 node111-vip
192.168.100.212 node112-vip

#scanip
192.168.100.213 11gscanip

--------------------------------------------------
1.4.创建系统组、用户
--------------------------------------------------
====================
1).存在性检查
====================
--------------------
a).检查
--------------------
# id oracle
# more /etc/passwd
# more /etc/group
//如果用户已经存在,需要确认这些参数。最好是删除重建用户和组,保证正确性

--------------------
b).删除用户方案
--------------------
# userdel -r oracle
# rm -rf /home/oracle
注:跳过步骤c)到创建用户


====================
2).创建系统组、用户
====================
a).创建系统组
--------------------
/usr/sbin/groupadd -g 1100 oinstall
/usr/sbin/groupadd -g 1101 dba
/usr/sbin/groupadd -g 1102 oper
/usr/sbin/groupadd -g 1103 asmadmin
/usr/sbin/groupadd -g 1104 asmdba
/usr/sbin/groupadd -g 1105 asmoper

--------------------
b).创建用户
--------------------
/usr/sbin/useradd -m -u 1100 -g oinstall -G dba,oper,asmdba oracle
/usr/sbin/useradd -m -u 1200 -g oinstall -G asmadmin,asmdba,asmoper grid

--------------------
c).检查用户
--------------------
# id oracle
# id grid

--------------------
d).修改用户密码
--------------------
# passwd oracle
# su - oracle
注:建议登录一次图形界面

--------------------------------------------------
1.5.创建安装目录
--------------------------------------------------
mkdir -p /u01/app/grid
chown grid:oinstall /u01/app/grid
chmod -R 775 /u01/app/grid
mkdir -p /u01/app/11.2.0/grid
chown -R grid:oinstall /u01/app/11.2.0/grid
chmod -R 775 /u01/app/11.2.0/grid

mkdir -p /u01/app/oraInventory
chown -R grid:oinstall /u01/app/oraInventory
chmod -R 775 /u01/app/oraInventory
mkdir -p /u01/app/oracle
mkdir /u01/app/oracle/cfgtoollogs
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/app/oracle
mkdir -p /u01/app/oracle/product/11.2.0/db_1
chown -R oracle:oinstall /u01/app/oracle/product/11.2.0/db_1
chmod -R 775 /u01/app/oracle/product/11.2.0/db_1

--------------------------------------------------
1.6.oracle用户环境变量
--------------------------------------------------
# su - oracle
$ vi /home/oracle/.profile
--加入以下内容:
#################################
#parameter for oracle 11g #
#################################
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1

#################################
#parameter for all #
#################################
#export ORACLE_SID=sourcedb
export ORACLE_TERM=xterm
export NLS_LANG=american_america.zhs16gbk #fit your own database
export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:/usr/sbin/:$PATH/sbin:$PATH

################################
#all alias #
################################
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'


--grid
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
#export ORACLE_SID=+ASM1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:/usr/sbin/:$PATH/sbin:$PATH

#确保PATH变量中/usr/bin在/usr/local/bin前面,否则会在optach升级时报错()

==================================================
二.RDBMS安装配置
==================================================
2.1.安装RDBMS(oracle 用户)(录屏:<nodename>_rdbms_install.log)
--------------------------------------------------
1).开始安装
====================
# su - oracle
$ cd /orastg/software
$ unzip p13390677_112040_AIX64-5L_1of7.zip 1>/dev/zero 2>db1.err
$ unzip p13390677_112040_AIX64-5L_2of7.zip 1>/dev/zero 2>db2.err
$ cd /orastg/software/database
$ export DISPLAY=10.1.25.30:0.0
$ ./runInstaller

所有节点按照要求以root用户执行rootpre.sh脚本(两个节点都需要)
# cd /orastg/software/database
# ./rootpre.sh

====================
2).图形界面
====================
-不接受安全更新
-skip software updates
-Install database software only
-SingleInstance
-增加简体中文到下一步
-选择企业版
-确认ORACLE_BASE,ORACLE_HOME无误
-确认用户组
-等待CVU检查
-检查check不通过问题
-确认配置信息
-等待安装过程
-以root用户按照主机顺序执行root脚本(录屏:<nodename>_root_script_out.log)

安装过程出现make emagent的报错需要将vim $ORACLE_HOME/sysman/lib/ins_emagent.mk
$(MK_EMAGENT_NMECTL)
to
$(MK_EMAGENT_NMECTL)–lnnz11


==================================================
三.RDBMS补丁安装
==================================================
3.1.补丁准备工作录屏:(录屏:<nodename>_pre-patch.log)
--------------------------------------------------
# su - oracle
$ cd /orastg/software/
$ unzip p6880880_112000_AIX64-5L-OPatch_patch.zip 1>/dev/zero 2>optach.err
$ unzip p17478514_112040_AIX64-5L-PSU112041.zip 1>/dev/zero 2>psu.err
$ unzip p18180390_112041_AIX64-5L.zip 1>/dev/zero 2>oneoff.err

注:确认所有.err的日志输出文件中无报错

--------------------------------------------------
3.2.安装Opatch(录屏:<nodename>_opatch-patch.log)
--------------------------------------------------
1).OPatch安装(两个节点root)
====================
a).备份原有OPatch并确认
--------------------
# mv /u01/app/oracle/product/11.2.0/db_1/OPatch /u01/app/oracle/product/11.2.0/db_1/OPatch_old
# ls -ltr /u01/app/oracle/product/11.2.0/db_1/ |grep OPatch

--------------------
b).patch安装
--------------------
# cp -r OPatch /u01/app/oracle/product/11.2.0/db_1/
# chown -R oracle:oinstall /u01/app/oracle/product/11.2.0/db_1/OPatch

====================
2).OPatch版本确认
====================
分别以grid和oracle确认opatch 版本
$ opatch lsinventory

--------------------------------------------------
3.3.安装PSU
--------------------------------------------------
1).清理Lib
====================
a).清理
--------------------
# slibclean

--------------------
b).确认lib是否被占用
--------------------
# genkld |grep oracle
注:需要没有返回结果

====================
2).RDBMS PSU安装(录屏:<nodename>_rdbms-psu-patch.log)
====================
a).PSU安装检测
--------------------
# su - oracle
$ opatch prereq CheckConflictAgainstOHWithDetail -ph /software/112041patch/17478514

-------------------
c).正式安装
-------------------
$ opatch apply -oh /u01/app/oracle/product/11.2.0/db_1 -local /software/112041patch/17478514

--------------------
d).完成
--------------------
opatch lsinventory

--------------------------------------------------
3.4.安装one-off补丁(录屏:<nodename>_rdbms-oneoff-patch.log)
--------------------------------------------------
# su - oracle
$ opatch prereq CheckConflictAgainstOHWithDetail -ph /software/112041patch/18180390
$ opatch apply -oh /u01/app/oracle/product/11.2.0/db_1 -local /software/112041patch/18180390

--------------------------------------------------
3.5.完成Patch安装(录屏:<nodename>_finish-patch.log)
--------------------------------------------------
1).确认所有Patch
====================
$ opatch lsinventory

升级时报错:/usr/bin/ld: warning: -z nolazyload ignored. Doc ID 2071922.1


alter user sys identified by oracle 2 ;修改oracle账户密码

上一篇:linux下图形化安装oracle数据适合初学者


下一篇:oracle ogg 单实例双向复制搭建(oracle-oracle)--Oracle GoldenGate