centos7.2系统安装oracle11g2
安装centos7系统环境(2核2G40G盘)使用centos7.2系统,也就是CentOS-7-x86_64-DVD-1511.iso镜像,最小化安装即可。
安装完成后调整网络设置IP,关闭关闭防火墙和selinux
vi /etc/sysconfig/network-scripts/ifcfg-eno16777736 ##配置网路
##重启网络
systemctl restart network
##安装工具
yum isntall vim wget net-tools unzip -y
##关闭防火墙 #关闭selinux
sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
设置主机名
hostnamectl set-hostname tester
hostname tester
vim /etc/hosts
192.168.1.5
2 下载oracle 11g
官网下载,下载的包如下,上传到机器上即可。
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
3 安装依赖包
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make pdksh sysstat unixODBC unixODBC-devel
yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33i686 compat-libstdc++-33.devel compat-libstdc++-33 compat-libstdc++-33.devel gcc gcc-c++ glibc glibc.i686 glibc-devel glibc-devel.i686 ksh libaio libaio.i686 libaio-devel libaio-devel.devel libgcc libgcc.i686 libstdc++ libstdc++.i686 libstdc++-devel libstdc++-devel.devel libXi libXi.i686 libXtst libXtst.i686 make sysstat unixODBC unixODBC.i686 unixODBC-devel unixODBC-devel.i686
检查依赖包是否都安装成功 (ksh和pdksh是冲突的,选择ksh)
rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make pdksh sysstat unixODBC unixODBC-devel | grep "not installed"
rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtstmake sysstatunixODBC unixODBC-devel
4 创建oinstall和dba组和oracle用户
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/useradd -g oinstall -G dba oracle
设置oracle用户密码passwd oracle
验证用户是否正确>
$> uid=1000(oracle) gid=1000(oinstall) 组=1000(oinstall),1001(dba)
5 配置内核参数
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
----------------------参数解读-----------------------
shmmax=物理内存80%80%,单位是字节
kernel.shmmax:表示单个共享内存段的最大值,以字节为单位,此值一般为物理内存的一半,不过大一点也没关系,这里设定的为4GB,即“4294967295/1024/1024/1024=4G”。
kernel.shmmin:表示单个共享内存段的最小值,默认为1byte
kernel.shmall:表示整个系统范围内可用共享内存页的总量,单位是页(page),在32位系统上一页等于4kB,也就是4096字节。计算公式是:shmmax/PAGE_SIZE
kernel.shmmni:表示整个系统范围内内存段的最大数量,一般为4096.
ip_local_port_range:表示端口的范围。在监听器帮助客户端进程和服务器进程建立连接时,会用到指定范围内的端口。
kernel.sem:表示设置的信号量,这4个参数内容大小固定。
net.core.rmem_default:表示接收套接字缓冲区大小的缺省值(以字节为单位)。
net.core.rmem_max:表示接收套接字缓冲区大小的最大值(以字节为单位)
net.core.wmem_default:表示发送套接字缓冲区大小的缺省值(以字节为单位)。
net.core.wmem_max:表示发送套接字缓冲区大小的最大值(以字节为单位)。
立即生效 sysctl -p
6 修改系统配置文件
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
oracle hard stack 10240
在/etc/pam.d/login 文件中增加以下内容
session required /lib64/security/pam_limits.so
session required pam_limits.so
在/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
执行source /etc/profile
7 创建oracle安装目录
mkdir -p /opt/app/oracle/
chmod 755 /opt/app/oracle/
chown oracle.oinstall -R /opt/app/oracle/
8 设置oracle环境变量
使用oracle账户
#su - oracle
$ vi ~/.bash_profile
#设置oracle变量
export ORACLE_BASE=/opt/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export ORACLE_PID=ora11g
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
完成后执行:
env | grep ORA #查看环境变量是否完成
ORACLE_BASE=/opt/app/oracle
ORACLE_HOME=/opt/app/oracle/product/11.2.0/db_1
9 安装oracle
在/opt目录下 解压oracle软件
# unzip linux.x64_11gR2_database_1of2.zip
# unzip linux.x64_11gR2_database_2of2.zip
解压后得到database目录,其中包含response目录,该目录中有三个rsp文件,用来作为静默安装时的应答文件的模板。
三个文件作用分别是:
db_install.rsp:安装应答
dbca.rsp:创建数据库应答
netca.rsp:建立监听、本地服务名等网络设置的应答
修改静默安装配置文件(注意修改对应的参数,比较重要,变量,名称,路径等)
$ cat /opt/database/response/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=tester
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/opt/app/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/opt/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/opt/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=ora11g
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=
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=
开始静默安装
$/opt/database/runInstaller -silent -force -responseFile /opt/database/response/db_install.rsp
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB. Actual 165908 MB Passed
Checking swap space: must be greater than 150 MB. Actual 16383 MB Passed
。。。。。
。。。。。(省略中间警告)
The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run
/opt/app/oracle/oraInventory/orainstRoot.sh
/opt/app/oracle/product/11.2.0/db_1/root.sh
To execute the configuration scripts:
[*]Open a terminal window
[*]Log in as "root"
[*]Run the scripts
[*]Return to this window and hit "Enter" key to continue
Successfully Setup Software.
安装完毕后会提示上述的信息,按照要求执行上述脚本
新开一个窗口 用root 执行对应脚本
/opt/app/oracle/oraInventory/orainstRoot.sh
/opt/app/oracle/product/11.2.0/db_1/root.sh
然后回到原窗口按enter即可
接着配置监听程序启动监听程勋
$ $ORACLE_HOME/bin/netca /silent /responseFile /opt/database/response/netca.rsp
Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /opt/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Listener "LISTENER" already exists.
Oracle Net Services configuration successful. The exit code is 0
启动监控程序
$/opt/app/oracle/product/11.2.0/db_1/bin/lsnrctl start LISTENER
静默dbca建库
vim /opt/database/response/dbca.rsp
GDBNAME = "ora11g.tester"78 行 全局数据库的名字=SID+主机域名
SID="ora11g" //149行 SID
CHARACTERSET="AL32UTF8" //415行 编码
NATIONALCHARACTERSET="UTF8" //425行 编码
执行建库
$ $ORACLE_HOME/bin/dbca -silent -responseFile /opt/database/response/dbca.rsp
Enter SYS user password:
Enter SYSTEM user password:
sh: /bin/ksh: No such file or directory
sh: /bin/ksh: No such file or directory
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
57% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
74% complete
85% complete
96% complete
100% complete
Look at the log file "/opt/app/oracle/cfgtoollogs/dbca/ora11g/ora11g.log" for further details.
启动数据库(默认等一会儿会自动起)
注意一定要有SID环境变量
$ echo $ORACLE_SID
ora11g
$ sqlplus / as sysdba
SQL*Plus:> Copyright (c) 1982, 2009, Oracle.All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition> With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> start
SP2-1506: START, @ or @@ command has no arguments
SQL> startup
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL>
使用show parameter;或者select table_name from dba_tables看看是否
启动监听:lsnrctl start
查看监听:lsnrctl status
停止监听:lsnrctl stop
参考文档:
https://blog.csdn.net/u010469514/article/details/73822099
http://www.boyfuli.com/archives/81
https://blog.csdn.net/h8178/article/details/78251198
页:
[1]