centos7 静默安装oracle11g

Oracle 11g

## 参考文章
https://jingyan.baidu.com/article/90895e0f29c92164ec6b0bd1.html

准备

准备yum源

yum -y install wget
wget -O /etc/yum.repos.d/CentOSBase.repo http://mirrors.aliyun.com/repo/Centos-7.repo
rm -rf /etc/yum.repos.d/CentOS-*
yum -y install vim net-tools lrzsz epel-release bash-completion

安装编译环境

yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake  pcre pcre-devel openssl openssl-devel   jemalloc-devel tlc libtool

安装unzip 工具、vim编辑器

yum -y install  unzip vim

在/etc/hosts文件中添加本机IP跟主机名

ip查看

[root@master ~]# ip a
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33:  mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:1d:ca:3d brd ff:ff:ff:ff:ff:ff
    inet 192.168.234.100/24 brd 192.168.234.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe1d:ca3d/64 scope link 
       valid_lft forever preferred_lft forever

hostname查看

[root@master ~]# hostname
master

添加到hosts

[root@master ~]# vim /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.234.100 master

准备oracle 11g 安装包

linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_1of1.zip

oracle 依赖包安装

 yum -y install gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel elfutils-libelf-devel-static elfutils-libelf-devel ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel

添加oinstall 、dba 组,新建oracle用户并加入oinstall、dba组中

groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle

设置oracle用户登录密码 连续输2遍密码即可

passwd oracle

修改内核参数:编辑 /etc/sysctl.conf

vim /etc/sysctl.conf
## 在最下面添加以下参数
fs.file-max = 6815744
 
fs.aio-max-nr = 1048576
 
kernel.shmall = 2097152
 
kernel.shmmax = 2147483648
 
kernel.shmmni = 4096
 
kernel.sem = 250 32000 100 128
 
net.ipv4.ip_local_port_range = 9000 65500
 
net.core.rmem_default = 4194304
 
net.core.rmem_max = 4194304
 
net.core.wmem_default = 262144
 
net.core.wmem_max = 1048576
## 加载参数
[root@master ~]# sysctl -p
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576

修改用户的限制文件,编辑 /etc/security/limits.conf

vim  /etc/security/limits.conf
## 在最下面添加以下参数
oracle           soft    nproc           2047

oracle           hard    nproc           16384

oracle           soft    nofile          1024

oracle           hard    nofile          65536

oracle           soft    stack           10240

修改/etc/pam.d/login文件

## 在最下面一行添加
session  required   /lib64/security/pam_limits.so

session  required   pam_limits.so

修改/etc/profile文件

## 在最下面添加
if [ $USER = "oracle" ]; then

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

   ulimit -p 16384

   ulimit -n 65536

  else

   ulimit -u 16384 -n 65536

  fi

fi

创建安装目录、修改文件权限

mkdir -p /u01/app/oracle/product/11.2.0
mkdir /u01/app/oracle/oradata
mkdir /u01/app/oracle/inventory
mkdir /u01/app/oracle/fast_recovery_area

chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/app/oracle

上传oracle软件包到 /tmp目录下

[root@master tmp]# ll
total 2295592
-rw-r--r-- 1 root root 1239269270 Sep 26  2018 linux.x64_11gR2_database_1of2.zip
-rw-r--r-- 1 root root 1111416131 Sep 26  2018 linux.x64_11gR2_database_2of2.zip

解压oracle软件包

unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64_11gR2_database_2of2.zip
## 解压后会出现一个database目录
[root@master tmp]# ll
total 2295592
drwxr-xr-x 8 root root        128 Aug 21  2009 database
-rw-r--r-- 1 root root 1239269270 Sep 26  2018 linux.x64_11gR2_database_1of2.zip
-rw-r--r-- 1 root root 1111416131 Sep 26  2018 linux.x64_11gR2_database_2of2.zip

安装

切换到oracle用户操作

## 切换到oracle
su - oracle

## 设置oracle用户环境变量
vim .bash_profile

##最下面添加以下参数
ORACLE_BASE=/u01/app/oracle

ORACLE_HOME=$ORACLE_BASE/product/11.2.0

ORACLE_SID=orcl

PATH=$PATH:$ORACLE_HOME/bin

export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH

export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

编辑安装文件

## 先切回到root用户编辑/tmp/database/response/db_install.rsp文件
su - root

[root@master tmp]# cd  /tmp/database/response/
[root@master response]# ll
total 76
-rw-rw-r-- 1 root root 44969 Feb 14  2009 dbca.rsp
-rw-rw-r-- 1 root root 22557 Aug 15  2009 db_install.rsp
-rwxrwxr-x 1 root root  5740 Feb 26  2009 netca.rsp

vim db_install.rsp

只修改以下参数,其他不变,仔细点
oracle.install.option=INSTALL_DB_SWONLY

ORACLE_HOSTNAME=你的hostname

UNIX_GROUP_NAME=oinstall

INVENTORY_LOCATION=/u01/app/oracle/inventory

SELECTED_LANGUAGES=en,zh_CN

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

ORACLE_BASE=/u01/app/oracle

oracle.install.db.InstallEdition=EE

oracle.install.db.DBA_GROUP=dba

oracle.install.db.OPER_GROUP=dba

DECLINE_SECURITY_UPDATES=true

## 切回到oracle用户安装
su - oracle

/tmp/database

./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /tmp/database/response/db_install.rsp

看到下面部分,则表明安装已经完成

You can find the log of this install session at:
 /u01/app/oracle/inventory/logs/installActions2019-06-12_04-05-23PM.log
The following configuration scripts need to be executed as the "root" user. 
 #!/bin/sh 
 #Root scripts to run

/u01/app/oracle/inventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0/root.sh
To execute the configuration scripts:
	 1. Open a terminal window 
	 2. Log in as "root" 
	 3. Run the scripts 
	 4. Return to this window and hit "Enter" key to continue 

Successfully Setup Software.

## 切回到root执行脚本
su - root
source /u01/app/oracle/inventory/orainstRoot.sh
source /u01/app/oracle/product/11.2.0/root.sh

用oracle用户登录配置监听

## 切回到oracle
su - oracle

##出现下图情况时,则需要配置DISPLAY变量,配完之后重新netca:
[oracle@master ~]$ netca -silent -responseFile /tmp/database/response/netca.rsp
****DISPLAY environment variable not set!
    Oracle Net Configuration Assistant is a GUI tool
    which requires that DISPLAY specify a location
    where GUI tools can display.
    Set and export DISPLAY, then re-run.
 
 ## 配置DISPLAY变量DISPLAY=localhost:0.0 ,发现缺少libXext.so.6
[oracle@master ~]$ export DISPLAY=localhost:0.0
[oracle@master ~]$ netca -silent -responseFile /tmp/database/response/netca.rsp
Exception in thread "main" java.lang.UnsatisfiedLinkError: /u01/app/oracle/product/11.2.0/jdk/jre/lib/amd64/xawt/libmawt.so: libXext.so.6: cannot open shared object file: No such file or directory
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1647)
	at java.lang.Runtime.load0(Runtime.java:769)
	at java.lang.System.load(System.java:968)
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1668)
	at java.lang.Runtime.loadLibrary0(Runtime.java:822)
	at java.lang.System.loadLibrary(System.java:993)
	at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.awt.NativeLibLoader.loadLibraries(NativeLibLoader.java:38)
	at sun.awt.DebugHelper.(DebugHelper.java:29)
	at java.awt.Component.(Component.java:547)

 ## 切回root安装libXext.so.6
 su - root
[root@master ~]# yum -y install libXext-devel libXext

## 切到oracle配置监听
[oracle@master ~]$ netca -silent -responseFile /tmp/database/response/netca.rsp

Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /tmp/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
    Running Listener Control: 
      /u01/app/oracle/product/11.2.0/bin/lsnrctl start LISTENER
    Listener Control complete.
    Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0

## 查看监听端口:
[oracle@master ~]$ netstat -ntlp| grep 1521
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp6       0      0 :::1521                 :::*                    LISTEN      28329/tnslsnr       


用oracle用户配置实例

## 切到root用户编辑配置文件/tmp/database/response/dbca.rsp
su - root

vim  /tmp/database/response/dbca.rsp
只修改以下参数:

GDBNAME = "orcl"

SID = "orcl"

SYSPASSWORD = "oracle"

SYSTEMPASSWORD = "oracle"

SYSMANPASSWORD = "oracle"

DBSNMPPASSWORD = "oracle"

DATAFILEDESTINATION =/u01/app/oracle/oradata

RECOVERYAREADESTINATION=/u01/app/oracle/fast_recovery_area

CHARACTERSET = "ZHS16GBK"

TOTALMEMORY = "1638"


## 切回到oracle用户 安装实例
su - oracle

[oracle@master ~]$ dbca -silent -responseFile /tmp/database/response/dbca.rsp
Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.

oracle关闭

## 切回到oracle用户操作
## 关闭监听
lsnrctl stop

## 关闭实例
sqlplus / as sysdba

SQL> shutdow immediate;

修改tns配置文件

[oracle@master ~]$ cd /u01/app/oracle/product/11.2.0/network/admin/
[oracle@master admin]$ ll
total 16
-rw-r--r-- 1 oracle oinstall 362 Jun 12 16:26 listener.ora
drwxr-xr-x 2 oracle oinstall  64 Jun 12 16:06 samples
-rw-r--r-- 1 oracle oinstall 187 May  7  2007 shrept.lst
-rw-r--r-- 1 oracle oinstall 214 Jun 12 16:26 sqlnet.ora
-rw-r----- 1 oracle oinstall 316 Jun 12 16:37 tnsnames.ora

vim tnsnames.ora

## 内容如下
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.234.100 )(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

修改监听配置文件

[oracle@master ~]$ cd /u01/app/oracle/product/11.2.0/network/admin/
[oracle@master admin]$ ll
total 16
-rw-r--r-- 1 oracle oinstall 362 Jun 12 16:26 listener.ora
drwxr-xr-x 2 oracle oinstall  64 Jun 12 16:06 samples
-rw-r--r-- 1 oracle oinstall 187 May  7  2007 shrept.lst
-rw-r--r-- 1 oracle oinstall 214 Jun 12 16:26 sqlnet.ora
-rw-r----- 1 oracle oinstall 316 Jun 12 16:37 tnsnames.ora

vim listener.ora 
## 内容如下
SID_LIST_LISTENER =
  (SID_LIST =
  (SID_DESC =
      (SID_NAME = orcl)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0)
      (GLOBAL_DBNAME= orcl)
    )
)

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.234.100 )(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle


oracle启动

## 启动实例
sqlplus / as sysdba

SQL> startup;

## 启动监听
lsnrctl start

你可能感兴趣的:(install)