ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

oracle 11.2.0.4静默安装

2020-11-20 22:31:30  阅读:387  来源: 互联网

标签:app db 0.4 11.2 Oracle var install oracle


oracle 11.2.0.4静默安装

1、安装包

1.1、上传安装包

xshell可用rz命令,选择安装包。

mobaxterm可用左侧栏上传功能。

2、安装准备

2.1、关闭防火墙、SELinux

sed -i 's/=enforcing/=disabled/g' /etc/selinux/config
systemctl stop firewalld

2.2、绑定主机名和主机IP

ifconfig | grep inet		//查看主机IP
        inet 66.1.30.32  netmask 255.255.255.0  broadcast 66.1.30.255
        inet 127.0.0.1  netmask 255.0.0.0
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
vim /etc/hosts		//添加
	66.1.30.32   Oracle		//新增行:IP 机器名(这是我的ip和主机名)

2.3、修改用户的限制文件

cat /etc/security/limits.conf                //在该文件内添加以下内容
	oracle           soft    nproc           2047
	oracle           hard    nproc           16384
	oracle           soft    nofile          1024
	oracle           hard    nofile          65536
	oracle           soft    stack           10240

2.4、修改内核参数

cat /etc/sysctl.conf //在文件中添加以下内容
	net.ipv4.ip_local_port_range= 9000 65500
	fs.file-max = 6815744
	kernel.shmall = 10523004
	kernel.shmmax = 6465333657
	kernel.shmmni = 4096
	kernel.sem = 250 32000 100128
	net.core.rmem_default=262144
	net.core.wmem_default=262144
	net.core.rmem_max=4194304
	net.core.wmem_max=1048576
	fs.aio-max-nr = 1048576
sysctl –p // 执行这条语句使配置生效

2.5、依赖包安装

yum install gcc* gcc-* gcc-c++-* glibc-devel-* glibc-headers-* compat-libstdc* libstdc* elfutils-libelf-devel* libaio-devel* sysstat* unixODBC-* pdksh-*

2.6、建立用户、组,安装目录

groupadd oinstall
groupadd dba
useradd –g oinstall -G dba -d /home/oracle oracle
echo "oracle" | passwd --stdin oracle
id oracle //查看用户所属组
	uid=10001(oracle) gid=10001(oinstall) groups=10001(oinstall),10002(dba)

2.7、创建安装目录

mkdir -p /var/app
mkdir -p /var/app/oracle
mkdir -p /var/app/oracle/product
mkdir -p /var/app/oracle/product/11.2.0
mkdir -p /var/app/oracle/product/11.2.0/dbhome_1
mkdir -p /home/oracle/backup
mkdir -p /home/oracle/oraInventory
chown -R oracle:oinstall /var/app
chown -R oracle:oinstall /home/oracle/backup
chown -R oracle:oinstall /home/oracle/oraInventory
chmod -R 775 /var/app

2.8、设置并刷新环境变量

cat /home/oracle/.bash_profile //给该文件添加以下内容
	umask 022
    export ORACLE_BASE=/var/app
    export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
    export ORACLE_SID=orcl
    export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
source /home/oracle/.bash_profile //执行该句使配置生效

3、开始安装

3.1、切换到oracle用户,解压安装包

su - oracle
cd /var/app/oracle/
unzip p13390677_112040_Linux-x86-64_1of7.zip ./
unzip p13390677_112040_Linux-x86-64_2of7.zip ./

解压后得到database目录,其中response目录里面有三个rsp文件,用来作为静默安装时应答文件的模板。分别为:

cd /var/app/oracle/database/response
ls -l
    -rwxrwxr-x 1 oracle oinstall 44637 Oct 31 02:18 dbca.rsp      //安装应答
    -rwxrwxr-x 1 oracle oinstall 25333 Oct 31 01:42 db_install.rsp      //创建数据库应答
    -rwxrwxr-x 1 oracle oinstall  5871 Aug 27  2013 netca.rsp		//建立监听,本地服务名等网络设置

3.2、修改配置文件

cp /var/app/oracle/database/response/ /home/oracle/		//备份
cat db_install.rsp | grep -v '^#' | grep -v '^$'

输出如下:

oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=oracle
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/var/app/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/var/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/var/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=false
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=
oracle.install.db.racOneServiceName=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=ora11g
oracle.install.db.config.starterdb.SID=ora11g
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=1500
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=oracle
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=abc@oracle.com
MYORACLESUPPORT_PASSWORD=password
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
COLLECTOR_SUPPORTHUB_URL=
oracle.installer.autoupdates.option=
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=

3.3、静默安装

cd /var/app/oracle/database
./runInstaller -silent -responseFile /var/app/oracle/database/response/db_install.rsp

3.4、出现如下输出即为成功:

Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB.   Actual 30447 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 8063 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2020-10-31_01-46-54AM. Please wait ...
[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: /var/app/oracle/oraInventory/logs/installActions2020-10-31_01-46-54AM.log
The installation of Oracle Database 11g was successful.
Please check '/var/app/oracle/oraInventory/logs/silentInstall2020-10-31_01-46-54AM.log' for more details.

As a root user, execute the following script(s):
        1. /var/app/oracle/oraInventory/orainstRoot.sh
        2. /var/app/oracle/product/11.2.0/dbhome_1/root.sh

3.5、按照提示操作

打开新的客户端使用root身份执行以下脚本

打开新的ssh窗口
sh /var/app/oracle/oraInventory/orainstRoot.sh
sh /var/app/oracle/product/11.2.0/dbhome_1/root.sh

3.6、执行完上面的脚本后回到安装界面按下Enter继续

3.7、配置Oracle监听

cd /var/app/oracle/database/response
netca /silent /responsefile /var/app/oracle/database/response/netca.rsp

运行成功之后,在/var/app/oracle/product/11.2.0/dbhome_1/network/admin目录下会生成sqlnet.ora和listener.ora两个文件。

ls /var/app/oracle/product/11.2.0/dbhome_1/network/admin
	listener.ora  samples  shrept.lst  sqlnet.ora  tnsnames.ora
netstat -tlnp | grep 1521
    tcp    0	0	0.0.0.0:1521	0.0.0.0:*	LISTEN	2101099/tnslsnr

如果监听没有启动,则手动启动监听器。

cd /var/app/oracle/database/response
lsnrctl start

3.8、配置Oracle数据库

cd /var/app/oracle/database/response
vim dbca.rsp
GDBNAME = "orcl11g.us.oracle.com"     //78 行 全局数据库的名字=SID+主机域名
SID = "ora11g"    //170行 SID
SYSPASSWORD = "oracle"    //211行
SYSTEMPASSWORD = "oracle"   //221行
CHARACTERSET="AL32UTF8" //418行 编码
NATIONALCHARACTERSET="UTF8" //429行 编码

3.9、创建oracle数据库

$ORACLE_HOME/bin/dbca -silent -responseFile /var/app/oracle/database/response/dbca.rsp

4、启动数据库

sqlplus / as sysdba		//oracle用户执行
SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/var/app/oracle/product/11.2.0/dbhome_1/dbs/initora11g.ora'
启动时会出现以上错误,解决方法如下:找到init.ora.78201817526文件,将其复制到/var/app/oracle/product/11.2.0/dbhome_1/dbs目录下
[oracle@Oracle admin]$ locate init.ora           //定位寻找目标文件
/var/app/admin/orcl11g/pfile/init.ora.78201817526               //目标文件
/var/app/oracle/product/11.2.0/dbhome_1/dbs/init.ora
/var/app/oracle/product/11.2.0/dbhome_1/srvm/admin/init.ora
[oracle@Oracle admin]$ cd /var/app/admin/orcl11g/pfile/
[oracle@Oracle pfile]$ ls
init.ora.78201817526
[oracle@Oracle pfile]$ cp init.ora.78201817526  /var/app/oracle/product/11.2.0/dbhome_1/dbs/
[oracle@Oracle dbs]$ mv init.ora.78201817526 initora11g.ora    //将目标文件改成所需文件名

5、oracle安装问题汇总

为方便区别用户,用#代表root用户、$代表oracle用户。

5.1、[INS-13013]

[FATAL] [INS-13013] Target environment do not meet some mandatory requirements.
   CAUSE: Some of the mandatory prerequisites are not met. See logs for details. /tmp/OraInstall2018-11-07_10-29-35PM/installActions2018-11-07_10-29-35PM.log
   ACTION: Identify the list of failed prerequisite checks from the log: /tmp/OraInstall2018-11-07_10-29-35PM/installActions2018-11-07_10-29-35PM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.
解决:增加忽略
加上-ignorePrereq命令,就可以了。
$ ./runInstaller -silent -force -noconfig -ignorePrereq -responseFile /var/app/oracle/oracle/database/response/db_install.rsp

5.2、[INS-32038]

[FATAL] [INS-32038] The operating system group specified for central inventory (oraInventory) ownership is invalid.
   CAUSE: User performing installation is not a member of the operating system group specified for central inventory(oraInventory) ownership.
   ACTION: Specify an operating system group that the installing user is a member of. All the members of this operating system group will have write permission to the central inventory directory (oraInventory).
解决:三种情况,自行查看
对oraInventory目录没有写权限
原因:
1、oraInventory目录权限设置不对
$ chown -R oracle:oinstall /var/app/oracle/oraInventory
2、Oracle所属组不对
系统安装时主动添加的Oracle用户,则会导致这个情况
$ id oracle
错误:
uid=504(oracle) gid=500(oracle) groups=500(oracle),501(wheel)
正常输出:
uid=504(oracle) gid=500(oinstall) groups=500(oinstall),501(dba)
# userdel oracle
# useradd –g oinstall -G dba -d /home/oracle oracle
# chown -R oracle:oinstall /u01/app/oracle
# chown -R oracle:oinstall /u01/app/oraInventory
思路就是:删除现在这个Oracle用户,重新创建一个新的Oracle用户,并且将需要的目录重新授予新Oracle用户
3、缺少/etc/oraInst.loc文件(这个问题我没遇到过暂时)
# vim /etc/oraInst.loc
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/var/app/oracle/oraInventory

5.3、[PRVF-0002]

[FATAL] [PRVF-0002] : Could not retrieve local nodename
A log of this session is currently saved as: /tmp/OraInstall2017-09-29_11-43-52AM/installActions2017-09-29_11-43-52AM.log. Oracle recommends that if you want to keep this log, you should move it from the temporary location to a more permanent location.
解决:绑定主机名和主机IP
# hostname
oracle
# ifconfig | grep inet		//查看主机IP
        inet 66.1.30.32  netmask 255.255.255.0  broadcast 66.1.30.255
        inet 127.0.0.1  netmask 255.0.0.0
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
# vim /etc/hosts		//添加
	66.1.30.32   Oracle		//新增行:IP 机器名(这是我的ip和主机名

5.4、重新安装Oracle时,没有orainstRoot.sh文件

$ ./runInstaller -silent -force -noconfig -responseFile /var/app/oracle/database/response/db_install_dtstack.rsp
Starting Oracle Universal Installer...
·
·
·
As a root user, execute the following script(s):

  \1. /var/app/oracle/product/11.2.4/db_1/root.sh
Successfully Setup Software.
重新安装 [Oracle](http://lib.csdn.net/base/oracle) 时,没有orainstRoot.sh文件。
重新安装RAC时,到excute configuration scripts时,只提示运行:root.sh这个文件,不提示orainstRoot.sh;这个文件,是为什么?
解决:删除/etc/oraInst.loc文件
原因:没删除/etc/oraInst.loc文件
[oracle@iz2zec57gfl6i9vbtdksl1z database]$ ./runInstaller -silent -force -noconfig -responseFile /var/app/oracle/database/response/db_install_dtstack.rsp
Starting Oracle Universal Installer...
·
·
·
As a root user, execute the following script(s):
  \1. /home/u01/app/oraInventory/orainstRoot.sh
  \2. /home/u01/app/oracle/product/11.2.4/db_1/root.sh
Successfully Setup Software.

5.5、启动Oracle出现:MEMORY_TARGET not supported

# su - oracle
# sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Sep 13 19:33:17 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORA-00845: MEMORY_TARGET not supported on this system
解决:增加挂载盘大小
# df -h | grep shm
	tmpfs      497M 205M 292M 42% /dev/shm
# cat /etc/fstab | grep tmpfs
# mount -o remount,size=4G /dev/shm
# df -h | grep shm
	tmpfs      4.0G 205M 3.9G  5% /dev/shm
删除其他用户登录oracle进程

5.6、启动Oracle出现:cannot mount

# su - oracle
# sqlplus / as sysdba
SQL> startup
ORACLE instance started.
Total System Global Area 413372416 bytes
Fixed Size      2253784 bytes
Variable Size     327158824 bytes
Database Buffers    79691776 bytes
Redo Buffers      4268032 bytes
ORA-01102: cannot mount database in EXCLUSIVE mode
解决:
# su - oracle
$ cd /var/app/oracle/database
$ ipcs -s
------ Semaphore Arrays --------
key    semid   owner   perms   nsems
0xbcf2a624 491520   oracle   640    154
0x50f506b0 884737   oracle   640    154
$ ipcrm -s 491520
$ ipcrm -s 884737
$ ipcs -s
------ Semaphore Arrays --------
key    semid   owner   perms   nsems
$ ipcs -s

5.7、内存问题

$ sqlplus monitor/monitor123
SQL*Plus: Release 11.2.0.4.0 Production on Thu Aug 31 18:51:59 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
ERROR:
ORA-01034: ORACLE not available
ORA-27102: out of memory
Linux-x86_64 Error: 12: Cannot allocate memory
Additional information: 26
Additional information: 229378
Additional information: 1619001344
Process ID: 0
Session ID: 0 Serial number: 0
Enter user-name:
解决:清理内存并重启数据库
1、首先检查linux服务器的当前内存使用情况:
# free -m
发现已经没有空闲内存
2、查看内核允许的最大共享内存段大小
# /proc/sys/kernel/shmmax
发现设置的足够大
3、使用top 查看当前消耗内存大的进程
发现oracle有好几个进程消耗了大量的资源
4、kill掉这几个进程
# kill -s 9  11111(进程号)
5、清理内存
# echo 1 > /proc/sys/vm/drop_caches
6、重启数据库
$ sqlplus / as sysdba
SQL> shutdown immediate
SQL> startup

5.8、锁账号(原因是密码错误次数过多)

$ sqlplus monitor/monitor123
SQL*Plus: Release 11.2.0.4.0 Production on Thu Aug 31 18:57:23 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
ERROR:
ORA-28000: the account is locked
解决:
# su - oracle
# sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Aug 31 18:50:39 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
SQL> alter user monitor account unlock;
User altered.

5.9、ORA-01045没有创建会话的权限

$ sqlplus monitor/monitor123
ERROR:
ORA-01045: user CUSTOMERCHAT lacks CREATE SESSION privilege; logon denied
解决:重新赋创建会话的权限
# su - oracle
# sqlplus / as sysdba
SQL> grant create session to monitor;

6、oracle使用

6.1、创建实例

# su - oracle
$ sqlplus / as sysdba
6.1.1、创建表空间
SQL> select name from v$datafile;		//查询用户表空间文件的路径
NAME
--------------------------------------------------------------------------------
/var/app/oradata/orcl11g/system01.dbf
/var/app/oradata/orcl11g/sysaux01.dbf
/var/app/oradata/orcl11g/undotbs01.dbf
/var/app/oradata/orcl11g/users01.dbf
SQL> CREATE TABLESPACE test datafile '/var/app/oradata/orcl11g/htest.dbf' size 600M autoextend on next 50m maxsize unlimited;		//创建用户表空间
Tablespace created.
SQL> CREATE USER htest IDENTIFIED BY htest DEFAULT TABLESPACE test;		//创建用户,指定密码和上边创建的用户表空间
User created.
SQL> grant connect,resource,dba to htest;		//赋予权限
Grant succeeded.
常用oracle命令
select username from dba_users;		//查询已创建的用户
alter user customerchat identified by 123456;		//修改用户密码
alter user customerchat account unlock;		//解锁用户
drop user 用户名 cascade;		//删除用户
drop tablespace tablespace_name;		//删除空的表空间,但是不包含物理文件
drop tablespace tablespace_name including contents;		//删除非空表空间,但是不包含物理文件
drop tablespace tablespace_name including datafiles;		//删除空表空间,包含物理文件
drop tablespace tablespace_name including contents and datafiles;		//删除非空表空间,包含物理文件
drop tablespace tablespace_name including contents and datafiles CASCADE CONSTRAINTS;		//如果其他表空间中的表有外键等约束关联到了本表空间中的表的字段,就要加上CASCADE CONSTRAINTS
6.1.2、建表
sqlplus htest/htest		//用创建的用户名、密码(usernmae/password)登陆
SELECT * FROM ALL_TABLES WHERE OWNER= 'HTEST';		//查询用户下所有表
CREATE TABLE TEST1031
(
  ID                VARCHAR(20) 		NOT NULL,                             
  NAME              VARCHAR(20) 	NOT NULL,                              
  CREATE_TIME       DATE      NOT NULL,
  UPDATE_TIME 	    DATE 		NOT NULL,                        
CONSTRAINT TEST1031 PRIMARY KEY(ID) USING INDEX TABLESPACE TEST
) TABLESPACE TEST;
INSERT  INTO  TEST1031  VALUES  ( '1','123',to_date ( '2020-11-01' , 'YYYY-MM-DD'), to_date ( '2020-11-02' , 'YYYY-MM-DD') ) ;
commit

select * from all_tab_comments;		//查询所有用户的表,视图等
select * from user_tab_comments;		//查询本用户的表,视图等
select * from all_col_comments;		//查询所有用户的表的列名和注释.
select * from user_col_comments;		//查询本用户的表的列名和注释
select * from all_tab_columns;		//查询所有用户的表的列名等信息(详细但是没有备注).
select * from user_tab_columns;		//查询本用户的表的列名等信息(详细但是没有备注).

登录新建的customerchat用户导入sql文件

sqlplus customerchat/customerchat		//--sqlplus登录

导入sql文件:@路径名/文件名

报如下错误:

ORA-01031: insufficient privileges

这是因为没有建表的权限

登录dba用户导入

sqlplus / as sysdba

导入sql文件报如下错误:

ORA-01950: no privileges on tablespace 'CUSTOMERCHAT'

这是由于创建表空间时设置了有限的大小,两种方法:

方法1: 授予用户对该表空间的UNLIMITED配额

ALTER USER CUSTOMERCHAT  QUOTA UNLIMITED ON customerchat;

方法2: 重新授权resource角色给用户之后,便可以创建表

GRANT RESOURCE TO CUSTOMERCHAT;

标签:app,db,0.4,11.2,Oracle,var,install,oracle
来源: https://www.cnblogs.com/luoyehanya/p/14013361.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有