Linux安装Oracle11g


title: Linux安装Oracle11g
categories: 数据库
tags:
- Oracle
timezone: Asia/Shanghai
date: 2019-01-06

环境

以下Linux发行版验证通过
REHL6.10 x86_64
REHL7.5 x86_64
CentOS7.5
Oracle Linux 6.10 x86_64
Oracle Linux 7.5 x86_64

使用Oracle版本
Oracle 11g 11.2.0.4

参考文献

https://www.oracle.com/technetwork/cn/articles/servers-storage-admin/ginnydbinstallonlinux6-1845247-zhs.html

第一步:修改IP为固定IP地址

vim /etc/sysconfig/network-scripts/ifcfg-eno16777736

第二步:配置计算机名

1.redhat7

hostnamectl set-hostname test.com
echo "192.168.0.63 `hostname`" >>/etc/hosts

systemctl restart network

2.redhat6

hostname test.com
sed -i "/HOSTNAME=/c HOSTNAME=`hostname`" /etc/sysconfig/network
echo "192.168.0.63 `hostname`" >>/etc/hosts

第三步:关闭防火墙、修改内核参数、创建用户和组、修改oracle变量、自动使用本地yum安装依赖包

1.有几个包是在RedHat7安装光盘里提供的,需要单独安装
rpm -ivh compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm

compat-libstdc+±33 for CentOS 7.5.1804 for x86_64 https://pan.baidu.com/s/1SJUuIFMEA_j9ZFNDxvMAIQ

compat-libstdc+±33 for CentOS 6.10 for x86_64 https://pan.baidu.com/s/1NHIwJ73_jkixH9Me97mmGg

pdksh-5.2.14-37.el5_8.1.x86_64.rpm https://pan.baidu.com/s/1cK0AZlMlw1A3rrP_ClRDNA

2.执行以下脚本

可以重复执行,已做判断。直接复制到sehll执行即可,建议创建shell脚本后使用

以下脚本已经针对linux6和linux7命令的不同做了判断区分,可以放心执行

################################################## 关闭防火墙和SELinux(OK)

setenforce 0
sed -i -r "/^SELINUX=/c SELINUX=disabled" /etc/selinux/config
which systemctl && systemctl stop firewalld
which systemctl && systemctl disable firewalld
which systemctl && systemctl stop iptables || service iptables stop
which systemctl && systemctl disable iptables || chkconfig iptables off

################################################## 配置内核参数和资源限制(OK)

# 修改/etc/sysctl.conf(修改配置文件之前会自动备份)(OK)
/bin/grep 666666 /etc/sysctl.conf && /bin/cp /etc/sysctl.conf.666666 /etc/sysctl.conf || /bin/cp /etc/sysctl.conf /etc/sysctl.conf.666666
cat <<EOF >>/etc/sysctl.conf
#add by 666666
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
# kernel.shmmax 最低:536870912
# kernel.shmmax 最大值:比物理内存小1个字节的值
# kernel.shmmax 推荐:超过一半的物理内存
kernel.shmmax = 956039168
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

# 输入以下命令使内核参数马上生效(OK)
/sbin/sysctl -p

# 配置limits.conf文件(修改配置文件之前会自动备份)(OK)
/bin/grep 666666 /etc/security/limits.conf && /bin/cp /etc/security/limits.conf.666666 /etc/security/limits.conf || /bin/cp /etc/security/limits.conf /etc/security/limits.conf.666666
cat <<EOF >>/etc/security/limits.conf
#add by 666666
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
EOF

# 修改/etc/pam.d/login(修改配置文件之前会自动备份)(OK)
/bin/grep 666666 /etc/pam.d/login && /bin/cp /etc/pam.d/login.666666 /etc/pam.d/login || /bin/cp /etc/pam.d/login /etc/pam.d/login.666666
cat <<EOF >>/etc/pam.d/login
#add by 666666
session    required     /lib64/security/pam_limits.so
session    required     pam_limits.so
EOF

# 修改/etc/profile(修改配置文件之前会自动备份)(OK)
/bin/grep 666666 /etc/profile && /bin/cp /etc/profile.666666 /etc/profile || /bin/cp /etc/profile /etc/profile.666666
cat <<EOF >>/etc/profile
#add by 666666
if [ \$USER = "oracle" ]; 
then
	if [ \$SHELL = "/bin/ksh" ]; 
	then
        ulimit -p 16384
        ulimit -n 65536
	else
	ulimit -u 16384 -n 65536
	fi
fi
EOF

# 使配置生效
source /etc/profile

################################################## 创建所需的组和用户(OK)
# 原始语句
# /usr/sbin/groupadd dba
# /usr/sbin/groupadd oper
# /usr/sbin/groupadd oinstall
# /usr/sbin/useradd -g oinstall -G dba oracle
# 优化以后
/bin/grep "^dba" /etc/group && echo "dba组已存在" || /usr/sbin/groupadd dba
/bin/grep "^oper" /etc/group && echo "dba组已存在" || /usr/sbin/groupadd oper
/bin/grep "^oinstall" /etc/group && echo "oinstall组已存在" || /usr/sbin/groupadd oinstall
/bin/grep "^oracle:" /etc/passwd && echo "oracle账户已存在" || /usr/sbin/useradd -g oinstall -G dba oracle
# 检查oracle用户的的所属组是否正确并修正
GROUPIDTemp=`cat /etc/group | grep oinstall | awk -F ":" '{print $3}'`
id oracle | grep gid=${GROUPIDTemp} && echo "oracle主组检查通过" || usermod --gid ${GROUPIDTemp} oracle
unset GROUPIDTemp
id oracle | grep dba && echo "oracle附属组检查通过" || usermod -aG dba oracle
################################################## 创建所需目录(可根据实际情况更改)(OK)

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

################################################## 修改oracle用户变量(可根据实际情况更改,对应上边建立目录)(OK)

/bin/grep 666666 /home/oracle/.bash_profile && /bin/cp /home/oracle/.bash_profile.666666 /home/oracle/.bash_profile || /bin/cp /home/oracle/.bash_profile /home/oracle/.bash_profile.666666
cat <<EOF >>/home/oracle/.bash_profile
#add by 666666
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=\$ORACLE_BASE/product/11.2.0
# 数据库实例名
ORACLE_SID=oracledb
PATH=\$PATH:\$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
EOF
################################################## 配置本地yum源并安装依赖包(OK)
mkdir -p /mnt/cdrom
mount /dev/cdrom /mnt/cdrom

cat <<EOF >/etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt/cdrom
gpgcheck=0
enabled=1
EOF

yum clean all       #清理本地缓存
yum clean plugins   #清理插件缓存
yum makecache       #构建缓存

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

# 检查以上修改是否是执行成功
# 
test `id -u` -eq 0 && echo "当前用户是root用户" || echo -e "\033[31m非root用户,可能会有错误,请注意----------Failed\033[0m"
grep SELINUX=disabled /etc/selinux/config && echo "SELinux成功关闭" || echo -e "\033[31mSELinux----------Failed\033[0m"
grep 666666 /etc/sysctl.conf && echo "/etc/sysctl.conf修改成功" || echo -e "\033[31m/etc/sysctl.conf修改失败----------Failed\033[0m"
grep 666666 /etc/security/limits.conf && echo "/etc/security/limits.conf修改成功" || echo -e "\033[31m/etc/security/limits.conf修改失败----------Failed\033[0m"
grep 666666 /etc/pam.d/login && echo "/etc/pam.d/login修改成功" || echo -e "\033[31m/etc/pam.d/login修改失败----------Failed\033[0m"
grep 666666 /etc/profile && echo "/etc/profile修改成功" || echo -e "\033[31m/etc/profile----------Failed\033[0m"
id oracle && echo "oracle账户创建成功" || echo -e "\033[31moracle账户创建失败----------Failed\033[0m"
ls /u01 > /dev/null 2>&1 && echo "oracle安装目录创建成功" || echo -e "\033[31moracle安装目录创建失败----------Failed\033[0m"
grep 666666 /home/oracle/.bash_profile && echo "oracle用户变量修改成功" || echo -e "\033[31moracle用户变量修改失败---------Failed\033[0m"

第四步:安装Oracle Database(使用oracle账户)

/home/oracle/database/runInstaller

1.不填写Email和密码信息
2.Skip software updates 跳过更新
3.Install database software only 只安装数据库软件,数据库稍后手动创建
4.Single instance database installation 单节点安装另外两个选项为RAC数据库创建和RAC单节点
5.添加Simplified Chinese简体中文
6.Enterprise Edition    企业版
7.选择安装目录,oracle用户配置文件里已写入,不用更改
8.Inventoey Dierctory   保持默认
9.权限相关  保持默认
10.安装程序自动检测当前系统是否满足安装条件,如果是按以上正确操作,应该全部满足
11.这里可以保存响应文件
12.开始安装,安装过程中会提示让使用root用户运行root.sh按提示执行即可。

第五步:创建数据库(使用oracle账户)

dbca

1.Next
2.Create a Database
3.General Purpose or Transcation Processing 选择一般用途或事务处理
4.Global Database Name和SID可以使用一样,输入之前配置文件里写好的oracledb
5.Configure Enterprise Manager  不选择配置企业管理器
6.设置用户口令
7.选择数据库文件的存储类型和存储位置    所有数据库文件使用公共位置:/u01/app/oracle/data
8.禁用快速恢复区
9.示例方案  意思是安装默认的示例数据库,任意选择
10.内存管理 默认下一步
11.信息展示 默认下一步
12.下一步开始创建并显示进度

第六步:创建监听(使用oracle账户)

netca

1.Listener configuration    配置监听
2.Add
3.Listener name 监听名字,默认LISTENER即可
4.Selected Protocols    协议选择TCP
5.可以选择默认的1521也可以手动指定
6.Would you like to configure another listener?    是否继续配置其他监听,选NO
7.退出即可。

附录:出错1:CentOS7在安装到80%左右的时候出现下边错误提示
Error in invoking target 'agent nmhs' of makefile'/u01/app/oracle/product/11.2.0/db_1/sysman/lib/ins_emagent.mk'.

官方解释

Unpublished bug 19692824 
During installation of Oracle Database or Oracle RAC on OL7, the following linking error may be encountered:
Error in invoking target 'agent nmhs' of makefile '<ORACLE_HOME>/sysman/lib/ins_emagent.mk'. See '<installation log>' for details.

If this error is encountered, the user should select Continue. Then, after the installation has completed, the user must download Patch 19692824 from My Oracle Support and apply it per the instructions included in the patch README. 
官方的解释说是先继续安装,然后再打补丁,这个bug19692824是在创建数据库的时候引发的。如果你在安装
数据库软件的时候就报错,建议使用下面的解决方法。

建议的解决方案

在makefile中添加链接libnnz11库的参数 
修改$ORACLE_HOME/sysman/lib/ins_emagent.mk,找到下面这行

$(MK_EMAGENT_NMECTL)
修改为:
$(MK_EMAGENT_NMECTL) -lnnz11
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值