CentOS7.2静默安装Oracle11G

一、CentOS7.2静默安装Oracle11G

1.#查看系统性能参数

cat /etc/sysctl.conf 

2.#查看安装包

rpm -qa |grep -E 'EMC|Ultra|multipath' 

3.#安装依赖包

yum -y install gcc gcc-c++ make binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static glibc glibc-common glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel numactl-devel sysstat unixODBC unixODBC-devel kernelheaders pdksh pcre-devel readline rlwrap 

4.#创建用户、组

groupadd oinstall && groupadd dba && useradd -g oinstall -G dba oracle
echo "123456" | passwd --stdin oracle && id oracle 

5.#上传软件包

1 http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
2 [linux.x64_11gR2_database_1of2.zip]
3 [linux.x64_11gR2_database_2of2.zip]
4 可以下载到本地通过ftp上传到虚拟机中,也可以使用wget命令,下载到虚拟机中。 

6.#创建安装包文件存放目录

mkdir -p /data/u01/software
mv linux.x64_11gR2_database_* /data/u01/software/ && cd /data/u01/software

7.#解压安装包文件

unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64_11gR2_database_2of2.zip  

8.#创建目录

mkdir -p /data/u01/app/oracle/product/11.2.0/dbhome_1
mkdir /data/u01/app/oracle/{oradata,inventory,fast_recovery_area}
chown -R oracle:oinstall /data/u01/app/oracle
chmod -R 775 /data/u01/app/oracle  

9.#修改内核参数

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

#使内核新配置生效
sysctl -p  

10.#修改用户限制

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  

11.#修改/etc/pam.d/login 文件

vim /etc/pam.d/login

#添加以下内容
session required /lib64/security/pam_limits.so
session required pam_limits.so  

12.#修改/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  

13.#设置 oracle 用户环境变量

su - oracle
vim .bash_profile

#添加以下内容
export ORACLE_BASE=/data/u01/app/oracle
export ORACLE_HOME=/data/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export ORACLE_UNQNAME=$ORACLE_SID
export PATH=$ORACLE_HOME/bin:$PATH
export NLS_LANG=american_america.AL32UTF8
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'

#生效
source .bash_profile  

14.#编辑静默安装响应文件

cp -R /data/u01/software/database/response/ . && cd response/
vim db_install.rsp

#设置以下内容
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=自己的主机名
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data/u01/app/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/data/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/data/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
DECLINE_SECURITY_UPDATES=true 

15.#安装

cd /data/u01/software/database/
./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq
等待几分钟  

16.#以 root 身份执行脚本

su - root
source .bash_profile 
sh /data/u01/app/oracle/inventory/orainstRoot.sh
sh /data/u01/app/oracle/product/11.2.0/dbhome_1/root.sh
vim /etc/hosts
127.0.0.1 后面加上主机名  

17.#查看监听响应文件配置信息

egrep -v "(^#|^$)" /home/oracle/response/netca.rsp

#以静默方式配置监听
su - oracle
source .bash_profile 
netca /silent /responsefile /home/oracle/response/netca.rsp  

18.#用Oracle用户启动

su - oracle
lsnrctl start
netstat -tunlp|grep 1521

#查看监听状态
lsnrctl status

#查看监听器配置文件 listener.ora
cat $ORACLE_HOME/network/admin/listener.ora

#查看监听服务名配置文件 tnsnames.ora
cat $ORACLE_HOME/network/admin/tnsnames.ora  

19.#配置文件

vim /home/oracle/response/dbca.rsp

设置以下参数
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "SYS 用户密码"
SYSTEMPASSWORD = "SYSTEM 用户密码"
SYSMANPASSWORD = "sysman"
DBSNMPPASSWORD = "dbsnmp"
DATAFILEDESTINATION =/data/u01/app/oracle/oradata
RECOVERYAREADESTINATION=/data/u01/app/oracle/fast_recovery_area
CHARACTERSET = "AL32UTF8"
TOTALMEMORY = "6144"  

20.#查看建库响应文件配置信息

[root@oracle ~]# egrep -v "(^#|^$)" /home/oracle/response/dbca.rsp 

21.#启用配置建立新库和实例

dbca -silent -responseFile /home/oracle/response/dbca.rsp  

22.#检查实例后台进程

ps -ef | grep ora_ | grep -v grep

#查看 ORACLE_UNQNAME 环境变量
env|grep ORACLE_UNQNAME  

23.#以 sysdba 身份登录

sqlplus / as sysdba  

24.#启动 oralce 数据库

SQL> startup
ORA-00845: MEMORY_TARGET not supported on this system

 

二、报错解决

SQL> startup
ORA-00845: MEMORY_TARGET not supported on this system
因为内存太小可以加大虚拟机的内存
或者临时解决如下:
解决方法

su - root
mount -o remount,size=4G /dev/shm
su - oracle
lsnrctl stop
lsnrctl start
sqlplus / as sysdba
SQL> startup

  

#ORA-28000: the account is locked
解决方法

[oracle@oracal ~]$ sqlplus /nolog
SQL>conn /as sysdba
SQL> alter profile default limit failed_login_attempts unlimited;
sqlplus /nolog
sqlplus /nolog

 

#ORA-01017: invalid username/password; logon denied
解决方法
密码不合适
用sys用户登录修改密码

[oracle@oracal ~]$ sqlplus / as sysdba
SQL> conn / as sysdba;
SQL> alter user scott identified by 123456;
SQL> alter user scott account unlock;
SQL> conn scott/123456;

 

#[ConfigureListener.isPortFree:1088] Returning is Port 1521 free: false

/etc/hosts里面127.0.0.0后面没有添加主机名
posted @ 2018-05-08 15:31  HaydenGuo  阅读(7890)  评论(1编辑  收藏  举报