RedHat7安装ORACLE11g步骤

http://www.cnblogs.com/muhehe/p/7816808.html
1.下载Oracle 11g,链接:https://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-linx8664soft-100572.html?ssSourceSiteId=otncn
linux.x64_11gR2_database_1of2.zip / linux.x64_11gR2_database_2of2.zip

2.创建运行oracle数据库的系统用户和用户组
[cindyma@localhost ~]$ su root  #切换到root
Password:
[root@localhost]# groupadd oinstall  #创建用户组oinstall
[root@localhost]# groupadd dba  #创建用户组dba
[root@localhost]# useradd -g oinstall -g dba -m oracle  #创建oracle用户,并加入到oinstall和dba用户组
[root@localhost]# passwd oracle  #设置用户oracle的登陆密码,不设置密码,在CentOS的图形登陆界面没法登陆
Changing password for user oracle.
New password:   # 密码
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:   # 确认密码
passwd: all authentication tokens updated successfully.
[root@localhost]# id oracle # 查看新建的oracle用户
uid=1001(oracle) gid=1002(dba) groups=1002(dba)

3.创建oracle数据库安装目录
[root@localhost]# cd /. #进入根目录
[root@localhost]# mkdir -p /data/oracle  #oracle数据库安装目录
[root@localhost]# mkdir -p /data/oraInventory  #oracle数据库配置文件目录
[root@localhost]# mkdir -p /data/database  #oracle数据库软件包解压目录
[root@localhost]# cd /data
[root@localhost data]# ls  #创建完毕检查一下(强迫症)
database oracle oraInventory
[root@localhost data]# chown -R oracle:oinstall /data/oracle  #设置目录所有者为oinstall用户组的oracle用户
[root@localhost data]# chown -R oracle:oinstall /data/oraInventory
[root@localhost data]# chown -R oracle:oinstall /data/database
[root@localhost data]#

4.(如果是centos系统,需要更改OS系统标识,Redhat不需要)
[root@localhost data]# cat /proc/version
Linux version 3.10.0-514.26.2.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Tue Jul 4 15:04:05 UTC 2017
[root@localhost data]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@localhost data]# vi /etc/redhat-release
[root@localhost data]# cat /etc/redhat-release
redhat-7

5.配置Redhat本地yum源
挂载DVD光盘到/mnt [root@ mnt]# mount /dev/cdrom /mnt
在目录/etc/yum.repos.d/创建文件 文件名.repo 
配置本地yum源
cd /etc/yum.repos.d/   #进入yum配置目录 
touch  rhel7.repo   #建立yum配置文件 
vim  rhel7.repo   #编辑配置文件,添加以下内容 
[rhel-yum]
name=rhel7   #自定义名称 
baseurl=file:///mnt#本地光盘挂载路径 
enabled=1   #启用yum源,0为不启用,1为启用 
gpgcheck=0  #检查GPG-KEY,0为不检查,1为检查 
:wq! #保存退出 
测试使用yum命令自动安装软件
yum clean all   #清除yum缓存 
yum makecache  #缓存本地yum源中的软件包信息

6.安装oracle数据库所需要的软件包
[root@localhost data]# yum -y install binutils* compat-libcap1* compat-libstdc++* gcc* gcc-c++* glibc* glibc-devel* ksh* libaio* libaio-devel* libgcc* libstdc++* libstdc+±devel* libXi* libXtst* make* sysstat* elfutils* unixODBC*

6.关闭防火墙
[root@localhost ~]# systemctl status firewalld.service #查看防火墙状态(运行中)
firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since 五 2018-11-23 10:46:17 CST; 4h 10min ago
Main PID: 1051 (firewalld)
CGroup: /system.slice/firewalld.service
└─1051 /usr/bin/python -Es /usr/sbin/firewalld --nofo…

11月 23 10:46:08 localhost.localdomain systemd[1]: Starting fir…
11月 23 10:46:17 localhost.localdomain systemd[1]: Started fire…
Hint: Some lines were ellipsized, use -l to show in full.

[root@localhost ~]# systemctl stop firewalld.service #关闭防火墙

[root@localhost ~]# systemctl status firewalld.service #已关闭
firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: inactive (dead) since 五 2018-11-23 14:59:00 CST; 29s ago
Main PID: 1051 (code=exited, status=0/SUCCESS)

11月 23 10:46:08 localhost.localdomain systemd[1]: Starting fir…
11月 23 10:46:17 localhost.localdomain systemd[1]: Started fire…
11月 23 14:58:58 localhost.localdomain systemd[1]: Stopping fir…
11月 23 14:59:00 localhost.localdomain systemd[1]: Stopped fire…
Hint: Some lines were ellipsized, use -l to show in full.

[root@localhost ~]# systemctl disable firewalld.service #禁止使用防火墙
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

7.关闭selinux(需重启生效)
[root@localhost data]# vi /etc/selinux/config
[root@localhost data]# cat /etc/selinux/config

This file controls the state of SELinux on the system.

SELINUX= can take one of these three values:

enforcing - SELinux security policy is enforced.

permissive - SELinux prints warnings instead of enforcing.

disabled - No SELinux policy is loaded.

SELINUX=disabled #此处修改为disabled

SELINUXTYPE= can take one of three two values:

targeted - Targeted processes are protected,

minimum - Modification of targeted policy. Only selected processes are protected.

mls - Multi Level Security protection.

SELINUXTYPE=targeted

8.修改内核参数(加入斜体部分)
[root@localhost ~]# vi /etc/sysctl.conf
[root@localhost ~]# cat /etc/stsctl.conf

sysctl settings are defined through files in

/usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.

Vendors settings live in /usr/lib/sysctl.d/.

To override a whole file, create a new file with the same in

/etc/sysctl.d/ and put new settings there. To override

only specific settings, add a file with a lexically later

name in /etc/sysctl.d/ and put new settings there.

For more information, see sysctl.conf(5) and sysctl.d(5).

net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.conf.all.rp_filter = 1
fs.file-max = 6815744 #设置最大打开文件数
fs.aio-max-nr = 1048576
kernel.shmall = 2097152 #共享内存的总量,8G内存设置:2097152*4k/1024/1024
kernel.shmmax = 2147483648 #最大共享内存的段大小
kernel.shmmni = 4096 #整个系统共享内存端的最大数
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500 #可使用的IPv4端口范围
net.core.rmem_default = 262144
net.core.rmem_max= 4194304
net.core.wmem_default= 262144
net.core.wmem_max= 1048576
9.使配置修改内核的参数生效
[root@localhost ~]# sysctl -p

10.对oracle用户设置限制,提高软件运行性能(斜体为添加部分)
[root@localhost ~]# vi /etc/security/limits.conf
[root@localhost ~]# cat /etc/security/limits.conf
在最下面部分添加内容(斜体为添加的内容)
@student - maxlogins 4
 
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
 
End of file

11.配置用户的环境变量(斜体部分为添加代码)
[root@localhost ~]# vi /home/oracle/.bash_profile
[root@localhost ~]# cat /home/oracle/.bash_profile

.bash_profile

Get the aliases and functions

if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

User specific environment and startup programs

PATH= P A T H : PATH: PATH:HOME/.local/bin:$HOME/bin

export PATH

export ORACLE_BASE=/data/oracle #oracle数据库安装目录
export ORACLE_HOME=KaTeX parse error: Expected 'EOF', got '#' at position 33: …ct/11.2.0/db_1 #̲oracle数据库路径 exp…ORACLE_HOME/bin:/usr/sbin:KaTeX parse error: Expected 'EOF', got '#' at position 6: PATH #̲添加系统环境变量 export…ORACLE_HOME/lib:/lib:/usr/lib #添加系统环境变量
export LANG=C #防止安装过程出现乱码
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK #设置Oracle客户端字符集,必须与Oracle安装时设置的字符集保持一致

12.使用户的环境变量配置立即生效
[root@localhost ~]# source /home/oracle/.bash_profile

13.将安装包移动到/usr/local/src路径下
14.重启系统,确保所有设置生效
[root@localhost Desktop]# reboot

15.从oracle用户进入/usr/local/src目录
[oracle@localhost /]$ cd /usr/local/src2
[oracle@localhost src]$ ls
linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip

16.解压两个软件包至/data/database/目录下
[oracle@localhost src]$ unzip linux.x64_11gR2_database_1of2.zip -d /data/database/
[oracle@localhost src]$ unzip linux.x64_11gR2_database_2of2.zip -d /data/database/

17.进入管理员权限,设置目录所有者为oinstall用户组的oracle用户,执行安装脚本

[oracle@localhost src]$ su root
Password:
[root@localhost src]# chown -R oracle:oinstall /data/database/database/
[oracle@localhost /]$ cd /data/database/database/
[oracle@localhost database]$ ls
doc install response rpm runInstaller sshsetup stage welcome.html
[oracle@localhost database]$ ./runInstaller
Starting Oracle Universal Installer…
(省略…)
17.1去掉I wish to receive security updates via My Oracle Surrport选项,点击Next。

17.2选择Install database software only,点击Next。

17.3,选择Single instance database installation,点击Next。

17.4在Available Languages中点选English、Simplified Chinese、Traditional Chinese,点击两个框中间的>,将选中的语言加入到右边的Selected Languages中,然后点击Next。

17.5按照实际情况,选择企业版本,如下图

17.6填写oracle的软件路径和基本路径,如下图:

17.7选择安装日志目录,如下图所示:

17.8选择dba组

17.9继续下一步安装操作

17.10安装完成

创建数据库
执行“dbca”命令

最后报错/etc/oratab is not accessible.
到控制台新建目录:
mkdir /etc/oratab
chown -R oracle.oinstall /etc/oratab
之后点击OK按钮,开始创建数据库

创建成功后进行验证
sqlplus “/ as sysdba”

你可能感兴趣的:(Linux,Oracle,运维,Redhat)