操作系统环境设置
检查系统版本:
cat /etc/redhat-release
结果如下:
CentOS Linux release 7.0.1406 (Core)
查看IP地址
ifconfig ent0
192.168.0.115
配置系统和安装所需软件包
关闭selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
关闭防火墙
systemctl disable iptables
进行一次升级
yum update -y
修改主机名并重启
将主机名修改为mes.dfec.com
vim /etc/hostname
修改hosts,添加一条主机记录
echo "127.0.0.1 mes mes.dfec.com" >> /etc/hosts
ping mes.dfec.com
安装oracle所需的软件包
yum install gcc gcc-c++ glibc glibc-devel glibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel zlib-devel unzip compat-libcap1 compat-libstdc++-33
结果如下:
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* extras: mirrors.cn99.com
* updates: mirrors.cn99.com
软件包 gcc-4.8.5-4.el7.x86_64 已安装并且是最新版本
软件包 glibc-2.17-106.el7_2.8.x86_64 已安装并且是最新版本
软件包 glibc-devel-2.17-106.el7_2.8.x86_64 已安装并且是最新版本
软件包 glibc-headers-2.17-106.el7_2.8.x86_64 已安装并且是最新版本
软件包 libaio-0.3.109-13.el7.x86_64 已安装并且是最新版本
软件包 libgcc-4.8.5-4.el7.x86_64 已安装并且是最新版本
软件包 libstdc++-4.8.5-4.el7.x86_64 已安装并且是最新版本
软件包 1:make-3.82-21.el7.x86_64 已安装并且是最新版本
软件包 sysstat-10.1.5-7.el7.x86_64 已安装并且是最新版本
软件包 unzip-6.0-15.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 compat-libcap1.x86_64.0.1.10-7.el7 将被 安装
---> 软件包 compat-libstdc++-33.x86_64.0.3.2.3-72.el7 将被 安装
---> 软件包 gcc-c++.x86_64.0.4.8.5-4.el7 将被 安装
---> 软件包 ksh.x86_64.0.20120801-22.el7_1.3 将被 安装
---> 软件包 libaio-devel.x86_64.0.0.3.109-13.el7 将被 安装
---> 软件包 libstdc++-devel.x86_64.0.4.8.5-4.el7 将被 安装
---> 软件包 unixODBC.x86_64.0.2.3.1-11.el7 将被 安装
---> 软件包 unixODBC-devel.x86_64.0.2.3.1-11.el7 将被 安装
---> 软件包 zlib-devel.x86_64.0.1.2.7-15.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
==================================================================================
Package 架构 版本 源 大小
==================================================================================
正在安装:
compat-libcap1 x86_64 1.10-7.el7 base 19 k
compat-libstdc++-33 x86_64 3.2.3-72.el7 base 191 k
gcc-c++ x86_64 4.8.5-4.el7 base 7.2 M
ksh x86_64 20120801-22.el7_1.3 updates 881 k
libaio-devel x86_64 0.3.109-13.el7 base 13 k
libstdc++-devel x86_64 4.8.5-4.el7 base 1.5 M
unixODBC x86_64 2.3.1-11.el7 base 413 k
unixODBC-devel x86_64 2.3.1-11.el7 base 55 k
zlib-devel x86_64 1.2.7-15.el7 base 50 k
事务概要
==================================================================================
安装 9 软件包
总下载量:10 M
安装大小:30 M
Is this ok [y/d/N]: y
Downloading packages:
(1/9): compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm | 191 kB 00:00:05
(2/9): gcc-c++-4.8.5-4.el7.x86_64.rpm | 7.2 MB 00:00:01
(3/9): libaio-devel-0.3.109-13.el7.x86_64.rpm | 13 kB 00:00:00
(4/9): libstdc++-devel-4.8.5-4.el7.x86_64.rpm | 1.5 MB 00:00:00
(5/9): unixODBC-2.3.1-11.el7.x86_64.rpm | 413 kB 00:00:00
(6/9): unixODBC-devel-2.3.1-11.el7.x86_64.rpm | 55 kB 00:00:00
(7/9): zlib-devel-1.2.7-15.el7.x86_64.rpm | 50 kB 00:00:00
(8/9): ksh-20120801-22.el7_1.3.x86_64.rpm | 881 kB 00:00:02
(9/9): compat-libcap1-1.10-7.el7.x86_64.rpm | 19 kB 00:00:10
----------------------------------------------------------------------------------
总计 977 kB/s | 10 MB 00:10
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : unixODBC-2.3.1-11.el7.x86_64 1/9
正在安装 : libstdc++-devel-4.8.5-4.el7.x86_64 2/9
正在安装 : gcc-c++-4.8.5-4.el7.x86_64 3/9
正在安装 : unixODBC-devel-2.3.1-11.el7.x86_64 4/9
正在安装 : ksh-20120801-22.el7_1.3.x86_64 5/9
正在安装 : libaio-devel-0.3.109-13.el7.x86_64 6/9
正在安装 : compat-libcap1-1.10-7.el7.x86_64 7/9
正在安装 : compat-libstdc++-33-3.2.3-72.el7.x86_64 8/9
正在安装 : zlib-devel-1.2.7-15.el7.x86_64 9/9
验证中 : zlib-devel-1.2.7-15.el7.x86_64 1/9
验证中 : gcc-c++-4.8.5-4.el7.x86_64 2/9
验证中 : libstdc++-devel-4.8.5-4.el7.x86_64 3/9
验证中 : unixODBC-devel-2.3.1-11.el7.x86_64 4/9
验证中 : unixODBC-2.3.1-11.el7.x86_64 5/9
验证中 : compat-libstdc++-33-3.2.3-72.el7.x86_64 6/9
验证中 : compat-libcap1-1.10-7.el7.x86_64 7/9
验证中 : libaio-devel-0.3.109-13.el7.x86_64 8/9
验证中 : ksh-20120801-22.el7_1.3.x86_64 9/9
已安装:
compat-libcap1.x86_64 0:1.10-7.el7 compat-libstdc++-33.x86_64 0:3.2.3-72.el7
gcc-c++.x86_64 0:4.8.5-4.el7 ksh.x86_64 0:20120801-22.el7_1.3
libaio-devel.x86_64 0:0.3.109-13.el7 libstdc++-devel.x86_64 0:4.8.5-4.el7
unixODBC.x86_64 0:2.3.1-11.el7 unixODBC-devel.x86_64 0:2.3.1-11.el7
zlib-devel.x86_64 0:1.2.7-15.el7
完毕!
添加oracle用户组
groupadd oinstall
groupadd dba
groupadd oper
useradd -g oinstall -G dba,oper oracle
修改系统参数
/etc/sysctl.conf
vim /etc/sysctl.conf
添加如下内容:
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
应用核心参数
sysctl -p
/etc/security/limits.conf
vim /etc/security/limits.conf
添加如下内容:
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft stack 10240
oracle hard stack 32768
创建安装文件夹
mkdir -p /oracle/app/oracle/product/12.1.2/db_1
chown oracle:oinstall /oracle -R
配置oracle用户环境变量
切换到oracle用户
su - oracle
配置环境变量
vim ~/.bash_profile
添加如下内容:
export TMP=/tmp
export ORACLE_HOSTNAME=mes.dfec.com
export ORACLE_UNQNAME=LIVENUX
export ORACLE_BASE=/oracle/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.1.2/db_1
export ORACLE_SID=ORCL
PATH=/usr/sbin:$PATH:$ORACLE_HOME/bin:$HOME/bin:/$HOME/.local/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
alias cdob='cd $ORACLE_BASE'
alias cdoh='cd $ORACLE_HOME'
alias tns='cd $ORACLE_HOME/network/admin'
alias envo='env | grep ORACLE'
应用环境变量
source .bash_profile
准备安装文件
下载安装文件
从http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html 下载oracle12c安装包
上传oracle安装文件
scp /Users/lihongjun/software/oracle12c/p21419221_121020_Linux-x86-64_1of10.zip [email protected]:/software
scp /Users/lihongjun/software/oracle12c/p21419221_121020_Linux-x86-64_2of10.zip [email protected]:/software
scp /Users/lihongjun/Downloads/CentOS-7.0-1406-x86_64-DVD.iso [email protected]:/software
解压oracle安装文件
unzip p21419221_121020_Linux-x86-64_1of10.zip
unzip p21419221_121020_Linux-x86-64_2of10.zip
复制一个应答文件
cd /software
cd database
cp response/db_install.rsp inst.rsp
mkdir -p /oracle/orainst/12.1.2/database/stage
修改应答文件
vim /software/database/inst.rsp
修改内容如下:
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.1.0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=ora1
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/oracle/orainst/12.1.2/database/stage
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/oracle/app/oracle/product/12.1.2/db_1
ORACLE_BASE=/oracle/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oper
oracle.install.db.BACKUPDBA_GROUP=dba
oracle.install.db.DGDBA_GROUP=dba
oracle.install.db.KMDBA_GROUP=dba
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
执行安装程序
./runInstaller -ignoreSysPrereqs -force -silent -responseFile /software/database/inst.rsp
查看是否有出错日志
The installation of Oracle Database 12c was successful.
Please check '/oracle/orainst/12.1.2/database/stage/logs/silentInstall2016-09-03_07-24-04PM.log' for more details.
As a root user, execute the following script(s):
1. /oracle/orainst/12.1.2/database/stage/orainstRoot.sh
2. /oracle/app/oracle/product/12.1.2/db_1/root.sh
Successfully Setup Software.
执行root.sh
su - root
cd /oracle/app/oracle/product/12.1.2/db_1
sh ./root.sh
执行结果如下:
Check /oracle/app/oracle/product/12.1.2/db_1/install/root_mes.dfec.com_2016-09-03_20-15-41.log for the output of root script
执行orainstRoot.sh
cd /oracle/orainst/12.1.2/database/stage
sh ./orainstRoot.sh
执行结果如下:
Changing permissions of /oracle/orainst/12.1.2/database/stage.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /oracle/orainst/12.1.2/database/stage to oinstall.
The execution of the script is complete.
配置监听器
查看netca response file参数
cd /software/database/response
sed -n '/^[^#]/p' netca.rsp
结果如下:
[GENERAL]
RESPONSEFILE_VERSION="12.1"
CREATE_TYPE="CUSTOM"
[oracle.net.ca]
INSTALLED_COMPONENTS={"server","net8","javavm"}
INSTALL_TYPE=""typical""
LISTENER_NUMBER=1
LISTENER_NAMES={"LISTENER"}
LISTENER_PROTOCOLS={"TCP;1521"}
LISTENER_START=""LISTENER""
NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}
NSN_NUMBER=1
NSN_NAMES={"EXTPROC_CONNECTION_DATA"}
NSN_SERVICE={"PLSExtProc"}
NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}
[root@#localhost response]# pwd
/software/database/response
编辑netca response file参数
cp /software/database/response/netca.rsp /software/database/netca.rsp
vim /software/database/netca.rsp
修改后的结果如下:
[GENERAL]
RESPONSEFILE_VERSION="12.1"
CREATE_TYPE="CUSTOM"
[oracle.net.ca]
INSTALLED_COMPONENTS={"server","net8","javavm"}
INSTALL_TYPE=""custom""
LISTENER_NUMBER=1
LISTENER_NAMES={"LISTENER"}
LISTENER_PROTOCOLS={"TCP;1521"}
LISTENER_START=""LISTENER""
NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}
NSN_NUMBER=1
NSN_NAMES={"EXTPROC_CONNECTION_DATA"}
NSN_SERVICE={"PLSExtProc"}
NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}
静默安装NET Listener
su - oracle
cd /oracle/app/oracle/product/12.1.2/db_1/bin
/oracle/app/oracle/product/12.1.2/db_1/bin/netca -silent -responseFile /software/database/netca.rsp
执行结果如下:
Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /software/database/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Configuring Listener:LISTENER
Listener configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/oracle/app/oracle/product/12.1.2/db_1/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
Profile configuration complete.
Oracle Net Services configuration successful. The exit code is 0
创建数据库
查看响应文件
cd /software/database
sed -n '/^[^#]/p' dbca.rsp
结果如下:
[GENERAL]
RESPONSEFILE_VERSION = "12.1.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "orcl12c.us.oracle.com"
SID = "orcl12c"
TEMPLATENAME = "General_Purpose.dbc"
[createTemplateFromDB]
SOURCEDB = "myhost:1521:orcl"
SYSDBAUSERNAME = "system"
TEMPLATENAME = "My Copy TEMPLATE"
[createCloneTemplate]
SOURCEDB = "orcl"
TEMPLATENAME = "My Clone TEMPLATE"
[DELETEDATABASE]
SOURCEDB = "orcl"
[generateScripts]
TEMPLATENAME = "New Database"
GDBNAME = "orcl12.us.oracle.com"
[CONFIGUREDATABASE]
[ADDINSTANCE]
DB_UNIQUE_NAME = "orcl12c.us.oracle.com"
NODENAME=
SYSDBAUSERNAME = "sys"
[DELETEINSTANCE]
DB_UNIQUE_NAME = "orcl12c.us.oracle.com"
INSTANCENAME = "orcl12c"
SYSDBAUSERNAME = "sys"
[CREATEPLUGGABLEDATABASE]
SOURCEDB = "orcl"
PDBNAME = "PDB1"
[UNPLUGDATABASE]
SOURCEDB = "orcl"
PDBNAME = "PDB1"
ARCHIVETYPE = "TAR"
[DELETEPLUGGABLEDATABASE]
SOURCEDB = "orcl"
PDBNAME = "PDB1"
[CONFIGUREPLUGGABLEDATABASE]
SOURCEDB = "orcl"
PDBNAME = "PDB1"
编辑响应文件dbca.rsp
cp /software/database/response/dbca.rsp /software/database/dbca.rsp
vim /software/database/dbca.rsp
修改的结果如下:
[GENERAL]
RESPONSEFILE_VERSION = "12.1.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "orcl12c.mes.dfec.com"
SID = "orcl12c"
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "SYS"
SYSTEMPASSWORD = "SYSTEM"
[createTemplateFromDB]
SOURCEDB = "myhost:1521:orcl"
SYSDBAUSERNAME = "system"
TEMPLATENAME = "My Copy TEMPLATE"
[createCloneTemplate]
SOURCEDB = "orcl"
TEMPLATENAME = "My Clone TEMPLATE"
[DELETEDATABASE]
SOURCEDB = "orcl"
[generateScripts]
TEMPLATENAME = "New Database"
GDBNAME = "orcl12.mes.dfec.com"
[CONFIGUREDATABASE]
[ADDINSTANCE]
DB_UNIQUE_NAME = "orcl12c.mes.dfec.com"
NODENAME=
SYSDBAUSERNAME = "sys"
[DELETEINSTANCE]
DB_UNIQUE_NAME = "orcl12c.mes.dfec.com"
INSTANCENAME = "orcl12c"
SYSDBAUSERNAME = "sys"
[CREATEPLUGGABLEDATABASE]
SOURCEDB = "orcl"
PDBNAME = "PDB1"
[UNPLUGDATABASE]
SOURCEDB = "orcl"
PDBNAME = "PDB1"
ARCHIVETYPE = "TAR"
[DELETEPLUGGABLEDATABASE]
SOURCEDB = "orcl"
PDBNAME = "PDB1"
[CONFIGUREPLUGGABLEDATABASE]
SOURCEDB = "orcl"
PDBNAME = "PDB1"
创建数据库
/oracle/app/oracle/product/12.1.2/db_1/bin/dbca -silent -responseFile /software/database/dbca.rsp
执行结果如下:
Copying database files
1% complete
2% complete
4% complete
DBCA Operation failed.
Look at the log file "/oracle/app/oracle/cfgtoollogs/dbca/orcl12c/orcl12c.log" for further details.
执行失败,查看log:
vim /oracle/app/oracle/cfgtoollogs/dbca/orcl12c/orcl12c.log
结果如下:
Database Configuration Assistant failed to detect options for this Oracle Installation.
ORA-12547: TNS:lost contact
Due to this failure some Database Configuration Assistant features will not be available. Do you want to continue?
Unique database identifier check passed.
/ has enough space. Required space is 6140 MB , available space is 33031 MB.
File Validations Successful.
Copying database files
DBCA_PROGRESS : 1%
DBCA_PROGRESS : 2%
ORA-12547: TNS:lost contact
DBCA_PROGRESS : 4%
Error while cataloging RMAN Backups
DBCA_PROGRESS : DBCA Operation failed.
查看IP地址
ifconfig eth0
结果如下:
eth0: flags=4163 mtu 1500
inet 192.168.0.115 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::21c:42ff:fe11:61b prefixlen 64 scopeid 0x20
ether 00:1c:42:11:06:1b txqueuelen 1000 (Ethernet)
RX packets 114131 bytes 30342139 (28.9 MiB)
RX errors 0 dropped 190 overruns 0 frame 0
TX packets 16014 bytes 4278352 (4.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
参考文档
http://blog.itpub.net/13804621/viewspace-767741/
http://www.cnblogs.com/fincod/p/3997503.html
http://www.linuxidc.com/Linux/2013-07/87696.htm
http://blog.csdn.net/yabingshi_tech/article/details/46801539