欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

1. Oracle安装部署文档

程序员文章站 2023-12-20 10:03:58
一. 部署环境步骤 1.1 软件环境 操作系统:CentOS release 6.5oracle安装包:linux.x64_11gR2_database_1of1.zip;linux.x64_11gR2_database_1of2.zip 1.2 配置主机名 1.3 配置网络 1.4 配置系统内核参 ......

一. 部署环境步骤

1.1 软件环境

操作系统:centos release 6.5
oracle安装包:linux.x64_11gr2_database_1of1.zip;linux.x64_11gr2_database_1of2.zip

1.2 配置主机名

# vim /etc/sysconfig/network
hostname= oracle235
# 或者执行 hostname oracle235

1.3 配置网络

# vim /etc/hosts
192.168.1.235 oracle235

1.4 配置系统内核参数

  配置 /etc/sysctl.conf :添加如下内容:

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

  注意上述参数中,需要根据实际情况修改 kernel.shmmax 参数的值,可以直接设置为物理内存大小。
  执行命令使之生效: 

# /sbin/sysctl -p

1.5 设置 shell对oracle用户的限制

  配置 /etc/security/limits.conf 文件:增加如下内容

oracle      soft  nproc  2047
oracle      hard  nproc  16384
oracle      soft  nofile 2047
oracle      hard  nofile 65536

  接着,修改 /etc/pam.d/login,在文件最后添加如下内容:

session required /lib64/security/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

  所有修改完毕,重启所有 linux 系统

1.6 创建grid/oracle用户和组

# /usr/sbin/groupadd oinstall
# /usr/sbin/groupadd dba
# /usr/sbin/groupadd oper
# /usr/sbin/useradd -g oinstall -g dba,oper oracle
# passwd oracle

  创建 oracle 软件安装目录

# mkdir -p /u01/orainventory
# chown -r oracle:oinstall /u01/
# chmod -r 775 /u01/

  配置 oracle 用户的环境变量

export oracle_base=/u01/app
export oracle_home=$oracle_base/oracle
export oracle_sid=orcl
export path=$path:$home/bin:$oracle_home/bin
export nls_lang=american_america.utf8
export ld_library_path=$oracle_home/lib:$ld_library_path
alias sqlplus='rlwrap sqlplus'

1.7 安装 oracle 安装包的依赖

binutils-2.17.50.0.6
compat-libstdc++-33-3.2.3
compat-libcap1
elfutils-libelf-0.125
elfutils-libelf-devel-0.125
elfutils-libelf-devel-static-0.125
gcc-4.1.2
gcc-c++-4.1.2
glibc-2.5-24
glibc-common-2.5
glibc-devel-2.5
glibc-headers-2.5
kernel-headers-2.6.18
ksh-20060214
libaio-0.3.106
libaio-devel-0.3.106 
libgcc-4.1.2
libgomp-4.1.2
libstdc++-4.1.2 
libstdc++-devel-4.1.2
make-3.81
sysstat-7.0.2
unixodbc-2.2.11
unixodbc-devel-2.2.11

  执行命令 查看是否遗漏包;

rpm -q binutils compat-libstdc++-33 compat-libcap1 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make sysstat unixodbc unixodbc-devel

  安装依赖包

yum install -y binutils compat-libstdc++-33 compat-libcap1 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make sysstat unixodbc unixodbc-devel

二. 用xshell打开图形界面

  可以采用 vnc 或者 xshell 软件登录 linux 界面去安装 oracle grid infrastructure 软件。本例采用 xshell 软件

2.1 安装与下载图形界面gnome

yum groupinstall "desktop"
yum groupinstall "x window system"

2.2 修改 /etc/gdm/custom.conf

[daemon]
[security]
allowremoteroot=true  
[xdmcp]
port=177
enable=true    
[gui]
[greeter]
[chooser]
[debug]

2.3 启动xshell工具

1. Oracle安装部署文档

 

三. 安装oracle数据库图解

3.1 安装 oracle 软件

  进入 linux 桌面;打开终端;用 oracle 用户登录。进入 oracle 安装包目录;执行命令

./runinstaller

  下面是每一步都图解演示:点击 next 按钮

1. Oracle安装部署文档

  跳过软件更新;点击next按钮

1. Oracle安装部署文档

  选择只安装数据库软件

1. Oracle安装部署文档

  选择单实例安装

1. Oracle安装部署文档

  选择languages

1. Oracle安装部署文档

  选择"enterprise edition"

1. Oracle安装部署文档

  选择oracle软件安装路径

1. Oracle安装部署文档

  安装前环境监测

1. Oracle安装部署文档

  安装oracle软件

1. Oracle安装部署文档

  接下来的时间慢慢等待 oracle 软件安装;在安装过程中要用 root 用户执行两个脚本;如下截图

1. Oracle安装部署文档

3.2 配置oracle数据库

  oracle服务器软件已经安装完成;接下来需要配置oracle数据库;在终端下执行命令

dbca

  执行dbca之后;会弹出数据库配置助手;如下图所示:

 

1. Oracle安装部署文档

  跳过软件更新;点击 next 按钮

1. Oracle安装部署文档

  选择定制;可以根据业务定制

1. Oracle安装部署文档

1. Oracle安装部署文档

1. Oracle安装部署文档

1. Oracle安装部署文档

1. Oracle安装部署文档

1. Oracle安装部署文档

1. Oracle安装部署文档

1. Oracle安装部署文档

1. Oracle安装部署文档

  经过漫长的等待;oracle安装就完成

四. oracle网络配置

  数据库启动之后,要想提供对外服务。还需要配置 oracle 的监听器配置文件 listener.ora(可以使用 netca 命令创建);而远程客户端则需要配置 tnsnames.ora 文件。与服务器建立网络连接。

4.1 服务器监听文件 listener.ora

  我们先看下数据库sid和service_name。 

sql> show parameter instance_name;
name            type       value
--------------  ---------  ---------------
service_names   string     ora235
sql> alter system set service_names='lottu' scope=both;
system altered.
sql> show parameter service_name;
name            type       value
--------------  ---------  ---------------
service_names   string     lottu

  一般 oracle 的实例名跟 service_name 是一致的

  在目录 $oracle_home/network/admin/ 目录下;配置监听文件 listener.ora

listener =
  (description_list =
    (description =
       (address_list =(address = (protocol = tcp)(host = 192.168.1.235)(port = 1521)(ip = first)))
       (address_list =
         (address = (protocol = ipc)(key = extproc))
       )
     )
  )

sid_list_listener =
  (sid_list =
   (sid_desc =
     (sid_name = ora235)
     (global_dbname = lottu)
     (oracle_home =/u01/app/oracle)
   )
  )

  再启动监听

lsnrctl start

4.2 客户端网络服务文件 tnsnames.ora

  在客户端的 $oracle_home/network/admin/ 目录下;配置如下:

t235=
  (description =
      (address = (protocol = tcp)(host = 192.168.1.235)(port = 1521))
    (connect_data =
      (sid = ora235)
    )
 (hs = ok)
  )
# 或者用 (service_name = lottu) 替换 (sid = ora235)

  测试是否配置ok?

[oracle@oracle235 admin]$ tnsping t235

tns ping utility for linux: version 11.2.0.4.0 - production on 03-aug-2018 23:48:59

copyright (c) 1997, 2013, oracle.  all rights reserved.

used parameter files:


used tnsnames adapter to resolve the alias
attempting to contact (description = (address = (protocol = tcp)(host = 192.168.1.235)(port = 1521)) (connect_data = (sid = ora235)) (hs = ok))
ok (0 msec)

  这样就可以通过客户端连接 oracle 服务器

五. oracle开机自启动

  默认 oracle 数据库是不会随着机器重启或者开机启动 oracle 服务。

5.1 修改oracle系统配置文件

  用 root 用户修改文件 /etc/oratab ;将 n 改成 y;本例如下

$oracle_sid:$oracle_home:<n|y>:
ora235:/u01/app/oracle:y

5.2 在 /etc/init.d/ 下创建文件oracle

#!/bin/bash
#chkconfig:345 61 61 
#description:oracle
#
# set ora_home to be equivalent to the $oracle_home
# from which you wish to execute dbstart and dbshut;
#
# set ora_owner to the user id of the owner of the
# oracle database in ora_home.
ora_home=/u01/app/oracle
ora_owner=oracle
if [ ! -f $ora_home/bin/dbstart ]
 then
 echo "oracle startup: cannot start"
 exit
fi
case "$1" in 
'start')
# start the oracle databases:
echo "starting oracle databases ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %t %a %d : starting oracle databases as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ora_owner -c "$ora_home/bin/dbstart" >>/var/log/oracle
echo "done"

# start the listener:
echo "starting oracle listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %t %a %d : starting oracle listeners as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ora_owner -c "$ora_home/bin/lsnrctl start" >>/var/log/oracle
echo "done."
echo "-------------------------------------------------" >> /var/log/oracle
date +" %t %a %d : finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;

'stop')
# stop the oracle listener:
echo "stoping oracle listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %t %a %d : stoping oracle listener as part of system down." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ora_owner -c "$ora_home/bin/lsnrctl stop" >>/var/log/oracle
echo "done."
rm -f /var/lock/subsys/oracle

# stop the oracle database:
echo "stoping oracle databases ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %t %a %d : stoping oracle databases as part of system down." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ora_owner -c "$ora_home/bin/dbshut" >>/var/log/oracle
echo "done."
echo ""
echo "-------------------------------------------------" >> /var/log/oracle
date +" %t %a %d : finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
;;

'restart')
$0 stop
$0 start
;;
esac

5.3 添加服务

# chmod 755 /etc/init.d/oracle
# chkconfig --level 35 oracle on
# ln -s /etc/init.d/oracle /etc/rc0.d/k01oracle
# ln -s /etc/init.d/oracle /etc/rc6.d/k01oracle

5.4 测试启动和关闭 oracle

[root@oracle235 ~]# service oracle stop
stoping oracle listeners ... 
done.
stoping oracle databases ... 
done.

[root@oracle235 ~]# service oracle start
starting oracle databases ... 
done
starting oracle listeners ... 
done.

  本课程总共有 12 课;是给公司员工培训所编辑。未完待续...

上一篇:

下一篇: