CentOS安装Oracle

准备资料

CentOS6.7

Oracle 11gR2 11.2.0.4.0

VMware® Workstation 12 Pro

MobaXterm

参考:http://docs.oracle.com/cd/E11882_01/install.112/e24326/

root用户要做的

虚拟机安装与配置略

硬件需求

free查看内存,swap保证1G-2G以上

free
grep MemTotal /proc/meminfo
grep SwapTotal /proc/meminfo

df查询分区,tmp保证1G-2G以上

df -h /dev/shm/
df -h /tmp
df -h

检查系统是多少位, x86_64代表64位

uname -m

设置主机名/etc/sysconfig/network,HOSTNAME=主机名

设置Hosts /etc/hosts,添加IP和主机名

软件需求

检查是否安装rpm -qa | grep 软件包名 yum list | grep 软件包名

安装软件包yum install 软件包名

Linux 6依赖的软件包

binutils-2.20.51.0.2-5.11.el6 (x86_64)
compat-libcap1-1.10-1 (x86_64)
compat-libstdc++-33-3.2.3-69.el6 (x86_64)
compat-libstdc++-33-3.2.3-69.el6.i686
gcc-4.4.4-13.el6 (x86_64)
gcc-c++-4.4.4-13.el6 (x86_64)
glibc-2.12-1.7.el6 (i686)
glibc-2.12-1.7.el6 (x86_64)
glibc-devel-2.12-1.7.el6 (x86_64)
glibc-devel-2.12-1.7.el6.i686
ksh
libgcc-4.4.4-13.el6 (i686)
libgcc-4.4.4-13.el6 (x86_64)
libstdc++-4.4.4-13.el6 (x86_64)
libstdc++-4.4.4-13.el6.i686
libstdc++-devel-4.4.4-13.el6 (x86_64)
libstdc++-devel-4.4.4-13.el6.i686
libaio-0.3.107-10.el6 (x86_64)
libaio-0.3.107-10.el6.i686
libaio-devel-0.3.107-10.el6 (x86_64)
libaio-devel-0.3.107-10.el6.i686
make-3.81-19.el6
sysstat-9.0.4-11.el6 (x86_64)

Linux 7 依赖的软件包

binutils-2.23.52.0.1-12.el7.x86_64 
compat-libcap1-1.10-3.el7.x86_64 
compat-libstdc++-33-3.2.3-71.el7.i686
compat-libstdc++-33-3.2.3-71.el7.x86_64
gcc-4.8.2-3.el7.x86_64 
gcc-c++-4.8.2-3.el7.x86_64 
glibc-2.17-36.el7.i686 
glibc-2.17-36.el7.x86_64 
glibc-devel-2.17-36.el7.i686 
glibc-devel-2.17-36.el7.x86_64 
ksh
libaio-0.3.109-9.el7.i686 
libaio-0.3.109-9.el7.x86_64 
libaio-devel-0.3.109-9.el7.i686 
libaio-devel-0.3.109-9.el7.x86_64 
libgcc-4.8.2-3.el7.i686 
libgcc-4.8.2-3.el7.x86_64 
libstdc++-4.8.2-3.el7.i686 
libstdc++-4.8.2-3.el7.x86_64 
libstdc++-devel-4.8.2-3.el7.i686 
libstdc++-devel-4.8.2-3.el7.x86_64 
libXi-1.7.2-1.el7.i686 
libXi-1.7.2-1.el7.x86_64 
libXtst-1.2.2-1.el7.i686 
libXtst-1.2.2-1.el7.x86_64 
make-3.82-19.el7.x86_64 
sysstat-10.1.5-1.el7.x86_64

ksh下载

http://rpmfind.net/linux/rpm2html/search.php?query=ksh

安装

rpm -ivh ksh-20120801-33.el6.x86_64.rpm

最后依然没有解决的

pdksh-5.2.14

libaio-devel-0.3.105

遗漏的

elfutils-libelf-devel

ODBC驱动

Linux 6

unixODBC-2.2.14-11.el6 (x86_64) or later
unixODBC-2.2.14-11.el6.i686 or later
unixODBC-devel-2.2.14-11.el6 (x86_64) or later
unixODBC-devel-2.2.14-11.el6.i686 or later

Linux 7

xODBC-2.3.1-6.el7.x86_64 or later
unixODBC-2.3.1-6.el7.i686 or later
unixODBC-devel-2.3.1-6.el7.x86_64 or later
unixODBC-devel-2.3.1-6.el7.i686 or later

创建用户和组

groupadd oinstall
groupadd dba
groupadd oper
useradd -g oinstall -G dba,oper oracle 
passwd oracle

验证是否创建成功

# id oracle
uid=502(oracle) gid=501(oinstall) 组=501(oinstall),502(dba)

若oracle用户已经存在,可以使用如下命令设置oracle用户初始群组为 oinstall,有效群组为 dba、oper

usermod -g oinstall -G dba,oper oracle

创建目录并分配权限

mkdir /u01/app/oracle
mkdir /u01/app/oraInventory
chown oracle:oinstall /u01
chown oracle:oinstall /u01/app
chown oracle:oinstall /u01/app/oracle
chown oracle:oinstall /u01/app/oraInventory
chmod 755 /u01/app/oracle
chmod 755 /u01/app/oraInventory

修改内核参数

vim /etc/sysctl.conf

添加

fs.suid_dumpable = 1
fs.aio-max-nr = 1048576
fs.file-max = 6815744
#kernel.shmall = 2097152
#kernel.shmmax = 536870912
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
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=1048586

执行命令时配置生效

/sbin/sysctl -p

修改系统资源限制

vim /etc/security/limits.conf

添加

oracle              soft    nproc   16384
oracle              hard    nproc   16384
oracle              soft    nofile  4096
oracle              hard    nofile  65536
oracle              soft    stack   10240

vim /etc/pam.d/login #R1的要求,R2不要求

添加

session required pam_limits.so

vim /etc/profile #R1的要求,R2不要求

添加

if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi

vim /etc/security/limits.d/90-nproc.conf

* soft nproc 1024修改为* - nproc 16384

关闭SELinux

设置SELinux不开机启动

vim /etc/selinux/config

SELINUX=disabled或者SELINUX=permissive

关闭SELinux

setenforce 0

oracle用户要做的

设置oracle账号登录时环境

vim /home/oracle/.bash_profile

ORACLE_BASE=/u01/app/oracle; #安装目录
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; #oracle家目录
ORACLE_SID=orcl; #实例名
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin;
export ORACLE_BASE ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH PATH;
if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
    ulimit -p 16384
    ulimit -n 65536
  else
    ulimit -u 16384 -n 65536
  fi
fi

$source .bash_profile

source .bash_profile

准备安装包

Installation Type Zip File
Oracle Database (includes Oracle Database and Oracle RAC)Note: you must download both zip files to install Oracle Database. p13390677_112040_platform_1of7.zip p13390677_112040_platform_2of7.zip
Oracle Grid Infrastructure (includes Oracle ASM, Oracle Clusterware, and Oracle Restart) p13390677_112040_platform_3of7.zip
Oracle Database Client p13390677_112040_platform_4of7.zip
Oracle Gateways p13390677_112040_platform_5of7.zip
Oracle Examples p13390677_112040_platform_6of7.zip
Deinstall p13390677_112040_platform_7of7.zip

ftp上传

解压

安装Oracle只需要第一个和第二个文件

cd ~
unzip p13390677_112040_platform_1of7.zip
unzip p13390677_112040_platform_2of7.zip

安装文件所在目录 /home/oracle/database/

保证权限

chmod -R 700 /home/oracle/database/
chmod -R oracle:oinstall /home/oracle/database/

图形安装

export LANG=en_US
/home/oracle/database/runInstaller

静默安装

./runInstaller oracle.install.option=INSTALL_DB_SWONLY \
    ORACLE_BASE=/u01/app/oracle/ \
    ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 \
    UNIX_GROUP_NAME=oinstall  \
    oracle.install.option=INSTALL_DB_AND_CONFIG \
    ORACLE_HOSTNAME=${HOSTNAME} \ #换成主机名
    oracle.install.db.DBA_GROUP=dba \
    oracle.install.db.OPER_GROUP=oinstall \
    oracle.install.db.BACKUPDBA_GROUP=dba  \
    oracle.install.db.DGDBA_GROUP=dba  \
    oracle.install.db.KMDBA_GROUP=dba  \
    FROM_LOCATION=../stage/products.xml \
    INVENTORY_LOCATION=/u01/app/oracle/oraInventory/ \
    SELECTED_LANGUAGES=en,zh_CN \ #界面显示语言
    oracle.install.db.InstallEdition=EE \ #企业版
    oracle.install.db.EEOptionsSelection=false \
    oracle.install.db.isRACOneInstall=false \
    oracle.install.db.config.starterdb.type=GENERAL_PURPOSE \
    oracle.install.db.config.starterdb.globalDBName=orcl \ #数据库名
    oracle.install.db.config.starterdb.SID=orcl \ #实例名
    oracle.install.db.config.starterdb.characterSet=ZHS16GBK \#字符集
    oracle.install.db.config.starterdb.memoryOption=true \ #
    oracle.install.db.config.starterdb.memoryLimit=1530 \ #内存限制
    oracle.install.db.config.starterdb.installExampleSchemas=false \ 
    oracle.install.db.config.starterdb.enableSecuritySettings=true \ 
    oracle.install.db.config.starterdb.control=DB_CONTROL \
    oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE \
    oracle.install.db.config.starterdb.automatedBackup.enable=false \
    oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/u01/app/oracle/oradata \
    oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/u01/app/oracle/recovery_area \
    SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \
    DECLINE_SECURITY_UPDATES=true \
    
    DECLINE_SECURITY_UPDATES=true  -silent -ignoreSysPrereqs -ignorePrereq -waitForCompletion

正在启动 Oracle Universal Installer...

检查临时空间: 必须大于 120 MB。 实际为 42865 MB 通过
检查交换空间: 必须大于 150 MB。 实际为 3967 MB 通过
准备从以下地址启动 Oracle Universal Installer /tmp/OraInstall2017-05-07_03-12-07AM. 请稍候...可以在以下位置找到本次安装会话的日志:
/u01/app/oracle/oraInventory/logs/installActions2017-05-07_03-12-07AM.log

Oracle Database 11g 的 安装 已成功。
请查看 '/u01/app/oracle/oraInventory/logs/silentInstall2017-05-07_03-12-07AM.log' 以获取详细资料。

以 root 用户的身份执行以下脚本:
1. /u01/app/oracle/oraInventory/orainstRoot.sh
2. /u01/app/oracle/product/11.2.0/dbhome_1/root.sh

安装中要执行的脚本

root用户执行

/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0/dbhome_1/root.sh

安装后的配置

备份root.sh脚本

cd ${ORACLE_HOME}
cp -p root.sh root.sh.bak

配置和更新数据库(可选)


/usr/local/bin/oraenv
sqlplus / AS SYSDBA
SQL>@?/rdbms/admin/utlrp.sql

生成客户端静态库

$ORACLE_HOME/bin/genclntst

ar: creating /u01/app/oracle/product/11.2.0/dbhome_1/lib/libclntst11.a
Created /u01/app/oracle/product/11.2.0/dbhome_1/lib/libclntst11.a

开关数据库选项

chopt [ enable | disable] db_option

Value       Description
dm          Oracle Data Mining RDBMS Files
dv          Oracle Database Vault
lbac            Oracle Label Security
olap            Oracle OLAP
partitioning    Oracle Partitioning
rat         Oracle Real Application Testing
ode_net     Oracle Database Extensions for .NET 1.x
ode_net_2   Oracle Database Extensions for .NET 2.0

使配置生效

srvctl stop database -d myDb
chopt enable lbac
srvctl start database -d myDb

dbca建库

netca创建监听

netmgr配置网络服务

修改tnsnames.ora和listener.ora

cd ${ORACLE_HOME}/network/admin/

# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = SID_NAME)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
      (PROGRAM = extproc)
      (ENVS = "EXTPROC_DLLS=ONLY:/u01/app/oracle/product/11.2.0/dbhome_1/lib/libclntst11.a")
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.116.199)(PORT = 1521))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

tnsnames.ora修改SERVICE_NAME为服务名,默认orcl

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

AMLUAT =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.116.199)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = SERVICE_NAME)
    )
  )

ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
    (CONNECT_DATA =
      (SID = CLRExtProc)
      (PRESENTATION = RO)
    )
  )

LISTENER_AMLUAT =
  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

启动监听

lsnrctl start

sqlplus登录

sqlplus /nolog
SQL>CONNECT SYS AS SYSDBA

启动数据库

方式一:SQL>startup
方式二:dbstart

关闭是shutdown

SQL Developer

jdk安装略

cd $ORACLE_HOME/sqldeveloper/
./sqldeveloper.sh

解锁账户

ALTER USER account IDENTIFIED BY password ACCOUNT UNLOCK;

设置Oracle开机启动

vim /etc/oratab

orcl:/u01/app/oracle/product/11.2.0/dbhome_1:N

N改为Y

vim /etc/rc.d/rc.local

su oracle -lc "/u01/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start"
su oracle -lc /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart

如果遇到以下错误:

ORACLE_HOME_LISTENER is not SET, unable to auto-start Oracle Net Listener

换中方式执行第二条命令,相当于加上参数$ORACLE_HOME

su oracle -lc "/u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart /u01/app/oracle/product/11.2.0/dbhome_1"

Oracle卸载

正常卸载

cd ${ORACLE_HOME}/deinstall/
./deinstall

如果是安装失败,需要下载卸载器程序

p13390677_112040_platform_7of7.zip

你可能感兴趣的:(CentOS安装Oracle)