centos7静默安装oracle 11g

post by rocdk890 / 2017-11-30 17:28 Thursday linux技术
系统: centos 7.x (64位)
oracle软件包: linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
服务器ip: 192.168.12.252

1.安装前准备

###关闭selinux
[root@localhost ~]# vim /etc/selinux/config
设置SELINUX=disabled

然后执行:
[root@localhost ~]# setenforce 0

###关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# systemctl stop iptables

###安装依赖包
[root@localhost ~]# wget http://public-yum.oracle.com/public-yum-ol7.repo -P /etc/yum.repos.d/
[root@localhost ~]# wget http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol7 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle

[root@localhost ~]#
1yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static \
2gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel \
3libgcc libgomp libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pcre-devel unzip

###更改hostname
[root@localhost ~]# vim /etc/hostname
改变内容为,自己设定的hostname,如下:
centos

[root@localhost ~]# vim /etc/hosts
把127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4改为:

127.0.0.1  centos localhost localhost.localdomain localhost4 localhost4.localdomain4
::1        centos localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.12.252 centos

###添加安装用户和用户组
[root@centos ~]# groupadd oinstall
[root@centos ~]# groupadd dba
[root@centos ~]# useradd -g oinstall -G dba oracle
[root@centos ~]# passwd oracle
[root@centos ~]# id oracle
如显示类似以下信息则表示添加用户和用户组成功
uid=1000(oracle) gid=1000(oinstall) groups=1000(oinstall),1001(dba)

###修改内核参数配置文件
[root@centos ~]# vim /etc/sysctl.conf
添加以下内容:

01fs.aio-max-nr = 1048576
02fs.file-max = 6815744
03kernel.shmall = 2097152
04kernel.shmmax = 1073741824
05kernel.shmmni = 4096
06kernel.sem = 250 32000 100 128
07net.ipv4.ip_local_port_range = 9000 65500
08net.core.rmem_default = 262144
09net.core.rmem_max = 4194304
10net.core.wmem_default = 262144
11net.core.wmem_max = 1048576

其中kernel.shmmax = 1073741824为本机物理内存(2G)的一半,单位为byte.

[root@centos ~]# sysctl -p

###修改用户的限制文件
[root@centos ~]# vim /etc/security/limits.conf
添加以下内容:

1oracle           soft    nproc           2047
2oracle           hard    nproc           16384
3oracle           soft    nofile          1024
4oracle           hard    nofile         65536
5oracle           soft    stack           10240

###修改/etc/pam.d/login文件
[root@centos ~]# vim /etc/pam.d/login
添加以下内容:

session required  /lib64/security/pam_limits.so
session required   pam_limits.so

###修改/etc/profile文件
[root@centos ~]# vim /etc/profile
添加以下内容:
1if [ $USER = "oracle" ]; then
2   if [ $SHELL = "/bin/ksh" ]; then
3       ulimit -p 16384
4       ulimit -n 65536
5    else
6       ulimit -u 16384 -n 65536
7   fi
8fi

使之生效:
[root@centos ~]# source /etc/profile

###创建安装目录和设置文件权限
[root@centos ~]# mkdir -p /data/oracle/oraclesetup
[root@centos ~]# mkdir -p /data/oracle/product/11.2.0
[root@centos ~]# mkdir /data/oracle/oradata
[root@centos ~]# mkdir /data/oracle/inventory
[root@centos ~]# mkdir /data/oracle/fast_recovery_area

[root@centos ~]# cd /data/oracle/oraclesetup
[root@centos oraclesetup]# unzip -o linux.x64_11gR2_database_1of2.zip && unzip -o linux.x64_11gR2_database_2of2.zip

[root@centos ~]# chown -R oracle:oinstall /data/oracle
[root@centos ~]# chmod -R 775 /data/oracle

###设置oracle用户环境变量
[root@centos ~]# su - oracle
ps:切换用户时切记要加"-",加-会拥有目标用户的环境变量,不加"-"则没有.

[oracle@centos ~]$ vim .bash_profile
添加如下内容:

1ORACLE_BASE=/data/oracle
2ORACLE_HOME=$ORACLE_BASE/product/11.2.0
3ORACLE_SID=orcl
4PATH=$PATH:$ORACLE_HOME/bin
5export ORACLE_BASE
6export ORACLE_HOME
7export ORACLE_SID
8export PATH

使之生效:
[oracle@centos ~]$ source .bash_profile

###编辑静默安装响应文件
[oracle@centos ~]$ cp -R /data/oracle/oraclesetup/database/response/ .
[oracle@centos ~]$ cd response/
[oracle@centos response]$ vim db_install.rsp
需要设置的选项如下:

01oracle.install.option=INSTALL_DB_SWONLY
02ORACLE_HOSTNAME=centos
03UNIX_GROUP_NAME=oinstall
04INVENTORY_LOCATION=/data/oracle/inventory
05SELECTED_LANGUAGES=en,zh_CN
06ORACLE_HOME=/data/oracle/product/11.2.0
07ORACLE_BASE=/data/oracle
08oracle.install.db.InstallEdition=EE
09oracle.install.db.DBA_GROUP=dba
10oracle.install.db.OPER_GROUP=dba
11DECLINE_SECURITY_UPDATES=true

2.静默安装oracle
[oracle@centos ~]$ cd /data/oracle/oraclesetup/database/
[oracle@centos database]$ ./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq

ps:Oracle开始在后台静默安装,如果提示Successfully则表示安装成功

###按照要求执行脚本,重新开一个终端,以root用户登录,执行脚本
[root@centos ~]# sh /data/oracle/inventory/orainstRoot.sh
[root@centos ~]# sh /data/oracle/product/11.2.0/root.sh

ps:请根据你们自己的提示执行脚本.

###以静默方式配置监听
[oracle@centos ~]$ netca /silent /responsefile /home/oracle/response/netca.rsp

成功后,通过netstat命令可以查看1521端口正在监听
[oracle@centos ~]$ netstat -tnulp | grep 1521
tcp6       0      0 :::1521                 :::*                    LISTEN      13816/tnslsnr

###以静默方式建立新库,同时也建立一个对应的实例
[oracle@centos ~]$ vim /home/oracle/response/dbca.rsp
设置以下参数:

01GDBNAME = "orcl"
02SID = "orcl"
03SYSPASSWORD = "oracle"
04SYSTEMPASSWORD = "oracle"
05SYSMANPASSWORD = "oracle"
06DBSNMPPASSWORD = "oracle"
07DATAFILEDESTINATION =/data/oracle/oradata
08RECOVERYAREADESTINATION=/data/oracle/fast_recovery_area
09CHARACTERSET = "AL32UTF8"
10TOTALMEMORY = "1638"

ps:其中TOTALMEMORY = "1638"为1638MB,一般设置为物理内存的80%

###进行静默配置
[oracle@centos ~]$ dbca -silent -responseFile /home/oracle/response/dbca.rsp

###建库后进行实例进程检查
[oracle@centos ~]$ ps -ef | grep ora_ | grep -v grep

###查看监听状态
[oracle@centos ~]$ lsnrctl status

###登录查看实例状态
[oracle@centos ~]$ sqlplus / as sysdba
SQL> select status from v$instance;
如显示
STATUS
------------
OPEN
则表示实例是启动状态

查看数据库编码
SQL> select userenv('language') from dual;
查看数据库版本
SQL> select * from v$version;

3.oracle开机自启动设置
[oracle@centos ~]$ vim /data/oracle/product/11.2.0/bin/dbstart

将ORACLE_HOME_LISTNER=$1修改为:
ORACLE_HOME_LISTNER=$ORACLE_HOME

[oracle@centos ~]$ vim /data/oracle/product/11.2.0/bin/dbshut

将ORACLE_HOME_LISTNER=$1修改为:
ORACLE_HOME_LISTNER=$ORACLE_HOME

###修改/etc/oratab文件
[oracle@centos ~]$ vim /etc/oratab
将orcl:/data/oracle/product/11.2.0:N 修改为:
orcl:/data/oracle/product/11.2.0:Y

输入dbshut和dbstart测试
[oracle@centos ~]$ dbshut
Oracle监听停止,进程消失
[oracle@centos ~]$ dbstart
Oracle监听启动,进程启动

切换到root账户建立自启动脚本
[oracle@centos ~]$ su -
[root@centos ~]# vim /etc/rc.d/init.d/oracle
添加以下内容(有些值如ORACLE_HOME和ORACLE_USER等根据实际情况可以修改)

01#!/bin/bash
02# oracle: Start/Stop Oracle Database 11g R2
03#
04# chkconfig: 345 90 10
05# description: The Oracle Database is an Object-Relational Database Management System.
06#
07# processname: oracle
08. /etc/rc.d/init.d/functions
09LOCKFILE=/var/lock/subsys/oracle
10ORACLE_HOME=/data/oracle/product/11.2.0
11ORACLE_USER=oracle
12case "$1" in
13'start')
14   if [ -f $LOCKFILE ]; then
15      echo $0 already running.
16      exit 1
17   fi
18   echo -n $"Starting Oracle Database:"
19   su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
20   su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
21   su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
22   touch $LOCKFILE
23   ;;
24'stop')
25   if [ ! -f $LOCKFILE ]; then
26      echo $0 already stopping.
27      exit 1
28   fi
29   echo -n $"Stopping Oracle Database:"
30   su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
31   su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"
32   su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
33   rm -f $LOCKFILE
34   ;;
35'restart')
36   $0 stop
37   $0 start
38   ;;
39'status')
40   if [ -f $LOCKFILE ]; then
41      echo $0 started.
42      else
43      echo $0 stopped.
44   fi
45   ;;
46*)
47   echo "Usage: $0 [start|stop|status]"
48   exit 1
49esac
50exit 0


chmod +x /etc/init.d/oracle
chkconfig oracle on

好了,oracle静默安装到此为止,剩下的就靠大家自己去折腾了.
ps:
http://blog.51cto.com/canonind/1883066
http://www.jianshu.com/p/03f0a0e826e0
http://kyle-ming.blogspot.com/2015/04/centos-7-oracle-11g.html
夜空- 本站版权
1、本站所有主题由该文章作者发表,该文章作者与夜空享有文章相关版权
2、其他单位或个人使用、转载或引用本文时必须同时征得该文章作者和夜空的同意
3、本帖部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责
4、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意
5、原文链接:blog.slogra.com/post-712.html

标签: centos 安装 远程 oracle install 静默 无图形界面

  1. 2018-12-15 22:35
    @kaka:可以的啊
  1. gravatar kaka
    2018-12-14 17:22
    博主您好,您的这边静默安装文档写的很好,我几乎每次都是一遍成功,所以我想转载到自己博客可以吗,我会写明转载地址的!
  1. gravatar kaka
    2018-05-03 11:42
    在执行实例检查前应该先启动实例,然后就发现报错找不到initoracl.ora 此时需要将/data/oracle/admin/orcl/pfile 下面的init.ora.******* 复制到/data/oracle/product/11.2.0/dbs 下 并更名为initorcl.ora,然后再次登陆SQL startup启动 发现还是报错ORA-00845: MEMORY_TARGET not supported on this system 这种情况是因为内存不足,两种解决方法1. 加大Linux的物理内存
    2. 在/etc/fstab中明确指定/dev/shm的挂载sizes大小参数
    在root下执行
    mount -t tmpfs shmfs -o size=1g /dev/shm  
    然后 vi /etc/fstab 中添加
    tmpfs                   /dev/shm                tmpfs   defaults size=1g       0 0  
    (这里我查资料有的是直接加8g 不过我自己虚拟机只分配2g内存,所以就设置成1g,也可以正常启动,所以这个参数你们可以是自己情况而定),然后登陆sqlplus 再次启动成功

评论:

正在载入...