Centos7.4安装Oracle11g
一、环境规划
HostName | IP | DB Name | Version | Oracle Home | Oracle Base |
---|---|---|---|---|---|
server01 | 192.168.1.113 | oradb | Oracle11g 11.2.0.4 | /opt/app/oracle/product/11.2.0/db_1 | /opt/app/oracle |
二、关闭防火墙
[root@server01 ~]# systemctl stop firewalld.service
[root@server01 ~]# systemctl disable firewalld.service
systemctl stop firewalld.service #停止firewall
systemctl start firewalld.service #启动firewall
systemctl disable firewalld.service #禁止firewall开机启动
systemctl enable iptables.service #允许开机自启
firewall-cmd --state #查看状态
vim /etc/sysconfig/iptables #查看防火墙配置端口
三、配置yum
[root@server01 ~]# mkdir /opt/yum
[root@server01 ~]# cd /run/media/admin/CentOS\ 7\ x86_64/
[root@server01 CentOS 7 x86_64]# cp -r * /opt/yum/
[root@db1 ~]# vim /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=file:///opt/yum
enabled=1
gpgcheck=0
[root@server01 CentOS 7 x86_64]# yum list
四、安装软件包
[root@server01 ~]# yum install bc binutils compat-libcap1 compat-libstdc++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make gcc gcc-c++ sysstat unixODBC* elfutils-libelf*
另外手动安装compat-libstdc++软件包:
[root@server01 soft]# rpm -ivh compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
warning: compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:compat-libstdc++-33-3.2.3-72.el7 ################################# [100%]
安装前检查依赖包:
[root@server1 ~]# rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' \
binutils \
compat-libcap1 \
compat-libstdc++ \
glibc \
glibc-devel \
ksh \
libaio \
libaio-devel \
libgcc \
libstdc++ libstdc++-devel \
libXi \
libXtst \
make gcc gcc-c++ sysstat unixODBC elfutils-libelf |grep 'not installed'
Centos7.4需要安装以下依赖包:
binutils-2.23.52.0.1-12.el7.x86_64
compat-libcap1-1.10-3.el7.x86_64
compat-libstdc++-33-3.2.3-71.el7.i686
compat-libstdc++-33-3.2.3-71.el7.x86_64
gcc-4.8.2-3.el7.x86_64
gcc-c++-4.8.2-3.el7.x86_64
glibc-2.17-36.el7.i686
glibc-2.17-36.el7.x86_64
glibc-devel-2.17-36.el7.i686
glibc-devel-2.17-36.el7.x86_64
ksh
libaio-0.3.109-9.el7.i686
libaio-0.3.109-9.el7.x86_64
libaio-devel-0.3.109-9.el7.i686
libaio-devel-0.3.109-9.el7.x86_64
libgcc-4.8.2-3.el7.i686
libgcc-4.8.2-3.el7.x86_64
libstdc++-4.8.2-3.el7.i686
libstdc++-4.8.2-3.el7.x86_64
libstdc++-devel-4.8.2-3.el7.i686
libstdc++-devel-4.8.2-3.el7.x86_64
libXi-1.7.2-1.el7.i686
libXi-1.7.2-1.el7.x86_64
libXtst-1.2.2-1.el7.i686
libXtst-1.2.2-1.el7.x86_64
make-3.82-19.el7.x86_64
sysstat-10.1.5-1.el7.x86_64
unixODBC-2.3.1-6.el7.x86_64 or later
unixODBC-2.3.1-6.el7.i686 or later
unixODBC-devel-2.3.1-6.el7.x86_64 or later
unixODBC-devel-2.3.1-6.el7.i686 or later
五、创建用户和组
1.创建用户和组
groupadd -g 600 oinstall;
groupadd -g 601 dba;
groupadd -g 602 oper;
useradd -u 700 -g oinstall -G dba,oper oracle;
[root@server01 ~]# id oracle
uid=700(oracle) gid=600(oinstall) groups=600(oinstall),601(dba),602(oper)
2.设置Oracle用户密码
[root@server01 ~]# passwd oracle
六、配置内核参数
[root@server01 ~]# vi /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1073741824
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
查看所有内核参数:
[root@server01 ~]# sysctl -a
内核生效:
[root@server01 ~]# sysctl -p
七、设置Oracle软件资源限制
[root@server01 ~]# vim /etc/security/limits.conf
#Oracle resource limit
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
Resource Shell Limit | Resource | Soft Limit | Hard Limit |
---|---|---|---|
Open file descriptors | nofile | at least 1024 | at least 65536 |
Number of processes available to a single user | nproc | at least 2047 | at least 16384 |
Size of the stack segment of the process | stack | at least 10240 KB | at least 10240 KB, and at most 32768 KB |
- Log in as an installation owner.
- Check the soft and hard limits for the file descriptor setting. Ensure that the result is in the recommended range. For example:
$ ulimit -Sn
1024
$ ulimit -Hn
65536
3.Check the soft and hard limits for the number of processes available to a user. Ensure that the result is in the recommended range. For example:
$ ulimit -Su
2047
$ ulimit -Hu
16384
4.Check the soft limit for the stack setting. Ensure that the result is in the recommended range. For example:
$ ulimit -Ss
10240
$ ulimit -Hs
32768
5.Repeat this procedure for each Oracle software installation owner.
八、修改/etc/pam.d/login
[root@server01 ~]# vim /etc/pam.d/login
session required pam_limits.so
或者添加完整路径:
session required /lib/security/pam_limits.so
session required /lib64/security/pam_limits.so
其中/lib是指32位操作系统使用,lib64是指64位操作系统使用.
九、关闭Selinux
[root@server01 ~]# setenforce 0
[root@server01 ~]# getenforce
Permissive
[root@server01 ~]# vim /etc/selinux/config
SELINUX=disabled
1.查看selinux状态:
sestatus -v
SELinux status:selinux防火墙的状态,enabled表示启用selinux防火墙
Current mode: selinux防火墙当前的安全策略,enforcing 表示强
也可以使用getenforce命令检查
2.临时关闭(不用重启机器)
setenforce 0
3.永久关闭(重启机器生效)
vim /etc/selinux/config
将SELINUX=enforcing改为SELINUX=disabled
sed -i 's/SELINUX=enforcing/SELINUX=disabled' /etc/selinux/config
十、创建Oracle用户目录
mkdir /etc/oracle
chown -R oracle.oinstall /etc/oracle
chmod -R 755 /etc/oracle
mkdir -p /opt/app/oracle/product/11.2.0/db_1;
chown -R oracle:oinstall /opt/app/;
chmod -R 775 /opt/app/;
mkdir /etc/oracle;
chown oracle.oinstall /etc/oracle;
chmod 755 /etc/oracle;
十一、配置Oracle用户环境变量
[root@server01 ~]# su - oracle
[oracle@server01 ~]$ vim .bash_profile
TMP=/tmp
TMPDIR=$TMP
ORACLE_SID=oradb
ORACLE_BASE=/opt/app/oracle
ORACLE_HOME=/opt/app/oracle/product/11.2.0/db_1
TNS_ADMIN=/etc/oracle
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
PATH=$ORACLE_HOME/bin:$PATH
export TMP
export TMPDIR
export ORACLE_SID
export ORACLE_BASE
export ORACLE_HOME
export TNS_ADMIN
export LD_LIBRARY_PATH
export PATH
[oracle@db1 ~]$ source .bash_profile
十二、解压安装包
[root@server01 ~]# cd /opt/soft
[root@server01 soft]# unzip p13390677_112040_Linux-x86-64_1of7.zip&&unzip p13390677_112040_Linux-x86-64_2of7.zip
[root@server01 soft]# chown -R oracle.oinstall database
[root@server01 soft]# chmod -R 755 database
十三、安装数据库软件
[root@server01 soft]# su - oracle
[oracle@server01 ~]$ cd /opt/soft/database/
[oracle@server01 database]$ ll
total 44
drwxr-xr-x. 4 oracle oinstall 248 Aug 27 2013 install
-rwxr-xr-x. 1 oracle oinstall 30016 Aug 27 2013 readme.html
drwxr-xr-x. 2 oracle oinstall 61 Aug 27 2013 response
drwxr-xr-x. 2 oracle oinstall 34 Aug 27 2013 rpm
-rwxr-xr-x. 1 oracle oinstall 3267 Aug 27 2013 runInstaller
drwxr-xr-x. 2 oracle oinstall 29 Aug 27 2013 sshsetup
drwxr-xr-x. 14 oracle oinstall 4096 Aug 27 2013 stage
-rwxr-xr-x. 1 oracle oinstall 500 Aug 27 2013 welcome.html
[oracle@server01 database]$ export DISPLAY=192.168.1.5:0.0
[oracle@server01 database]$ ./runInstaller
此错误主要因为C库的问题,解决办法就是手动指定C库位置出现agent nmhs问题后,找到$ORACLE_HOME/sysman/lib/ins_emagent.mk文件,在文件里找字符串
[oracle@server01 ~]$ vim $ORACLE_HOME/sysman/lib/ins_emagent.mk
$(MK_EMAGENT_NMECTL)
替换为
$(MK_EMAGENT_NMECTL) -lnnz11
注意:lnnz和$(MK_EMAGENT_NMECTL)之间有空格
然后点“重试“按钮就可以了
[root@server01 ~]# /opt/app/oraInventory/orainstRoot.sh
Changing permissions of /opt/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /opt/app/oraInventory to oinstall.
The execution of the script is complete.
[root@server01 ~]# /opt/app/oracle/product/11.2.0/db_1/root.sh
Performing root user operation for Oracle 11g
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /opt/app/oracle/product/11.2.0/db_1
Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...
Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Finished product-specific root actions.
十四、创建数据库
[oracle@server01 ~]$ export DISPLAY=192.168.1.5:0.0
[oracle@server01 ~]$ dbca