第一步:到oracle官网上下载oracle12c的镜像文件

第二步:添加用户和组

用普通用户登录后,打开命令行工具(terminal)

转到root用户

[vmtest@localhost ~]$ su root

Password:

添加组

[root@localhost vmtest]# groupadd dba

添加用户

[root@localhost vmtest]# useradd oracle

将oracle用户分配给dba组

[root@localhost vmtest]# usermod -g dba oracle

为oracle用户设置密码

[root@localhost vmtest]# passwd oracle

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 vmtest]# tail /etc/group

gdm:x:42:

gnome-initial-setup:x:983:

avahi:x:70:

slocate:x:21:

sshd:x:74:

tcpdump:x:72:

oprofile:x:16:

vmtest:x:1000:vmtest

dba:x:1001:

oracle:x:1002:

[root@localhost vmtest]# tail /etc/passwd

nfsnobody:x:65534:65534:Anonymous NFSUser:/var/lib/nfs:/sbin/nologin

pulse:x:171:171:PulseAudio SystemDaemon:/var/run/pulse:/sbin/nologin

gdm:x:42:42::/var/lib/gdm:/sbin/nologin

gnome-initial-setup:x:988:983::/run/gnome-initial-setup/:/sbin/nologin

avahi:x:70:70:Avahi mDNS/DNS-SDStack:/var/run/avahi-daemon:/sbin/nologin

sshd:x:74:74:Privilege-separatedSSH:/var/empty/sshd:/sbin/nologin

tcpdump:x:72:72::/:/sbin/nologin

oprofile:x:16:16:Special user account to be used byOProfile:/var/lib/oprofile:/sbin/nologin

vmtest:x:1000:1000:vmtest:/home/vmtest:/bin/bash

oracle:x:1001:1001::/home/oracle:/bin/bash

第三步:创建安装目录

新建文件夹(软件目录)

[root@localhost vmtest]# mkdir -p /u01/app/oracle

将文件夹分配给用户oracle

[root@localhost vmtest]# chown oracle:dba /u01/app/oracle

设置文件夹权限

[root@localhost vmtest]# chmod 777 /u01/app/oracle

新建附属文件夹

[root@localhost vmtest]# mkdir /u01/app/oraInventory

[root@localhost vmtest]# chown oracle:dba /u01/app/oraInventory

[root@localhost vmtest]# chmod 775 /u01/app/oraInventory

验证刚才的操作

[root@localhost vmtest]# ls -l /u01/app

total 0

drwxrwxrwx. 2 oracle dba 6 Aug 2 07:52 oracle

drwxrwxr-x. 2 oracle dba 6 Aug 2 07:55 oraInventory

第四步:修改linux内核文件

打开/etc/sysctl.conf,

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

按键盘上i,进入插入模式,将红色那一段文字添加到文件末尾,按esc,然后输入:wq保存

# 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).

kernel.shmmax = 68719476736

kernel.shmall = 6029312

kernel.shmmni = 4096

kernel.sem =250 32000 100 128

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 262144

net.ipv4.ip_local_port_range =9000 65500

fs.file-max=65536

fs.aio-max-nr=1048576

~

~

"/etc/sysctl.conf" 55L, 794C written

修改limits文件

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

# /etc/security/limits.conf

#

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

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

#

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

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

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

#That means for example that setting a limit for wildcard domainhere

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

#subdirectory, but a user specific setting here can be overridenonly

#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,

#                 formaxlogin 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 - limitsthe core file size (KB)

#        - data - max data size (KB)

#        - fsize - maximumfilesize (KB)

#        - memlock - maxlocked-in-memory address space (KB)

#        - nofile - maxnumber of open file descriptors

#        - rss - maxresident set size (KB)

#        - stack - maxstack size (KB)

#        - cpu - max CPUtime (MIN)

#        - nproc - maxnumber of processes

#        - as - addressspace limit (KB)

#        - maxlogins - maxnumber of logins for this user

#        - maxsyslogins -max number of logins on the system

#        - priority - thepriority to run user process with

#        - locks - maxnumber of file locks the user can hold

#        - sigpending -max number of pending signals

#        - msgqueue - maxmemory used by POSIX message queues (bytes)

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

#        - rtprio - maxrealtime 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

# End of file

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft nofile 1024

oracle hard nofile 65536

oracle soft stack 10240

oracle hard stack 10240

"/etc/security/limits.conf" 84L, 2588C written

[root@localhost vmtest]# vi /etc/pam.d/login

#%PAM-1.0

auth [user_unknown=ignore success=ok ignore=ignore default=bad]pam_securetty.so

auth       substack     system-auth

auth       include      postlogin

account    required     pam_nologin.so

account    include      system-auth

password   include      system-auth

# pam_selinux.so close should be the first session rule

session    required     pam_selinux.so close

session    required     pam_loginuid.so

session    optional     pam_console.so

# pam_selinux.so open should only be followed by sessions to beexecuted in the user context

session    required     pam_selinux.so open

session    required     pam_namespace.so

session    optional     pam_keyinit.so force revoke

session    include      system-auth

session    include      postlogin

-session   optional     pam_ck_connector.so

session required /lib/security/pam_limits.so

session required pam_limits.so

~

"/etc/pam.d/login" 23L, 878C written

修改hosts

[root@localhost vmtest]# vi /etc/hosts

127.0.0.1   localhostlocalhost.localdomain localhost4 localhost4.localdomain4

::1         localhostlocalhost.localdomain localhost6 localhost6.localdomain6

192.168.189.128 localhost.localdomain //主机名

192.168.189.128 localhost

"/etc/hosts" 6L, 224C written

内核文件修改结束,重启电脑并以oracle用户登录

第五步:配置oracle用户下的概要文件

在oracle用户下,修改文件.bashrc,红色为需要添加的内容

[oracle@localhost ~]$ vi /home/oracle/.bashrc

# .bashrc

# Source global definitions

if [ -f /etc/bashrc ]; then

. /etc/bashrc

fi

# Uncomment the following line if you don't like systemctl'sauto-paging feature:

# export SYSTEMD_PAGER=

# User specific aliases and functions

umask 002

ORACLE_BASE=/u01/app/oracle      //oracle安装目录,与第三步创建的安装目录相同

export ORACLE_BASE

ORACLE_HOME=$ORACLE_BASE/product/12.2.0/dbhome_1   //oracle软件包目录

export ORACLE_HOME

ORACLE_SID=orcl

export ORACLE_SID

PATH=/usr/bin:/bin:usr/local/bin:/usr/bin/X11:/usr/bin/X11R6

PATH=$PATH:$ORACLE_HOME/bin

export PATH

export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

".bashrc" 37L, 515C written

.bash_profile环境变量设置

#vi .bash_profile

exportORACL_BASE=/u01/app/oracle         /*oracle安装目录*/
export ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1   /运行目录/

exportORACLE_SID=orcl                             /数据库实例名/

export PATH=$PATH:$ORACLE_HOME/bin      /sqlplus运行目录/

第六步:上传并解压oracle软件包

我用的是secureCRT远程工具,用secureCRT连接到linux服务器后,定位到想上传的文件夹

# cd /home/oracle/Downloads

# rz

输入rz,打开文件框,

找到要上传的文件,点击“add”,然后点击“OK”,开始上传

注:如果服务器安装的是centos,默认会带有rzsz工具,如果没有这个工具,在服务器上下载lrzsz软件包,安装上就行。

上传之后,解压文件

用命令行检查加压后的文件是否属于用户oracle

[oracle@localhost ~]$ cd /home/oracle/Downloads

[oracle@localhost Downloads]$ ls -l

total 4176512

drwxr-xr-x. 7 oracle dba       117 Jan 27  2017 database

-rw-r--r--. 1 oracle dba 3453696911 Jul 27 08:40linuxx64_12201_database.zip

第七步:安装oracle

定位到刚才解压的文件夹

# cd /home/oracle/Downloads/database

# ./runInstaller

等一会,安装程序启动

不注册,到下一步

选第二项:只安装数据库软件,(到后面进行手动配置)

这里两个路径是第五步中设置的ORACLE_BASE和ORACLE_HOME变量

这个路径是第三步建的第二个文件夹

到这一步,会有依赖项提示,解决依赖包问题会是比较麻烦的,我们选的centos7系统本身带的依赖包是比较全的,现在我们只解决划红线这一项,其他都忽略即可。

首先查一下与所需依赖包相关的其他包的版本号

# rpm –qa | grep libaio

Libaio-0.3.109-13.el7.x86_64

现在根据这个版本号,找libaio-devel-0.3.109-13.el7.x86_64这个rpm包(网上搜)

定位到上传的文件夹

$ cd /home/oracle/Downloads

显示所有文件

$ ls

切换到root账号下,安装文件

$ su root

Password:

$ rpm –ivh libaio-devel-0.3.109-13.el7.x86_64

重新检查依赖项,发现刚才那个警告没有了。

其他三项全部忽略,如果在安装过程中还报其他依赖项的错误,反过头来按照这个步骤安装相应依赖包。


等吧…

安装完成。

切换到root用户

运行 ./root.sh

# cd $ORACLE_HOME

# ./root.sh

Performing root user operation.

The following environment variables are set as:

ORACLE_OWNER= oracle

ORACLE_HOME=  /u01/app/oracle/product/12.2.0/dbhome_1

Enter the full pathname of the local bin directory:[/usr/local/bin]:

Copying dbhome to/usr/local/bin ...

Copying oraenv to/usr/local/bin ...

Copying coraenv to/usr/local/bin ...

Creating /etc/oratab file...

Entries will be added to the /etc/oratab file as needed by

Database Configuration Assistant when a database is created

Finished running generic part of root script.

Now product-specific root actions will be performed.

Do you want to setup Oracle Trace File Analyzer (TFA) now ?yes|[no] :

yes

Installing Oracle Trace File Analyzer (TFA).

Log File:/u01/app/oracle/product/12.2.0/dbhome_1/install/root_localhost.localdomain_2017-08-08_08-15-23-754009678.log

Finished installing Oracle Trace File Analyzer (TFA)

安装完成。

第八步:创建数据库

在命令行输入

# dbca

如果输入dbca没反应,那应该是第五步里的ORACLE_BASE和ORACLE_HOME环境变量设置错误。

等吧。。。

安装完成

第九步:配置监听(用于远程连接数据库)

在命令行输入netca

服务名与第五步里SID一致

修改配置文件

打开listener.ora

$ cd $ORACLE_HOME/network/admin

$ vi listener.ora

在文件末尾添加

SID_LIST_LISTENER=
  (SID_LIST=
      (SID_DESC=
                     #BEQUEATH CONFIG
         (GLOBAL_DBNAME=orcl)
         (SID_NAME=orcl)
        (ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1)
                     #PRESPAWN CONFIG
        (PRESPAWN_MAX=20)
        (PRESPAWN_LIST=
         (PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))
        )
       )
      )

保存,重启

第十步:启动数据库和监听

在命令行输入

$ sqlplus / as sysdba

启动数据库

SQL> startup

退出sql

Sql>exit

启动监听

$ lsnrctl start

OK,服务器和监听全部启动。

第十一步:其他设置

如果没有安装防火墙组件,先安装,指令如下

#yum install systemd
#yum install firewalld

关闭防火墙

# systemctl stop firewalld.service

关闭开机制动启动

# systemctl disable firewalld.service

如果客户端不是oracle12c,比如是oracle11g,需要修改文件(如果没有则新建):

$ORACLE_HOME/network/admin/sqlnet.ora,在该文件最后添加一行文字(不需重启oracle):

SQLNET.ALLOWED_LOGON_VERSION=8

在登录时,如果出现ORA-01017:用户名密码错误的信息,可能是由于oracle12c对用户名大小写敏感造成的,可以通过系统用户登录sqlplus

#sqlplus / as sysdba

并通过下列语句修改

sql> alter system set sec_case_sensitive_logon = false;

修改后如果还报用户名错误,那么在服务器端重新设置用户的密码,就可以了

Sql>alter user test1user identified by ****;

第十二步:测试远程连接

通过sqlplus创建表空间

SQL>  create tablespaceNOTIFYDB datafile '$ORACLE_BASE/oradata/orcl/test1.dbf' size 100M reuse autoextendon next 40M maxsize 1000M;

Tablespace created.

创建用户

SQL> create user test1user identified by test1pw defaulttablespace NOTIFYDB

2  ;

User created.

为用户授权

SQL> grant dba to test1user;

Grant succeeded.

SQL> grant connect,resource to test1user;

Grant succeeded.

SQL> grant select any table to test1user;

Grant succeeded.

SQL> grant delete any table to test1user;

Grant succeeded.

SQL> grant update any table to test1user;

Grant succeeded.

SQL> grant insert any table to test1user;

Grant succeeded.

通过plsql连接该表空间

成功。

最后一步:设置oracle数据库和监听程序开机自动启动。

切换到root用户

编辑文件/etc/oratab

[root@localhost dbhome_1]# vi /etc/oratab

#

# This file is used by ORACLE utilities.  It is created by root.sh

# and updated by either Database Configuration Assistant whilecreating

# a database or ASM Configuration Assistant while creating ASMinstance.

# A colon, ':', is used as the field terminator.  A new line terminates

# the entry.  Linesbeginning with a pound sign, '#', are comments.

#

# Entries are of the form:

#  $ORACLE_SID:$ORACLE_HOME:<N|Y>:

#

# The first and second fields are the system identifier and home

# directory of the database respectively.  The third field indicates

# to the dbstart utility that the database should ,"Y", or should not,

# "N", be brought up at system boot time.

#

# Multiple entries with the same $ORACLE_SID are not allowed.

#

#

orcl:/u01/app/oracle/product/12.2.0/dbhome_1:Y

添加上面最后一行文字,保存。

编辑文件rc.local并添加最后两行文字

[root@localhost dbhome_1]# vi /etc/rc.d/rc.local

su oracle -lc "/opt/oracle/102/bin/lsnrctl start"

#!/bin/bash

# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES

#

# It is highly advisable to create own systemd services or udevrules

# to run scripts during boot instead of using this file.

#

# In contrast to previous versions due to parallel executionduring boot

# this script will NOT be run after all other services.

#

# Please note that you must run 'chmod +x /etc/rc.d/rc.local' toensure

# that this script will be executed during boot.

touch /var/lock/subsys/local

su oracle -lc"/u01/app/oracle/product/12.2.0/dbhome_1/bin/lsnrctl start"

su oracle -lc/u01/app/oracle/product/12.2.0/dbhome_1/bin/dbstart

其中第一行因为lsnrctl之后有空格,需要引号,第二行加不加引号都可以。修改完保存退出即可。

但是还有一个很重要的问题,如果是在以前的centos版本中,这样就可以了。但是centos7 的/etc/rc.local不会开机执行,是因为

#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In constrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

翻译:

#这个文件是为了兼容性的问题而添加的。
#强烈建议创建自己的systemd服务或udev规则来在开机时运行脚本而不是使用这个文件。
#与以前的版本引导时的并行执行相比较,这个脚本将不会在其他所有的服务后执行。
#请记住,你必须执行“chmod +x /etc/rc.d/rc.local”来确保确保这个脚本在引导时执行。

好,现在执行指令

# chmod +x /etc/rc.d/rc.local

设置完成

重启

用指令lsnrctl status 看监听程序是否打开

登录sqlplus / as sysdba

如果显示

表示数据库已经启动,

如果现实:

Connect to an idle database

说明数据库没有启动

Linux(Centos7)安装oracle12c相关推荐

  1. Linux Centos7安装Oracle12c第二版本

    环境: CentOS7@VMware12,分配资源:CPU:2颗,内存:4GB,硬盘空间:30GB Oracle12C企业版64位 下载地址:http://www.oracle.com/technet ...

  2. LINUX CentOS7安装字体库

    LINUX CentOS7安装字体库 2017年12月26日 17:06:07 q260996583 阅读数:4866更多 个人分类: linux JAVA画图时常用到Font 类对象 这样的对象依赖 ...

  3. linux centos7 安装最新版git 教程

    2019独角兽企业重金招聘Python工程师标准>>> linux centos7 安装最新版git 教程 2018年08月22日 11:53:59 alisen169 阅读数:13 ...

  4. linux下scrapy安装教程,linux centos7安装scrapy

    linux centos7安装scrapy 时间:2018-01-02 17:41作者:scrapy中文网阅读: 本scrapy中文教程主要介绍,centos7 linux下scrapy的安装,pyt ...

  5. linux6.8 添加字体,linux CentOS7 安装字体库-转

    前言 报表中发现有中文乱码和中文字体不整齐(重叠)的情况,首先考虑的就是操作系统是否有中文字体,在CentOS 7中发现输入命令查看字体列表是提示命令无效: 如上图可以看出,不仅没有中文字体,连字体库 ...

  6. Linux编译安装qt5.9,Linux CentOS7 安装 Qt 5.9.2

    Linux CentOS7 安装 Qt 5.9.2 参考链接 http://doc.qt.io/qt-5/linux.html sudo yum groupinstall "C Develo ...

  7. linux centos7 安装beanstalk

    linux centos7 安装beanstalk 第一步 安装命令:yum install beanstalkd 第二步: 设置开机自启动命令:systemctl enable beanstalkd ...

  8. seafile安装教程 Linux,CentOS7安装seafile开源版

    CentOS7安装seafile开源版 1.安装环境及版本 本文基于CentOS Linux release 7.9系统进行安装, 2.安装docker 3.安装mysql 4.部署Seafile服务 ...

  9. Linux下安装Oracle12c图形化及静默两种方法安装操作手册

    首先确定服务器硬件条件 内存:大于2G 命令(free -g) 磁盘空间:100G 命令(df -h) 共享空间:大于等于2G 命令(df -h) 内核版本:64位 命令(uname -m) 注意:图 ...

  10. linux centos7 安装gc,Linux(Centos7)安装Java JDK及卸载

    步骤一.下载安装包 a.因为Java JDK区分32位和64位,所以安装之前需先判断一下我们操作系统为多少位,命令如下: uname -a 解释:如果有x86_64就是64位的,没有就是32位的.后面 ...

最新文章

  1. DDD领域驱动设计基本理论知识总结
  2. 【例题 6-6 UVA - 679】Dropping Balls
  3. 训练好的神经网络 如何预测_显存不够,如何训练大型神经网络?
  4. ACM试题 - 括号配对问题 - Java中字符串截取和定位问题
  5. C++虚基类成员可见性
  6. 正则表达式的一些规则
  7. 51单片机——硬件基础
  8. tablediff同步
  9. 对于java引用的总结
  10. 性能测试实战--计划测试(一)
  11. wildfly 21中应用程序的部署
  12. Zomm20210715
  13. 因果,稳定,无源,无损系统(1)
  14. 【python爬虫】爬取Bing词典的单词存到SQLite数据库
  15. 易基因|亮点研究:oxRRBS+RRBS揭示牦牛下丘脑在神经调节和髓鞘形成中的表观调控机制
  16. 道达尔远景光伏助力中天钢铁打造低碳绿色钢城
  17. html input光标位置,js控制input框内光标位置(setSelectionRange详解)
  18. ProxmoxVE 干掉 VMware
  19. Huawei U8825d 对4G手机内存重新分区过程[把2Gb内置SD卡容量划分给DATA分区使用]...
  20. 声学多普勒流速剖面仪_声学多普勒流速剖面仪(ADCP)的应用实例

热门文章

  1. 初中计算机学的动画,初中信息技术教案制作GIF动画
  2. 使用linux记事本的技巧
  3. 20款响应式bootstrap后台模板源码下载
  4. 使用天天模拟器运行安卓程序(AS)
  5. 极光一键登录PHP方法
  6. Adobe After Effects CC v2017安装教程
  7. 我曾经经常说NO,对不起 No.155
  8. 中国 地球科学相关数据共享平台 汇总(持续更新)
  9. 巴菲特的一些投资理念
  10. 突发!复旦大学一教师因工作关系怀恨在心,持刀杀害同事