centos安装oracle11g-11.2.0(1)

1.设置主机名

hostnamectl set-hostname orcl

2.配置hosts文件

根据主机名和ip 配置hosts文件

cat <<EOF >>/etc/hosts
##OracleBegin##
##Public IP
10.211.55.188     orcl
##OracleEnd##
EOF

3.关闭防火墙

systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld

4.修改selinux为disabled

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

5.安装依赖包

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

6.检查是否安装成功

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

7.Linux7需要手动安装compat-libstdc++依赖包:

这里我使用了yum直接安装
yum install compat-libstdc++-33-3.2.3-72.el7.x86_64

8.配置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

9.关闭透明大页和numa

sed -i 's/quiet/quiet transparent_hugepage=never numa=off/' /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg

10.配置系统参数文件

创建1.sh文件

touch 1.sh
chmod +x 1.sh
./1.sh
1.sh中的内容

##计算shmall和shmmax值
memTotal=$(grep MemTotal /proc/meminfo | awk '{print $2}')
totalMemory=$((memTotal / 2048))
shmall=$((memTotal / 4))
if [ $shmall -lt 2097152 ]; then
  shmall=2097152
fi
shmmax=$((memTotal * 1024 - 1))
if [ "$shmmax" -lt 4294967295 ]; then
  shmmax=4294967295
fi
echo $shmall
echo $shmmax
##配置系统参数
cat <<EOF >>/etc/sysctl.conf
#OracleBegin
##shmmal's Calculation formula: physical memory 8G:(8*1024*1024*1024)/4096=2097152
##shmmax's Calculation formula: physical memory 8G:(8/2)*1024*1024*1024 -1=4294967295
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = $shmall
kernel.shmmax = $shmmax
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

11.配置系统资源限制

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
EOF

cat <<EOF >>/etc/pam.d/login
#OracleBegin
session required pam_limits.so 
session required /lib64/security/pam_limits.so
#OracleEnd
EOF

12.创建用户和组

/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

13.创建oracle的安装目录

mkdir -p /u01/app/oracle/product/11.2.0/db
mkdir -p /u01/app/oraInventory
mkdir -p /oradata
chown -R oracle:oinstall /oradata
chown -R oracle:oinstall /u01/app
chmod -R 775 /u01/app

14.配置用户环境变量

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/db
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]\$ '
EOF

15.将安装包上传并解压安装包

安装在下网盘链接
unzip -q p13390677_112040_Linux-x86-64_1of7.zip
unzip -q p13390677_112040_Linux-x86-64_2of7.zip

16.启动安装

解决乱码问题
root用户下执行

exportNLS_LANG=AMERICAN_AMERICA.UTF8
export LC_ALL=C
进入到database文件夹
执行
./runInstaller -jreLoc /etc/alternatives/jre_1.8.0

image

image

image

image

image

image

image

image
image

17.此时显示缺少pdksh-5.2.14,上传rpm包

在网盘链接

rpm -ivh pdksh-5.2.14-37.el5.x86_64.rpm

注意:如果显示缺少ksh依赖包,使用yum安装,如果版本过高或过低,先删除原本的ksh,在重新下载

删除依赖:yum remove ksh-20120801-142.el5.x86_64 
安装依赖:yum install ksh-20120801-142.el7.x86_64

点击再次检查(check again)
image
image
image
image

18.解决方案

su - oracle
sed -i 's/^\(\s*\$(MK_EMAGENT_NMECTL)\)\s*$/\1 -lnnz11/g' $ORACLE_HOME/sysman/lib/ins_emagent.mk

执行完点击retry重试
image
image

19.root用户执行以下脚本

/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0/db/root.sh

image

20.重启reboot

21.打开监听

su - oracle
lsnrctl start
lsnrctl status

22.创建数据库

dbca

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

23.测试连接数据库

su - oracle
sqlplus / as sysdba
select sysdate from dual;

##创建数据库用户
create user test identified by test;
grant dba to test;
conn test/test

##创建表
create table test (id number not null,name varchar2(100));
insert into test values (1,'lucifer');
commit;

24.通过navicat连接数据库

image

image
连接成功

25.相关链接

链接:https://pan.baidu.com/s/1lNXcXuK35na1Zk-0gHq1zg
提取码:42x3

转载于:https://cloud.tencent.com/developer/article/1846293

posted on 2022-03-02 16:32  BlogZhang  阅读(95)  评论(0编辑  收藏  举报

导航