linux下oracle11g安装

1、安装包准备

linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip

2、服务器基本参数修改

    1、设置系统:Oracle只支持操作系统Red Hat Enterprise Linux 6,故需将/etc/redhat-release中的内容改成Red Hat

[root~]# vim  /etc/redhat-release 
#CentOS Linux release 7.5.1804 (Core)
Red Hat Enterprise Linux 6

    2、关闭selinux,防火墙的不必要的服务

修改vim /etc/selinux/config
SELINUX=disabled
systemctl status firewalld
systemctl stop firewalld
设置hosts

vim /etc/hosts
192.168.10.119  Oracle

    3、修改用户的限制文件

在 /etc/security/limits.conf 该文件内添加以下内容

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

    4、修改内核参数

在/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        // 执行这条语句使配置生效

    5、安装依赖包

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

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

    1、建立用户、组

groupadd oinstall
groupadd dba
groupadd oper
useradd -g oinstall -G dba,oper oracle
echo "oracle" | passwd --stdin oracle
id oracle  //查看用户所属组

    2、创建安装目录及修改权限

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

    3、设置环境变量

在/home/oracle/.bash_profile 文件中添加以下内容

umask 022
export ORACLE_BASE=/home/var/app
export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=ora11g
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib

source /home/oracle/.bash_profile  //执行该句使配置生效

4、安装Oracle

    1、拷贝Oracle安装文件到指定目录

cp /tmp/oracle11/linux.x64_11gR2_database_* /home/var/app/oracle/

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

su - oracle

cd /home/var/app/oracle/

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

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

cd database/response/

-rw-rw-r--. 1 oracle oinstall 44969 Feb 14  2009 dbca.rsp           //安装应答
-rw-rw-r--. 1 oracle oinstall 22557 Aug 15  2009 db_install.rsp     //创建数据库应答
-rwxrwxr-x. 1 oracle oinstall  5740 Feb 26  2009 netca.rsp          //建立监听,本地服务名等网络设置

    3、修改配置文件,安装Oracle数据库

    先备份

cp -r /home/var/app/oracle/database/response/ /home/oracle/

    修改后的静默安装配置文件db_install.rsp内容如下:

[oracle@hz response]$ 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 # 主机名称(hostname查询)
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/home/var/app/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/home/var/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/home/var/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=false
oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0
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=ora11g
oracle.install.db.config.starterdb.SID=gslbtest
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.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.dbcontrol.emailAddress=
oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
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=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=

    4、开始静默安装

cd /home/var/app/oracle/database/

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

    查看安装进度

cd /home/var/app/oracle/oraInventory/logs/

tail -f installActions*log

    当出现以下信息时

The following configuration scripts need to be executed as the "root" user. 
 #!/bin/sh 
 #Root scripts to run

/home/var/app/oracle/oraInventory/orainstRoot.sh
/home/var/app/oracle/product/11.2.0/dbhome_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 

Successfully Setup Software.

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

/home/var/app/oracle/oraInventory/orainstRoot.sh
/home/var/app/oracle/product/11.2.0/dbhome_1/root.sh



[root@oracle ~]# /home/var/app/oracle/oraInventory/orainstRoot.sh
Changing permissions of /home/var/app/oracle/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /home/var/app/oracle/oraInventory to oinstall.
The execution of the script is complete.
[root@oracle ~]# /home/var/app/oracle/product/11.2.0/dbhome_1/root.sh
Check /home/var/app/oracle/product/11.2.0/dbhome_1/install/root_oracle_2020-03-10_11-27-51.log for the output of root script

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

5、配置Oracle监听

    1、运行监听文件

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





执行过程
[oracle@hz-ott-gsdservice-02 response]$ netca /silent /responsefile /home/var/app/oracle/database/response/netca.rsp

Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /home/var/app/oracle/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
    Running Listener Control: 
      /home/var/app/oracle/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

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

[oracle@ response]$ cd /home/var/app/oracle/product/11.2.0/dbhome_1/network/admin
[oracle@hz-ott-gsdservice-02 admin]$ ls
listener.ora  samples  shrept.lst  sqlnet.ora

    执行以下命令查看监听器是否已经在1521端口上开始工作了

[oracle@ admin]$ netstat -tlnp | grep 1521
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp6       0      0 :::1521                 :::*                    LISTEN      28355/tnslsnr 

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

lsnrctl start

    2、配置Oracle数据库

    

cd /home/var/app/oracle/database/response


/home/var/app/oracle/database/response
[oracle@Oracle response]$ vi dbca.rsp
GDBNAME = "gslbtest"     //78 行 全局数据库的名字=SID+主机域名
SID="gslbtest"    //149行 SID
SYSPASSWORD = "oracle"    //190行
SYSTEMPASSWORD = "oracle"   //200行
CHARACTERSET="AL32UTF8" //415行 编码
NATIONALCHARACTERSET="UTF8" //425行 编码

    3、创建数据库

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





执行过程

[oracle@ response]$ $ORACLE_HOME/bin/dbca -silent -responseFile  /home/var/app/oracle/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 "/home/var/app/cfgtoollogs/dbca/gslbtest/gslbtest.log" for further details.

    至此完成数据库实例的创建。

    查看监听状态:

[oracle@ response]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 10-MAR-2020 11:47:22

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                10-MAR-2020 11:32:00
Uptime                    0 days 0 hr. 15 min. 22 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/var/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /home/var/app/diag/tnslsnr/oracle/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Oracle)(PORT=1521)))
Services Summary...
Service "gslbtest.us.oracle.com" has 1 instance(s).
  Instance "gslbtest", status READY, has 1 handler(s) for this service...
Service "gslbtestXDB.us.oracle.com" has 1 instance(s).
  Instance "gslbtest", status READY, has 1 handler(s) for this service...
The command completed successfully

    4、启动数据库

[oracle@ response]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Tue Mar 10 11:48:45 2020

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

Connected to an idle instance.

SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/home/var/app/oracle/product/11.2.0/dbhome_1/dbs/initora11g.ora'

    启动时会出现以上错误,解决方法如下:找到类似init.ora.78201817526文件,将其复制到/home/var/app/oracle/product/11.2.0/dbhome_1/dbs目录下

   一般在/home/var/app/admin/gslbtest/pfile/  其中gslbtest为SID

cd /home/var/app/admin/gslbtest/pfile/
cp init.ora.2102020114522 /home/var/app/oracle/product/11.2.0/dbhome_1/dbs/
cd /home/var/app/oracle/product/11.2.0/dbhome_1/dbs/
mv init.ora.2102020114522 initora11g.ora

    进入到Oracle SQL命令行中,执行startup

SQL> startup
ORACLE instance started.

Total System Global Area 5.3715E+10 bytes
Fixed Size                  2217992 bytes
Variable Size            2.8454E+10 bytes
Database Buffers         2.5233E+10 bytes
Redo Buffers               25333760 bytes
Database mounted.
Database opened.

 

创建表空间

create tablespace ottgslb   datafile '/home/var/app/oradata/gslbtest/ottgslb.dbf'  size 3G   autoextend on next 1G  maxsize 20G;

创建用户并指定表空间
create user ottgslbtest identified by ottgslbtest default tablespace ottgslb;

授权

grant create session to ottgslbtest;  
grant create table to ottgslbtest;  
grant create tablespace to ottgslbtest;  
grant create view to ottgslbtest; 
grant connect,resource,dba to ottgslbtest;

 

posted @ 2020-03-10 11:36  泉love水  阅读(327)  评论(0编辑  收藏  举报