linux怎么安装oracle

linux怎么安装oracle,第1张

在linux下安装oracle数据库步骤:

1、下载oracle安装文件

一、检查必要条件

1.1、检查内存及交换分区

Oracle要求2GB以上的内存

#查看内存大小

grep MemTotal /proc/meminfo

#查看交换区大小

grep SwapTotal /proc/meminfo

#也可以使用下面的命令查看内存大小

free -m1234567

交换分区要求

内存大小

交换分区要求

1GB~2GB 内存的1.5倍

2GB~16GB 和内存大小相等

大于16GB 16GB

1.2、确认 *** 作系统位数

[root@FSWWOA /]# uname -m

x86_6412

x86_64:表示用的是Intel的处理器,并且 *** 作系统是64位的

i386:表示是32位

1.3、检查硬盘空间

#查看临时目录空间

[root@FSWWOA /]# df -h /tmp

#查看硬盘总空间

[root@FSWWOA /]# df -h1234

Oracle安装是要求/tmp目录要有至少1GB的空间。

以下是Oracle各个版本安装是所需的空间

版本

所需空间

Enterprise Edition(企业版) 4.7GB

Standard Edition(标准版) 4.6GB

二、安装必要软件

首先需要检查系统版本,然后从Oracle官方文档中找到对应的Linux版本。

[root@FSWWOA /]# cat /proc/version

Linux version 2.6.32-71.el6.x86_64 (root@CentOS6064.localdomain) (gcc version 4.4.4 20110726 (Red Hat 4.4.4-13) (GCC) ) #1 SMP Wed Feb 29 15:21:16 CST 201212

Oracle官方文档中对应的版本如下

On Red Hat Enterprise Linux 6

2.6.32-71.el6.x86_64 or later

然后根据Linux版本找到其必要安装的软件,如下

The following or later version of packages for Oracle Linux 6, Red Hat Enterprise Linux 6, and Asianux Server 4 must be installed:

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)1234567891011121314151617181920212223

检查系统是否安装以上的软件,如果没有安装则安装这些软件

yum install -y binutils.x86_64 binutils-devel.x86_64

yum install -y compat-libcap1.x86_64

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

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

yum install -y gcc.x86_64 gcc-c++.x86_64

yum install -y glibc.x86_64 glibc.i686 glibc-devel.x86_64 glibc-devel.i386

yum install -y ksh.x86_64

yum install -y libgcc.i386 libgcc.x86_64

yum install -y libstdc++.i386 libstdc++.x86_64 libstdc++-devel.i386 libstdc++-devel.x86_64

yum install -y libaio libaio-devel

yum install -y make.x86_64

yum install -y sysstat.x86_64

yum install -y pdksh.x86_64

/*-------------------------------------*/

yum install -y unixODBC.x86_64 unixODBC.i386 unixODBC-devel.i386 unixODBC-devel.x86_64123456789101112131415

三、创建Oracle用户和组

[root@FSWWOA /]# groupadd dba

[root@FSWWOA /]# groupadd oinstall

#添加用户

[root@FSWWOA /]# useradd -g oinstall -G dba oracle

#设置Oracle的密码

[root@FSWWOA /]# pwd oracle oracle

#这里密码使用:oracle12345678

四、修改系统参数

4.1、修改用户的SHELL的限制

修改/etc/security/limits.conf文件

vi /etc/security/limits.conf1

然后在文件中添加如下内容

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft nofile 1024

oracle hard nofile 655361234

4.2、修改/etc/pam.d/login 文件

vi /etc/pam.d/login1

然后在文件中添加如下内容

session required /lib/security/pam_limits.so

session required pam_limits.so12

4.3、修改系统核心参数

修改/etc/sysctl.conf文件vi /etc/sysctl.conf,然后在文件中加入

fs.aio-max-nr = 1048576

fs.file-max = 6815744

kernel.shmall = 2097152

kernel.shmmax = 536870912

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 = 10485761234567891011

执行sysctl -p是配置立刻生效。使用sysctl -a查看所有系统参数。

五、创建Oracle安装目录

5.1创建Oracle安装目录

cd /u01

mkdir -p app/oracle/product/11.2.0/dbhome_1

mkdir app/oradata123

5.2修改目录所有者

[root@FSWWOA u01]# chown -R oracle:oinstall app

[root@FSWWOA u01]# ll

总用量 20

drwxr-xr-x. 4 oracle oinstall 4096 11月 25 08:46 app

drwx------. 2 root root 16384 11月 24 14:29 lost+found12345

六、修改系统环境变量

使用vi ~/.bash_profile打开环境变量配置文件。加入如下内容

export ORACLE_BASE=/u01/app

export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1

export ORACLE_SID=orcl

export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

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

export NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK 123456

然后使用source ~/.bash_profile是配置立即生效。使用env | grep ORACLE可以查看环境变量配置。

七、安装Oracle

7.1解压Oracle安装文件

将Oracle拷贝至Linux服务器上,然后解压

unzip linux.x64_11gR2_database_1of2.zip

unzip linux.x64_11gR2_database_2of2.zip12

如果使用光盘安装,则使用mount -t iso9660 /dev/dvd /mnt/dvd挂载光盘

7.2设置安装环境

如果Linux系统字符编码是中文的,在安装过程中Oracle安装界面会全部乱码。可使用export LANG=en_US,将会话的字符集改为英文字符集,然后再安装就不会出现乱码。

另外,Oracle安装时需要图形界面的支持。

剩余部分见PDF文档(后续图片太多不再一一上传),剩余部分如下:

7.3开始安装Oracle

八、测试安装结果

九、修改防火墙配置,将Oracle端口添加到例外

十、将Oracle设置自启动

十一、设置Oracle用户名密码不区分大小写

一、使用脚本初始化环境

脚本如下:(标红处修改对应的配置需求)

#!/bin/bash

#1.配置主机名/etc/hosts 并关闭防火墙及selinux

echo ' 172.168.0.xx linux.tk ' >>/etc/hosts

#注意修改为服务器的ip和主机名

systemctl stop firewalld

systemctl disable firewalld

setenforce 0

#sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

#2.安装相关软件包

yum -y install telnet vim lszrz gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel

elfutils-libelf-devel-static ksh libaio libaio-devel numactl-devel sysstat

unixODBC unixODBC-devel pcre-devel wget unzip

#3.配置内核参数

echo "fs.aio-max-nr = 1048576" >>/etc/sysctl.conf

echo "fs.file-max = 6815744" >>/etc/sysctl.conf

echo "kernel.shmmni = 4096" >>/etc/sysctl.conf

echo "kernel.sem = 250 32000 100 128" >>/etc/sysctl.conf

echo "net.ipv4.ip_local_port_range = 9000 65500" >>/etc/sysctl.conf

echo "net.core.rmem_default = 262144" >>/etc/sysctl.conf

echo "net.core.rmem_max = 4194304" >>/etc/sysctl.conf

echo "net.core.wmem_default = 262144" >>/etc/sysctl.conf

echo "net.core.wmem_max = 1048576" >>/etc/sysctl.conf

sysctl -p

#4.oracle用户资源限制

echo "oracle soft nproc 2047" >>/etc/security/limits.conf

echo "oracle hard nproc 16384" >>/etc/security/limits.conf

echo "oracle soft nofile 4096" >>/etc/security/limits.conf

echo "oracle hard nofile 65536" >>/etc/security/limits.conf

#5.登录配置

echo "session required /lib64/security/pam_limits.so" >>/etc/pam.d/login

echo "session required pam_limits.so" >>/etc/pam.d/login

#改授权

echo "if [ $USER = 'oracle' ]then" >>/etc/profile

echo "if [ $SHELL = '/bin/ksh' ]then" >>/etc/profile

echo "ulimit -p 16384" >>/etc/profile

echo "ulimit -n 65536" >>/etc/profile

echo "else" >>/etc/profile

echo "ulimit -u 16384 -n 65536" >>/etc/profile

echo "fi" >>/etc/profile

echo "fi" >>/etc/profile

source /etc/profile

#6.创建用户组和用户

groupadd oinstall

groupadd dba

groupadd oper

useradd -g oinstall -G dba,oper oracle

echo 'oracle' | passwd --stdin oracle

#7.创建相关目录

mkdir -p /u01/app/oracle

mkdir -p /u01/app/oraInventory

chown -R oracle:oinstall /u01/app

#8.配置oracle用户环境变量

echo "ORACLE_SID=oraexport ORACLE_SID" >>/home/oracle/.bash_profile

#sid指定为现场的sid

echo "ORACLE_BASE= /u01/app/oracle export ORACLE_BASE" >>/home/oracle/.bash_profile

echo "ORACLE_HOME=$ORACLE_BASE/ product/11.2.0/dbhome_1 export ORACLE_HOME" >>/home/oracle/.bash_profile

echo "ORACLE_PATH=/u01/app/common/oracle/sqlexport ORACLE_PATH" >>/home/oracle/.bash_profile

echo "ORACLE_TERM=xtermexport ORACLE_TERM" >>/home/oracle/.bash_profile

echo "TNS_ADMIN=$ORACLE_HOME/network/adminexport TNS_ADMIN" >>/home/oracle/.bash_profile

echo "ORA_NLS11=$ORACLE_HOME/nls/dataexport ORA_NLS11" >>/home/oracle/.bash_profile

echo "PATH=.:${JAVA_HOME}/bin:${PATH}:$ORACLE_HOME/bin " >>/home/oracle/.bash_profile

echo "PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin " >>/home/oracle/.bash_profile

echo "export PATH " >>/home/oracle/.bash_profile

echo "export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK" >>/home/oracle/.bash_profile

echo "LD_LIBRARY_PATH=$ORACLE_HOME/lib" >>/home/oracle/.bash_profile

echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib " >>/home/oracle/.bash_profile

echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib " >>/home/oracle/.bash_profile

echo "export LD_LIBRARY_PATH" >>/home/oracle/.bash_profile

echo "export LANG=en_US.UTF-8 " >>/home/oracle/.bash_profile

echo "export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK" >>/home/oracle/.bash_profile

echo "CLASSPATH=$ORACLE_HOME/JRE " >>/home/oracle/.bash_profile

echo "CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib" >>/home/oracle/.bash_profile

echo "CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib" >>/home/oracle/.bash_profile

echo "CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib" >>/home/oracle/.bash_profile

echo "export CLASSPATH" >>/home/oracle/.bash_profile

echo "THREADS_FLAG=nativeexport THREADS_FLAG" >>/home/oracle/.bash_profile

echo "nls_date_format='yyyy-mm-dd hh24:mi:ss' " >>/home/oracle/.bash_profile

echo "export nls_date_format " >>/home/oracle/.bash_profile

echo "export TEMP=/tmp " >>/home/oracle/.bash_profile

echo "export TMPDIR=/tmp " >>/home/oracle/.bash_profile

echo "umask 022 " >>/home/oracle/.bash_profile

source ~/.bash_profile

二、上传或者下载oracle安装包并解压,例如放置在/opt/目录下

unzip p13390677_112040_Linux-x86-64_1of7.zip

unzip p13390677_112040_Linux-x86-64_2of7.zip

直接在目录解压,会在当前目录中生成database目录

三、修改应答文件安装数据库软件

修改前建议先备份下

cp /opt/database/response/*.rsp /opt/database/rspbak

3.1、生成修改响应文件(/opt/database/response/db_install.rsp)

备注:清空源文件,复制粘贴如下内容(标红处需要修改对应的设置需求):

oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0

oracle.install.option=INSTALL_DB_SWONLY

ORACLE_HOSTNAME= linux.tk

UNIX_GROUP_NAME=oinstall

INVENTORY_LOCATION= /u01/app/oraInventory

SELECTED_LANGUAGES=en,zh_CN

ORACLE_HOME= /u01/app/oracle/product/11.2.0/dbhome_1

ORACLE_BASE= /u01/app/oracle

oracle.install.db.InstallEdition=EE

oracle.install.db.EEOptionsSelection=false

oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:10.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0

oracle.install.db.DBA_GROUP=dba

oracle.install.db.OPER_GROUP=oper

DECLINE_SECURITY_UPDATES=true

oracle.installer.autoupdates.option=SKIP_UPDATES

3.2、开始安装

1)、用oracle用户登录 *** 作

# su - oracle

$ cd /opt/database

$ ./runInstaller -silent -responseFile /opt/database/response/db_install.rsp

2)、在安装过程中可以新开会话,使用tailf 命令查看进度

# tailf /u01/app/oraInventory/logs/installActions2022-XX-XX_03-28-06PM.log

提示安装结束,需要在root用户执行两个脚本,如下:

# /u01/app/oraInventory/orainstRoot.sh

# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh

四、修改应答文件安装数据库实例(/opt/database/response/dbca.rsp)

安装实例前,需要新建一个实例存放的目录(/home/OracleData/),如下:

# mkdir /home/OracleData

# chown -R oracle:oinstall /home/OracleData/

4.1、修改应答文件

[GENERAL]

RESPONSEFILE_VERSION = "11.2.0"

OPERATION_TYPE = "createDatabase"

[CREATEDATABASE]

GDBNAME = "ora"

SID = "ora"

TEMPLATENAME = "General_Purpose.dbc"

SYSPASSWORD = "***012"

SYSTEMPASSWORD = "***012"

DATAFILEDESTINATION = /home/OracleData/

RECOVERYAREADESTINATION = /u01/app/oracle/flash_recovery_area

CHARACTERSET = "ZHS16GBK"

TOTALMEMORY = "2048"

4.2、建实例,登录oracle用户

# su - oracle

$ dbca -silent -responseFile /opt/database/response/dbca.rsp

此安装过程是有进度显示,不用tailf查看,不过也可以查看对应的log日志查看进度

4.3、删除实例

编辑应答文件

#vim /opt/database/response/del_dbca.rsp

[GENERAL]

RESPONSEFILE_VERSION = "11.2.0"

OPERATION_TYPE = "deleteDatabase"

[DELETEDATABASE]

SOURCEDB = "ora "

$ dbca -silent -responseFile del_dbca.rsp

五、启动监听,配置自启动等

5.1、启动监听

# su – oracle

$ lsnrctl start

查看状态 lsnrctl status

# netstat -tnulp | grep 1521

# ps -ef | grep ora_ | grep -v grep

5.2、设置自启动

修改vim /etc/oratab 如下

ora:/u01/app/oracle/product/11.2.0/dbhome_1: Y

5.3、修改dbstart文件

vim /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart

将ORACLE_HOME_LISTNER=$1

修改为ORACLE_HOME_LISTNER=$ORACLE_HOME

5.4、将dbstart加入开机自启动,/etc/rc.d/rc.local中增加

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

赋权限 chmod +x /etc/rc.d/rc.local

5.3、登录数据库设置权限等

sqlplus / as sysdba

startup

alter system register

create user ora identified by ***012

grant dba to ora

exit

六、远程连接数据库

6.1、开放1521端口

firewall-cmd --zone=public --add-port=1521/tcp --permanent

firewall-cmd –reload

firewall-cmd --list-ports


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/6057978.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-13
下一篇 2023-03-13

发表评论

登录后才能评论

评论列表(0条)

保存