Oracl安装部署
一、前置条件准备
- 修改hostname:?hostname oracle
- 修改/etc/hosts:添加192.168.10.106 oracle
- 添加软件开发工具
- 搭建yum源
- mkdir /media/cdrom
- mount /dev/cdrom /media/cdrom
- vim /etc/yum.repo.d/rhel.repo
- 添加一下内容
[rhel-dvd-Server] # 名字
name = Red Hat Enterprise Linux x86 - Server # 注释
baseurl = file:///media/cdrom # 路径
enabled = 1 # 开启词yum源
gpgcheck =0 # key认证关闭
?
-
?执行代码
1 yum -y install binutils compat-libcap1 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel
?
- 修改内核文件
-
[[email?protected] ~]# vi /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4294967295
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
各参数详解:
1:kernel.shmmax:
是核心参数中最重要的参数之一,用于定义单个共享内存段的最大值。设置应该足够大,能在一个共享内存段下容纳下整个的SGA,设置的过低可能会导致需要创建多个共享内存段,这样可能导致系统性能的下降。至于导致系统下降的主要原因为在实例启动以及ServerProcess创建的时候,多个小的共享内存段可能会导致当时轻微的系统性能的降低(在启动的时候需要去创建多个虚拟地址段,在进程创建的时候要让进程对多个段进行“识别”,会有一些影响),但是其他时候都不会有影响。
官方建议值:
32位linux系统:可取最大值为4GB(4294967296bytes)-1byte,即4294967295。建议值为多于内存的一半,所以如果是32为系统,一般可取值为4294967295。32位系统对SGA大小有限制,所以SGA肯定可以包含在单个共享内存段中。
64位linux系统:可取的最大值为物理内存值-1byte,建议值为多于物理内存的一半,一般取值大于SGA_MAX_SIZE即可,可以取物理内存-1byte。例如,如果为12GB物理内存,可取12*1024*1024*1024-1=12884901887,SGA肯定会包含在单个共享内存段中。?
2:kernel.shmall:
??? 该参数控制可以使用的共享内存的总页数。Linux共享内存页大小为4KB,共享内存段的大小都是共享内存页大小的整数倍。一个共享内存段的最大大小是16G,那么需要共享内存页数是16GB/4KB=16777216KB /4KB=4194304(页),也就是64Bit系统下16GB物理内存,设置kernel.shmall = 4194304才符合要求(几乎是原来设置2097152的两倍)。这时可以将shmmax参数调整到16G了,同时可以修改SGA_MAX_SIZE和SGA_TARGET为12G(您想设置的SGA最大大小,当然也可以是2G~14G等,还要协调PGA参数及OS等其他内存使用,不能设置太满,比如16G)
3:kernel.shmmni:
该参数是共享内存段的最大数量。shmmni缺省值4096,一般肯定是够用了。
4:fs.file-max:
该参数决定了系统中所允许的文件句柄最大数目,文件句柄设置代表linux系统中可以打开的文件的数量。
5:fs.aio-max-nr:
??????此参数限制并发未完成的请求,应该设置避免I/O子系统故障。
6:kernel.sem:
以kernel.sem = 250 32000 100 128为例:
?????? 250是参数semmsl的值,表示一个信号量集合中能够包含的信号量最大数目。
?????? 32000是参数semmns的值,表示系统内可允许的信号量最大数目。
?????? 100是参数semopm的值,表示单个semopm()调用在一个信号量集合上可以执行的操作数量。
?????? 128是参数semmni的值,表示系统信号量集合总数。
7:net.ipv4.ip_local_port_range:
表示应用程序可使用的IPv4端口范围。
8:net.core.rmem_default:
表示套接字接收缓冲区大小的缺省值。
9:net.core.rmem_max:
表示套接字接收缓冲区大小的最大值。
10:net.core.wmem_default:
表示套接字发送缓冲区大小的缺省值。
11:net.core.wmem_max:
表示套接字发送缓冲区大小的最大值。
-
sysctl -p:重新加载内核文件
-
用户环境设置
-
创建用户
1 [[email?protected]e ~]# groupadd -g 500 oinstall
2 [[email?protected] ~]# groupadd -g 501 dba
3 [[email?protected] ~]# useradd -g oinstall -G dba oracle
4 [[email?protected] ~]# passwd oracle 设置密码(aptech)
5 [[email?protected] ~]# mkdir -p /u01/app/oracle
6 [[email?protected] ~]# chown -R oracle:oinstall /u01/app/
7 [[email?protected] ~]# chmod -R 775 /u01/app/
?
- 设置环境变量
[[email?protected] ~]#vi ~oracle/.bash_profile
添加以下内容:
umask=022
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/dbhome_1
export ORACLE_SID=orcl
export NLS_LANG="SIMPLIFIED CHINESE_CHINA".UTF8
export PATH=$ORACLE_HOME/bin:$PATH
export LANG=zh_CN.UTF-8
export DISPLAY=:0.0
注释:
en_US.UTF-8英文
export DISPLAY=:0.0
把oracle安装时的图形界面显示到指定机器的图形界面上去,本机安装就使用export DISPLAY=:0.0,如果需要在客户端远程连接到oracle服务器上安装,需要指定客户端的ip,
例如export DISPLAY=192.168.10.100:0.0,需要结合xhost +来授权使用图形界面
?
- source ~oracle/.bash_profile:重新加载
-
设置重启后或重启终端要加载的变量
1 [[email?protected] ~]#vi ~oracle/.bashrc 设置重启后或重启终端要加载的变量
2 在末尾添加
3 umask=022
4 export ORACLE_BASE=/u01/app/oracle
5 export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/dbhome_1
6 export ORACLE_SID=orcl
7 export NLS_LANG="SIMPLIFIED CHINESE_CHINA".UTF8
8 export PATH=$ORACLE_HOME/bin:$PATH
9 export LANG=zh_CN.UTF-8
10 export DISPLAY=:0.0
?
- source ~oracle/.bashrc :重新加载
-
用户资源限制调整
-
修改pam认证模块
1 [[email?protected] ~]# vi /etc/pam.d/login
2 在末尾添加以下两行:
3 session required /lib/security/pam_limits.so
4 session required pam_limits.so
5
6 [[email?protected] ~]# vi /etc/security/limits.conf
7 在末尾添加:
8 oracle soft nproc 2047
9 oracle hard nproc 16384
10 oracle soft nofile 1024
11 oracle hard nofile 65536
12 oracle soft stack 10240
?
- 配置全局环境变量
1 [[email?protected] ~]# vi /etc/profile
2 在末尾添加:
3
4 if [ $USER = "oracle" ]; then
5 if [ $SHELL = "/bin/ksh" ]; then
6 ulimit -p 16384
7 ulimit -n 65535
8 else
9 ulimit -u 16384 -n 65536
10 fi
11 fi
注释:
ulimit –p :设置管道缓冲区,K字节
ulimit –n :最大可打开文件数
ulimit –u:每个用户最大进程数
[[email?protected] ~]# source /etc/profile
?
?
二、
将所需的所有软件包拷贝到linux的/opt目录下
1:解压文件(解压后会有database文件夹)
[[email?protected] ~]# cd /opt
[[email?protected] opt]# unzip linuxx64_12201_database.zip
[[email?protected] opt]# ls database/
?
2:取消所有限制,并以oracle用户登录
在linux图形桌面打开终端
[[email?protected] ~]# xhost +
[[email?protected] ~]#su oracle
[[email?protected] ~]$
[[email?protected] ~]$ cd /opt/database/
[[email?protected] database]$ ./runInstaller
?
?
?
注释:
xhost +:允许其他用户启动的图形程序并将图形显示在当前屏幕上
?
?
3:按照安装向导进行安装,直到安装结束
?
当安装过程中弹出如下界面时,打开一个终端,输入提示的两个脚本并执行,执行后点确定
? ?
?
?
3:flash插件的安装
[[email?protected] database]# rpm –ivh flash-player-npapi-29.0.0.113-release.x86_64.rpm
?
4:安装完后重启系统,然后启动监听,启动oracle数据库(方法见后文)
?
5:用命令登陆以验证安装结果
[[email?protected] root]$ sqlplus sys/aptech AS SYSDBA
SQL>
?
6:用浏览器登陆EM平台
https://127.0.0.1:5500/em
?
7:解决命令行中上下键不能翻历史命令的问题
安装过程:
将软件拷贝到/root下
挂载光盘到/media/cdrom下
?
[[email?protected] ~]## yum -y install readline*
[[email?protected] ~]# cd /opt
[[email?protected] opt]# tar zxvf rlwrap-0.42.tar.gz
[[email?protected] opt]# cd rlwrap-0.42/
[[email?protected] rlwrap-0.42]# ./configure && make && make install
这样就可以使用 rlwarp 了
[[email?protected] rlwrap-0.42]# su oracle
[[email?protected] rlwrap-0.42]$ vi ~oracle/.bash_profile
[[email?protected] rlwrap-0.42]$ vi ~/.bashrc
在末尾添加
alias sqlplus=‘rlwrap sqlplus‘
alias rman=‘rlwrap rman‘
alias lsnrctl=‘rlwrap lsnrctl‘
?
保存退出
使文件立即生效
[[email?protected] opt]$ source ~oracle/.bash_profile
[[email?protected] rlwrap-0.42]$ source ~oracle/.bashrc
安装完rlwrap后,有些可能使用SecureCRT会再次出现乱码,这是修改一下SecureCRT的字符编码:
【选项】->【会话选项】->【终端】->【外观】+
?
8:数据库的启动
启动过程分为:启动实例、由实例装载数据库、打开数据库
SQL> startup nomount
只启动实例
?
SQL> startup mount
启动实例,并加载数据库,但不打开数据库
?
SQL> startup
启动实例、由实例装载数据库、打开数据库
?
SQL> alter database mount;
如果使用startup nomount启动实例,可以用此命令加载数据库,但不会启动数据库
?
SQL> alter database open;
如果当前处于数据库已加载状态,可以使用此命令打开数据库
?
9:关闭数据库
SQL> shutdown normal
等同于直接使用shutdown命令,
?
?
SQL> shutdown immediate
?
SQL> shutdown transactional
?
SQL> shutdown abort
?
10:启动与关闭监听
[[email?protected] ~]$ lsnrctl start
?
[[email?protected] ~]$ lsnrctl stop
?
?
[[email?protected] ~]$ lsnrctl
?
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 03-8月 -2018 05:08:52
?
Copyright (c) 1991,2016,Oracle. All rights reserved.
?
欢迎来到LSNRCTL,请键入"help"以获得信息。
?
LSNRCTL>
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|