centos7静默安装oracle 11g
系统: 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 ~]#
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static \ gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel \ libgcc 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
添加以下内容:
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
其中kernel.shmmax = 1073741824为本机物理内存(2G)的一半,单位为byte.
[root@centos ~]# sysctl -p
###修改用户的限制文件
[root@centos ~]# 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文件
[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
添加以下内容:
if [ $USER = "oracle" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi fi
使之生效:
[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
添加如下内容:
ORACLE_BASE=/data/oracle ORACLE_HOME=$ORACLE_BASE/product/11.2.0 ORACLE_SID=orcl PATH=$PATH:$ORACLE_HOME/bin export ORACLE_BASE export ORACLE_HOME export ORACLE_SID export 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
需要设置的选项如下:
oracle.install.option=INSTALL_DB_SWONLY ORACLE_HOSTNAME=centos UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/data/oracle/inventory SELECTED_LANGUAGES=en,zh_CN ORACLE_HOME=/data/oracle/product/11.2.0 ORACLE_BASE=/data/oracle oracle.install.db.InstallEdition=EE oracle.install.db.DBA_GROUP=dba oracle.install.db.OPER_GROUP=dba DECLINE_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
设置以下参数:
GDBNAME = "orcl" SID = "orcl" SYSPASSWORD = "oracle" SYSTEMPASSWORD = "oracle" SYSMANPASSWORD = "oracle" DBSNMPPASSWORD = "oracle" DATAFILEDESTINATION =/data/oracle/oradata RECOVERYAREADESTINATION=/data/oracle/fast_recovery_area CHARACTERSET = "AL32UTF8" TOTALMEMORY = "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等根据实际情况可以修改)
#!/bin/bash # oracle: Start/Stop Oracle Database 11g R2 # # chkconfig: 345 90 10 # description: The Oracle Database is an Object-Relational Database Management System. # # processname: oracle . /etc/rc.d/init.d/functions LOCKFILE=/var/lock/subsys/oracle ORACLE_HOME=/data/oracle/product/11.2.0 ORACLE_USER=oracle case "$1" in 'start') if [ -f $LOCKFILE ]; then echo $0 already running. exit 1 fi echo -n $"Starting Oracle Database:" su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start" su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole" touch $LOCKFILE ;; 'stop') if [ ! -f $LOCKFILE ]; then echo $0 already stopping. exit 1 fi echo -n $"Stopping Oracle Database:" su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop" su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut" su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole" rm -f $LOCKFILE ;; 'restart') $0 stop $0 start ;; 'status') if [ -f $LOCKFILE ]; then echo $0 started. else echo $0 stopped. fi ;; *) echo "Usage: $0 [start|stop|status]" exit 1 esac exit 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
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
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 再次启动成功