linux安装oracle 11gr2
本次实验oracle安装的环境为:
CentOS Linux release 7.0.1406 (Core) 内存:8G,磁盘50G,内核:4Core
安装分为三步:
1.安装oracle软件
2.建立监听
3.建库
1. 基础环境优化:
1)关闭防火墙:systemctl stop firewalld
systemctl disable firewalld
2)关闭selinux:sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config grep SELINUX=disabled /etc/selinux/config
setenforce 0
2.创建运行oracle用户和用户组
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
mkdir -p /home/data/oracle ##创建oracle安装目录
chown -R oracle.dba /home/data/oracle 目录授权
mkdir -p /home/data/oraInventory ##创建oracle配置文件目录
chown -R oracle.dba /home/data/oraInventory
mkdir /u01/app/oracle -p ##创建oracle的产品目录
chown -R oracle.dba /u01/app/oracle
3.修改Oracle用户限制
执行vim /etc/security/limits.conf文件,修改操作系统对oracle用户资源的限制。
oracle soft nproc 2047
oracle hard nproc 16384 ##oracle用户进程不能超过16384个并且会在2047个的时候报警
oracle soft nofile 1024
oracle hard nofile 65536 ###oracle用户可以打开的文件描述符不能超过65535个,并且会在1024个的时候进行
解释以上设置:
hard和soft的区别: soft是一个警告值,而hard则是一个真正意义的阀值,超过就会报错,一般情况下都是设为同一个值。
要使limits.conf文件配置生效,必须要确保pam_limits.so文件被加入到启动文件中。编辑文件:vim /etc/pam.d/login
session required pam_selinux.so open
session required pam_namespace.so
session optional pam_keyinit.so force revoke
session include system-auth
session include postlogin
session optional pam_ck_connector.so
session required /lib/security/pam_limits.so
session required pam_limits.so
4.配置内核参数和资源限制
编辑/etc/sysctl.conf文件,设置相关参数的系统默认值。每次操作系统启动时,便会自动设置这些内核参数。
net.ipv4.ip_forward = 0
# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0
# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0
# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1
# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1
# Controls the default maxmimum size of a mesage queue
kernel.msgmnb = 65536
# Controls the maximum size of a message, in bytes
kernel.msgmax = 65536
# Controls the maximum shared segment size, in bytes
kernel.shmmax = 68719476736
# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 4294967296
fs.aio-max-nr = 1048576
fs.file-max = 6815744
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
执行sysctl -p 查看并生效:(-p:从指定的文件加载系统参数,如不指定即从/etc/sysctl.conf中加载)
5.配置Oracle用户环境变量
su - oracle
vim ~/.bash_profile
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=orcl (具体根据实例名称调整)
export ROACLE_PID=ora11g
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export PATH=$PATH:$ORACLE_HOME/bin
source /home/oracle/.bash_profile 使之生效,使用echo $ORACLE_HOME 来显示是否生效
6.配置本地host解析
vim /etc/hosts
10.2.22.163 dev_test
6.5 安裝依賴包
采用yum安装,如下:
yum install -y binutils*
yum install -y compat-libstdc*
yum install -y elfutils-libelf*
yum install -y gcc*
yum install -y glibc*
yum install -y ksh*
yum install -y libaio*
yum install -y libgcc*
yum install -y libstdc*
yum install -y make*
yum install -y sysstat*
yum install libXp* -y
yum install -y glibc-kernheaders
7.图形化安装oracle需要用vnc来安装
首先在liunx服务器上安装oracle的客户端
下载客户端
yum install tigervnc-server tigervnc-server-module -y
yum -y groupinstall GNOME Desktop
配置vnc的配置文件:
vim /etc/sysconfig/vncservers
VNCSERVERS="1:root 2:oracle"
VNCSERVERARGS[1]="-geometry 800x600 -nolisten tcp"
VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp
su - oracle
vncserver :2 ###启动vnc
登陆vnc开始安装oracle
登陆注意:ip::端口
cd 到安装包的解压目录
执行: ./runInstaller -jreLoc /usr/lib/jvm/jre-1.8.0 (11g的在centos7 安装需要设置java参数)
如下选则只创建库,不要创建实例,使用dbca建库
此处有failed必须解决否则会有报错
安装后点击finish,跑到大概84%的进度时候报错如下:解决:
解决:
su - oracle
cd $ORACLE_HOME/sysman/lib
cp ins_emagent.mk ins_emagent.mk.bak
vim ins_emagent.mk
大概在:190行
$(MK_EMAGENT_NMECTL) 后加-lnnz11
修改前: $(MK_EMAGENT_NMECTL)修改后: $(MK_EMAGENT_NMECTL) -lnnz11
8.配置后之后:
切换到root用户
cd /home/data/oracle
sh orainstRoot.sh
cd /u01/app/oracle/product/11.2.0/db_1
sh root.sh
8.5 创建网络监听
netca
直接下一步,启动1521的监听
9.启动监听
lsnrctl start
10.DBCA建库
实例名称
把这个建立EM勾掉,不要勾选,否则建库很慢,后面的automatic tesks也取消掉
处理:
cd $ORACLE_HOME/inventory/Scripts/ext/lib/
cp libclntsh.so.11.1 $ORACLE_HOME/lib/
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11.2.0.1.0 安装需要修改,因为这个版本有bug
[oracle@dg ~]$ vi /etc/oraInst.loc
inventory_loc=/u01/app/oraInventory
inst_group=oinstall
-rw-rw-r--. 1 root root 56 Dec 2 15:17 /etc/oraInst.loc
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11g静默安装命令
./runInstaller -silent -force -noconfig -IgnoreSysPreReqs -ignorePrereq oracle.install.option=INSTALL_DB_SWONLY DECLINE_SECURITY_UPDATES=true UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/u01/app/oraInventory SELECTED_LANGUAGES=en ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 ORACLE_BASE=/u01/app/oracle oracle.install.db.InstallEdition=EE oracle.install.db.isCustomInstall=false oracle.install.db.DBA_GROUP=dba oracle.install.db.OPER_GROUP=dba oracle.install.db.isRACOneInstall=false oracle.install.db.config.starterdb.type=GENERAL_PURPOSE SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
oracle 静默安装数据库dbca
dbca -silent -ignorePreReqs -ignorePrereqFailure -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE \
-gdbname orcl -sid orcl \
-createAsContainerDatabase FALSE \
-sysPassword oracle -systemPassword oracle -dbsnmpPassword oracle \
-datafileDestination '/oradata' \
-storageType FS \
-characterset AL32UTF8 -nationalCharacterSet AL16UTF16 \
-totalMemory 132096 \
-databaseType MULTIPURPOSE \
-emConfiguration NONE