Oracle 11g静默安装
一、前提:
1、修改系统时间
[root@localhost ~]# date -s “2022-05-09 09:11:40”
[root@localhost ~]# hwclock -w
2、修改主机名
修改/etc/hosts文件
[root@localhost ~]# vi /etc/hosts192.168.3.201 oracle
二、安装
1.系统环境准备
1.1 查看并配置当前yum源
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir repo_bak
1.2 下载网易和阿里云repo文件(当前是阿里云服务器,所以用的第二条指令)
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
[root@localhost yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost yum.repos.d]# ls
1.3 清楚yum缓存 重新生成yum缓存
[root@localhost yum.repos.d]# yum clean all
[root@localhost yum.repos.d]# yum makecache
1.4 安装依赖包
当前使用操作系统为64位,所以选择相应64位依赖包进行安装,另外如提示没有相应依赖包,可选择安装新版本的
[root@localhost yum.repos.d]# yum install -y binutils
[root@localhost yum.repos.d]# yum install -y compat-libcap1
[root@localhost yum.repos.d]# yum install -y compat-libstdc++-33
[root@localhost yum.repos.d]# yum install -y gcc
[root@localhost yum.repos.d]# yum install -y gcc-c++
[root@localhost yum.repos.d]# yum install -y glibc
[root@localhost yum.repos.d]# yum install -y glibc-devel
[root@localhost yum.repos.d]# yum install -y ksh
[root@localhost yum.repos.d]# yum install -y libaio
[root@localhost yum.repos.d]# yum install -y libaio-devel
[root@localhost yum.repos.d]# yum install -y libgcc
[root@localhost yum.repos.d]# yum install -y libstdc++
[root@localhost yum.repos.d]# yum install -y libstdc++-devel
[root@localhost yum.repos.d]# yum install -y libXi
[root@localhost yum.repos.d]# yum install -y libXtst
[root@localhost yum.repos.d]# yum install -y make
[root@localhost yum.repos.d]# yum install -y sysstat
[root@localhost yum.repos.d]# yum install -y elfutils-libelf-devel
[root@localhost yum.repos.d]# yum install -y unixODBC
[root@localhost yum.repos.d]# yum install -y unixODBC-devel
1.5 创建用户组和用户
# 确认本地没有oracle用户,若有需删除:userdel xxx
[root@localhost ~]# id oracle
[root@localhost ~]# groupadd oinstall
[root@localhost ~]# groupadd dba
[root@localhost ~]# useradd -g oinstall -G dba oracle
[root@localhost ~]# id oracle
uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba)
[root@localhost ~]# passwd oracle # 本次未设置oracle密码
1.6 修改系统标识符(oracle默认不支持centos)
[root@localhost db]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@localhost db]# vi /etc/redhat-release
删掉里面的内容输入redhat-7
[root@localhost db]# cat /etc/redhat-release
redhat-7
1.7 修改内核参数
[root@localhost db]# vi /etc/sysctl.conf
(在文件末尾添加)内容如下:
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
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
修改后,生效:/sbin/sysctl -p
1.8 配置Oracle用户参数
1.8.1 /etc/security/limits.conf文件
[root@localhost /]# 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
1.8.2 修改/etc/pam.d/login 文件
vi /etc/pam.d/login
session required /lib/security/pam_limits.so
1.8.3 修改/etc/profile 文件
使用文本编辑器或vi命令增加或修改以下内容
其中的oracle为给oracle安装创建的用户名,如果要创建为其他名字,需要修改为其对应位置在末尾或者export变量配置前都可以;
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
1.9 关闭selinux&&防火墙
1.9.1 永久关闭:设置后需要重启才能生效:reboot
vi /etc/sysconfig/selinux
SELINUX=enforcing 改为 SELINUX=disabled
1.9.2 关闭防火墙
systemctl status firewall
systemctl stop firewall
systemctl disable firewall
1.10 创建安装目录app&&静默安装目录etc
[root@localhost home]# mkdir -p /home/oracle/app/
[root@localhost home]# mkdir -p /home/oracle/etc/
[root@localhost home]# chown -R oracle:oinstall /home/oracle/app/
[root@localhost home]# chmod 775 /home/oracle/app/
1.11 上传oracle安装包到:/home/oracle/app/下,并解压
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
1.12 拷贝/home/oracle/app/database/response文件到/home/oracle/etc/目录下
拷贝前:
拷贝后:
2.数据库安装
2.1 配置环境变量
cd /home/oracle
vim .bash_profile
source .bash_profile
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export ORACLE_BASE=/home/oracle/app/
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=HNTMS
export ORACLE_TERM=xterm
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export LANG=C
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export ORACLE_UNQNAME=HNTMS
export PATH=$ORACLE_HOME/bin:$PATH
export PATH
export SQLPATH=/home/oracle/labs
2.2 编辑/home/oracle/etc/目录下db_install.rsp
vim db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/home/oracle/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN,zh_TW
ORACLE_HOME=/home/oracle/app/product/11.2.0/dbhome_1
ORACLE_BASE=/home/oracle/app/
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=false
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=
oracle.install.db.config.starterdb.SID=
oracle.install.db.config.starterdb.characterSet=ZHS16GBK
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
DECLINE_SECURITY_UPDATES=true
2.3在路径:/home/oracle/app/database下执行命令
./runInstaller -silent -force -responseFile /home/oracle/etc/db_install.rsp -ignorePrereq
2.4 出现sucessfully,代表安装完成,再执行root.sh
[oracle@oracle dbhome_1]#./root.sh
2.5 配置监听:
2.5.1编辑/home/oracle/etc/目录下netca.rsp
[oracle@oracle etc]# vim netca.rsp
Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /home/oracle/etc/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/home/oracle/app/product/11.2.0/dbhome_1/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
2.5.2 执行netca.rsp
su - oracle
cd app/product/11.2.0/dbhome_1/bin
netca /silent /responsefile /home/oracle/etc/netca.rsp
2.6 启动监听
[oracle@oracle bin]#lsnrctl start
3建库
3.1 配置:/home/oracle/etc/dbca.rsp
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "HNTMS" #数据库的名字
SID = "HNTMS" #对应的实例名字
SYSPASSWORD = "sys" #SYS管理员密码
SYSTEMPASSWORD = "sys" #SYSTEM管理员密码
SYSMANPASSWORD = "sys"
DBSNMPPASSWORD = "sys"
TEMPLATENAME = "General_Purpose.dbc" #建库用的模板文件
CHARACTERSET = "ZHS16GBK"
红色部分为实例名称,可根据情况修改
3.2静默dbca建库
执行:dbca -silent -responseFile /home/oracle/etc/dbca.rsp
3.3建库完成:
3.4验证启动:
登录数据库: sqlplus / as sysdba
启动:SQL> startup
停止:SQL> shutdown immediate;
三、附录
查看oracle进程
ps -ef|grep ora
查看监听状态
lsnrctl status
启动监听
lsnrctl start
数据库操作
sqlplus / as sysdba // 登录数据库
select open_mode from v$database;
select status from v$instance; //查看数据库状态
alter user sys identified by oracle; //改sys超级管理员密码
alter user system identified by oracle; //改system管理员密码
exit // 退出数据库
sqlplus sys/oracle as sysdba //使用sys超级管理员登录数据库
startup // 启动数据库
select name from v$database; //查看数据库
shutdown abort //关闭数据库
conn system/oracle //切换用户conn后面直接跟用户名和密码就可以
select userenv('language') from dual; //查询字符集
卸载命令:
cd /home/oracle/app/product/11.2.0/dbhome_1/deinstall/
./deinstall