千家信息网

CentOS7静默安装数据库oralce11gR2

发表于:2024-12-12 作者:千家信息网编辑
千家信息网最后更新 2024年12月12日,一、系统版本操作系统: CentOS Linux release 7.3.1611 (Core)二、oracle软件版本oracle版本:linux.x64_11gR2linux.x64_11gR2_
千家信息网最后更新 2024年12月12日CentOS7静默安装数据库oralce11gR2

一、系统版本

操作系统: CentOS Linux release 7.3.1611 (Core)

二、oracle软件版本

oracle版本:linux.x64_11gR2
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip

三、创建用户、组

A) 创建用户和组

groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle

B) 创建数据库安装目录

mkdir -p /opt/oracle ##$ORACLE_BASE
mkdir -p /opt/oracle/product/112010/db_1 ##$ORACLE_HOME
mkdir /opt/oracle/oradata ##存放数据库目录
mkdir /opt/oracle/inventory
mkdir /opt/oracle/flash_recovery_area
chown -R oracle:oinstall /opt/oracle
chmod -R 775 /opt/oracle

C) 将oracle使用者加入到sudo群组中
vi /etc/sudoers
输入上面的命令后,打开sudoers文件进行编辑,找到
root ALL=(ALL) ALL

这行,并且在底下再加入以下命令:
oracle ALL=(ALL) ALL

四、修改系统参数、及环境变量

1、关闭selinux
vi /etc/selinux/config
修改: SELINUX=disabled

2、关闭防火墙
systemctl stop firewalld.service #停止服务|firewall
systemctl disable firewalld.service #禁止firewall开机启动

3、修改/etc/hosts文件
vi /etc/hosts
10.143.200.188 DATAFS

4、修改内核参数
vi /etc/sysctl.conf

修改以下内容
kernel.shmall = 2097152
kernel.shmmax = 1073741824

添加以下内容
fs.aio-max-nr = 1048576
fs.file-max = 6815744
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

5、修改用户限制文件

#vi /etc/security/limits.conf
行末添加以下内容

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240

6、关联设置
vi /etc/pam.d/login
行末添加以下内容:
session required /lib64/security/pam_limits.so
session required pam_limits.so

7、修改/etc/profile
#vi /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

source /etc/profile

8、Oralce用户修改用户环境变量

#vi /home/oracle/.bash_profile
在最底下加入以下内容
#For Oracle
export ORACLE_BASE=/opt/oracle;
export ORACLE_HOME=/opt/oracle/product/112010/db_1
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export LC_ALL="en_US"
export LANG="en_US"
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"

if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022

fi

source /home/oracle/.bash_profile
查看命令:# env

五、安装依赖包

安装依赖包比较多,最好服务器能够访问外网,这样就简单多了,如果真的无法访问外网只能下载对应的rpm包安装了.

yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel gcc gcc-c++ libaio-devel libaio libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh ksh libaio.i686 glibc.i686 compat-libstdc++-33.i686 libaio-devel.i686 libgcc.i686 libstdc++.i686 unixODBC.i686 unixODBC-devel.i686

rpm包安装:#rpm -ivh * --force --nodeps

六、正式开始安装数据库

1、安装包解压命令(使用oracle用户解压 )

$unzip linux.x64_11gR2_database_1of2.zip
$unzip linux.x64_11gR2_database_2of2.zip
修改目录所属用户
chown -R oracle:oinstall database

解压完成后会生成database目录,解压后的文件中database/response下有有db_install.rsp、dbca.rsp和netca.rsp三个应答文件,分别数据库安装文件、建立数据库实例和监听配置安装文件,在下面的步骤中会用到这3个文件.

2、编辑数据库安装文件db_install.rsp
vi db_install.rsp
20 oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
29 oracle.install.option=INSTALL_DB_SWONLY #安装类型
37 ORACLE_HOSTNAME=DATAFS #主机名称
42 UNIX_GROUP_NAME=oinstall #安装组
47 INVENTORY_LOCATION=/opt/oracle/inventory #INVENTORY目录
78 SELECTED_LANGUAGES=en,zh_CN #选择语言
83 ORACLE_HOME=/opt/oracle/product/112010/db_1 #oracle_home
88 ORACLE_BASE=/opt/oracle #oracle_base
99 oracle.install.db.InstallEdition=EE ##oracle版本
108 oracle.install.db.isCustomInstall=true
142 oracle.install.db.DBA_GROUP=dba #dba用户组
147 oracle.install.db.OPER_GROUP=dba #oper用户组
160 oracle.install.db.config.starterdb.type=GENERAL_PURPOSE #数据库类型
165 oracle.install.db.config.starterdb.globalDBName=orcl #globalDBName
170 oracle.install.db.config.starterdb.SID=orcl #SID
200 oracle.install.db.config.starterdb.memoryLimit=800 #自动管理内存的最小内存(M)
233 oracle.install.db.config.starterdb.password.ALL=oracle #设定所有数据库用户使用同一个密码
385 DECLINE_SECURITY_UPDATES=true #设置安全更新

3、安装数据库软件(使用oracle用户)
#su - oracle
进入刚才的database目录
./runInstaller -silent -responseFile /ghca/database/response/db_install.rsp -ignorePrereq
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB. Actual 13773 MB Passed
Checking swap space: must be greater than 150 MB. Actual 2047 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-09-20_09-16-02PM. Please wait ...

接下来就是等待(有点长,不要着急!!!),快的话10分钟左右,慢一点可能需要30分钟左右,要看服务器配置。

安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在后台进行,如果出现[FATAL],则安装程序已经停止了。
可以在以下位置找到本次安装会话的日志。
安装失败会打印一下信息
[FATAL] [INS-32076] English cannot be removed from the selected languages list.
CAUSE: An attempt was made to remove English from the selected languages list.
ACTION: Select English as one of the selected product languages.
A log of this session is currently saved as: /tmp/OraInstall2018-09-20_09-16-02PM/installActions2018-09-20_09-16-02PM.log. Oracle recommends that if you want to keep this log, you should move it from the temporary location to a more permanent location.

查看log日志信息:
cat /tmp/OraInstall2018-09-20_09-16-02PM/installActions2018-09-20_09-16-02PM.log. Oracle

正常安装日志信息:
[oracle@DATAFS database]$ [WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
CAUSE: The Central Inventory is located in the Oracle base.
ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
[WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
CAUSE: The Central Inventory is located in the Oracle base.
ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
You can find the log of this install session at:
/opt/oracle/inventory/logs/installActions2018-09-20_09-47-28PM.log

tail -f /opt/oracle/inventory/logs/installActions2018-09-20_09-47-28PM.log

安装成功的日志如下:
The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run

/opt/oracle/inventory/orainstRoot.sh
/opt/oracle/product/112010/db_1/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

4、 安装后操作,按照要求执行脚本
打开新的终端,以root身份登录,执行脚本:

#/opt/oracle/inventory/orainstRoot.sh
#/opt/oracle/product/112010/db_1/root.sh

[root@DATAFS db_1]# /opt/oracle/inventory/orainstRoot.sh
Changing permissions of /opt/oracle/inventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /opt/oracle/inventory to oinstall.
The execution of the script is complete.
[root@DATAFS db_1]# /opt/oracle/product/112010/db_1/root.sh
Check /opt/oracle/product/112010/db_1/install/root_DATAFS_2018-09-20_22-36-50.log for the output of root script

完成后,返回原来的终端按下回车键,等待程序安装完成.

七、监听器配置

执行命令 : netca /silent /responseFile /ghca/database/response/netca.rsp ###----此处必须写绝对路径
[oracle@DATAFS response]$ netca /silent /responseFile /ghca/database/response/netca.rsp

Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /ghca/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Configuring Listener:LISTENER
Listener configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/opt/oracle/product/112010/db_1/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
Profile configuration complete.
Oracle Net Services configuration successful. The exit code is 0

查看端口是否占用:
[root@DATAFS ~]# ss -tnl|grep 1521
LISTEN 0 128 :::1521 :::*
[root@DATAFS ~]#

查看监听状态:

[oracle@DATAFS response]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 21-SEP-2018 12:22:08

Copyright (c) 1991, 2009, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DATAFS)(PORT=1521)))
STATUS of the LISTENER

Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 21-SEP-2018 12:20:29
Uptime 0 days 0 hr. 1 min. 41 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/112010/db_1/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/DATAFS/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DATAFS)(PORT=1521)))
The listener supports no services
The command completed successfully

八、安装数据库实例

1 修改/ghca/database/response/dbca.rsp响应文件中的重要参数

本次安装过程中设置了下列参数:(注意下面参数视情况而定,不要照抄,原文件都有说明的)
RESPONSEFILE_VERSION ="11.2.0" #不能更改

OPERATION_TYPE ="createDatabase"

GDBNAME ="orcl" #数据库的名字

SID ="ORCL" ##对应的实例名字

TEMPLATENAME ="General_Purpose.dbc" ##建库用的模板文件

SYSPASSWORD ="oracle" ##SYS管理员密码

SYSTEMPASSWORD ="oracle" ##SYSTEM管理员密码

SYSMANPASSWORD= "oracle"

DBSNMPPASSWORD= "oracle"

DATAFILEDESTINATION =/opt/oracle/oradata ##数据文件存放目录

RECOVERYAREADESTINATION=/opt/oracle/flash_recovery_area ##恢复数据存放目录

CHARACTERSET ="ZHS16GBK" ##字符集,重要!!!建库后一般不能更改,所以建库前要确定清楚。

TOTALMEMORY ="1638" #1638MB,物理内存2G*80%。

2、 开始安装数据库实例
dbca -silent -responseFile /ghca/database/response/response/dbca.rsp
[oracle@DATAFS response]$ dbca -silent -responseFile /ghca/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 "/opt/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.

到此数据库实例安装就完成了.

九、监听配置报错

配置监听时,没有使用netca.rsp相应的文件的绝对路径
[oracle@DATAFS response]$ netca /silent /responseFile netca.rsp

Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = ./netca.rsp
Oracle Net Configuration Assistant could not find the Response File at the given location.
Oracle Net Services configuration failed. The exit code is 1

十、数据库启停

登录数据库 sqlplus / as sysdba
启动:SQL> startup
停止:SQL> shutdown immediate;

十一、创建表空间以及用户、权限等

1、管理员用户创建表空间保存数据
create tablespace IDR_TS datafile '/opt/oracle/oradata/orcl/IDR_TS01.dbf' size 1024m;

2、创建用户数据操作用户

create user operator identified by "123456"
default tablespace operator
temporary tablespace TEMP
profile DEFAULT
quota unlimited on IDR_TS;

以下权限是可选的,根据自己需要给用户赋权
grant connect to operator;
grant dba to operator;
grant javasyspriv to operator;
-- Grant/Revoke system privileges
grant create any sequence to operator;
grant create any table to operator;
grant create any view to operator;
grant unlimited tablespace to operator;
-- Grant/Revoke role privileges
grant connect to operator;
grant dba to operator;
grant exp_full_database to operator;
grant imp_full_database to operator;
grant javasyspriv to operator;
grant resource to operator;
-- Grant/Revoke system privileges
grant create any sequence to operator;
grant alter any table to operator;
grant alter any trigger to operator;
grant alter session to operator;
grant alter system to operator;
grant alter tablespace to operator;
grant alter user to operator;
grant analyze any to operator;
grant create any procedure to operator;
grant create any synonym to operator;
grant create any table to operator;
grant create any trigger to operator;
grant create cluster to operator;
grant create database link to operator;
grant create procedure to operator;
grant create public synonym to operator;
grant create role to operator;
grant create sequence to operator;
grant create session to operator;
grant create synonym to operator;
grant create table to operator;
grant create any view to operator;
grant delete any table to operator;
grant drop any index to operator;
grant drop any synonym to operator;
grant drop any table to operator;
grant drop any trigger to operator;
grant drop public synonym to operator;
grant execute any procedure to operator;
grant insert any table to operator;
grant lock any table to operator;
grant select any table to operator;
grant unlimited tablespace to operator;
grant update any table to operator;
到此就可以使用operator登录进行数据操作了.数据库完整的安装就结束了.

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< installation is complete >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

0