linux系统(CentOS7)虚拟机上安装oracle 11g,解决oracle图形界面卡住无法点击next问题

学习orcale过程中,首先是环境的搭建,但是oracle在windows中安装容易,卸载难,所以想在虚拟机中进行安装数据库,并将虚拟机作为数据库和应用服务器,这里用的linux系统是CentOS-7,网上说是在redhat基础上进一步优化的版本。

安装过程中遇到很多问题,也是尝试5,6次最终才成功的,也是网上四处找资料,最终才成功,感谢各位前辈,本文章只为方便自己以后翻阅,趁还记得,把一些注意的点都列出来,尽量避免以后安装再走弯路。

一、环境准备

安装包:

1.VMware最新版,网上有注册码,搜索即可。

2.CentOS-7-x86_64-DVD-1511.iso

3.linux.x64_11gR2_database_1of2.zip

  linux.x64_11gR2_database_2of2.zip

4.用的过程中使用到SecureCRT和SecureFX

5.还用到Xmanager中的Xstart

以上觉得不是重点,不给下载地址,不描述安装过程,安装完CentOS 7,截图如下:

虚拟机安装简易安装GNOME桌面版本,跟上图一样,虚拟机安装CentOS后续单独把步骤写下来。

二、安装Oracle前准备

1.创建运行oracle数据库的系统用户和用户组

[sonny@localhost ~]$ su root  #切换到root(我安装时的密码是abc123,oracle用户密码后面设置的是oracle)

Password:

[root@localhost sonny]# groupadd oinstall  #创建用户组oinstall

[root@localhost sonny]# groupadd dba  #创建用户组dba

[root@localhost sonny]# useradd -g oinstall -g dba -m oracle  #创建oracle用户,并加入到oinstall和dba用户组

[root@localhost sonny]# passwd oracle  #设置用户oracle的登陆密码,不设置密码,在CentOS的图形登陆界面没法登陆

Changing password for user oracle.

New password:   # 密码(我设置为oracle)

BAD PASSWORD: The password is shorter than 8 characters

Retype new password:   # 确认密码

passwd: all authentication tokens updated successfully.

[root@localhost sonny]# id oracle # 查看新建的oracle用户

uid=1001(oracle) gid=1002(dba) groups=1002(dba)

[root@localhost sonny]#

为啥要创建oinstall用户组及dba组?这里可以暂不 ,有兴趣可以查看

 

#################################################

http://www.oracle.com/technetwork/cn/articles/hunter-rac11gr2-iscsi-2-092412-zhs.html#13

 参考理论上单例按照需要3种用户组,实际只建两个oinstall和dba,后面再安装oracle数据库的时候把OSOPER组也设置是dba组。

a.oracle 清单组(一般为oinstall):

 OINSTALL 组的成员被视为 Oracle 软件的“所有者”,拥有对 Oracle 中央清单 (oraInventory) 的写入权限。在一个 Linux 系统上首次安装 Oracle 软件时,
 OUI 会创建 /etc/oraInst.loc 文件。该文件指定 Oracle 清单组的名称(默认为 oinstall)以及 Oracle 中央清单目录的路径。

b.数据库管理员(OSDBA,一般为 dba):

 OSDBA 组的成员可通过操作系统身份验证使用 SQL 以 SYSDBA 身份连接到一个 Oracle 实例。该组的成员可执行关键的数据库管理任务,如创建数据库、启动和关
 闭实例。该组的默认名称为dba。SYSDBA 系统权限甚至在数据库未打开时也允许访问数据库实例。对此权限的控制完全超出了数据库本身的范围。不要混淆 SYSDBA
 系统权限与数据库角色 DBA。DBA 角色不包括 SYSDBA 或 SYSOPER 系统权限。

c.数据库操作员组(OSOPER,一般为 oper):

 OSOPER 组的成员可通过操作系统身份验证使用 SQL 以 SYSOPER 身份连接到一个 Oracle 实例。这个可选组的成员拥有一组有限的数据库管理权限,如管理和运行备份。
 该组的默认名称为oper。SYSOPER 系统权限甚至在数据库未打开时也允许访问数据库实例。对此权限的控制完全超出了数据库本身的范围。要使用该组,选择 Advanced 安装类型来安装 Oracle 数据库软件。
 

#################################################

 

2.创建oracle数据库安装目录

[sonny@localhost ~]$ su root

Password:

[root@localhost sonny]# mkdir -p /data/oracle  #oracle数据库安装目录

[root@localhost sonny]# mkdir -p /data/oraInventory  #oracle数据库配置文件目录

[root@localhost sonny]# mkdir -p /data/database  #oracle数据库软件包解压目录

[root@localhost sonny]# 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]#  

 

3.修改OS系统标识

 oracle默认不支持CentOS系统安装,(Oracle Database 11g Release 2 的 OS要求请百度)

 我安装是64位数据库,On Linux x86-64:Red Hat Enterprise Linux 7  (RHEL 7)

 另外,CentOS7.0.1511 基于 RHEL7.2  参考

 修改文件 /etc/RedHat-release 

[sonny@localhost data]$ su root

Password:

[root@localhost data]# cat /proc/version   #cat命令查询文件中内容,比较简单快捷。

Linux version 3.10.0-327.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Thu Nov 19 22:10:57 UTC 2015

[root@localhost data]# cat /etc/redhat-release  #这里cat文件查看系统标示为CentOS需要修改为redhat-7

CentOS Linux release 7.2.1511 (Core)

[root@localhost data]# vi /etc/redhat-release   

#这里修改文件,按i进行修改,删除第一行修改为redhat-7,按esc后输入  :wq 进行保存并退出

[root@localhost data]# cat /etc/redhat-release

redhat-7

[root@localhost data]#  

 

4.安装oracle数据库所需要的软件包

重复一遍,我安装时Oracle Database 11g Release 2 64位数据库。

Oracle Database Package Requirements for Linux x86-64 如下

参考:https://docs.oracle.com/cd/E11882_01/install.112/e47689/pre_install.htm#BABCFJFG

操作系统:Oracle Linux 7 and Red Hat Enterprise Linux 7

The following packages (or later versions) must be installed:

binutils-2.23.52.0.1-12.el7.x86_64

compat-libcap1-1.10-3.el7.x86_64

gcc-4.8.2-3.el7.x86_64

gcc-c++-4.8.2-3.el7.x86_64

glibc-2.17-36.el7.i686

glibc-2.17-36.el7.x86_64

glibc-devel-2.17-36.el7.i686

glibc-devel-2.17-36.el7.x86_64

ksh

libaio-0.3.109-9.el7.i686

libaio-0.3.109-9.el7.x86_64

libaio-devel-0.3.109-9.el7.i686

libaio-devel-0.3.109-9.el7.x86_64

libgcc-4.8.2-3.el7.i686

libgcc-4.8.2-3.el7.x86_64

libstdc++-4.8.2-3.el7.i686

libstdc++-4.8.2-3.el7.x86_64

libstdc++-devel-4.8.2-3.el7.i686

libstdc++-devel-4.8.2-3.el7.x86_64

libXi-1.7.2-1.el7.i686

libXi-1.7.2-1.el7.x86_64

libXtst-1.2.2-1.el7.i686

libXtst-1.2.2-1.el7.x86_64

make-3.82-19.el7.x86_64

sysstat-10.1.5-1.el7.x86_64 

最保险办法,一个一个的安装,命令也很简单,反正文档要求高版本也可以:

[sonny@localhost data]$ su root

Password:

[root@localhost data]# yum install binutils
省略...

如果觉得麻烦,复制下面语句执行:

yum install -y binutils compat-gcc* compat-glibc* compat-libcap1 compat-libstd* compat-libstdc++-33 compat-libstdc++-33.i686 compat-libstdc++-33*.i686 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-devel.i686 glibc-devel*.i686 glibc-headers glibc.i686 glibc*.i686 ksh libaio libaio-devel libaio-devel.i686 libaio-devel*.i686 libaio.i686 libaio*.i686 libgcc libgcc.i686 libgcc*.i686 libstdc++ libstdc++-devel libstdc++-devel*.i686 libstdc++.i686 libstdc++*.i686 libXp make numactl sysstat unixODBC unixODBC-devel unixODBC-devel*.i686 unixODBC*.i686

 

5.关闭防火墙 CentOS 7.2默认使用的是firewall作为防火墙

[sonny@localhost /]$ su root

Password:

[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 Thu 2016-04-07 18:54:29 PDT; 2h 20min ago

 Main PID: 802 (firewalld)

   CGroup: /system.slice/firewalld.service

           └─802 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

 

Apr 07 18:54:25 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...

Apr 07 18:54:29 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.

 

[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 Thu 2016-04-07 21:15:34 PDT; 9s ago

 Main PID: 802 (code=exited, status=0/SUCCESS)

 

Apr 07 18:54:25 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...

Apr 07 18:54:29 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.

Apr 07 21:15:33 localhost systemd[1]: Stopping firewalld - dynamic firewall daemon...

Apr 07 21:15:34 localhost systemd[1]: Stopped firewalld - dynamic firewall daemon.

 

[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.

 

[root@localhost /]#

 防火墙先禁用,搞好之后再配置,个人虚拟机,不用防火墙~~

 

6.关闭selinux(需重启生效)

[root@localhost /]# vi /etc/selinux/config

[root@localhost /]# 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

 

[root@localhost /]#

为啥要关闭selinux?因为selinux太高深,非专业人士搞不懂~~

 

7.修改内核参数

红色部分为添加代码

[sonny@localhost /]$ su root

Password:

[root@localhost /]# vi /etc/sysctl.conf

[root@localhost /]# cat /etc/sysctl.conf

# System default settings live in /usr/lib/sysctl.d/00-system.conf.

# To override those settings, enter new settings here, or in an /etc/sysctl.d/<name>.conf file

#

# 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

[root@localhost /]#

使配置参数生效

[root@localhost /]# sysctl -p

[root@localhost /]#  

 

8.对oracle用户设置限制,提高软件运行性能(红色为添加部分

[sonny@localhost /]$ su root

Password:

[root@localhost /]# vi /etc/security/limits.conf

[root@localhost /]# cat /etc/security/limits.conf

# /etc/security/limits.conf

#

#This file sets the resource limits for the users logged in via PAM.

#It does not affect resource limits of the system services.

#

#Also note that configuration files in /etc/security/limits.d directory,

#which are read in alphabetical order, override the settings in this

#file in case the domain is the same or more specific.

#That means for example that setting a limit for wildcard domain here

#can be overriden with a wildcard setting in a config file in the

#subdirectory, but a user specific setting here can be overriden only

#with a user specific setting in the subdirectory.

#

#Each line describes a limit for a user in the form:

#

#<domain>        <type>  <item>  <value>

#

#Where:

#<domain> can be:

#        - a user name

#        - a group name, with @group syntax

#        - the wildcard *, for default entry

#        - the wildcard %, can be also used with %group syntax,

#                 for maxlogin limit

#

#<type> can have the two values:

#        - "soft" for enforcing the soft limits

#        - "hard" for enforcing hard limits

#

#<item> can be one of the following:

#        - core - limits the core file size (KB)

#        - data - max data size (KB)

#        - fsize - maximum filesize (KB)

#        - memlock - max locked-in-memory address space (KB)

#        - nofile - max number of open file descriptors

#        - rss - max resident set size (KB)

#        - stack - max stack size (KB)

#        - cpu - max CPU time (MIN)

#        - nproc - max number of processes

#        - as - address space limit (KB)

#        - maxlogins - max number of logins for this user

#        - maxsyslogins - max number of logins on the system

#        - priority - the priority to run user process with

#        - locks - max number of file locks the user can hold

#        - sigpending - max number of pending signals

#        - msgqueue - max memory used by POSIX message queues (bytes)

#        - nice - max nice priority allowed to raise to values: [-20, 19]

#        - rtprio - max realtime priority

#

#<domain>      <type>  <item>         <value>

#

 

#*               soft    core            0

#*               hard    rss             10000

#@student        hard    nproc           20

#@faculty        soft    nproc           20

#@faculty        hard    nproc           50

#ftp             hard    nproc           0

#@student        -       maxlogins       4

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft nofile 1024

oracle hard nofile 65536

 

# End of file

[root@localhost /]#  

 

9.配置用户的环境变量(红色部分为添加代码)

[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=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

export ORACLE_BASE=/data/oracle                      #oracle数据库安装目录

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1   #oracle数据库路径

export ORACLE_SID=orcl                   #oracle启动数据库实例名

export ORACLE_TERM=xterm             #xterm窗口模式安装

export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH                  #添加系统环境变量

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib      #添加系统环境变量

export LANG=C               #防止安装过程出现乱码

export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK                #设置Oracle客户端字符集,必须与Oracle安装时设置的字符集保持一致,如:ZHS16GBK,否则出现数据导入导出中文乱码问题

 

[root@localhost /]#  

使上述配置立即生效:

[oracle@localhost /]$ su root

Password:

[root@localhost /]# source /home/oracle/.bash_profile

[root@localhost /]#

10.上述都搞定了,上传安装包我喜欢SecureFX,将oracle安装包上传到/usr/local/src

 

11.解压安装包(root用户权限)

[oracle@localhost /]$ cd /usr/local/src  #进入/usr/local/src目录

[oracle@localhost src]$ ls

linux.x64_11gR2_database_1of2.zip  linux.x64_11gR2_database_2of2.zip

[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/  #解压

(省略...)

[oracle@localhost src]$ su root

Password:

[root@localhost src]# chown -R oracle:oinstall /data/database/database/

[root@localhost src]#  

 

 

三、oracle安装,真正开始安装,前面都是为安装做的准备工作。

(0)前置(配置图形界面先决条件):

这里说明下,可能由于我安装的CentOS分辨率问题,导致oracle图形界面过程中的某些弹窗无法正常弹出

安装过程弹框界面是一个白色竖线一般,整个界面无法点击next按钮,最好的解决办法:这里推荐使用Xmanager工具中的Xstart。

Xstart使用的前提要求CentOS上安装了xterm

保持CentOS联网状态,以root用户登录,执行命令:yum install -y xterm

安装完毕后,启动Xstart,输入主机IP并用oracle用户登录,

输入命令:/usr/bin/xterm -ls -display $DISPLAY

点击运行后,以本机的图形界面弹出linux命令终端,在这个终端执行安装命令可正常处理弹窗问题。

2.启动oralce安装,到/data/database/database/目录下,执行runInstaller

为了避免安装过程出现乱码,执行之前,输入命令:export LANG=en_US.UTF-8

启动oracle安装:./runInstaller

 

(1)进入安装界面,如下图所示,去掉“I wish receive security via My Oracle Support”的勾选,单击“next”,选“yes”继续。

 (2)选中“Create and configure a database”,点击“next”

  (3)选中“DesktopClass”,点击“next”

 (4)这里如果安装前准备按照文档操作的话,这里只需填写passwrod即可(password都设置成orcl,无视警告),点击“next”

  (5)之后的配置一般都选择默认,当流转到这个界面时,选中Character sets选项,

 修改字符集为UTF-8后继续“next”

  (6)之后配置继续按照默认即可,当流转到这个界面时,可以为所有用户设置密码,我设置的abc123,点击“next”

   (6)流转到这个页面,如果之前安装依赖包会有下面图中包提示失败,一个一个检查package,在准备阶段中漏掉的,此处再安装,有些系统报错是因为现有的包的版本比检测要高,最后忽略即可。点击Check_Again 多检查几次

(7)之后点击next,Finish,开始执行安装,等待安装,安装过程会有个别报错,暂时忽略,弹出框中选择continue。

安装大概30分钟左右,等弹出这个页面时,点击Password Management(密码管理)按钮,进入密码管理页面,发现sys,system用户没有被勾选,说明是可用的,这里我将sys用户密码设置为sys,system用户密码设置为system。如果新手练习用,建议再放开两个用户Scott和Hr,分别设置密码为tiger和hr,保存后点击OK按钮。

(8)安装完成后,退出oracle账户,进入root账户。

在桌面单击右键,选择“在终端中打开”,输入:su - oracle

输入密码,切换到oracle用户。

启动监听:lsnrctl start #必须将监听启动,如果之前防火墙没关,还需要关闭防火墙。

输入:sqlplus /nolog

输入:conn sys/sys@orcl as sysdba

其中,orcl是实例名,sys是它的密码。如果出现下图所示的“Connected.”则连接成功,说明数据库建立成功(这里是在CentOS终端上使用的)。

如果在window使用SecureCRT等工具连接CentOS的可以

输入:sqlplus scott/tiger@192.168.78.130:1521/orcl ,回车(查询ip,使用ifconfig 命令)

查询当前用户:show user

查询用户下有几张表:select * from tab

查询表字段:desc emp ; #emp是表名

查询表数据:select * from emp

退出SQL命令模式exit;

 

#################################

如果使用的是SecureCRT,如果无法使用BackSpace和delete按钮

解决方法:

 先打开Options–>Session Options–>Terminal–>Emulation(中文:选项–>回话选项–>终端–>仿真) 界面下 :

1.终端(T):选择Linux,默认为VT100.

2.ANSI颜色(A)打上勾。

然后打开Options–>Session Options–>Terminal–>Emulation–>Mapped Keys(中文:选项–>回话选项–>终端–>仿真–>映射键)

选中复选框 (Backspace sends delete、  Delete sends backspace)

#################################

 

(9)、oracle的配置

1、创建表空间

打开终端,输入:su - oracle

输入密码:

输入:sqlplus “/as sysdba” (此处是用dba身份登录数据库,系统的超级用户)

创建临时表空间:

create temporary tablespace table_test tempfile '/data/oracle/table_test.dbf ' 点击Enter

size 1024m 点击Enter

autoextend on 点击Enter

next 100m maxsize 10240m 点击Enter

extent management local; 点击Enter

说明:

1) table_test是临时表空间的名字

2) /data/oracle/table_test.dbf是在/data/oracle下建一个名为table_test.dbf的表(注意:单引号为英文状态下的输入),

3) 1024m是表空间初始大小,

4) 100m是表空间自动增长大小,

5) 10240m是表空间最大的大小。

 

2、创建数据表空间

create tablespace data logging datafile '/data/oracle/data.dbf' 点击Enter

size 1024m 点击Enter

autoextend on 点击Enter

next 100m maxsize 10240m 点击Enter

extent management local; 点击Enter

3、创建用户并指定表空间

create user data identified by 123 default tablespace data temporary tablespacetable_test;

其中data为用户名,123为用户密码,table_test是临时表空间的名字。

4、给用户授予权限

grant dba to data;

至此,oracle在centos7下的安装和配置也就完成了,别人已经可以访问你的数据库了。

 

 

 

 

 

 

 

原文地址:https://www.cnblogs.com/nichoc/p/6416475.html