linux下静默安装oracle
linux下静默安装oracle
centos7.7
oracle11gR2
安装前的准备
1禁用ipv6
新加
[ ~]# vim /etc/sysconfig/network NETWORKING_IPV6=no
修改/etc/hosts,把ipv6那句本地主机名解析的注释掉
[ ~]# vim /etc/hosts # ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
在/etc/modprobe.d/dist.conf文件中添加
[ ~]# vim /etc/modprobe.d/dist.conf alias net-pf-10 off alias ipv6 off
2在/etc/hosts文件添加本机IP跟主机名
[ ~]# hostname localhost.localdomain
[ ~]# vim /etc/hosts 192.168.0.33 localhost.localdomain
3关闭selinux
[ ~]# vim /etc/selinux/config SELINUX=disabled
4关闭firewalld防火墙
关闭防火墙
[ ~]# systemctl stop firewalld
关闭开机自启动防火墙
[ ~]# systemctl disable firewalld
查看防火墙状态
[ ~]# systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man:firewalld(1)
5安装oracle 11g依赖包
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
6修改内核参数
添加
[ ~]# vim /etc/sysctl.conf io-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
让更改的配置立即生效
[ ~]# sysctl –p
7修改用户的限制文件
添加
[ ~]# 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
8修改/etc/pam.d/login文件
添加
[ ~]# vim /etc/pam.d/login session required /lib64/security/pam_limits.so session required pam_limits.so
9修改/etc/profile文件
添加
[ ~]# cat /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
10新建oracle用户并加入oinstall、dba组中
[ ~]# groupadd oinstall [ ~]# groupadd dba [ ~]# useradd -g oinstall -G dba oracle [ ~]# passwd oracle
查看
[ ~]# id oracle uid=1000(oracle) gid=1000(oinstall) groups=1000(oinstall),1001(dba)
11创建安装目录,修改文件权限
[ ~]# 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/
[ ~]# ll /u01/app/ total 0 drwxrwxr-x. 11 oracle oinstall 169 Feb 18 07:31 oracle
准备安装
1 将oracle软件包放在/tmp目录下
可以通过wget从官网下载,或者通过xftp上传
[ ~]# ll /tmp/ -rw-r--r--. 1 root root 1239269270 Feb 2 21:36 linux.x64_11gR2_database_1of2.zip -rw-r--r--. 1 root root 1111416131 Feb 2 21:35 linux.x64_11gR2_database_2of2.zip
2解压
安装解压软件
[ ~]# yum install unzip zip -y
解压
[ tmp]# unzip linux.x64_11gR2_database_1of2.zip [ tmp]# unzip linux.x64_11gR2_database_2of2.zip
在tmp目录下多了一个目录
[ tmp]# ls database/ doc install response rpm runInstaller sshsetup stage welcome.html
3切换到oracle用户,设置oracle用户环境变量
[ tmp]# su - oracle Last login: Tue Feb 18 07:50:52 CST 2020 from 192.168.0.31 on pts/0
添加
[ ~]$ vim .bash_profile export PATH 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
4编辑配置文件/tmp/database/response/db_install.rsp
备份配置文件
[ oracle]# cp /tmp/database/response/db_install.rsp /root/
编辑
[ oracle]# vim /tmp/database/response/db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY ORACLE_HOSTNAME=localhost.localdomain 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
5根据配置文件安装oracle
oracle用户下,/tmp/database/目录下执行
[ database]$ ./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /tmp/database/response/db_install.rsp
6报错:交换分区不足
Checking swap space: 0 MB available, 150 MB required.
创建交换分区
[ database]$ su root Password: [ database]# dd if=/dev/zero of=/swapfile bs=1024 count=300000 [ database]# mkswap /swapfile [ database]# swapon /swapfile
查看
[ database]# swapon -s Filename Type Size Used Priority /swapfile file 299996 0 -2
加入到文件中
[ database]# vim /etc/fstab /swapfile swap swap defaults 0 0 [ database]# chown root:root /swapfile [ database]# chmod 0600 /swapfile
7再次安装当出现如下界面,已经按照完成
/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.
8切换root用户运行脚本
[ database]# sh /u01/app/oracle/inventory/orainstRoot.sh [ database]# sh /u01/app/oracle/product/11.2.0/root.sh
配置监听
1切换到oracle用户,执行netca命令
[ database]# su - oracle
[ ~]$ 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变量
[ ~]$ export DISPLAY=localhost:0.0
当提示
[ ~]$ 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)
需要安装
[ oracle]# yum install libXp [ oracle]# yum install libXp-devel
再次执行上面netca语句,输入下面内容,则成功执行
Listener configuration complete. Oracle Net Services configuration successful. The exit code is 0
2会生成listener.ora和sqlnet.ora两个文件
[ ~]$ ls /u01/app/oracle/product/11.2.0/network/admin/ listener.ora samples shrept.lst sqlnet.ora
3查看监听端口
[ oracle]# yum install net-tools [ oracle]# netstat -tnulp | grep 1521 tcp6 0 0 :::1521 :::* LISTEN 14861/tnslsnr
建立新库和实例
1root用户下,修改配置文件
[ oracle]# 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"
2进行静默配置
[ oracle]# su - oracle [ ~]$ 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.
3完成建库后进行实例检查
[ ~]$ ps -ef | grep ora_ | grep -v grep oracle 16464 1 0 07:32 ? 00:00:00 ora_pmon_orcl oracle 16466 1 0 07:32 ? 00:00:00 ora_vktm_orcl oracle 16470 1 0 07:32 ? 00:00:00 ora_gen0_orcl oracle 16472 1 0 07:32 ? 00:00:00 ora_diag_orcl oracle 16474 1 0 07:32 ? 00:00:00 ora_dbrm_orcl oracle 16476 1 0 07:32 ? 00:00:00 ora_psp0_orcl oracle 16478 1 0 07:32 ? 00:00:00 ora_dia0_orcl oracle 16480 1 0 07:32 ? 00:00:00 ora_mman_orcl
4查看监听状态
[ ~]$ lsnrctl status
底部出现如下信息,即成功
The command completed successfully
5登录查看实例状态
[ database]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 18 18:54:16 2020 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to an idle instance. SQL>
6启动数据库
SQL> startup ORA-01081: cannot start already-running ORACLE - shut it down first
我是重启过机器,再次尝试,成功
SQL> startup
ORACLE instance started.
Total System Global Area 759943168 bytes
Fixed Size 2217224 bytes
Variable Size 448793336 bytes
Database Buffers 306184192 bytes
Redo Buffers 2748416 bytes
Database mounted.
Database opened.
SQL> select * from v$database;
DBID NAME CREATED RESETLOGS_CHANGE# RESETLOGS
PRIOR_RESETLOGS_CHANGE# PRIOR_RES LOG_MODE CHECKPOINT_CHANGE#
...
```
相关推荐
choice0 2020-07-30
diediexiaomi 2020-04-11
GeorgeTH 2019-11-01
sunboy 2019-08-17
mingwei 2019-06-04
88560398 2019-04-27
89421950 2016-07-07
moyigg 2019-07-01
apk0 2012-09-14
apk0 2012-04-24
一只刚刚上路的猿 2012-04-21
chenhuizhuchz 2018-11-11
oraclewindows 2018-09-18
wuqingyong 2018-08-30
82427713 2018-08-16
Maplematics 2017-10-20
FCBarceIona 2017-04-23
Enn的数据库 2017-03-15
hepeng 2017-01-16