Linux安装oracle数据库

准备工作

oracle下载:【Oracle下载地址

比如我下面使用的就是这两个文件

安装Xmanager6工具

1、安装依赖包(中间部分日志省略)

[root@*** ~]# yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*.i686 elfutils-libelf-devel gcc gcc-c++ glibc*.i686 glibc 
Loaded plugins: fastestmirror, langpacks
base                                                                                                                                                                                                                                                   | 3.6 kB  00:00:00     
extras                                                                                                                                                                                                                                                 | 3.4 kB  00:00:00     
updates                                                                                                                                                                                                                                                | 3.4 kB  00:00:00     
(1/4): base/7/x86_64/group_gz                                                                                                                                                                                                                          | 166 kB  00:00:00     
(2/4): extras/7/x86_64/primary_db                                                                                                                                                                                                                      | 205 kB  00:00:00     
(3/4): updates/7/x86_64/primary_db                                                                                                                                                                                                                     | 6.4 MB  00:00:00     
(4/4): base/7/x86_64/primary_db                                
.
.
.
Dependency Updated:
  cpp.x86_64 0:4.8.5-36.el7_6.2          elfutils.x86_64 0:0.172-2.el7            elfutils-libelf.i686 0:0.172-2.el7  elfutils-libelf.x86_64 0:0.172-2.el7  elfutils-libs.i686 0:0.172-2.el7   elfutils-libs.x86_64 0:0.172-2.el7  glibc-common.x86_64 0:2.17-260.el7_6.5 
  glibc-devel.x86_64 0:2.17-260.el7_6.5  glibc-headers.x86_64 0:2.17-260.el7_6.5  libgcc.i686 0:4.8.5-36.el7_6.2      libgcc.x86_64 0:4.8.5-36.el7_6.2      libgomp.x86_64 0:4.8.5-36.el7_6.2  libstdc++.i686 0:4.8.5-36.el7_6.2   libstdc++.x86_64 0:4.8.5-36.el7_6.2    
  zlib.i686 0:1.2.7-18.el7               zlib.x86_64 0:1.2.7-18.el7              

Complete!

2、创建oracle用户和组

[root@*** ~]# groupadd dba
[root@*** ~]# groupadd oinstall 
[root@*** ~]# groupadd oper
[root@*** ~]# useradd -g oinstall -G dba,oper oracle
[root@*** ~]# echo "123456" | passwd --stdin oracle #oracle
Changing password for user oracle.
passwd: all authentication tokens updated successfully.

参数说明:

dba组用于管理数据库
oinstall组用于安装数据库
-g 表示这个用户的主组 
-G 标识这个用户的其它组

注意:dba、oinstall都可以自己命名;一个用户只能有一个主组,可以属于多个组。

3、创建目录,上传oracle文件,如果rz命令未安装,参考【Linux:-bash: rz: command not found

[root@*** ~]#  mkdir -p /opt/oracle/product/12/db
[root@*** ~]# cd /opt/oracle/
[root@*** oracle]# rz -e
[root@*** oracle]# ls
linuxamd64_12102_database_1of2.zip  linuxamd64_12102_database_2of2.zip  product

4、设置权限,将目录 /opt/oracle 中所有文件的所有者和组更改为用户 oracle 和组oinstall 

[root@*** oracle]# chown -R oracle:oinstall /opt/oracle/
You have new mail in /var/spool/mail/root
[root@*** oracle]# chmod -R 775 /opt/oracle

5、修改内核参数,sysctl -p使更改生效。

增加:

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4098955264
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 = 1048576
[root@*** oracle]# vi /etc/sysctl.conf
[root@*** oracle]# sysctl -p
net.ipv4.icmp_echo_ignore_broadcasts = 1
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4098955264
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 = 1048576

6、修改limits.conf,vi /etc/security/limits.conf,该文件修改即时生效,如果没有生效,重新登录即可。增加:

oracle soft nproc 2047  
oracle hard nproc 16384  
oracle soft nofile 1024  
oracle hard nofile 65536  
oracle soft stack 10240

修改文件,vi /etc/pam.d/login,增加:

session required pam_limits.so

7、修改profile文件:vi /etc/profile,Login shell 启动时才会运行 /etc/profile 这个脚本,该文件中设置的变量是全局变量。增加:

if [ $USER = "oracle" ]; then  
if [ $SHELL = "/bin/ksh" ]; then  
ulimit -p 16384  
ulimit -n 65536a  
else  
ulimit -u 16384 -n 65536  
fi  
fi

8、修改环境变量:vi ~oracle/.bash_profile,增加:

RACLE_BASE=/opt/oracle
ORACLE_HOME=$ORACLE_BASE/product/12/db      
ORACLE_SID=oracle
export ORACLE_BASE ORACLE_HOME ORACLE_SID
PATH=$ORACLE_HOME/bin:$PATH
export PATH

9、重启系统。

[root@*** oracle]# reboot

10、进入oracle目录,解压文件

[root@*** ~]# cd /opt/oracle
[root@*** oracle]# su oracle
[oracle@*** oracle]$ unzip linuxamd64_12102_database_1of2.zip 
.
.
.
[oracle@*** oracle]$ unzip linuxamd64_12102_database_2of2.zip
.
.
.

11、设置为英文字符集环境

[oracle@*** oracle]$ export LANG="en_US"

12、使用Xmanager添加Xstart,怎么样安装使用Xmanager6的教程可以直接在网上找。

执行命令:/usr/bin/xterm -ls -display $DISPLAY

 如果连接出现问题,参考:【Xmanager6运行错误

正常连接:

13、在Xstart窗口中运行以下命令

[root@*** ~]# cd /opt/oracle/database/
[root@*** database]# su oracle
[oracle@*** database]$ ls
install  response  rpm  runInstaller  sshsetup  stage  welcome.html
[oracle@*** database]$ ./runInstaller 
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 500 MB.   Actual 23974 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 4095 MB    Passed
Checking monitor: must be configured to display at least 256 colors.    Actual 16777216    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2019-07-25_10-48-31AM. Please wait ...[oracle@*** database]$ 

如果遇到Check if the DISPLAY variable is set错误,请参考:【Linux:Check if the DISPLAY variable is set.

14、进入安装页面,取消I wish...的选中,点击Next,弹出框直接选择Yes

 15、Installation Option(安装选项),我这里选择Install database software only

16、 Grid Installation Options(数据库安装选项),选择单机的就好了

17、Product Languages(产品语言),默认为English

 18、Database Edition(数据库版本)

19、 Installation Location(安装路径)

20、Create Inventory(创建库存)

默认路径出现错误,它是第4步分配权限导致的,解决办法:在路径中增加/oracle

21、 Operating System Groups(操作系统组)

22、Prerequis ite Checks(先决条件检查)

以上问题解决:

Swap Size解决方法

Linux:OS Kernel Parameters : shmmax

Linux:Package:ksh

Linux: Package:libaio-devel-0.3.109 (x86_64)

23、Summary(总结)

 24、Install Product(产品安装),Finish(完成)页直接点Close就可以了。

 

25、启动数据图形化界面装数据库

[oracle@*** database]$ dbca

 26、选择配置

 27、选择数据库模板

 28、配置数据库容器

29、配置Orale EM

 30、数据库账号密码设置,密码Oracle推荐的标准:长度至少应为8个字符,必须至少包含一个大写字符、一个小写字符和一个数字。

 31、监听器配置

 32、配置数据库存储方式

 33、数据库配置:示例方案和数据库安全配置

 34、初始化参数:内存、块、连接数量、字符集、连接模式

35、创建配置

36、校验通过,直接跳转Summary页面

37、Progress Page

 运行root.sh文件

Enter the full pathname of the local bin directory: [/usr/local/bin]:时,直接按Enter键

[root@*** ~]# cd /opt/oracle/product/12/db/
[root@*** db]# ls
addnode     bin    cfgtoollogs  css  dbs        demo         dv   install        javavm  jlib  log  network  odbc    opmn         ord  perl     precomp  racg      rest       slax          sqlpatch  suptools  usm  xdk
apex        ccr    clone        ctx  dc_ocm     diagnostics  has  instantclient  jdbc    ldap  md   nls      olap    oracore      oui  plsql    QOpatch  rdbms     root.sh    sqldeveloper  sqlplus   sysman    utl
assistants  cdata  crs          cv   deinstall  dmu          hs   inventory      jdk     lib   mgw  oc4j     OPatch  oraInst.loc  owm  plugins  R        relnotes  scheduler  sqlj          srvm      ucp       wwg
[root@*** db]# ./root.sh 
Performing root user operation.

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /opt/oracle/product/12/db

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.

 运行完root.sh后,点掉Database Configuration ...弹窗,最后的Finish点击Close。

启动与关闭

1)、切换用户

[root@*** oracle]# su - oracle
Last login: Thu Jul 25 22:42:14 CST 2019 from 40.76.65.78 on pts/0
Last failed login: Fri Jul 26 09:24:09 CST 2019 from 121.239.47.214 on ssh:notty
There were 7 failed login attempts since the last successful login.

2)、查看监听及数据库状态(HOST为oracle服务器ip,此处用星号代替)

[oracle@*** ~]$ lsnrctl status

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 26-JUL-2019 10:38:05

Copyright (c) 1991, 2014, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST= *.*.*.*)(PORT=1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused

3)、启动监听

[oracle@*** ~]$ lsnrctl start

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 26-JUL-2019 10:39:17

Copyright (c) 1991, 2014, Oracle.  All rights reserved.

Starting /opt/oracle/product/12/db/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.1.0.2.0 - Production
System parameter file is /opt/oracle/product/12/db/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/***/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=*.*.*.*)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=*.*.*.*)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date                26-JUL-2019 10:39:19
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /opt/oracle/product/12/db/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/***/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=*.*.*.*)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

4)、 以 DBA 身份进入 sqlplus

[oracle@*** ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Fri Jul 26 10:40:41 2019

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected.
SQL> 

5)、启动db

SQL> startup
ORACLE instance started.

Total System Global Area 2466250752 bytes
Fixed Size		    2927384 bytes
Variable Size		  671089896 bytes
Database Buffers	 1778384896 bytes
Redo Buffers		   13848576 bytes
Database mounted.
Database opened.

6)、关闭db,关闭需要一定时间,稍微耐心等待下。

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

 关闭db的其他命令及含义:

shutdown normal:不允许任何用户创建新的连接,等待已连接用户完成事务和会话后,生成检查点并关闭数据文件,启动时不需要实例恢复;

shutdown transactional:不允许任何用户创建新的连接,等待已连接用户完成事务,不等待会话结束,生成检查点并关闭数据文件,启动时不需要实例恢复;

shutdown immediate:不允许任何用户创建新的连接,已连接用户未提交的事务回滚,不等待会话结束,生成检查点并关闭数据文件,启动时不需要实例恢复;

shutdown abort:不允许任何用户创建新的连接,已连接用户未提交事务不回滚,不等待会话结束,不生成检查点,不关闭数据文件,启动时需要实例恢复,数据库异常时,以上3个命令不能关闭db时考虑使用这个命令。

根据不同需求使用不同命令关闭db。

7)、关闭监听

SQL> quit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
[oracle@*** ~]$ lsnrctl stop

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 26-JUL-2019 11:20:43

Copyright (c) 1991, 2014, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=*.*.*.*)(PORT=1521)))
The command completed successfully

以上就是Linux安装oracle数据库的步骤。

创建用户及连接,参考【Linux创建oracle用户、连接数据库

 

 

 

如果有写的不对的地方,请大家多多批评指正,非常感谢!

包涵以下版本的87个安装包: bind-libs-9.9.4-61.el7.x86_64.rpm bind-libs-lite-9.9.4-61.el7.x86_64.rpm bind-license-9.9.4-61.el7.noarch.rpm bind-utils-9.9.4-61.el7.x86_64.rpm compat-libcap1-1.10-7.el7.x86_64.rpm compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm cpp-4.8.5-28.0.1.el7_5.1.x86_64.rpm elfutils-libelf-devel-0.160-1.el7.i686.rpm elfutils-libelf-devel-0.160-1.el7.x86_64.rpm elfutils-libelf-devel-static-0.160-1.el7.i686.rpm elfutils-libelf-devel-static-0.160-1.el7.x86_64.rpm gcc-4.8.5-28.0.1.el7_5.1.x86_64.rpm gcc-c++-4.8.5-28.0.1.el7_5.1.x86_64.rpm glibc-2.17-222.el7.x86_64.rpm glibc-2.17-78.el7.i686.rpm glibc-2.17-78.el7.x86_64.rpm glibc-common-2.17-222.el7.x86_64.rpm glibc-devel-2.17-222.el7.x86_64.rpm glibc-devel-2.17-78.el7.i686.rpm glibc-devel-2.17-78.el7.x86_64.rpm glibc-headers-2.17-222.el7.x86_64.rpm gssproxy-0.7.0-17.el7.x86_64.rpm kernel-container-3.10.0-0.0.0.2.el7.x86_64.rpm kernel-headers-3.10.0-862.9.1.el7.x86_64.rpm keyutils-1.5.8-3.el7.x86_64.rpm ksh-20120801-137.0.1.el7.x86_64.rpm libaio-devel-0.3.109-13.el7.x86_64.rpm libbasicobjects-0.1.1-29.el7.x86_64.rpm libcollection-0.7.0-29.el7.x86_64.rpm libdmx-1.1.3-3.el7.x86_64.rpm libevent-2.0.21-4.el7.x86_64.rpm libgcc-4.8.5-28.0.1.el7_5.1.x86_64.rpm libgomp-4.8.5-28.0.1.el7_5.1.x86_64.rpm libICE-1.0.9-9.el7.x86_64.rpm libini_config-1.3.1-29.el7.x86_64.rpm libmpc-1.0.1-3.el7.x86_64.rpm libnfsidmap-0.25-19.el7.x86_64.rpm libpath_utils-0.2.1-29.el7.x86_64.rpm libref_array-0.1.5-29.el7.x86_64.rpm libselinux-2.5-12.0.1.el7.x86_64.rpm libselinux-python-2.5-12.0.1.el7.x86_64.rpm libselinux-utils-2.5-12.0.1.el7.x86_64.rpm libsepol-2.5-8.1.el7.x86_64.rpm libSM-1.2.2-2.el7.x86_64.rpm libstdc++-4.8.5-28.0.1.el7_5.1.x86_64.rpm libstdc++-devel-4.8.5-28.0.1.el7_5.1.x86_64.rpm libtirpc-0.2.4-0.10.el7.x86_64.rpm libverto-libevent-0.2.5-4.el7.x86_64.rpm libX11-1.6.5-1.el7.x86_64.rpm libX11-common-1.6.5-1.el7.noarch.rpm libXau-1.0.8-2.1.el7.x86_64.rpm libxcb-1.12-1.el7.x86_64.rpm libXext-1.3.3-3.el7.x86_64.rpm libXi-1.7.9-1.el7.x86_64.rpm libXinerama-1.1.3-2.1.el7.x86_64.rpm libXmu-1.1.2-2.el7.x86_64.rpm libXrandr-1.5.1-2.el7.x86_64.rpm libXrender-0.9.10-1.el7.x86_64.rpm libXt-1.1.5-3.el7.x86_64.rpm libXtst-1.2.3-1.el7.x86_64.rpm libXv-1.0.11-1.el7.x86_64.rpm libXxf86dga-1.1.4-2.1.el7.x86_64.rpm libXxf86misc-1.0.3-7.1.el7.x86_64.rpm libXxf86vm-1.1.4-1.el7.x86_64.rpm lm_sensors-libs-3.4.0-4.20160601gitf9185e5.el7.x86_64.rpm mailx-12.5-19.el7.x86_64.rpm mpfr-3.1.1-4.el7.x86_64.rpm net-tools-2.0-0.22.20131004git.el7.x86_64.rpm nfs-utils-1.3.0-0.54.0.1.el7.x86_64.rpm oracle-rdbms-server-11gR2-preinstall-1.0-5.el7.x86_64.rpm policycoreutils-2.5-22.0.1.el7.x86_64.rpm psmisc-22.20-15.el7.x86_64.rpm quota-4.01-17.el7.x86_64.rpm quota-nls-4.01-17.el7.noarch.rpm rpcbind-0.2.0-44.el7.x86_64.rpm selinux-policy-3.13.1-192.0.3.el7_5.4.noarch.rpm selinux-policy-targeted-3.13.1-192.0.3.el7_5.4.noarch.rpm smartmontools-6.5-1.el7.x86_64.rpm sysstat-10.1.5-13.el7.x86_64.rpm tcp_wrappers-7.6-77.el7.x86_64.rpm unixODBC-2.3.1-10.el7.i686.rpm unixODBC-2.3.1-10.el7.x86_64.rpm unixODBC-devel-2.3.1-10.el7.i686.rpm unixODBC-devel-2.3.1-10.el7.x86_64.rpm unzip-6.0-19.el7.x86_64.rpm xorg-x11-utils-7.5-22.el7.x86_64.rpm xorg-x11-xauth-1.0.9-1.el7.x86_64.rpm 安装方法直接输入: rpm -ivh *.rpm --nodeps --force
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值