Oracle 11g 基于云服务器HECS +Centos7.6静默安装教程(无图形界面,远程安装)

发布于:2022-11-09 ⋅ 阅读:(650) ⋅ 点赞:(0)

一、安装前环境准备

华为云购买的x86服务器,Centos7.6操作系统最小化安装,2vCPUs | 4GiB CentOS 7.6 64bit
,40G磁盘空间,已配置好网络。

1、已下载Oracle 11g Linux安装文件:linux.x64_11gR2_database_1of2.zip和linux.x64_11gR2_database_2of2.zip

官网比较慢,我从这搞的https://blog.csdn.net/qq_43278189/article/details/123687994

2、通过winscp工具上传到服务器/opt/software/oracle目录中。

二、操作系统准备工作

本章节使用root用户操作。
1.登录操作系统
2.yum 安装 unzip 软件,用来解压上传的Oracle安装文件。

yum install unzip -y

3.解压Oracle 安装程序

 cd /opt/software/oracle
 unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64_11gR2_database_2of2.zip

等待解压完成后,会在同目录下生产一个database文件夹,里面就Oracle 11g安装文件。
4.Yum 安装vim软件,用于编辑配置文件(个人习惯,不安装vim,使用vi也可以)。
yum install vim -y 5.在/etc/hosts文件中添加自己的IP和主机名。注意替换
vim /etc/hosts
添加192.168.222.111 centos

6.关闭selinux
vim /etc/selinux/config
设置SELINUX=disabled
setenforce 0

7.关闭防火墙

 service iptables stop
systemctl disable iptables
 systemctl stop firewalld
systemctl disable firewalld

8.安装Oracle 11g依赖包

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

9.添加安装用户和用户组。ID要是有占用就换个别的数

 groupadd oinstall
 groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle
id oracle
uid=1001(oracle) gid=1001(oinstall)=1001(oinstall),1002(dba)

10.修改内核参数配置文件
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

[root@oraclehost ~]# sysctl -p

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

11.修改用户的限制文件
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文件:
vim /etc/pam.d/login

添加以下内容:

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

修改/etc/profile文件:
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

12.创建安装目录和设置文件权限

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

13.设置oracle用户环境变量,注意切换用户

su - 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

14.编辑静默安装响应文件. 注意/opt/software/oracle/ 替换为实际安装包路径
[oracle@oraclehost ~]$ cp -R /opt/software/oracle/database/response/ .
cd response/
vim db_install.rsp

需要设置的选项如下: 一个个的自己设置的值

oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=centos
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 11g

进入安装包路径
[oracle@oraclehost response]$ cd /opt/software/oracle/database/
[oracle@oraclehost database]$ ./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq

开始Oracle在后台静默安装。安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在后台进行,如果出现[FATAL],则安装程序已经停止了。

报错了
[oracle@oraclehostdatabase]$ ./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq
Starting Oracle Universal Installer…

Checking Temp space: must be greater than 120 MB. Actual 22949 MB Passed
Checking swap space: 0 MB available, 150 MB required. Failed <<<<

Some requirement checks failed. You must fulfill these requirements before

continuing with the installation,

解决方法:
查看命令
[oracle@oraclehostdatabase]$ swapon -s
返回为空 说明确实没有。
Root 用户执行
[root@oraclehostoracle]# dd if=/dev/zero of=/home/swapfile bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 1.07932 s, 497 MB/s
[root@oraclehostoracle]# mkswap /home/swapfile
Setting up swapspace version 1, size = 524284 KiB
no label, UUID=f43636d7-0fd1-4659-8405-ec30082ab4ec

[root@oraclehostoracle]# swapon /home/swapfile
swapon: /home/swapfile: insecure permissions 0644, 0600 suggested.

修改 fstab 配置。用 vim 打开 /etc/fstab 文件,在其最后添加如下一行:
/swapfile swap swap defaults 0 0

[root@oraclehostoracle]# ll /home/swapfile
-rw-r–r-- 1 root root 536870912 Nov 4 10:08 /home/swapfile
[root@oraclehostoracle]# vi /etc/fstab
[root@oraclehostoracle]# chmod 644 /home/swapfile
[root@oraclehostoracle]# swapon -s
Filename Type Size Used Priority
/home/swapfile file 524284 0 -2

可以在以下位置找到本次安装会话的日志:
/u01/app/oracle/inventory/logs/installActions2015-06-08_04-00-25PM.log
可以切换终端执行top命令查看后台进程一直是在安装的,/u01目录也在不断增大,
当出现以下提示时,代表安装成功:

按照要求执行脚本。
重新打开终端,以root身份登录,执行脚本:
[root@oraclehost ~]# sh /u01/app/oracle/inventory/orainstRoot.sh
[root@oraclehost ~]# sh /u01/app/oracle/product/11.2.0/root.sh

四、以静默方式配置监听

重新使用oracle用户登录
[oracle@oraclehost ~]$ netca /silent /responsefile /home/oracle/response/netca.rsp

成功运行后,在/u01/app/oracle/product/11.2.0/network/admin/中生成listener.ora和sqlnet.ora
失败了,猜测是1521 已经被占用了,查询了一下结果并没有。重新执行了一遍居然又成功了,呵呵哒

[oracle@oraclehost~]$ netca /silent /responsefile /home/oracle/response/netca.rsp

Parsing command line arguments:
Parameter “silent” = true
Parameter “responsefile” = /home/oracle/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
The information provided for this listener is currently in use by other software on this computer.
Listener start failed.
Check the trace file for details: /u01/app/oracle/cfgtoollogs/netca/trace_OraDb11g_home1-22110410AM2548.log
Oracle Net Services configuration failed. The exit code is 1
[oracle@oraclehost~]$ vi /u01/app/oracle/cfgtoollogs/netca/trace_OraDb11g_home1-22110410AM2548.log

Yum安装netstat软件,软件包是在net-tools中。
[root@oraclehost ~]# yum install net-tools
切换用户
[oracle@oraclehost ~]$ lsnrctl start
注意用户
root 通过netstat命令可以查看1521端口正在监听。

五、以静默方式建立新库,同时也建立一个对应的实例。

[oracle@oraclehost~]$ cp /home/oracle/response/dbca.rsp /home/oracle/response/dbca.rsp.bak
[oracle@oraclehost~]$ vim /home/oracle/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”

其中TOTALMEMORY = “1638” 为1638MB,物理内存2G*80%。

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

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

查看监听状态:
[oracle@oraclehost~]$ lsnrctl status

登录查看实例状态:
[oracle@oraclehost ~]$ sqlplus / as sysdba
SQL> select status from v$instance;

图片版可以看我发布的资源~

本文含有隐藏内容,请 开通VIP 后查看