一、前期准备工作
1.1 为方便操作,装完系统后我们先安装Vmware Tools:
1.1.1、安装工具
在VMware的菜单栏上选择"虚拟机/安装虚拟机工具(VM/Install VMware Tools...)"
1.1.2、挂载光盘
# mkdir /mnt/cdrom
# mount /dev/cdrom /mnt/cdrom
1.1.3、进入挂载目录,将压缩文件复制至/tmp目录下
# cp VMwareTools-9.4.0-1280544.tar.gz /tmp
1.1.4、解压并安装
#cd /tmp
#tar -xzvf VMwareTools-9.4.0-1280544.tar.gz
#cd vmware-tools-distrib
#./vmware-install.pl
#安装过程所有问题一律Enter,安装完成后重启
1.2 设置本地时间:
#配置ntpd服务
[root@rac1 ~]# vim /etc/sysconfig/ntpd
OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid -g"
#关闭iptables
[root@rac1 ~]# chkconfig iptables off
[root@rac1 ~]# service iptables stop
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
[root@rac1 ~]# rm -rf /etc/localtime
[root@rac1 ~]# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@rac1 ~]# ntpdate time.nist.gov
29 Nov 11:22:03 ntpdate[2689]: the NTP socket is in use, exiting
[root@rac1 ~]# clock -w
[root@rac1 ~]# hwclock --systohc #将系统时间写入硬件时钟
[root@rac1 ~]# hwclock;date
Tue 29 Nov 2016 11:23:06 AM CST -1.052091 seconds
Tue Nov 29 11:23:06 CST 2016
1.3 IP和hosts配置:
1.3.1、需求:
IP
主机名
public
192.168.2.206
rac1
192.168.2.207
rac2
private
192.168.10.206
rac1-priv
192.168.10.207
rac2-priv
vip
192.168.2.208
rac1-vip
192.168.2.209
rac2-vip
SCAN
192.168.2.10
rac-cluster
1.3.2、修改IP和host配置文件:
查看VPN:nmcli con
列举系统中的网络接口:nmcli dev list
[root@rac1 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=00:0C:29:96:F1:81
TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.2.206
NETMASK=255.255.255.0
GATEWAY=192.168.2.1
DNS1=192.168.2.1
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
[root@rac1 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE="eth1"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=00:0C:29:96:F1:8B
TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.3.206
NETMASK=255.255.255.0
#GATEWAY=192.168.10.1
DNS1=192.168.10.1
NAME="System eth1"
UUID=47b8c9f9-98ef-422c-8dca-ca18d5c0c203
1.3.3、hosts配置:
[root@rac1 ~]# vim /etc/hosts
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
#eth0 public ip
192.168.2.206 rac1 rac1.localdomain
192.168.2.207 rac2 rac2.localdomain
#eth1 private ip
192.168.10.206 rac1-priv rac1-priv.localdomain
192.168.10.207 rac2-priv rac2-priv.localdomain
#virtual ip
192.168.2.208 rac1-vip rac1-vip.localdomain
192.168.2.209 rac2-vip rac2-vip.localdomain
#scan ip
192.168.2.210 rac-cluster rac-cluster-scan
这里存在一个NetworkManager的bug:
Bug 668830 - NetworkManager adds hostname to /etc/hosts pointing to localhost
该问题在NetworkManager-0.8.1-9.el6.x86_64.rpm中被解决
检查本机NetworkManager版本号:
[root@rac1 ~]# rpm -qa|grep Network
NetworkManager-0.8.1-5.el6.x86_64
NetworkManager-gnome-0.8.1-5.el6.x86_64
NetworkManager-glib-0.8.1-5.el6.x86_64
在网上下载0.8.1-9版本以上的相关rpm离线包并安装:
[root@rac1 home]# rpm -Uvh NetworkManager-0.8.1-107.el6.x86_64.rpm NetworkManager-glib-0.8.1-107.el6.x86_64.rpm NetworkManager-gnome-0.8.1-107.el6.x86_64.rpm --nodeps
[root@rac1 home]# rpm -qa|grep Network
NetworkManager-0.8.1-107.el6.x86_64
NetworkManager-glib-0.8.1-107.el6.x86_64
NetworkManager-gnome-0.8.1-107.el6.x86_64
[root@rac1 home]# cd --
[root@rac1 ~]# service NetworkManager restart
Stopping NetworkManager daemon: [ OK ]
Setting network parameters... [ OK ]
Starting NetworkManager daemon: [ OK ]
[root@rac1 ~]# chkconfig NetworkManager on
[root@rac1 ~]# service network restart
1.4 依赖软件包安装:
1.4.1、配置本地yum源
1、删除本地yum源
[root@rac1 ~]# # rpm -aq | grep yum|xargs rpm -e --nodeps
2、下载新的yum安装包,上传至/home目录下
yum-3.2.27-14.el6.noarch.rpm
python-iniparse-0.3.1-2.1.el6.noarch.rpm
yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm
3、安装yum软件包
[root@rac1 home]# rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm --force
[root@rac1 home]# rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm --force
[root@rac1 home]# rpm -ivh yum-3.2.27-14.el6.noarch.rpm yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm
--force 即使覆盖属于其它包的文件也强迫安装
--nodeps 如果该RPM包的安装依赖其它包,即使其它包没装,也强迫安装。
4、 更改yum源
[root@rac1 home]# cd /etc/yum.repos.d/
[root@rac1 yum.repos.d]# vi CentOS6-Base-163.repo
编辑文件,把文件里面的$releasever全部替换为版本号,即6 最后保存!
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-6 - Base - 163.com
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-6 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-6 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-6 - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
5、清理yum缓存
[root@rac1 yum.repos.d]# yum clean all
[root@rac1 yum.repos.d]# yum makecache
6、安装软件依赖包
[root@rac1 ~]# yum install binutils-2.*
[root@rac1 ~]# yum install compat-libstdc++-33*
[root@rac1 ~]# yum install elfutils-libelf-0.*
[root@rac1 ~]# yum install elfutils-libelf-devel-*
[root@rac1 ~]# yum install libaio-0.*
[root@rac1 ~]# yum install libaio-devel-0.*
[root@rac1 ~]# yum install sysstat-9.*
[root@rac1 ~]# yum install glibc-2.*
[root@rac1 ~]# yum install glibc-common-2.*
[root@rac1 ~]# yum install glibc-devel-2.* glibc-headers-2.*
[root@rac1 ~]# yum install ksh-2* #官方要求安装pdksh-5* 包,需要手动下载离线包进行安装
[root@rac1 ~]# yum install make-3.*
[root@rac1 ~]# yum install libgcc-4.*
[root@rac1 ~]# yum install libstdc++-4.*
[root@rac1 ~]# yum install libstdc++-4.*.i686*
[root@rac1 ~]# yum install libstdc++-devel-4.*
[root@rac1 ~]# yum install gcc-4.*x86_64*
[root@rac1 ~]# yum install gcc-c++-4.*x86_64*
[root@rac1 ~]# yum install libtool-ltdl*i686*
[root@rac1 ~]# yum install ncurses*i686*
[root@rac1 ~]# yum install readline*i686*
[root@rac1 ~]# yum install unixODBC*
[root@rac1 ~]# yum install libXp
1.5 建立用户及组
#组
[root@rac1 ~]# groupadd -g 1300 dba
[root@rac1 ~]# groupadd -g 1301 oper
[root@rac1 ~]# groupadd -g 1000 oinstall
[root@rac1 ~]# groupadd -g 1200 asmadmin
[root@rac1 ~]# groupadd -g 1201 asmdba
[root@rac1 ~]# groupadd -g 1202 asmoper
#用户
[root@rac1 ~]# useradd -m -u 1100 -g oinstall -G asmadmin,asmdba,asmoper,dba -s /bin/bash grid
[root@rac1 ~]# useradd -m -u 1101 -g oinstall -G dba,oper,asmdba -s /bin/bash Oracle
#设置密码
[root@rac1 ~]# passwd oracle
Changing password for user oracle.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@rac1 ~]# passwd grid
Changing password for user grid.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
1.6 创建grid和oracle用户目录结构
#这个目录存放oracle安装或升级信息
[root@rac1 ~]# mkdir -p /u01/app/oraInventory
[root@rac1 ~]# chown -R grid:oinstall /u01/app/oraInventory
[root@rac1 ~]# chmod -R 775 /u01/app/oraInventory
#这个目录存放asm实例信息
[root@rac1 ~]# mkdir -p /u01/app/grid
[root@rac1 ~]# chmod -R 775 /u01/app/grid
[root@rac1 ~]# chown -R grid:oinstall /u01/app/grid
#这个目录主要存放grid软件信息
[root@rac1 ~]# mkdir -p /u01/app/11.2.0/grid
[root@rac1 ~]# chown -R grid:oinstall /u01/app/11.2.0/grid
[root@rac1 ~]# chmod -R 775 /u01/app/11.2.0/grid
#oracle用户目录
[root@rac1 ~]# mkdir -p /u01/app/oracle
[root@rac1 ~]# mkdir -p /u01/app/oracle/cfgtoollogs
[root@rac1 ~]# chown -R oracle:oinstall /u01/app/oracle
[root@rac1 ~]# chmod -R 775 /u01/app/oracle
[root@rac1 ~]# mkdir -p /u01/app/oracle/product/11.2.0/db_1
[root@rac1 ~]# chown -R oracle:oinstall /u01/app/oracle/product/11.2.0/db_1
[root@rac1 ~]# chmod -R 775 /u01/app/oracle/product/11.2.0/db_1
1.7 修改系统参数
[root@rac1 ~]# vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
[root@rac1 ~]# vi /etc/pam.d/login
session required pam_limits.so
[root@rac1 ~]# vi /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
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
kernel.shmall = 2097152
kernel.shmmax = 4294967295
[root@rac1 ~]# sysctl -p
1.8 用户环境变量设置
#grid 用户
[root@rac1 ~]# su - grid
[grid@rac1 ~]$ vim /home/grid/.bash_profile
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=+ASM1
[grid@rac1 ~]$ source /home/grid/.bash_profile
#oracle用户
[grid@rac1 ~]$ su - oracle
Password:
[oracle@rac1 ~]$ vim /home/oracle/.bash_profile
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=rac1
[oracle@rac1 ~]$ source /home/oracle/.bash_profile