linux下安装oracle

2018-10-22  本文已影响0人  明明就_c565

资源

下载自己操作系统对应的软件包:官网下载地址

配置内核参数

编辑  /etc/sysctl.conf 添加如下内容

fs.file-max = 6815744

kernel.sem = 250 32000 100 128

kernel.shmmni = 4096

kernel.shmall = 1073741824

kernel.shmmax = 4398046511104

kernel.panic_on_oops = 1

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

net.ipv4.conf.all.rp_filter = 2

net.ipv4.conf.default.rp_filter = 2

fs.aio-max-nr = 1048576

net.ipv4.ip_local_port_range = 9000 65500

更改当前内核参数

[root@localhost heweiwei]# sysctl -p

net.ipv4.ip_forward = 1

net.ipv4.conf.default.rp_filter = 1

net.ipv4.conf.default.accept_source_route = 0

kernel.sysrq = 0

kernel.core_uses_pid = 1

net.ipv4.tcp_syncookies = 1

error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key

error: "net.bridge.bridge-nf-call-iptables" is an unknown key

error: "net.bridge.bridge-nf-call-arptables" is an unknown key

kernel.msgmnb = 65536

kernel.msgmax = 65536

kernel.shmmax = 68719476736

kernel.shmall = 4294967296

fs.file-max = 6815744

kernel.sem = 250 32000 100 128

kernel.shmmni = 4096

kernel.shmall = 1073741824

kernel.shmmax = 4398046511104

kernel.panic_on_oops = 1

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

net.ipv4.conf.all.rp_filter = 2

net.ipv4.conf.default.rp_filter = 2

fs.aio-max-nr = 1048576

net.ipv4.ip_local_port_range = 9000 65500

限制oracle用户资源使用

编辑 /etc/security/limits.conf 添加如下内容

oracle  soft  nofile    1024

oracle  hard  nofile    65536

oracle  soft  nproc    16384

oracle  hard  nproc    16384

oracle  soft  stack    10240

oracle  hard  stack    32768

oracle  hard  memlock    134217728

oracle  soft  memlock    134217728

安装所有依赖

可以写个安装脚本

#!/bin/bash

yum install binutils -y

yum install compat-libcap1 -y

yum install compat-libstdc++-33 -y

yum install compat-libstdc++-33.i686 -y

yum install glibc -y

yum install glibc.i686 -y

yum install glibc-devel -y

yum install glibc-devel.i686 -y

yum install ksh -y

yum install libaio -y

yum install libaio.i686 -y

yum install libaio-devel -y

yum install libaio-devel.i686 -y

yum install libX11 -y

yum install libX11.i686 -y

yum install libXau -y

yum install libXau.i686 -y

yum install libXi -y

yum install libXi.i686 -y

yum install libXtst -y

yum install libXtst.i686 -y

yum install libgcc -y

yum install libgcc.i686 -y

yum install libstdc++ -y

yum install libstdc++.i686 -y

yum install libstdc++-devel -y

yum install libstdc++-devel.i686 -y

yum install libxcb -y

yum install libxcb.i686 -y

yum install make -y

yum install nfs-utils -y

yum install net-tools -y

yum install smartmontools -y

yum install sysstat -y

yum install unixODBC -y

yum install unixODBC-devel -y

创建oracle用户组

[root@localhost heweiwei]# groupadd -g 54321 oinstall

[root@localhost heweiwei]# groupadd -g 54322 dba

[root@localhost heweiwei]# groupadd -g 54323 oper

[root@localhost heweiwei]# useradd -u 54321 -g oinstall -G dba,oper oracle

修改设置SELINUX

将/etc/selinux/config 中 `SELINUX` 修改为permissive

[root@localhost oracle]# vim /etc/selinux/config

[root@localhost oracle]# setenforce Permissive

setenforce: SELinux is disabled

关闭防火墙

[root@localhost oracle]# service iptables stop

创建Oracle安装目录

[root@localhost oracle]# mkdir -p /usr/local/products/oracle12c

[root@localhost oracle]# chown -R oracle:oinstall /usr/local/products/

[root@localhost oracle]# chmod -R 775 /usr/local/products/

配置Oracle环境变量并验证

oracle用户名下,配置oracle用户下环境变量

[oracle@localhost ~]$ vim .bash_profile

export TMP=/tmp

export TMPDIR=$TMP

export ORACLE_HOSTNAME=localhost  // 注意要换成 /etc/hosts 中的用户

export ORACLE_UNQNAME=cdb1

export ORACLE_BASE=/usr/local/products

export ORACLE_HOME=$ORACLE_BASE/oracle12c

export ORACLE_SID=cdb1

export PATH=/usr/sbin:/usr/local/bin:$PATH

export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib

export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

[oracle@localhost ~]$ source .bash_profile

[oracle@localhost ~]$ echo $ORACLE_HOME

/usr/local/products/oracle12c

安装

我的目录/home下空间不够 所以我创建了/oracle目录(实际应该为/home/oracle目录),将官网下载的文件包解压

unzip linuxx64_12201_database.zip 我这里采用静态安装

./runInstaller -ignoreSysPrereqs -ignorePrereq -waitforcompletion \

-showProgress -silent -responseFile/oracle/database/response/db_install.rsp\

oracle.install.option=INSTALL_DB_SWONLY \

UNIX_GROUP_NAME=oinstall \

INVENTORY_LOCATION=/usr/local/products/oracle12c/oraInventory \

ORACLE_HOME=/usr/local/products/oracle12c \

ORACLE_BASE=/usr/local/products \

oracle.install.db.InstallEdition=EE \

oracle.install.db.OSDBA_GROUP=dba \

oracle.install.db.OSBACKUPDBA_GROUP=dba \

oracle.install.db.OSDGDBA_GROUP=dba \

oracle.install.db.OSKMDBA_GROUP=dba \

oracle.install.db.OSRACDBA_GROUP=dba

[oracle@localhost database]$ ./runInstaller -ignoreSysPrereqs -ignorePrereq -waitforcompletion -showProgress -silent -responseFile /oracle/database/response/db_install.rsp oracle.install.option=INSTALL_DB_SWONLY UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/usr/local/products/oracle12c/oraInventory ORACLE_HOME=/usr/local/products/oracle12c ORACLE_BASE=/usr/local/products oracle.install.db.InstallEdition=EE oracle.install.db.OSDBA_GROUP=dba oracle.install.db.OSBACKUPDBA_GROUP=dba oracle.install.db.OSDGDBA_GROUP=dba oracle.install.db.OSKMDBA_GROUP=dba oracle.install.db.OSRACDBA_GROUP=dba

Starting Oracle Universal Installer...

Checking Temp space: must be greater than 500 MB.  Actual 36281 MB    Passed

Checking swap space: must be greater than 150 MB.  Actual 7107 MB    Passed

Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-10-22_10-58-44AM. Please wait ...[WARNING] [INS-32016] The selected Oracle home contains directories or files.

  ACTION: To start with an empty Oracle home, either remove its contents or choose another location.

[WARNING] [INS-32055] 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:

/usr/local/products/oracle12c/oraInventory/logs/installActions2018-10-22_10-58-44AM.log

Prepare in progress.

..................................................  8% Done.

Prepare successful.

Copy files in progress.

..................................................  17% Done.

..................................................  22% Done.

..................................................  27% Done.

..................................................  32% Done.

..................................................  40% Done.

..................................................  45% Done.

..................................................  50% Done.

..................................................  55% Done.

..................................................  60% Done.

..................................................  65% Done.

..................................................  70% Done.

..................................................  75% Done.

..................................................  80% Done.

....................

Copy files successful.

Link binaries in progress.

..........

Link binaries successful.

Setup files in progress.

..............................

Setup files successful.

Setup Inventory in progress.

Setup Inventory successful.

Finish Setup successful.

The installation of Oracle Database 12c was successful.

Please check '/usr/local/products/oracle12c/oraInventory/logs/silentInstall2018-10-22_10-58-44AM.log' for more details.

Setup Oracle Base in progress.

Setup Oracle Base successful.

..................................................  95% Done.

As a root user, execute the following script(s):

1. /usr/local/products/oracle12c/oraInventory/orainstRoot.sh

2. /usr/local/products/oracle12c/root.sh

..................................................  100% Done.

Successfully Setup Software.

根据提示运行脚本

[root@localhost database]# /usr/local/products/oracle12c/oraInventory/orainstRoot.sh

Changing permissions of /usr/local/products/oracle12c/oraInventory.

Adding read,write permissions for group.

Removing read,write,execute permissions for world.

Changing groupname of /usr/local/products/oracle12c/oraInventory to oinstall.

The execution of the script is complete.

[root@localhost database]# /usr/local/products/oracle12c/root.sh

Check /usr/local/products/oracle12c/install/root_localhost.localdomain_2018-10-22_11-05-52-854397878.log for the output of root script

[root@localhost database]#

[root@localhost oracle]# su oracle

[oracle@localhost ~]$

安装成功

测试如下:

[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Mon Oct 22 11:11:14 2018

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

Connected to an idle instance.

SQL>

数据库创建

执行下列命令:OraPasswd1 是自己的密码,包含大小写及数字

dbca -silent -createDatabase \

-templateName /usr/local/products/oracle12c/assistants/dbca/templates/General_Purpose.dbc \

-gdbname cdb1 -sid cdb1 -responseFile /home/oracle/database/response/dbca.rsp \

-characterSet AL32UTF8 \

-sysPassword OraPasswd1 \

-systemPassword OraPasswd1 \

-createAsContainerDatabase true \

-numberOfPDBs 1 \

-pdbName pdb1 \

-pdbAdminPassword OraPasswd1 \

-automaticMemoryManagement false \

-ignorePreReqs

[oracle@localhost ~]$ dbca -silent -createDatabase -templateName /usr/local/products/oracle12c/assistants/dbca/templates/General_Purpose.dbc -gdbname cdb1 -sid cdb1 -responseFile /oracle/database/response/dbca.rsp -characterSet AL32UTF8 -sysPassword OraPasswd1 -systemPassword OraPasswd1 -createAsContainerDatabase true -numberOfPDBs 1 -pdbName pdb1 -pdbAdminPassword OraPasswd1 -automaticMemoryManagement false -ignorePreReqs

Copying database files

1% complete

13% complete

25% complete

Creating and starting Oracle instance

26% complete

30% complete

31% complete

35% complete

38% complete

39% complete

41% complete

Completing Database Creation

42% complete

43% complete

44% complete

46% complete

49% complete

50% complete

Creating Pluggable Databases

55% complete

75% complete

Executing Post Configuration Actions

100% complete

Look at the log file "/usr/local/products/cfgtoollogs/dbca/cdb1/cdb1.log" for further details.

[oracle@localhost ~]$

dbca -silent -createDatabase \

-templateName /usr/local/products/oracle12c/assistants/dbca/templates/General_Purpose.dbc \

-gdbname cdb1 -sid cdb1 -responseFile /home/oracle/database/response/dbca.rsp \

-characterSet AL32UTF8 \

-sysPassword OraPasswd1 \

-systemPassword OraPasswd1 \

-createAsContainerDatabase true \

-numberOfPDBs 1 \

-pdbName pdb1 \

-pdbAdminPassword OraPasswd1 \

-automaticMemoryManagement false \

-ignorePreReqs

数据库监听配置

使用默认的netca.rsp文件  执行netca -silent -responseFile /home/oracle/database/response/netca.rsp

netca -silent -responseFile /oracle/database/response/netca.rsp  // 因为/home空间不足 所以安装时创建了/oracle 来安装

启动

[oracle@localhost ~]$ lsnrctl start

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 22-OCT-2018 17:16:26

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

Starting /usr/local/products/oracle12c/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.2.0.1.0 - Production

System parameter file is /usr/local/products/oracle12c/network/admin/listener.ora

Log messages written to /usr/local/products/diag/tnslsnr/localhost/listener/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1539)))

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1539)))

STATUS of the LISTENER

------------------------

Alias                    LISTENER

Version                  TNSLSNR for Linux: Version 12.2.0.1.0 - Production

Start Date                22-OCT-2018 17:16:26

Uptime                    0 days 0 hr. 0 min. 0 sec

Trace Level              off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File  /usr/local/products/oracle12c/network/admin/listener.ora

Listener Log File        /usr/local/products/diag/tnslsnr/localhost/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1539)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

The listener supports no services

The command completed successfully

查看状态

[oracle@localhost ~]$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 22-OCT-2018 17:18:59

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1539)))

STATUS of the LISTENER

------------------------

Alias                    LISTENER

Version                  TNSLSNR for Linux: Version 12.2.0.1.0 - Production

Start Date                22-OCT-2018 17:16:26

Uptime                    0 days 0 hr. 2 min. 33 sec

Trace Level              off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File  /usr/local/products/oracle12c/network/admin/listener.ora

Listener Log File        /usr/local/products/diag/tnslsnr/localhost/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1539)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

The listener supports no services

The command completed successfully

参考

Linux命令行安装Oracle12c

上一篇下一篇

猜你喜欢

热点阅读