CentOS7.7下安装Oracle11g数据库

目录

1、准备工作

1.1、虚拟机准备

1.2、系统环境准备

2、安装数据库

3、开始图形界面安装


1、准备工作

1.1、虚拟机准备

配置静态IP和主机名

#配置静态IP
#因为我这里的虚拟机网络模式是桥接模式,所以在配置的时候,一定要注意虚拟机的IP网段要你和主机保持#一致

#主机的IP可以通过运行命令:ipconfig /all 进行查询
[root@linux-oracle1 ~]# vim /etc/sysconfig/network-scripts/ifcfg-enp0s3

TYPE="Ethernet"
BOOTPROTO="static"
DEFROUTE="yes"
PEERDNS="yes"
PEERROUTES="yes"
IPADDR="192.168.100.88"
GATEWAY="192.168.100.1"
NETMASK="255.255.255.0"
DNS1="202.96.128.86"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="enp0s3"
UUID="41947f86-52f0-41d7-b5e1-767a77373e9e"
DEVICE="enp0s3"
ONBOOT="yes"

#以上是我的虚拟机配置,可以参考。GATEWAY、NETMASK及DNS1(为了能上网)这些和主机的默认网关、子#网掩码和DNS保持一次,只是IPADDR和主机做区分,例如我的主机IP为192.168.100.80,虚拟机的IP我这#里设置了192.168.100.88


#重启网络,让配置生效

[root@linux-oracle1 ~]# service network restart 
Restarting network (via systemctl):                        [  确定  ]

#这里静态IP就配置完成了!

#配置主机名

[root@Linux-init ~]# hostnamectl set-hostname 主机名

例如:hostnamectl set-hostname Linux-oracle1

退出后重新登录,就可以看到主机名已经生效

#配置hosts
[root@linux-oracle1 ~]# vim /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.100.88 Linux-oracle1

#把虚拟机IP和主机名的映射关系写在配置文件最后一行

1.2、系统环境准备

#关闭Selinux
[root@linux-oracle1 ~]# vim /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
# 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

#SELINUX参数由原来的enforcing改成disabled

#关闭防火墙

[root@linux-oracle1 ~]# systemctl stop firewalld.service
[root@linux-oracle1 ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

#优化系统内核
[root@linux-oracle1 ~]# vim /etc/sysctl.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.ip_local_port_range= 9000 65500
fs.file-max = 6815744
kernel.shmall = 10523004
kernel.shmmax = 6465333657
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default=262144
net.core.wmem_default=262144
net.core.rmem_max=4194304
net.core.wmem_max=1048576
fs.aio-max-nr = 1048576

[root@linux-oracle1 ~]# sysctl -p
net.ipv4.ip_local_port_range = 9000 65500
fs.file-max = 6815744
kernel.shmall = 10523004
kernel.shmmax = 6465333657
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576

2、安装数据库

#安装依赖
[root@linux-oracle1 ~]# yum -y install  gcc gcc-c++ make binutilscompat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-commonglibc-devel libaio libaio-devel libgcclibstdc++ libstdc++-devel unixODBC unixODBC-devel

#创建用户和组
[root@linux-oracle1 ~]# groupadd -g 200 oinstall
[root@linux-oracle1 ~]# groupadd -g 201 dba
[root@linux-oracle1 ~]# useradd -u 440 -g oinstall -G dba oracle
[root@linux-oracle1 ~]# passwd oracle
更改用户 oracle 的密码 。
新的 密码:
无效的密码: 密码包含用户名在某些地方
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。

#修改系统资源限制
[root@linux-oracle1 ~]# vim /etc/security/limits.conf #末尾添加如下
oracle  soft  nproc  2047
oracle  hard  nproc  16384
oracle  soft  nofile  1024
oracle  hard  nofile  65536

[root@linux-oracle1 ~]# vim /etc/pam.d/login
session    required    pam_namespace.so #在该行下面添加
session    required    pam_limits.so

#创建安装目录及设置权限
[root@linux-oracle1 ~]# mkdir /opt/oracle/app/ -p
[root@linux-oracle1 ~]# mkdir /opt/oracle/oradata/
[root@linux-oracle1 ~]# chmod 755 /opt/oracle/
[root@linux-oracle1 ~]# chmod 775 /opt/oracle/app/
[root@linux-oracle1 ~]# chown oracle.oinstall -R /opt/oracle/

#切换到Oracle用户,通过rz命令将安装介质上传到服务器。也可以通过其他软件(例如:winscp、sftp等)

#如果没有rz命令可以用root用户通过yum -y install lrzsz命令来安装

[root@linux-oracle1 ~]# su - oracle
[oracle@linux-oracle1 ~]$ cd /opt/oracle/
[oracle@linux-oracle1 oracle]$ rz

[oracle@linux-oracle1 oracle]$ ll
总用量 2487200
drwxrwxr-x. 2 oracle oinstall          6 1月  19 09:55 app
drwxr-xr-x. 2 oracle oinstall          6 1月  19 09:55 oradata
-rw-r--r--. 1 oracle oinstall 1395582860 10月 10 2016 p13390677_112040_Linux-x86-64_1of7.zip
-rw-r--r--. 1 oracle oinstall 1151304589 10月 10 2016 p13390677_112040_Linux-x86-64_2of7.zip

#解压
[oracle@linux-oracle1 oracle]$ unzip p13390677_112040_Linux-x86-64_1of7.zip
[oracle@linux-oracle1 oracle]$ unzip p13390677_112040_Linux-x86-64_2of7.zip

[oracle@linux-oracle1 oracle]$ ll
总用量 2487200
drwxrwxr-x. 2 oracle oinstall          6 1月  19 09:55 app
drwxr-xr-x. 7 oracle oinstall        136 8月  27 2013 database
drwxr-xr-x. 2 oracle oinstall          6 1月  19 09:55 oradata
-rw-r--r--. 1 oracle oinstall 1395582860 10月 10 2016 p13390677_112040_Linux-x86-64_1of7.zip
-rw-r--r--. 1 oracle oinstall 1151304589 10月 10 2016 p13390677_112040_Linux-x86-64_2of7.zip

#我们可以看到当前目录下生成了一个叫database的目录

#设置oracle环境变量,oracle用户下执行
[oracle@linux-oracle1 ~]$ vi ~/.bash_profile #末尾添加如下内容:
export ORACLE_BASE=/opt/oracle/app
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_PID=orcl
export ORACLE_SID=orcl

[oracle@linux-oracle1 ~]$ source ~/.bash_profile #立即生效

#掉图形界面开始安装
#安装xhost

[root@linux-oracle1 ~]# yum whatprovides "*/xhost"
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirror.bit.edu.cn
extras/7/x86_64/filelists_db                                                                                                                                      | 207 kB  00:00:00     
updates/7/x86_64/filelists_db                                                                                                                                     | 3.5 MB  00:00:02     
xorg-x11-server-utils-7.7-20.el7.x86_64 : X.Org X11 X server utilities
源    :base
匹配来源:
文件名    :/usr/bin/xhost



[root@linux-oracle1 ~]# yum install xorg-x11-server-utils-7.7-20.el7.x86_64 #安装的包名根据上一步执行结果不同而不同

#此时我们发现执行xhost + 命令还是有报错。如下:
[root@linux-oracle1 ~]# export DISPLAY=linux-oracle1:1
[root@linux-oracle1 ~]# xhost +
xhost:  unable to open display "linux-oracle1:1"

#我可以通过安装vnc服务来解决
[root@linux-oracle1 ~]# yum install tigervnc-server

#启动vnc服务
[root@linux-oracle1 ~]# vncserver

You will require a password to access your desktops.

Password:
Verify:
Would you like to enter a view-only password (y/n)? y
Password:
Verify:
xauth:  file /root/.Xauthority does not exist

New 'linux-oracle1:1 (root)' desktop is linux-oracle1:1

Creating default startup script /root/.vnc/xstartup
Creating default config /root/.vnc/config
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/linux-oracle1:1.log

#再次执行xhost +

[root@linux-oracle1 ~]# export DISPLAY=linux-oracle1:1
[root@linux-oracle1 ~]# xhost +
access control disabled, clients can connect from any host

#此时我们看到的输出结果就正常了。

#为了方便Xmanager调用图形界面。我们需要安装xterm
[root@linux-oracle1 ~]# yum install xterm

#通过Xmanager工具调用图形界面安装Oracle,打开套件中的Xstart,如下图所示:

红框所示的位置配置一定要添加:/usr/bin/xterm -ls -display $DISPLAY

然后点击运行。输入oracle用户的命令。效果如下图所示:

#在上图所在的页面再次执行xhost +

[root@linux-oracle1 ~]# export DISPLAY=linux-oracle1:1
[root@linux-oracle1 ~]# xhost +
access control disabled, clients can connect from any host

命令执行后的效果如下图:

此时,我们看到调出来的图形界面是乱码,如下图:

为了解决乱码问题。我们在安装前,需要加上字符集参数LANG=en.US。如下图:

3、开始图形界面安装

[root@linux-oracle1 ~]# yum install compat-libstdc++*

再次Check Again,其他可以忽略

遇到问题,进入命令行模式,更改

#修改配置
[oracle@linux-oracle1 ~]$ vim /home/oracle/app/oracle/product/11.2.0/dbhome_2/sysman/lib/ins_emagent.mk #注意你自己的配置文件路径,根据弹窗提示的目录去修改目录路径下的配置文件

在如图位置加上相关配置即可:

注意第一个是字母l,后面是两个数字1,保存退出后,回到安装页面点击Retry继续安装

用root用户执行上图所示路径下的两个脚本。

搞定!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章