GVKun编程网logo

oracle 的乐观锁和悲观锁(oracle乐观锁实例)

3

在本文中,我们将给您介绍关于oracle的乐观锁和悲观锁的详细内容,并且为您解答oracle乐观锁实例的相关问题,此外,我们还将为您提供关于Fororacledatabases,ifthetopsho

在本文中,我们将给您介绍关于oracle 的乐观锁和悲观锁的详细内容,并且为您解答oracle乐观锁实例的相关问题,此外,我们还将为您提供关于For oracle databases, if the top showing the oracle database, then oracle process is using the top c、How I Simplified Oracle Database 12c and 11g Installations on Oracle Linux 6、NodeJS-Oracle DB - NJS-040 连接超时,在 ICP 中使用带有 Lopback 的 oracle 驱动程序(loopback-connector-oracle)、Oracle 10g AND Oracle 11g手工建库案例--Oracle 11g的知识。

本文目录一览:

oracle 的乐观锁和悲观锁(oracle乐观锁实例)

oracle 的乐观锁和悲观锁(oracle乐观锁实例)

  • 一、问题引出

    ① 假设当当网上用户下单买了本书,这时数据库中有条订单号为 001 的订单,其中有个 status 字段是’有效’, 表示该订单是有效的;

    ② 后台管理人员查询到这条 001 的订单,并且看到状态是有效的;

    ③ 用户发现下单的时候下错了,于是撤销订单,假设运行这样一条 SQL: update order_table set status = ‘取消’ where order_id = 001;

    ④ 后台管理人员由于在②这步看到状态有效的,这时,虽然用户在③这步已经撤销了订单,可是管理人员并未刷新界面,看到的订单状态还是有效的,于是点击” 发货” 按钮,将该订单发到物流部门,同时运行类似如下 SQL,将订单状态改成已发货:update order_table set status = ‘已发货’ where order_id = 001;

    二、概念

    为了得到最大的性能,一般数据库都有并发机制,不过带来的问题就是数据访问的冲突。为了解决这个问题,大多数数据库的方法就是数据的锁定。

    悲观锁:对数据的冲突采取一种悲观的态度,也就是说假设数据肯定会冲突,所以在数据开始读取的时候就把数据锁定住。

    乐观锁:认为数据一般情况下不会造成冲突,所以在数据进行提交更新的时候,才会正式对数据的冲突与否进行检测,如果发现冲突了,则让用户返回错误的信息,让用户决定如何去做。

    脏读:当一个事务读取其他完成一半事务的记录时,就会发生脏读。例如:用户 A、B 看到的值都是 6,用户 B 把值改为 2,用户 A 督导的值仍为 6.

    丢失更新:一个事务的更新覆盖了其他事务的更新结果。例如:用户 A 把值从 6 改为 2,用户 B 把值从 2 改为 6,则用户 A 丢失了他的更新。

    上面场景就是典型的‘脏读’, 数据库的乐观锁做法和悲观锁做法主要就是解决上面场景并发的问题!!! 

    三、悲观锁

    SqlServer:数据的锁定通常采用页级锁的方式,也就是说对一张表内的数据是一种串行化的更新插入机制,在任何时间同一张表只会插 1 条数据,别的想插入的数据要等到这一条数据插完以后才能依次插入。带来的后果就是性能的降低,在多用户并发访问的时候,当对一张表进行频繁操作时,会发现响应效率很低,数据库经常处于一种假死状态。

    Oracle:用的是行级锁,只是对想锁定的数据才进行锁定,其余的数据不相干,所以在对 Oracle 表中并发插数据的时候,基本上不会有任何影响。

    悲观锁是对数据的冲突采取一种悲观的态度,假设数据肯定会冲突,在数据开始读取的时候就把数据锁定住。

    Oracle 的悲观锁需要利用一条现有的连接,分成两种方式,从 SQL 语句的区别来看,就是一种是 for update,一种是 for update nowait 的形式。

    ① 执行 select xxx for update 操作时,数据会被锁定,只有执行 comit 或 rollover 才会释放

    ② 执行 select xxx for update nowait 操作时,数据也会被锁定,其他人访问时或返回 ORA-00054 错误,内容是资源正忙,需要采取相应的业务措施进行处理。

    Oracle 中的悲观锁就是利用 Oracle 的 Connection 对数据进行锁定。在 Oracle 中,用这种行级锁带来的性能损失是很小的,只是要注意程序逻辑,不要给你一不小心搞成死锁了就好。而且由于数据的及时锁定,在数据提交时候就不呼出现冲突,可以省去很多恼人的数据冲突处理。缺点就是你必须要始终有一条数据库连接,就是说在整个锁定到最后放开锁的过程中,你的数据库连接要始终保持住。

    四、乐观锁

    乐观锁就是一开始假设不会造成数据冲突,在最后提交的时候再进行数据冲突检测。在乐观锁中,我们有 3 种常用的做法来实现:

    ①第一种就是在数据取得的时候把整个数据都 copy 到应用中,在进行提交的时候比对当前数据库中的数据和开始的时候更新前取得的数据。当发现两个数据一模一样以后,就表示没有冲突可以提交,否则则是并发冲突,需要去用业务逻辑进行解决。

    ②第二种乐观锁的做法就是采用版本戳,这个在 Hibernate 中得到了使用。采用版本戳的话,首先需要在你有乐观锁的数据库 table 上建立一个新的 column,比如为 number 型,当你数据每更新一次的时候,版本数就会往上增加 1。比如同样有 2 个 session 同样对某条数据进行操作。两者都取到当前的数据的版本号为 1,当第一个 session 进行数据更新后,在提交的时候查看到当前数据的版本还为 1,和自己一开始取到的版本相同。就正式提交,然后把版本号增加 1,这个时候当前数据的版本为 2。当第二个 session 也更新了数据提交的时候,发现数据库中版本为 2,和一开始这个 session 取到的版本号不一致,就知道别人更新过此条数据,这个时候再进行业务处理,比如整个 Transaction 都 Rollback 等等操作。在用版本戳的时候,可以在应用程序侧使用版本戳的验证,也可以在数据库侧采用 Trigger (触发器) 来进行验证。不过数据库的 Trigger 的性能开销还是比较的大,所以能在应用侧进行验证的话还是推荐不用 Trigger。

    ③第三种做法和第二种做法有点类似,就是也新增一个 Table 的 Column,不过这次这个 column 是采用 timestamp 型,存储数据最后更新的时间。在 Oracle9i 以后可以采用新的数据类型,也就是 timestamp with time zone 类型来做时间戳。这种 Timestamp 的数据精度在 Oracle 的时间类型中是最高的,精确到微秒 (还没与到纳秒的级别),一般来说,加上数据库处理时间和人的思考动作时间,微秒级别是非常非常够了,其实只要精确到毫秒甚至秒都应该没有什么问题。和刚才的版本戳类似,也是在更新提交的时候检查当前数据库中数据的时间戳和自己更新前取到的时间戳进行对比,如果一致则 OK,否则就是版本冲突。如果不想把代码写在程序中或者由于别的原因无法把代码写在现有的程序中,也可以把这个时间戳乐观锁逻辑写在 Trigger 或者存储过程中。

    五、结论

    ① 如果系统并发量不大且不允许脏读,可以使用悲观锁解决并发问题。

    ② 如果系统并发非常大的话,悲观锁会带来很大性能问题,所以一般采用乐观锁。

    六、参考资料

    [1] oracle 的乐观锁和悲观锁 http://www.blogjava.net/cheneyfree/archive/2008/01/25/177773.html

    [2] 乐观锁和悲观锁的区别 http://www.cnblogs.com/Bob-FD/p/3352216.html


For oracle databases, if the top showing the oracle database, then oracle process is using the top c

For oracle databases, if the top showing the oracle database, then oracle process is using the top c

Note 805586.1 Troubleshooting Session Administration (Doc ID 805586.1) Note 822527.1 How To Find Where The Memory Is Growing For A Process (Doc ID 822527.1) Note 273646.1 How to diagnose the high cpu utilization of ORACLE.EXE in Windows environment Note 728539.1 Find Blocking Sessions In sqlPLUS Note 61552.1 Troubleshooting Oracle Database Hanging Issues for versions from 7 to 9--Exhaustive Note 164760.1 Detecting and Resolving Locking Conflicts using TopSessions

How I Simplified Oracle Database 12c and 11g Installations on Oracle Linux 6

How I Simplified Oracle Database 12c and 11g Installations on Oracle Linux 6

How I Simplified Oracle Database 12c and 11g Installations on Oracle Linux 6

by Ginny Henningsen; updated by Michele Casey

How to simplify the installation of Oracle Database 12c or 11g on Oracle Linux 6 by installing the oracle-rdbms-server-12cR1-preinstall or oracle-rdbms-server-11gR2-preinstall RPM package, which automatically performs a number of tasks, such as installing required software packages, resolving package dependencies, and modifying kernel parameters.

 

Published September 2012 (updated September 2017)

READ THIS FIRST: Important Changes Since Publication

While the content in this article is still valid, several details have changed.  For example:

  • For Oracle Database 12c Release 2, the preinstall RPM has a different name than the one used in the article belowpu:
    • oracle-database-server-12cR2-preinstall
    • See also this documentation: Automatically Configuring Oracle Linux with Oracle Preinstallation RPM
  • The preinstall RPMs are published on Oracle Linux yum server for both Oracle Linux 6 and 7 in the Latest repositories which are configured and enabled by default in recent releases of Oracle Linux 6 and 7 


 

Introducing the oracle-rdbms-server-12cR1-preinstall and oracle-rdbms-server-11gR2-preinstall RPM for Oracle Linux

Before installing Oracle Database 12c or 11g on a system, you need to preconfigure the operating environment since the database requires certain software packages, package versions, and tweaks to kernel parameters. (Be sure to review the appropriate Oracle Database installation guide to familiarize yourself with hardware, software, and operating system requirements.)

Want to comment on this article? Post the link on Facebook''s OTN Garage page.  Have a similar article to share? Bring it up on Facebook or Twitter and let''s discuss.

Note: This article applies to Oracle Linux 6. A previous article, "How I Simplified Oracle Database Installation on Oracle Linux," covered performing a similar task on versions of Oracle Linux 5.

On Oracle Linux, I discovered that there is a remarkably easy way to address these installation prerequisites: First, depending on your database version, install either the RPM package called oracle-rdbms-server-12cR1-preinstall or oracle-rdbms-server-11gR2-preinstall. This RPM performs a number of preconfiguration steps, including the following:

  • Automatically downloading and installing any additional software packages and specific package versions needed for installing Oracle Grid Infrastructure and Oracle Database 12 c Release 1 (12.1) or 11g Release 2 (11.2.0.3), with package dependencies resolved via yum or up2date capabilities.
  • Creating the user oracle and the groups oinstall (for OraInventory) and dba (for OSDBA), which are used during database installation. (For security purposes, this user has no password by default and cannot log in remotely. To enable remote login, please set a password using the passwd tool.)
  • Modifying kernel parameters in /etc/sysctl.conf to change settings for shared memory, semaphores, the maximum number of file descriptors, and so on.
  • Setting hard and soft shell resource limits in /etc/security/limits.conf, such as the locked-in memory address space, the number of open files, the number of processes, and core file size.
  • Setting numa=off in the kernel for x86_64 machines.

Note that oracle-rdbms-server-12cR1-preinstall and oracle-rdbms-server-11gR2-preinstall parses the existing /etc/sysctl.conf and /etc/security/limits.conf files and updates values only as needed for database installation. Any precustomized settings not related to database installation are left as is.

The oracle-rdbms-server-12cR1-preinstall and oracle-rdbms-server-11gR2-preinstall RPM packages are accessible through the Oracle Unbreakable Linux Network (ULN, which requires a support contract), from the Oracle Linux distribution media, or from the Oracle public yum repository. Thus, whether or not your system is registered with ULN to access Oracle patches and support, you can use oracle-rdbms-server-12cR1-preinstall and oracle-rdbms-server-11gR2-preinstall to simplify database installation on Oracle Linux. In addition, the Oracle public yum repository now includes all security and bug errata, ensuring systems are secured and stable with the latest security updates and bug fixes.

Installing the oracle-rdbms-server-12cR1-preinstall or oracle-rdbms-server-11gR2-preinstall RPM

The remainder of this article steps through the procedure that I used for installing oracle-rdbms-server-11gR2-preinstall on Oracle Linux via the Oracle public yum repository. The same steps outlined in the following section can be used for either version of the preinstall RPM package. I started with a system running Oracle Linux Release 6 Update 4 for x86_64, a 64-bit version of Oracle Linux that I downloaded from the Oracle software delivery cloud (requires registration or login). First, I set up a yum configuration file that pointed to the correct repository, and then I installed the oracle-rdbms-server-11gR2-preinstall RPM from that repository.

Here are the steps for preconfiguring a system for Oracle Database installation using oracle-rdbms-server-11gR2-preinstall. Remember, the steps are the same when using the oracle-rdbms-server-12cR1-preinstall package; you simply need to change the name of the RPM package during the yum installation step.

  1. As an authorized user (for example, root), retrieve the file that configures repository locations:
     
    # cd /etc/yum.repos.d
    
    # wget http://yum.oracle.com/public-yum-ol6.repo
  2. Using a text editor, modify the file, changing the field enabled=0 to enabled=1 to reflect repositories that correspond to the machine''s operating system release.
     

    Here is an excerpt of public-yum-old6.repo with the changed lines in boldface.

    [ol6_latest]
    
    name=Oracle Linux $releasever Latest ($basearch)
    
    baseurl=http://yum.oracle.com/repo/OracleLinux/OL6/latest/$basearch/
    
    gpgkey=http://yum.oracle.com/RPM-GPG-KEY-oracle-ol6
    
    gpgcheck=1
    
    enabled=1
    
    
    
    
    
    [ol6_UEK_latest]
    
    name=Latest Unbreakable Enterprise Kernel for Oracle Linux $releasever ($basearch)
    
    baseurl=http://yum.oracle.com/repo/OracleLinux/OL6/UEK/latest/$basearch/
    
    gpgkey=http://yum.oracle.com/RPM-GPG-KEY-oracle-ol6
    
    gpgcheck=1
    
    enabled=1
     

    Because the target system is running Oracle Linux Release 6 Update 4 for x86_64, which installs the Oracle Unbreakable Enterprise Kernel by default, there are two repositories to enable, [ol6_latest] and [ol6_UEK_latest].

  3. Next, install the oracle-rdbms-server-11gR2-preinstall RPM using the yum install command. If you are using Oracle Database 12c, then you would type yum install.
     

    The output in Listing 1 shows how the installation checks dependencies and then downloads and installs the required packages.

    # yum install oracle-rdbms-server-11gR2-preinstall
    
    Loaded plugins: refresh-packagekit, rhnplugin, security
    
    Setting up Install Process
    
    Resolving Dependencies
    
    --> Running transaction check
    
    ---> Package oracle-rdbms-server-11gR2-preinstall.x86_64 0:1.0-6.el6 will be installed
    
    --> Processing Dependency: gcc-c++ for package: oracle-rdbms-server-11gR2-preinstall-1.0-6.el6.x86_64
    
    --> Processing Dependency: gcc for package: oracle-rdbms-server-11gR2-preinstall-1.0-6.el6.x86_64
    
    --> Processing Dependency: libaio-devel for package: oracle-rdbms-server-11gR2-preinstall-1.0-6.el6.x86_64
    
    --> Processing Dependency: libstdc++-devel for package: oracle-rdbms-server-11gR2-preinstall-1.0-6.el6.x86_64
    
    --> Processing Dependency: glibc-devel for package: oracle-rdbms-server-11gR2-preinstall-1.0-6.el6.x86_64
    
    --> Processing Dependency: compat-libstdc++-33 for package: oracle-rdbms-server-11gR2-preinstall-1.0-6.el6.x86_64
    
    --> Processing Dependency: ksh for package: oracle-rdbms-server-11gR2-preinstall-1.0-6.el6.x86_64
    
    --> Processing Dependency: compat-libcap1 for package: oracle-rdbms-server-11gR2-preinstall-1.0-6.el6.x86_64
    
    --> Running transaction check
    
    ---> Package compat-libcap1.x86_64 0:1.10-1 will be installed
    
    ---> Package compat-libstdc++-33.x86_64 0:3.2.3-69.el6 will be installed
    
    ---> Package gcc.x86_64 0:4.4.6-4.el6 will be installed
    
    --> Processing Dependency: cpp = 4.4.6-4.el6 for package: gcc-4.4.6-4.el6.x86_64
    
    --> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.6-4.el6.x86_64
    
    ---> Package gcc-c++.x86_64 0:4.4.6-4.el6 will be installed
    
    --> Processing Dependency: libmpfr.so.1()(64bit) for package: gcc-c++-4.4.6-4.el6.x86_64
    
    ---> Package glibc-devel.x86_64 0:2.12-1.80.el6_3.4 will be installed
    
    --> Processing Dependency: glibc-headers = 2.12-1.80.el6_3.4 for package: glibc-devel-2.12-1.80.el6_3.4.x86_64
    
    --> Processing Dependency: glibc-headers for package: glibc-devel-2.12-1.80.el6_3.4.x86_64
    
    ---> Package ksh.x86_64 0:20100621-16.el6 will be installed
    
    ---> Package libaio-devel.x86_64 0:0.3.107-10.el6 will be installed
    
    ---> Package libstdc++-devel.x86_64 0:4.4.6-4.el6 will be installed
    
    --> Running transaction check
    
    ---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed
    
    --> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
    
    --> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
    
    ---> Package cpp.x86_64 0:4.4.6-4.el6 will be installed
    
    ---> Package glibc-headers.x86_64 0:2.12-1.80.el6_3.4 will be installed
    
    --> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.12-1.80.el6_3.4.x86_64
    
    --> Processing Dependency: kernel-headers for package: glibc-headers-2.12-1.80.el6_3.4.x86_64
    
    ---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed
    
    --> Running transaction check
    
    ---> Package kernel-uek-headers.x86_64 0:2.6.32-300.32.1.el6uek will be installed
    
    ---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed
    
    --> Finished Dependency Resolution
    
    
    
    Dependencies Resolved
    
    
    
    ================================================================================
    
     Package                         Arch   Version                Repository  Size
    
    ================================================================================
    
    Installing:
    
     oracle-rdbms-server-11gR2-preinstall
    
                                     x86_64 1.0-6.el6              ol6_latest  15 k
    
    Installing for dependencies:
    
     cloog-ppl                       x86_64 0.15.7-1.2.el6         ol6_latest  93 k
    
     compat-libcap1                  x86_64 1.10-1                 ol6_latest  17 k
    
     compat-libstdc++-33             x86_64 3.2.3-69.el6           ol6_latest 183 k
    
     cpp                             x86_64 4.4.6-4.el6            ol6_latest 3.7 M
    
     gcc                             x86_64 4.4.6-4.el6            ol6_latest  10 M
    
     gcc-c++                         x86_64 4.4.6-4.el6            ol6_latest 4.7 M
    
     glibc-devel                     x86_64 2.12-1.80.el6_3.4      ol6_latest 970 k
    
     glibc-headers                   x86_64 2.12-1.80.el6_3.4      ol6_latest 600 k
    
     kernel-uek-headers              x86_64 2.6.32-300.32.1.el6uek ol6_latest 713 k
    
     ksh                             x86_64 20100621-16.el6        ol6_latest 684 k
    
     libaio-devel                    x86_64 0.3.107-10.el6         ol6_latest  13 k
    
     libstdc++-devel                 x86_64 4.4.6-4.el6            ol6_latest 1.5 M
    
     mpfr                            x86_64 2.4.1-6.el6            ol6_latest 156 k
    
     ppl                             x86_64 0.10.2-11.el6          ol6_latest 1.3 M
    
    
    
    Transaction Summary
    
    ================================================================================
    
    Install      15 Package(s)
    
    
    
    Total download size: 25 M
    
    Installed size: 61 M
    
    Is this ok [y/N]: Downloading Packages:
    
    --------------------------------------------------------------------------------
    
    Total                                           710 kB/s |  25 MB     00:35     
    
    Running rpm_check_debug
    
    Running Transaction Test
    
    Transaction Test Succeeded
    
    Running Transaction
    
    
    
      Installing : mpfr-2.4.1-6.el6.x86_64                                     1/15 
    
      Installing : libstdc++-devel-4.4.6-4.el6.x86_64                          2/15 
    
      Installing : cpp-4.4.6-4.el6.x86_64                                      3/15 
    
      Installing : ppl-0.10.2-11.el6.x86_64                                    4/15 
    
      Installing : cloog-ppl-0.15.7-1.2.el6.x86_64                             5/15 
    
      Installing : kernel-uek-headers-2.6.32-300.32.1.el6uek.x86_64            6/15 
    
      Installing : glibc-headers-2.12-1.80.el6_3.4.x86_64                      7/15 
    
      Installing : glibc-devel-2.12-1.80.el6_3.4.x86_64                        8/15 
    
      Installing : gcc-4.4.6-4.el6.x86_64                                      9/15 
    
      Installing : gcc-c++-4.4.6-4.el6.x86_64                                 10/15 
    
      Installing : compat-libstdc++-33-3.2.3-69.el6.x86_64                    11/15 
    
      Installing : libaio-devel-0.3.107-10.el6.x86_64                         12/15 
    
      Installing : ksh-20100621-16.el6.x86_64                                 13/15 
    
      Installing : compat-libcap1-1.10-1.x86_64                               14/15 
    
    
    
      Installing : oracle-rdbms-server-11gR2-preinstall-1.0-6.el6.x86_64      15/15 
    
      Verifying  : gcc-4.4.6-4.el6.x86_64                                      1/15
    
      Verifying  : compat-libcap1-1.10-1.x86_64                                2/15 
    
      Verifying  : ksh-20100621-16.el6.x86_64                                  3/15 
    
      Verifying  : glibc-devel-2.12-1.80.el6_3.4.x86_64                        4/15 
    
      Verifying  : libaio-devel-0.3.107-10.el6.x86_64                          5/15 
    
      Verifying  : oracle-rdbms-server-11gR2-preinstall-1.0-6.el6.x86_64       6/15 
    
      Verifying  : gcc-c++-4.4.6-4.el6.x86_64                                  7/15 
    
      Verifying  : glibc-headers-2.12-1.80.el6_3.4.x86_64                      8/15 
    
      Verifying  : libstdc++-devel-4.4.6-4.el6.x86_64                          9/15 
    
      Verifying  : compat-libstdc++-33-3.2.3-69.el6.x86_64                    10/15 
    
      Verifying  : mpfr-2.4.1-6.el6.x86_64                                    11/15 
    
      Verifying  : kernel-uek-headers-2.6.32-300.32.1.el6uek.x86_64           12/15 
    
      Verifying  : cpp-4.4.6-4.el6.x86_64                                     13/15 
    
      Verifying  : ppl-0.10.2-11.el6.x86_64                                   14/15 
    
      Verifying  : cloog-ppl-0.15.7-1.2.el6.x86_64                            15/15 
    
    
    
    Installed:
    
      oracle-rdbms-server-11gR2-preinstall.x86_64 0:1.0-6.el6                       
    
    
    
    Dependency Installed:
    
      cloog-ppl.x86_64 0:0.15.7-1.2.el6                                             
    
      compat-libcap1.x86_64 0:1.10-1                                                
    
      compat-libstdc++-33.x86_64 0:3.2.3-69.el6                                     
    
      cpp.x86_64 0:4.4.6-4.el6                                                      
    
      gcc.x86_64 0:4.4.6-4.el6                                                      
    
      gcc-c++.x86_64 0:4.4.6-4.el6                                                  
    
      glibc-devel.x86_64 0:2.12-1.80.el6_3.4                                        
    
      glibc-headers.x86_64 0:2.12-1.80.el6_3.4                                      
    
      kernel-uek-headers.x86_64 0:2.6.32-300.32.1.el6uek                            
    
      ksh.x86_64 0:20100621-16.el6                                                  
    
      libaio-devel.x86_64 0:0.3.107-10.el6                                          
    
      libstdc++-devel.x86_64 0:4.4.6-4.el6                                          
    
      mpfr.x86_64 0:2.4.1-6.el6                                                     
    
      ppl.x86_64 0:0.10.2-11.el6                                                    
    
    
    
    Complete!

    Listing 1: Installing the oracle-rdbms-server-11gR2-preinstall RPM

    The yum installation logs messages about kernel changes in the file /var/log/oracle-rdbms-server-11gR2-preinstall/results/orakernel.log, and it makes backups of current system settings in the directory /var/log/oracle-rdbms-server-11gR2-preinstall/backup.

  4. At this point, the system is ready for the installation of Oracle Database. For example, to install Oracle Database 11g Release 2, follow the directions in Chapter 4, "Installing Oracle Database," of the Database Installation Guide for Linux."
     

    Here are the steps I followed while installing Oracle Database 11g Release 2 in my test environment. Make sure you review all documentation and follow recommended best practices before installing into your production environment.

    1. As root, create a parent directory in a file system that has sufficient space to be the target location for the downloaded files:
       
      # mkdir /home/OraDB11g
      
      # cd /home/OraDB11g
       

      The amount of disk space needed in the file system varies according to the specific installation type, but roughly twice the size of the zip archives, or 5 GB, is enough to house the software and data files.

    2. Into this target directory, download the installation media files from the Oracle Database Software Downloads page on Oracle Technology Network.
    3. Extract the files:
       
      # unzip linux.x64_11gR2_database_1of2.zip
      
      # unzip linux.x64_11gR2_database_2of2.zip 
    4. Log in as the user oracle. Change directory to the database directory and enter the following command to run the Oracle Universal Installer:
       
      $ cd /home/OraDB11g/database
      
      $ ./runInstaller

    The Oracle Universal Installer performs a number of checks, verifying that the necessary OS packages and versions are installed. In addition, it checks kernel parameters set by the oracle-rdbms-server-11gR2-preinstall installation. During the kernel settings check, the installer might flag a few settings as "failed," and you should investigate these failures. In some cases, you still might be able to continue with the database installation. If you check kernel settings in /etc/sysctl.conf, you''ll see that oracle-rdbms-server-11gR2-preinstall has modified and added the necessary settings to ensure the minimum requirements are met, as defined in section 2.10.1, "Displaying and Changing Kernel Parameter Values," in Chapter 2, "Oracle Database Preinstallation Requirements," of the Oracle Database Installation Guide 11g Release2 (11.2) for Linux. Below is the list of requirements:

    fs.aio-max-nr = 1048576
    
    fs.file-max = 6815744
    
    kernel.shmall = 2097152
    
    kernel.shmmax = 4294967295
    
    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
     

    If necessary, you can (as root) edit the file /etc/sysctl.conf to specify a setting manually, for example:

    # vi /etc/sysctl.conf 
    
    # /sbin/sysctl -p
     

    The Oracle Universal Installer performs additional checks, such as verifying the glibc version, sufficient disk space, environmental variable and path settings, and sufficient physical memory and swap space. Generally, installing oracle-rdbms-server-11gR2-preinstall takes care of the prerequisites so that you can proceed directly with installing the database.

Final Thoughts

Installing the oracle-rdbms-server-12cR1-preinstall and oracle-rdbms-server-11gR2-preinstall RPMs can save time when installing Oracle Database 12c and 11g on Oracle Linux. These RPMs address most Oracle Database installation prerequisites and greatly simplify the installation process.

See Also

Here are the resources referenced earlier in this document:

  • Oracle Unbreakable Linux Network: https://linux.oracle.com
  • Oracle Linux yum server: http://yum.oracle.com/
  • Oracle software delivery cloud (requires registration or login): https://edelivery.oracle.com/linux
  • Chapter 4, "Installing Oracle Database," of the Database Installation Guide for Linux: http://docs.oracle.com/cd/E11882_01/install.112/e24321/inst_task.htm#BABBBHJH
  • Oracle Database Software Downloads page on Oracle Technology Network: http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html

And here are some additional resources from the Oracle Database Documentation Library (http://www.oracle.com/pls/db112/homepage). Relevant subsections from the Oracle Database Installation Guide 11g Release 2 (11.2) for Linux (http://download.oracle.com/docs/cd/E11882_01/install.112/e16763/toc.htm) with currently valid URLs are as follows:

  • "About the Oracle RDBMS Pre-Install and Oracle Validated RPMs" from Chapter 1, "Overview of Oracle Database Installation": http://download.oracle.com/docs/cd/E11882_01/install.112/e16763/install_overview.htm#BABDBHCJ
  • Chapter 2, "Oracle Database Preinstallation Requirements": http://download.oracle.com/docs/cd/E11882_01/install.112/e16763/pre_install.htm#BABFDGHJ
  • "Downloading Oracle Software" from Chapter 4, "Installing Oracle Database," which describes how to download installation files from the Oracle Technology Network Website: http://docs.oracle.com/cd/E11882_01/install.112/e16763/inst_task.htm#autoId6

Also see the blog entry "Oracle RDBMS Server 11gR2 Pre-Install RPM for Oracle Linux 6 has been released": https://blogs.oracle.com/linux/entry/oracle_rdbms_server_11gr2_pre

About the Authors

Ginny Henningsen has worked for the last 15 years as a freelance writer developing technical collateral and documentation for high-tech companies. Prior to that, Ginny worked for Sun Microsystems, Inc. as a Systems Engineer in King of Prussia, PA and Milwaukee, WI. Ginny has a BA from Carnegie-Mellon University and a MSCS from Villanova University.

Michele Casey is the Director of Product Management for Oracle Linux. She has worked with commercial Linux distributions and open source projects as a product manager since 2006. She has also held positions as a system administrator, project manager, and technical support engineer.

Revision 1.1, 07/09/2013; added information about using the
oracle-rdbms-server-12cR1-preinstall package to install
Oracle Database 12c

 

Follow us:

NodeJS-Oracle DB - NJS-040 连接超时,在 ICP 中使用带有 Lopback 的 oracle 驱动程序(loopback-connector-oracle)

NodeJS-Oracle DB - NJS-040 连接超时,在 ICP 中使用带有 Lopback 的 oracle 驱动程序(loopback-connector-oracle)

如何解决NodeJS-Oracle DB - NJS-040 连接超时,在 ICP 中使用带有 Lopback 的 oracle 驱动程序(loopback-connector-oracle)?

我正在使用 loopback-connector-oracle 4.1.1 版寻求有关我面临的问题的一些信息。分析如下: 我们有 DB 连接配置,可以使用 json 文件格式的 oracle 连接器使用属性连接到 oracle DB 数据源。 "maxConn": 20,“主机”:DB_HOST, “端口”:DB_PORT, “数据库”:DB_NAME, “密码”:DB_PASSWORD, “用户”:DB_USER, "connector": "oracle",

有两个进程/pod 正在运行,每个进程/pod 都有自己的池供oracle 连接器使用。发生的情况是,在一个实例中,oracle 能够连接并处理请求,但在第二个 pod/进程中,我注意到 njs-040 错误连接超时。由于两者都运行在同一个环境中,所以连接性不会成为问题。我正在寻求您的帮助或意见以了解连接池耗尽的原因?正如我所看到的,DB 上的连接/会话数量配置的数量较少。 当我重新启动 pod/进程时,一切都会恢复正常。在我的流程中遇到的一些问题,如果您可以指导并提供宝贵的意见,我正在寻求您的帮助。

  • 如果使用连接池(oracle 连接器),它也应该释放对象,耗尽的机会会减少吗?
  • 在进程/pod 启动并通过连接器 (oracle) 获取数据源中的连接对象后,发生网络问题并且进程和数据库之间的连接丢失,连接器是否恢复?根据我的观察,我在其他进程中注意到的似乎应该被恢复,当它与范围一起运行时,在一个进程中可能会导致什么?

我非常感谢您的回复。 提前致谢 桑吉夫

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

Oracle 10g AND Oracle 11g手工建库案例--Oracle 11g

Oracle 10g AND Oracle 11g手工建库案例--Oracle 11g

Oracle 10g AND Oracle 11g手工建库案例--Oracle 11g

系统环境:

操作系统: RedHat EL6

Oracle: Oracle 10g and Oracle 11g

 

手工建库相对来说很容易实现,本案例是从10g和11g,通过手工建库的方式做一个简单的对比,可以看出11g和10g之间的一个简单的差异!

VMware+Linux+Oracle 10G RAC全程详细图解

案例二:

在Oracle 11g 环境下手工建库

DB_NAME=''test1''

INSTANCE_NAME=''test1''

1、建立Instance的初始化参数文件和口令文件

[oracle@rh6 dbs]$cat inittest1.ora

db_name=''test1''

memory_target=400m //Oracle 11g增加了内存自动管理

processes = 150

audit_file_dest=''$ORACLE_BASE/admin/test1/adump''

audit_trail =''db''

db_block_size=8192

db_domain=''''

open_cursors=300

remote_login_passwordfile=''EXCLUSIVE''

undo_tablespace=''UNDOTBS1''

# You may want to ensure that control files are created on separate physical

# devices

control_files = /u01/app/oracle/oradata/test1/control01.ctl

compatible =''11.2.0''

 

[oracle@rh6 dbs]$ orapwd file=orapwtest1 password=oracle entries=3

 

2、建立数据库相关的目录

Oracle 11g增加了diagnostic directory,,默认的为$ORACLE_BASE

[oracle@rh6 dbs]$ mkdir -p $ORACLE_BASE/admin/test1/adump

[oracle@rh6 dbs]$ mkdir -p /u01/app/oracle/oradata/test1

 

3、建立建库脚本

[oracle@rh6 ~]$ cat cr_db.sql

CREATE DATABASE test1

USER SYS IDENTIFIED BY oracle

USER SYSTEM IDENTIFIED BY oracle

LOGFILE

GROUP 1 (''/u01/app/oracle/oradata/test1/redo01a.log'') SIZE 50M ,

GROUP 2 (''/u01/app/oracle/oradata/test1/redo02a.log'') SIZE 50M

MAXLOGFILES 10

MAXLOGMEMBERS 5

MAXLOGHISTORY 1

MAXDATAFILES 200

CHARACTER SET zhs16gbk

DATAFILE ''/u01/app/oracle/oradata/test1/system01.dbf'' SIZE 325M REUSE

SYSAUX DATAFILE ''/u01/app/oracle/oradata/test1/sysaux01.dbf'' SIZE 325M REUSE

DEFAULT TEMPORARY TABLESPACE tempts1

TEMPFILE ''/u01/app/oracle/oradata/test1/temp01.dbf''

SIZE 100M REUSE

UNDO TABLESPACE undotbs1

DATAFILE ''/u01/app/oracle/oradata/test1/undotbs01.dbf''

SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;

 

4、启动Instance并建立数据库

[oracle@rh6 ~]$ export ORACLE_SID=test1

[oracle@rh6 ~]$ sqlplus ''/as sysdba''

SQL*Plus: Release 11.2.0.1.0 Production on Wed May 21 10:59:58 2014

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

Connected to an idle instance.

10:59:59 SYS@ test1>startup nomount;

ORACLE instance started.

Total System Global Area 417546240 bytes

Fixed Size 2213936 bytes

Variable Size 268437456 bytes

Database Buffers 142606336 bytes

Redo Buffers 4288512 bytes

11:00:12 SYS@ test1>@/home/oracle/cr_db

Database created.

Elapsed: 00:01:23.44

11:01:51 SYS@ test1>

 

建库告警日志:

CREATE TABLESPACE sysaux DATAFILE ''/u01/app/oracle/oradata/test1/sysaux01.dbf'' SIZE 325M REUSE

EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ONLINE

Wed May 21 11:01:08 2014

Completed: CREATE TABLESPACE sysaux DATAFILE ''/u01/app/oracle/oradata/test1/sysaux01.dbf'' SIZE 325M REUSE

EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ONLINE

processing ?/rdbms/admin/dplsql.bsq

processing ?/rdbms/admin/dtxnspc.bsq

CREATE UNDO TABLESPACE UNDOTBS1 DATAFILE ''/u01/app/oracle/oradata/test1/undotbs01.dbf''

SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED

Wed May 21 11:01:23 2014

Successfully onlined Undo Tablespace 2.

Completed: CREATE UNDO TABLESPACE UNDOTBS1 DATAFILE ''/u01/app/oracle/oradata/test1/undotbs01.dbf''

SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED

CREATE TEMPORARY TABLESPACE TEMPTS1 TEMPFILE ''/u01/app/oracle/oradata/test1/temp01.dbf''

SIZE 100M REUSE

Completed: CREATE TEMPORARY TABLESPACE TEMPTS1 TEMPFILE ''/u01/app/oracle/oradata/test1/temp01.dbf''

SIZE 100M REUSE

ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMPTS1

Completed: ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMPTS1

ALTER DATABASE DEFAULT TABLESPACE SYSTEM

Completed: ALTER DATABASE DEFAULT TABLESPACE SYSTEM

processing ?/rdbms/admin/dfmap.bsq

processing ?/rdbms/admin/denv.bsq

processing ?/rdbms/admin/drac.bsq

processing ?/rdbms/admin/dsec.bsq

processing ?/rdbms/admin/doptim.bsq

processing ?/rdbms/admin/dobj.bsq

processing ?/rdbms/admin/djava.bsq

processing ?/rdbms/admin/dpart.bsq

Wed May 21 11:01:34 2014

processing ?/rdbms/admin/drep.bsq

processing ?/rdbms/admin/daw.bsq

processing ?/rdbms/admin/dsummgt.bsq

processing ?/rdbms/admin/dtools.bsq

processing ?/rdbms/admin/dexttab.bsq

processing ?/rdbms/admin/ddm.bsq

processing ?/rdbms/admin/dlmnr.bsq

processing ?/rdbms/admin/ddst.bsq

Wed May 21 11:01:43 2014

SMON: enabling tx recovery

Starting background process SMCO

Wed May 21 11:01:44 2014

SMCO started with pid=17, OS id=2816

Wed May 21 11:01:50 2014

replication_dependency_tracking turned off (no async multimaster replication found)

Starting background process QMNC

Wed May 21 11:01:50 2014

QMNC started with pid=20, OS id=2826

Completed: CREATE DATABASE test1

USER SYS IDENTIFIED BY ****USER SYSTEM IDENTIFIED BY ****LOGFILE

GROUP 1 (''/u01/app/oracle/oradata/test1/redo01a.log'') SIZE 50M ,

GROUP 2 (''/u01/app/oracle/oradata/test1/redo02a.log'') SIZE 50M

MAXLOGFILES 10

MAXLOGMEMBERS 5

MAXLOGHISTORY 1

MAXDATAFILES 200

CHARACTER SET zhs16gbk

DATAFILE ''/u01/app/oracle/oradata/test1/system01.dbf'' SIZE 325M REUSE

SYSAUX DATAFILE ''/u01/app/oracle/oradata/test1/sysaux01.dbf'' SIZE 325M REUSE

DEFAULT TEMPORARY TABLESPACE tempts1

TEMPFILE ''/u01/app/oracle/oradata/test1/temp01.dbf''

SIZE 100M REUSE

UNDO TABLESPACE undotbs1

DATAFILE ''/u01/app/oracle/oradata/test1/undotbs01.dbf''

SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED

 

更多详情见请继续阅读下一页的精彩内容:

10gRAC-10.2.0.4-dbca建库时配置OEM遇到BUG-p8350262

Oracle 11g R2 手动建库(create database manually)

Oracle 11g + ASM DBCA 建库问题解决心得

Linux下Oracle 10g手工建库全过程

Oracle 9i数据库手工建库过程简记

静默安装Oracle 11gR2软件并且手动建库

关于oracle 的乐观锁和悲观锁oracle乐观锁实例的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于For oracle databases, if the top showing the oracle database, then oracle process is using the top c、How I Simplified Oracle Database 12c and 11g Installations on Oracle Linux 6、NodeJS-Oracle DB - NJS-040 连接超时,在 ICP 中使用带有 Lopback 的 oracle 驱动程序(loopback-connector-oracle)、Oracle 10g AND Oracle 11g手工建库案例--Oracle 11g的相关信息,请在本站寻找。

本文标签: