- 配置yum源
cd /etc
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
mkdir yum.repos.d
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 清理缓存
yum clean all
# 建缓存
yum makecache
#安装epel源
yum -y install epel-release
- Selinux配置
#selinux修改后需要重启主机生效:
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
- 配置Hosts文件
cat <<EOF >>/etc/hosts
##OracleBegin##
##Public IP
192.168.129.191 oracle11g
##OracleEnd##
EOFhostnamectl set-hostname orcl
- 防火墙配置
systemctl stop firewalld
systemctl disable firewalld
- 安装Oracle依赖包
yum install -y bc \
binutils \
compat-libcap1 \
compat-libstdc++-33 \
gcc \
gcc-c++ \
elfutils-libelf \
elfutils-libelf-devel \
glibc \
glibc-devel \
ksh \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
libxcb \
libX11 \
libXau \
libXi \
libXtst \
libXrender \
libXrender-devel \
make \
net-tools \
nfs-utils \
smartmontools \
sysstat \
e2fsprogs \
e2fsprogs-libs \
fontconfig-devel \
expect \
unzip \
openssh-clients \
readline* \
psmisc --skip-broken
- 检查是否安装成功
rpm -q bc binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ elfutils-libelf elfutils-libelf-devel glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libxcb libX11 libXau libXi libXtst libXrender libXrender-devel make net-tools nfs-utils smartmontools sysstat e2fsprogs e2fsprogs-libs fontconfig-devel expect unzip openssh-clients readline | grep "not installed"
- 配置ZeroConf
##关闭Zeroconf service的服务守护进程
systemctl stop avahi-daemon.socket
systemctl stop avahi-daemon.service
systemctl disable avahi-daemon.service
systemctl disable avahi-daemon.socket
- ##关闭NOZEROCONF
cat <<EOF >>/etc/sysconfig/network
#OracleBegin
NOZEROCONF=yes
#OracleEnd
EOF
- 关闭GRUB
sed -i 's/quiet/quiet transparent_hugepage=never numa=off/' /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
- 配置系统参数文件
##配置系统参数
cat <<EOF >>/etc/sysctl.conf
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
EOF##系统参数生效
sysctl -p
- 配置系统资源限制
cat <<EOF >>/etc/security/limits.conf
#OracleBegin
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
oracle soft nproc 2047
oracle hard nproc 16384
oracle hard memlock 134217728
oracle soft memlock 134217728
#OracleEnd
EOFcat <<EOF >>/etc/pam.d/login
#OracleBegin
session required pam_limits.so
session required /lib64/security/pam_limits.so
#OracleEnd
EOF
- 创建用户和组
/usr/sbin/groupadd -g 54321 oinstall
/usr/sbin/groupadd -g 54322 dba
/usr/sbin/groupadd -g 54323 oper/usr/sbin/useradd -u 54321 -g oinstall -G dba,oper oracle
echo oracle | passwd --stdin oracle
- 创建Oracle安装目录
mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1
mkdir -p /u01/app/oraInventory
mkdir -p /u01/app/oracle/oradata
chown -R oracle:oinstall /u01/app
chmod -R 775 /u01/app
- 配置用户环境变量
cat <<EOF >>/home/oracle/.bash_profile
################OracleBegin#########################
umask 022
export TMP=/tmp
export TMPDIR=\$TMP
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_HOSTNAME=orcl
export ORACLE_TERM=xterm
export TNS_ADMIN=\$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib
export ORACLE_SID=orcl
export PATH=/usr/sbin:\$PATH
export PATH=\$ORACLE_HOME/bin:\$ORACLE_HOME/OPatch:\$PATH
alias sas='sqlplus / as sysdba'
export PS1="[\`whoami\`@\`hostname\`:"'\$PWD]\$ '
EOFsource /home/oracle/.bash_profile
- 解压Oracle软件安装包
##需要按顺序解压1,2安装包:
cd /soft
unzip -q Linux-x86-64_1of2.zip
unzip -q Linux-x86-64_2of2.zip
##授权/soft给oracle读写权限
chown -R oracle:oinstall /soft
- 安装VNC软件
yum install -y tigervnc*su - oracle
vncserver
##输入密码export DISPLAY=192.168.129.191:1
- 连接VNC远程工具或者直接打开虚拟机图形化界面
##右键打开终端工具:
进入/soft/database开始安装Oracle软件:
su oracle
./runInstaller
- 之后按照提示进行操作
swap设置的太小。
#创建swap文件 bs的设置的值一般为内存的1.5倍以上
swapoff -a rm /var/swap
dd if=/dev/zero of=/var/swap bs=1024 count=8000000
#需要更改swap文件的权限,确保只有root才可读
chmod 600 /var/swap
#告知系统将该文件用于swap
mkswap /var/swap
#开始使用该swap
swapon /var/swap
#使Swap文件永久生效,/etc/fstab加入配置
echo "/var/swap swap swap sw 0 0" >> /etc/fstab