linux下静默安装oracle
Posted 冥思苦想
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux下静默安装oracle相关的知识,希望对你有一定的参考价值。
linux下静默安装oracle
centos7.7
oracle11gR2
安装前的准备
1禁用ipv6
新加
[root@localhost ~]# vim /etc/sysconfig/network
NETWORKING_IPV6=no
修改/etc/hosts,把ipv6那句本地主机名解析的注释掉
[root@localhost ~]# vim /etc/hosts
# ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
在/etc/modprobe.d/dist.conf文件中添加
[root@localhost ~]# vim /etc/modprobe.d/dist.conf
alias net-pf-10 off
alias ipv6 off
2在/etc/hosts文件添加本机IP跟主机名
[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]# vim /etc/hosts
192.168.0.33 localhost.localdomain
3关闭selinux
[root@localhost ~]# vim /etc/selinux/config
SELINUX=disabled
4关闭firewalld防火墙
关闭防火墙
[root@localhost ~]# systemctl stop firewalld
关闭开机自启动防火墙
[root@localhost ~]# systemctl disable firewalld
查看防火墙状态
[root@localhost ~]# 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修改内核参数
添加
[root@localhost ~]# 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
让更改的配置立即生效
[root@localhost ~]# sysctl –p
7修改用户的限制文件
添加
[root@localhost ~]# 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文件
添加
[root@localhost ~]# vim /etc/pam.d/login
session required /lib64/security/pam_limits.so
session required pam_limits.so
9修改/etc/profile文件
添加
[root@localhost ~]# 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组中
[root@localhost ~]# groupadd oinstall
[root@localhost ~]# groupadd dba
[root@localhost ~]# useradd -g oinstall -G dba oracle
[root@localhost ~]# passwd oracle
查看
[root@localhost ~]# id oracle
uid=1000(oracle) gid=1000(oinstall) groups=1000(oinstall),1001(dba)
11创建安装目录,修改文件权限
[root@localhost ~]# mkdir -p /u01/app/oracle/product/11.2.0/
[root@localhost ~]# mkdir /u01/app/oracle/oradata/
[root@localhost ~]# mkdir /u01/app/oracle/inventory/
[root@localhost ~]# mkdir /u01/app/oracle/fast_recovery_area/
[root@localhost ~]# chown -R oracle:oinstall /u01/app/oracle
[root@localhost ~]# chmod -R 775 /u01/app/oracle/
[root@localhost ~]# ll /u01/app/
total 0
drwxrwxr-x. 11 oracle oinstall 169 Feb 18 07:31 oracle
准备安装
1 将oracle软件包放在/tmp目录下
可以通过wget从官网下载,或者通过xftp上传
[root@localhost ~]# 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解压
安装解压软件
[root@localhost ~]# yum install unzip zip -y
解压
[root@localhost tmp]# unzip linux.x64_11gR2_database_1of2.zip
[root@localhost tmp]# unzip linux.x64_11gR2_database_2of2.zip
在tmp目录下多了一个目录
[root@localhost tmp]# ls database/
doc install response rpm runInstaller sshsetup stage welcome.html
3切换到oracle用户,设置oracle用户环境变量
[root@localhost tmp]# su - oracle
Last login: Tue Feb 18 07:50:52 CST 2020 from 192.168.0.31 on pts/0
添加
[oracle@localhost ~]$ 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
备份配置文件
[root@localhost oracle]# cp /tmp/database/response/db_install.rsp /root/
编辑
[root@localhost 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/目录下执行
[oracle@localhost database]$ ./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /tmp/database/response/db_install.rsp
6报错:交换分区不足
Checking swap space: 0 MB available, 150 MB required.
创建交换分区
[oracle@localhost database]$ su root
Password:
[root@localhost database]# dd if=/dev/zero of=/swapfile bs=1024 count=300000
[root@localhost database]# mkswap /swapfile
[root@localhost database]# swapon /swapfile
查看
[root@localhost database]# swapon -s
Filename Type Size Used Priority
/swapfile file 299996 0 -2
加入到文件中
[root@localhost database]# vim /etc/fstab
/swapfile swap swap defaults 0 0
[root@localhost database]# chown root:root /swapfile
[root@localhost 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用户运行脚本
[root@localhost database]# sh /u01/app/oracle/inventory/orainstRoot.sh
[root@localhost database]# sh /u01/app/oracle/product/11.2.0/root.sh
配置监听
1切换到oracle用户,执行netca命令
[root@localhost database]# su - oracle
[oracle@localhost ~]$ 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变量
[oracle@localhost ~]$ export DISPLAY=localhost:0.0
当提示
[oracle@localhost ~]$ 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)
需要安装
[root@localhost oracle]# yum install libXp
[root@localhost oracle]# yum install libXp-devel
再次执行上面netca语句,输入下面内容,则成功执行
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
2会生成listener.ora和sqlnet.ora两个文件
[oracle@localhost ~]$ ls /u01/app/oracle/product/11.2.0/network/admin/
listener.ora samples shrept.lst sqlnet.ora
3查看监听端口
[root@localhost oracle]# yum install net-tools
[root@localhost oracle]# netstat -tnulp | grep 1521
tcp6 0 0 :::1521 :::* LISTEN 14861/tnslsnr
建立新库和实例
1root用户下,修改配置文件
[root@localhost 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进行静默配置
[root@localhost oracle]# su - oracle
[oracle@localhost ~]$ 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完成建库后进行实例检查
[oracle@localhost ~]$ 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查看监听状态
[oracle@localhost ~]$ lsnrctl status
底部出现如下信息,即成功
The command completed successfully
5登录查看实例状态
[oracle@localhost 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#
...
```
以上是关于linux下静默安装oracle的主要内容,如果未能解决你的问题,请参考以下文章