DBA宝典我爱编程

CentOS 7.1静默安装11.2.0.3 64位单机数据库软

2018-02-08  本文已影响21人  小麦苗DB宝

第1章 CentOS 7.1静默安装11.2.0.3 64位单机数据库软件

1.1  安装前的准备工作

1.1.1      软件准备

1.1.2      检查硬件

注意这里的内存应该满足要求,不然可能引起数据库在安装过程中长时间的挂起等待。。。。

在正式安装开始前,请先检查你的软硬件条件是否满足安装需要。

硬件上可以使用命令查看内存情况和 CPU 特性:

more  /proc/meminfo

more  /proc/cpuinfo

其中内存的要求是不低于 1G

下面的不是必须的,可选使用

cat /etc/redhat-release

#df –k /dev/shm 检查共享内存

#df –k   /tmp 检查临时磁盘空间

#more /proc/version 检查操作系统版本

#uname –r 检查内核版本

内存:

# grep MemTotal /proc/meminfo

交换空间

# grep SwapTotal /proc/meminfo

磁盘空间

# df -ah

# free

#free -m

1.1.3      修改hosts文件、修改主机名

永久生效:

[root@localhost ~]# hostnamectl set-hostname COSLHR

或修改文件/etc/hostname:

[root@localhost ~]# cat  /etc/hostname

COSLHR

临时生效:

[root@localhost ~]# hostname COSLHR

查看/etc/hosts文件中必须包含a fully qualified name for the server,必须包含127.0.0.1和真实的IP地址这2行:

[root@localhost ~]# cat /etc/hosts

# Do not remove the following line, or various programs

# that require network functionality will fail.

127.0.0.1               localhost.localdomain localhost

::1             localhost6.localdomain6 localhost6

192.168.59.155 COSLHR

注意将主机名对应到真实IP地址,否则Oracle有可能将监听程序仅仅建立在127.0.0.1上。

注意:修改主机名后,需要重启系统后生效。

1.1.3.1     配置固定IP

DEVICE=ens33

IPADDR=192.168.59.51

NETMASK=255.255.255.0

NETWORK=192.168.59.0

BROADCAST=192.168.59.255

GATEWAY=192.168.59.2

ONBOOT=yes

USERCTL=no

BOOTPROTO=static

#HWADDR=00:0c:29:97:f1:5b

TYPE=Ethernet

IPV6INIT=no

DNS1=202.96.209.5

DNS2=8.8.8.8

NAME="ens33"

1.1.4      安装软件包检查

http://blog.itpub.net/26736162/viewspace-2133603/

可以统一检查:

rpm -q \

binutils \

compat-libstdc++-33 \

elfutils-libelf \

elfutils-libelf-devel \

expat \

gcc \

gcc-c++ \

glibc \

glibc-common \

glibc-devel \

glibc-headers \

libaio \

libaio-devel \

libgcc \

libstdc++ \

libstdc++-devel \

make \

pdksh \

sysstat \

unixODBC \

unixODBC-devel | grep "not installed"

如果部分包不存在,可以批量更新安装,但如果依赖关系缺失,可能需要多执行两遍或者手工调整,所以建议使用yum进行安装:

package compat-libstdc++-33 is not installed

package elfutils-libelf-devel is not installed

package gcc-c++ is not installed

package libaio-devel is not installed

package libstdc++-devel is not installed

package pdksh is not installed

package unixODBC is not installed

package unixODBC-devel is not installed

依次安装如下的包:

yum install -y compat-libstdc++-33

yum install -y elfutils-libelf-devel

yum install -y gcc-c++

yum install -y libaio-devel

yum install -y libstdc++-devel

yum install -y pdksh

yum install -y unixODBC

yum install -y unixODBC-devel

安装完成后再次检查是否还有没有安装的包。

注意:其中的pdksh包可以忽略。

1.1.5      内核参数--shell限制

1.1.5.1 /etc/security/limits.conf

设置Shell Limits

在/etc/security/limits.conf文件中加入下列行:

oracle soft nofile 65536

oracle hard nofile 65536

oracle soft nproc 16384

oracle hard nproc 16384

为安装用户设置资源限制

要改善 Linux 系统上的软件性能,必须对 Oracle 软件所有者用户(grid、oracle)增加以下资源限制:

Shell 限制 limits.conf 中的条目 硬限制

打开文件描述符的最大数      nofile   65536

可用于单个用户的最大进程数     nproc   16384

进程堆栈段的最大大小        stack  10240

1.1.5.2 /etc/pam.d/login

在/etc/pam.d/login文件中加入下列行,如果里面没有的话:

session required /lib/security/pam_limits.so

session required pam_limits.so

1.1.5.3 /etc/profile

对默认的 shell 启动文件进行以下更改,以便更改所有 Oracle 安装所有者的 ulimit 设置:

在/etc/profile后加入以下语句:

if [ $USER = "oracle" ]; then

        if [ $SHELL = "/bin/ksh" ]; then

                ulimit -p 16384

                ulimit -n 16384

        else

                ulimit -u 16384 -n 16384

        fi

fi  

1.1.5.4 /etc/sysctl.conf

Configuring Kernel Parameters for Linux

vim /etc/sysctl.conf

fs.aio-max-nr = 1048576

fs.file-max = 6815744

kernel.shmall = 2097152

kernel.shmmax = 4294967295

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 -p

参数的含义:http://blog.itpub.net/26736162/viewspace-2147273/

1.1.6      关闭防火墙

systemctl status firewalld.service

systemctl stop firewalld.service

systemctl disable firewalld.service

[root@localhost /]# systemctl status firewalld.service

● firewalld.service - firewalld - dynamic firewall daemon

   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)

Active: active (running) since Thu 2016-04-07 18:54:29 PDT; 2h 20min ago

 Main PID: 802 (firewalld)

   CGroup: /system.slice/firewalld.service

 └─802 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Apr 07 18:54:25 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...

Apr 07 18:54:29 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.

[root@localhost /]# systemctl stop firewalld.service  #关闭防火墙

[root@localhost /]# systemctl status firewalld.service  #再次查看防火墙状态,发现已关闭

● firewalld.service - firewalld - dynamic firewall daemon

   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)

Active: inactive (dead) since Thu 2016-04-07 21:15:34 PDT; 9s ago

 Main PID: 802 (code=exited, status=0/SUCCESS)

Apr 07 18:54:25 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...

Apr 07 18:54:29 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.

Apr 07 21:15:33 localhost systemd[1]: Stopping firewalld - dynamic firewall daemon...

Apr 07 21:15:34 localhost systemd[1]: Stopped firewalld - dynamic firewall daemon.

[root@localhost /]# systemctl disable firewalld.service  #禁止使用防火墙(重启也是禁止的)

Removed symlink /etc/systemd/system/dbus-org.Fedoraproject.FirewallD1.service.

Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

[root@localhost /]#

1.1.7      禁用selinux

修改/etc/selinux/config

编辑文本中的SELINUX=enforcing为SELINUX=disabled

[root@OCPLHR ~]# vi /etc/selinux/config

[root@OCPLHR ~]# more /etc/selinux/config

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

#       enforcing - SELinux security policy is enforced.

#       permissive - SELinux prints warnings instead of enforcing.

#       disabled - SELinux is fully disabled.

SELINUX=disabled

# SELINUXTYPE= type of policy in use. Possible values are:

#       targeted - Only targeted network daemons are protected.

#       strict - Full SELinux protection.

SELINUXTYPE=targeted

[root@OCPLHR ~]# /usr/sbin/sestatus -v

SELinux status:                 disabled

[root@OCPLHR ~]#  getenforce

Disabled

临时关闭(不用重启机器):setenforce 0

查看SELinux状态:

1、/usr/sbin/sestatus -v  ##如果SELinux status参数为enabled即为开启状态

SELinux status:  enabled

2、getenforce  ##也可以用这个命令检查

1.2  新建用户和组

The Oracle Inventory group (oinstall) 数据库安装组

The OSDBA group (dba) 数据库管理员组

The Oracle software owner (oracle) 管理员用户

groupadd oinstall

groupadd dba

useradd -g oinstall -G dba -m  oracle

passwd oracle

-m 表示为用户oracle 新建一个根目录

-g 表示为用户指定一个主group

-G 表示为用户指定一个副group

这样oracle既属于oinstall组也属于dba组。

平时主要是oinstall组发生作用。

[root@localhost ~]# id oracle

uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba) context=root:system_r:unconfined_t:SystemLow-SystemHigh

1.2.1      配置用户的环境变量

vi /home/oracle/.bash_profile

umask 022

export ORACLE_SID=orcl

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib

export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"

export TMP=/tmp

export TMPDIR=$TMP

export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH

export EDITOR=vi

export TNS_ADMIN=$ORACLE_HOME/network/admin

export ORACLE_PATH=.:$ORACLE_BASE/dba_scripts/sql:$ORACLE_HOME/rdbms/admin

export SQLPATH=$ORACLE_HOME/sqlplus/admin

#export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK" --AL32UTF8 SELECT userenv('LANGUAGE') db_NLS_LANG FROM DUAL;

export NLS_LANG="AMERICAN_CHINA.ZHS16GBK"

alias sas='sqlplus / as sysdba'

#export PS1="[\u@\h-\`echo \$ORACLE_SID\` \W]$ "

#export PS1='[$LOGNAME@'`hostname`:'$PWD'']# '

1.3  新建安装目录

mkdir  -p  /u01/app/oracle

chown -R  oracle:oinstall  /u01/app

chmod  -R  775  /u01/app

1.4 准备oracle安装文件

1.4.1      拷贝安装文件

[root@localhost ~]# mkdir -p /soft

[root@localhost ~]# chmod 777 /soft

可以直接拷贝,也可以用SecureFX、XFTP软件等方式拷贝到/soft目录下:

1.4.1.1     计算MD5值

安装文件MD5

p10404530_112030_Linux-x86-64_1of7.zipbd bf 8e 26 36 63 21 4d c6 0b 0f de f5 a3 0b 0a

p10404530_112030_Linux-x86-64_2of7.zipe5 6b 3d 9c 6b c5 4b 77 17 e1 4b 6c 54 9c ef 9e

p10404530_112030_Linux-x86-64_3of7.zip69 5c ba d7 44 75 22 39 c7 64 87 e3 24 f7 b1 ab

[root@OCPLHR soft]# md5sum p10404530_112030_Linux-x86-64_1of7.zip

bdbf8e263663214dc60b0fdef5a30b0a  p10404530_112030_Linux-x86-64_1of7.zip

[root@OCPLHR soft]# md5sum p10404530_112030_Linux-x86-64_2of7.zip

e56b3d9c6bc54b7717e14b6c549cef9e  p10404530_112030_Linux-x86-64_2of7.zip

[root@OCPLHR soft]#

[root@OCPLHR soft]#

[root@OCPLHR soft]# md5sum p10404530_112030_Linux-x86-64_3of7.zip 

695cbad744752239c76487e324f7b1ab  p10404530_112030_Linux-x86-64_3of7.zip

D:\Users\xiaomaimiao>certutil -hashfile "G:\安装文件\数据库\Oracle\oracle db安装\11.2.0.3\11.2.0.3_linux\64位\p10404530_112030_Linux-x86-64_1of7.zip" MD5

MD5 哈希(文件 G:\安装文件\数据库\Oracle\oracle db 安装\11.2.0.3\11.2.0.3_linux\64位\p10404530_112030_Linux-x86-64_1of7.zip):

bd bf 8e 26 36 63 21 4d c6 0b 0f de f5 a3 0b 0a

CertUtil: -hashfile 命令成功完成。

D:\Users\xiaomaimiao>certutil -hashfile "G:\安装文件\数据库\Oracle\oracle db安装\11.2.0.3\11.2.0.3_linux\64位\p10404530_112030_Linux-x86-64_2of7.zip" MD5

MD5 哈希(文件 G:\安装文件\数据库\Oracle\oracle db 安装\11.2.0.3\11.2.0.3_linux\64位\p10404530_112030_Linux-x86-64_2of7.zip):

e5 6b 3d 9c 6b c5 4b 77 17 e1 4b 6c 54 9c ef 9e

CertUtil: -hashfile 命令成功完成。

D:\Users\xiaomaimiao>certutil -hashfile "G:\安装文件\数据库\Oracle\oracle db安装\11.2.0.3\11.2.0.3_linux\64位\p10404530_112030_Linux-x86-64_3of7.zip" MD5

MD5 哈希(文件 G:\安装文件\数据库\Oracle\oracle db 安装\11.2.0.3\11.2.0.3_linux\64位\p10404530_112030_Linux-x86-64_3of7.zip):

69 5c ba d7 44 75 22 39 c7 64 87 e3 24 f7 b1 ab

CertUtil: -hashfile 命令成功完成。

1.4.2      解压安装文件

[root@OCPLHR soft]# ll

total 3401656

drwx------ 2 root root      16384 Jan  5 14:42 lost+found

-rw-r--r-- 1 root root 1358454646 Dec 14  2011 p10404530_112030_Linux-x86-64_1of7.zip

-rw-r--r-- 1 root root 1142195302 May 25  2012 p10404530_112030_Linux-x86-64_2of7.zip

-rw-r--r-- 1 root root  979195792 May 26  2012 p10404530_112030_Linux-x86-64_3of7.zip

[root@OCPLHR soft]# chmod 777 *

[root@OCPLHR soft]# ll

total 3401656

drwxrwxrwx 2 root root      16384 Jan  5 14:42 lost+found

-rwxrwxrwx 1 root root 1358454646 Dec 14  2011 p10404530_112030_Linux-x86-64_1of7.zip

-rwxrwxrwx 1 root root 1142195302 May 25  2012 p10404530_112030_Linux-x86-64_2of7.zip

-rwxrwxrwx 1 root root  979195792 May 26  2012 p10404530_112030_Linux-x86-64_3of7.zip

解压oracle安装文件包:如果不想输出信息,则可以加上 “>  /dev/null 2>&1”,-d表示解压到的目录:

unzip p10404530_112030_Linux-x86-64_1of7.zip  -d /tmp >  /dev/null 2>&1 && unzip p10404530_112030_Linux-x86-64_2of7.zip  -d /tmp  >  /dev/null 2>&1

unzip  p10404530_112030_Linux-x86-64_1of7.zip >  /dev/null 2>&1  && unzip p10404530_112030_Linux-x86-64_2of7.zip > /dev/null 2>&1

切换到oracle用户,图形界面登录,执行oracle安装文件

[root@OCPLHR soft]# su - oracle

[oracle@OCPLHR ~]$ cd /soft/

[oracle@OCPLHR soft]$ ll

total 3401656

drwxrwxrwx 2 root root      16384 Jan  5 14:42 lost+found

-rwxrwxrwx 1 root root 1358454646 Dec 14  2011 p10404530_112030_Linux-x86-64_1of7.zip

-rwxrwxrwx 1 root root 1142195302 May 25  2012 p10404530_112030_Linux-x86-64_2of7.zip

-rwxrwxrwx 1 root root  979195792 May 26  2012 p10404530_112030_Linux-x86-64_3of7.zip

[oracle@OCPLHR soft]$ ll

total 3401664

drwxrwxrwx 2 root   root          16384 Jan  5 14:42 lost+found

-rwxrwxrwx 1 root   root     1358454646 Dec 14  2011 p10404530_112030_Linux-x86-64_1of7.zip

-rwxrwxrwx 1 root   root     1142195302 May 25  2012 p10404530_112030_Linux-x86-64_2of7.zip

-rwxrwxrwx 1 root   root      979195792 May 26  2012 p10404530_112030_Linux-x86-64_3of7.zip

[oracle@OCPLHR soft]$ unzip  p10404530_112030_Linux-x86-64_1of7.zip >  /dev/null 2>&1  && unzip p10404530_112030_Linux-x86-64_2of7.zip >  /dev/null 2>&1                                                 

[oracle@OCPLHR soft]$ ll

total 3401664

drwxr-xr-x 8 oracle oinstall       4096 Sep 22  2011 database

drwxrwxrwx 2 root   root          16384 Jan  5 14:42 lost+found

-rwxrwxrwx 1 root   root     1358454646 Dec 14  2011 p10404530_112030_Linux-x86-64_1of7.zip

-rwxrwxrwx 1 root   root     1142195302 May 25  2012 p10404530_112030_Linux-x86-64_2of7.zip

-rwxrwxrwx 1 root   root      979195792 May 26  2012 p10404530_112030_Linux-x86-64_3of7.zip

[oracle@OCPLHR soft]$ du -sh database

2.5G    database

[oracle@OCPLHR soft]$ cd database/

[oracle@OCPLHR database]$ ll

total 100

drwxr-xr-x 12 oracle oinstall  4096 Sep 19  2011 doc

drwxr-xr-x  4 oracle oinstall  4096 Sep 22  2011 install

-rwxr-xr-x  1 oracle oinstall 28122 Sep 22  2011 readme.html

drwxr-xr-x  2 oracle oinstall  4096 Sep 22  2011 response

drwxr-xr-x  2 oracle oinstall  4096 Sep 22  2011 rpm

-rwxr-xr-x  1 oracle oinstall  3226 Sep 22  2011 runInstaller

drwxr-xr-x  2 oracle oinstall  4096 Sep 22  2011 sshsetup

drwxr-xr-x 14 oracle oinstall  4096 Sep 22  2011 stage

-rwxr-xr-x  1 oracle oinstall  5466 Aug 23  2011 welcome.html

1.5  开始静默安装

可以只执行一条命令即可安装完成数据库软件的部署:

/soft/database/runInstaller -silent  -force -noconfig -IgnoreSysPreReqs -ignorePrereq  -showProgress \

oracle.install.option=INSTALL_DB_SWONLY \

DECLINE_SECURITY_UPDATES=true \

UNIX_GROUP_NAME=oinstall \

INVENTORY_LOCATION=/u01/app/oraInventory \

SELECTED_LANGUAGES=en \

ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 \

ORACLE_BASE=/u01/app/oracle \

oracle.install.db.InstallEdition=EE \

oracle.install.db.isCustomInstall=false \

oracle.install.db.DBA_GROUP=dba \

oracle.install.db.OPER_GROUP=dba \

oracle.install.db.isRACOneInstall=false \

oracle.install.db.config.starterdb.type=GENERAL_PURPOSE \

SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \

oracle.installer.autoupdates.option=SKIP_UPDATES

[root@localhost ~]# su - oracle

Last login: Wed Feb  7 08:48:45 PST 2018 on pts/3

[oracle@localhost ~]$ cd /soft/

[oracle@localhost soft]$ ll

total 2442048

drwxr-xr-x. 8 oracle oinstall       4096 Sep 22  2011 database

-rw-r--r--. 1 root   root     1358454646 Dec 13  2011 p10404530_112030_Linux-x86-64_1of7.zip

-rw-r--r--. 1 root   root     1142195302 May 25  2012 p10404530_112030_Linux-x86-64_2of7.zip

[oracle@localhost soft]$ cd database/

[oracle@localhost database]$ ll

total 52

drwxr-xr-x. 12 oracle oinstall  4096 Sep 18  2011 doc

drwxr-xr-x.  4 oracle oinstall  4096 Sep 22  2011 install

-rwxr-xr-x.  1 oracle oinstall 28122 Sep 22  2011 readme.html

drwxr-xr-x.  2 oracle oinstall    58 Sep 22  2011 response

drwxr-xr-x.  2 oracle oinstall    33 Sep 22  2011 rpm

-rwxr-xr-x.  1 oracle oinstall  3226 Sep 22  2011 runInstaller

drwxr-xr-x.  2 oracle oinstall    28 Sep 22  2011 sshsetup

drwxr-xr-x. 14 oracle oinstall  4096 Sep 22  2011 stage

-rwxr-xr-x.  1 oracle oinstall  5466 Aug 22  2011 welcome.html

[oracle@localhost database]$ /soft/database/runInstaller -silent  -force -noconfig -IgnoreSysPreReqs -ignorePrereq  -showProgress \

> oracle.install.option=INSTALL_DB_SWONLY \

> DECLINE_SECURITY_UPDATES=true \

> UNIX_GROUP_NAME=oinstall \

> INVENTORY_LOCATION=/u01/app/oraInventory \

> SELECTED_LANGUAGES=en \

> ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 \

> ORACLE_BASE=/u01/app/oracle \

> oracle.install.db.InstallEdition=EE \

> oracle.install.db.isCustomInstall=false \

> oracle.install.db.DBA_GROUP=dba \

> oracle.install.db.OPER_GROUP=dba \

> oracle.install.db.isRACOneInstall=false \

> oracle.install.db.config.starterdb.type=GENERAL_PURPOSE \

> SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \

> oracle.installer.autoupdates.option=SKIP_UPDATES

Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 91506 MB    Passed

Checking swap space: must be greater than 150 MB.   Actual 1586 MB    Passed

Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-02-07_08-58-36AM. Please wait ...[oracle@localhost database]$ You can find the log of this install session at:

 /u01/app/oraInventory/logs/installActions2018-02-07_08-58-36AM.log

Prepare in progress.

..................................................   9% Done.

Prepare successful.

Copy files in progress.

..................................................   14% Done.

..................................................   20% Done.

..................................................   26% Done.

..................................................   31% Done.

..................................................   36% Done.

..................................................   44% Done.

..................................................   49% Done.

..................................................   55% Done.

..................................................   63% Done.

..................................................   68% Done.

..................................................   73% Done.

..................................................   78% Done.

..................................................   83% Done.

..............................

Copy files successful.

Link binaries in progress.

..........

Link binaries successful.

Setup files in progress.

..................................................   88% Done.

..................................................   94% Done.

Setup files successful.

The installation of Oracle Database 11g was successful.

Please check '/u01/app/oraInventory/logs/silentInstall2018-02-07_08-58-36AM.log' for more details.

Execute Root Scripts in progress.

As a root user, execute the following script(s):

        1. /u01/app/oraInventory/orainstRoot.sh

        2. /u01/app/oracle/product/11.2.0/dbhome_1/root.sh

..................................................   100% Done.

Execute Root Scripts successful.

Successfully Setup Software.

[oracle@localhost database]$

[root@localhost ~]# /u01/app/oraInventory/orainstRoot.sh

Changing permissions of /u01/app/oraInventory.

Adding read,write permissions for group.

Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.

The execution of the script is complete.

[root@localhost ~]# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh

Check /u01/app/oracle/product/11.2.0/dbhome_1/install/root_localhost.localdomain_2018-02-07_09-10-23.log for the output of root script

[root@localhost ~]#

上一篇下一篇

猜你喜欢

热点阅读