Centos下Oracle11gR2安装教程与自动化配置脚本的方法

系统环境准备

开发组件与依赖库安装

Centos下Oracle11gR2安装教程与自动化配置脚本的方法

安装centos时选择Server with GUI,右面的可以不勾选,后面统一来装

配置本地yum源

以上包如果缺乏可配置本地yum源进行安装

sudo mount /dev/cdrom /mnt/

[galen@localhost yum.repos.d]$ sudo vim /etc/yum.repos.d/cdrom.repo
[galen@localhost yum.repos.d]$ cat cdrom.repo 
[c7-media]
name=isofile
baseurl=file:///mnt
enable=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[galen@localhost yum.repos.d]$ sudo mv CentOS-Base.repo CentOS-Base.repo-bak
[galen@localhost yum.repos.d]$ sudo mv CentOS-Media.repo CentOS-Media.repo-bak
[galen@localhost yum.repos.d]$ sudo mv cdrom.repo CentOS-Media.repo

配置好yum源后开始安装依赖库,如下

yum install glibc glibc-devel glibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh compat-libcap1  compat-libstdc++ elfutils-libelf-devel gcc-c++

关闭防火墙

[galen@localhost ~]$ systemctl stop firewalld.service 
[galen@localhost ~]$ systemctl disable firewalld.service 
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

关闭selinux

编辑/etc/sysconfig/selinux文件,保存退出后执行 setenforce 0命令

vim /etc/sysconfig/selinux
SELINUX=disabled
#SELINUXTYPE=targeted  #注释掉

创建oracle用户、修改系统参数

创oracle建用户和组

[root@localhost galen]# groupadd oinstall
[root@localhost galen]# groupadd dba
[root@localhost galen]# useradd -g oinstall -G dba oracle
[root@localhost galen]# passwd oracle

[root@localhost galen]# id oracle
uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba)

系统参数设置

官方推荐值:

fs.aio-max-nr = 1048576  
fs.file-max = 6815744  
kernel.shmall = 2097152 
kernel.shmmax = 536870912 #推荐超过一半的物理内存
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 

通过 /sbin/sysctl -a |grep xxx 查看系统各参数,如果大于官方推荐值不修改,如果小于官方推荐值则修改为官方推荐值,写入/etc/sysctl.conf文件中,使用sysctl -p使其生效,示例如下

[root@localhost etc]# cat sysctl.conf
fs.aio-max-nr = 6815744
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

修改资源限制如下

[root@localhost etc]# vim /etc/security/limits.conf
oracle		soft		nproc		2048
oracle		hard		nproc		16384
oracle		soft		nofile		1024
oracle		hard		nofile		65536
oracle		soft		stack		10240 

添加以下内容到/etc/pam.d/login

[root@localhost ~]# vim /etc/pam.d/login
session required  pam_limits.so

添加以下内容到/etc/profile

[root@localhost ~]# vim /etc/profile
if [[ $USER = "oracle" ]]; then
	if [[ $SHELL = "/bin/ksh" ]]; then
		ulimit -p 16384
		ulimit -n 65536
	else
		ulimit -u 16384 -n 65536
	fi
fi

保存后执行source /etc/profile生效

配置oracle用户环境变量,在/home/oracle/.bash_profile中加入如下内容

[root@localhost ~]# vim /home/oracle/.bash_profile
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LANG="en_US.UTF-8"
export NLS_LANG=american_AMERICA.UTF8
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"

创建oracle安装目录

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

安装oracle 11g

挂载oracle11g安装包iso(也可以通过其他方式将oracle安装包传到主机),将安装文件复制到oracle home目录下,修改文件权限给oracle用户

Centos下Oracle11gR2安装教程与自动化配置脚本的方法

扫一扫手机访问