Linnux下Oracle 10G和Oracle 11G双版本数据库并存的安装和配置
心血来潮,突然想在OEL6下面安装Oracle10g和Oracle11g,2个版本共存,方便学习和实验,这个安装过程其实不难操作,如果你有分别安
心血来潮,突然想在OEL6下面安装Oracle10g和Oracle11g,2个版本共存,方便学习和实验,这个安装过程其实不难操作,如果你有分别安装过10g和11g的经验,相信具体操作是很容易的,最总要的一点是如何让2个版本共存和正常使用。
在虚拟机上测试了整个安装过程,本本比较懒,过程相当缓慢。
环境
WMWARE WORKSTAION 7
OS OracleLinux-R6 32Bit 1G内存 30G硬盘1+20G硬盘2(用于存放安装软件)
DATABASE
10201_database_linux32
linux_11gR2
之所以选择的操作系统是OEL,主要是出于兼容性考虑,毕竟这是Oracle自家的玩意儿,自己公司的产品的兼容性肯定要比与别家的相比好点。
PS:不过令我很郁闷的一点就是,启动数据库安装程序的时候,为什么相同的环境变量配置,使用Red Hat Enterprise的时候都能够正常显示中文,但是一到OEL就是经典的方块,不过操作系统是5.x还是6.x,不过database是10.x还是11.x。
下面是安装过程的简单记录和汇总。
一、 首先安装oracle10g
1. 建立oracle安装需要的组
root用户执行
groupadd oinstall
groupadd dba
groupadd oper
2. 建立oracle用户
root用户执行
useradd oracle -g oinstall -G dba,oper
passwd oracle
3. 修改oracle的配置文件
oracle用户执行
添加下面的行到.bash_profile
export EDITOR=vi #设置sqlplus默认编辑器为vi
alias sqlplus=’rlwrap sqlplus’ #一个小工具,能够让sqlplus想windows下一样使用方向键
export NLS_LANG=”SIMPLIFIED CHINESE_CHINA.UTF8″
export ORACLE_SID=TEST10G
export ORACLE_BASE=/opt/oracle/db/10g
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib:
export PATH=$ORACLE_HOME/bin:/usr/bin:/usr/ccs/bin:/etc:/bin:/usr/openwin/bin:/usr/local/bin:/usr/X11R6/bin:
umask 022
4. 修改内核参数
root用户执行
添加下面的行到/etc/sysctl.conf
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.shmall = 2097152
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144
5. 修改资源限制
root用户执行
添加下面的行到/etc/security/limits.conf
oracle soft nofile 65536
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
4. 建立相关的目录
root用户执行
mkdir /opt/oracle
chown oracle:oinstall /opt/oracle
5. 格式化、挂载新增加的硬盘
root用户执行
[root@ ~]# fdisk -l
[root@ ~]# fdisk /dev/sdb
输入 n p 1 w
[root@ ~]# mkfs -t ext4 -c /dev/sdb1
[root@ ~]# mkdir /media/newdriver
[root@ ~]# mount /dev/sdb1 /media/newdriver/
[root@ ~]# mkdir /media/newdriver/ora
[root@ ~]# chown oracle:oinstall /media/newdriver/ora
6. 上传软件并解压软件
oracle用户执行
unzip -q 10201_database_linux32.zip
7. 版本欺骗
root用户执行
cp /etc/RedHat-release /etc/redhat-release.bak
vi /etc/redhat-release修改这个文件为
#Red Hat Enterprise Linux Server release 6.0 (Santiago)
Red Hat 4
8. 乱码问题
oracle用户执行
在执行./runInstaller之前
export LANG=en_US
9. 安装过程中遇到的错误
9.1. 缺少libXp包
root用户执行
Exception in thread “main” java.lang.UnsatisfiedLinkError: /tmp/OraInstall2011-07-30_01-41-36AM/jre/1.4.2/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory
解决办法:缺少libXp包,Linux安装光盘中查找安装即可,具体安装细节不在赘述。
由于从来没有在Linux6版本中安装过10g版本的数据库,一开始还怕会有不少问题,还好,一切顺利,接下来的11g版本相信也不会有什么问题。
10. 安装rlwrap
root用户执行
[root@ ~]# tar zxvf rlwrap-0.37.tar.gz
[root@ ~]# cd rlwrap-0.37
[root@ rlwrap-0.37]# ./configure
[root@ rlwrap-0.37]# make
[root@ rlwrap-0.37]# make install
11. 使用启动脚本
使用启动脚本之前需要做一些修改,主要是配置下ORACLE_HOME_LISTNER这个变量.
vi $ORACLE_HOME/bin/dbstart
把79行的
ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle
修改成
ORACLE_HOME_LISTNER=$ORACLE_HOME
否则报错:
[oracle@gtlions bin]$ ./dbstart
Failed to auto-start Oracle Net Listene using /ade/vikrkuma_new/oracle/bin/tnslsnr
12. 使用关闭脚本
由于在10g版本当中没有随着关闭脚本配置关闭监听的功能,脚本中写道
# Oracle Net Listener is NOT shutdown using this script.
因此我们需要增加监听的停止脚本,我们可以借鉴下11g的关闭脚本,拷贝相关部分过来即可
ORACLE_HOME_LISTNER=$ORACLE_HOME
if [ ! $ORACLE_HOME_LISTNER ] ; then
echo “ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener”
echo “Usage: $0 ORACLE_HOME”
else
LOG=$ORACLE_HOME_LISTNER/listener.log
# Set the ORACLE_HOME for the Oracle Net Listener, it gets reset to
# a different ORACLE_HOME for each entry in the oratab.
export ORACLE_HOME=$ORACLE_HOME_LISTNER
# Stop Oracle Net Listener
if [ -f $ORACLE_HOME_LISTNER/bin/tnslsnr ] ; then
echo “$0: Stoping Oracle Net Listener” >> $LOG 2>&1
$ORACLE_HOME_LISTNER/bin/lsnrctl stop >> $LOG 2>&1 &
else
echo “Failed to auto-stop Oracle Net Listener using $ORACLE_HOME_LISTNER/bin/tnslsnr”
fi
fi
13. 配置/etc/oratab
增加或者修改如下内容,注意最后的一个Y,,安装完成的时候默认是会写入这个文件一行记录,但是最后一位是N
/etc/oratab TEST10G:/opt/oracle/db/10g/product/10.2.0/db_1:Y
二、 接着安装oracle11g
1. 修改oracle的配置文件
注意,首先备份好这个文件,因为这个文件是10g版本使用的配置文件,只有同时保存了2个版本的对应的配置文件,在以后的使用过程中才能方便的切换。
备份后修改先前配置,修改后对应设置如下:
export NLS_LANG=”SIMPLIFIED CHINESE_CHINA.UTF8″
export ORACLE_SID=TEST11G
export ORACLE_BASE=/opt/oracle/db/11g/base
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib:
export PATH=$ORACLE_HOME/bin:/usr/bin:/usr/ccs/bin:/etc:/bin:/usr/openwin/bin:/usr/local/bin:/usr/X11R6/bin:
umask 022
2. 版本恢复原状
vi /etc/redhat-release
修改这个文件为
Red Hat Enterprise Linux Server release 6.0 (Santiago)
3. 乱码问题
在执行./runInstaller之前export LANG=en_US
三、 配置和使用
最后,如何分别使用和同时使用这2个版本的数据库。
当然是通过使用不同的配置文件来实现的啦,重点在于每次使用不同版本的数据库的时候切换到相应的环境变量。
有多个办法比如:
1、逐个设置相关的变量;
2、备份2个版本的环境变量参数文件.bash_profile,登陆后手工切换;
3、这里我用的SecureCRT的ssh工具,针对oracle配置两个会话,设置在登录后执行不同的脚本,在这么我们就是要让它来替我们完成环境变量的设置。
四、 最后
特地查看了下2个版本的安装目录的占用空间的大小,数据文件上差不多,10g的占用1.1g,11g的占用1.4g,但是安装软件占用的就相差很大了,11g的几乎是10g的3倍,前者是3.7g,后者才1.3g。大家伙啊11g。
-The End-

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is suitable for small and large enterprises. 1) Small businesses can use MySQL for basic data management, such as storing customer information. 2) Large enterprises can use MySQL to process massive data and complex business logic to optimize query performance and transaction processing.

MySQL index cardinality has a significant impact on query performance: 1. High cardinality index can more effectively narrow the data range and improve query efficiency; 2. Low cardinality index may lead to full table scanning and reduce query performance; 3. In joint index, high cardinality sequences should be placed in front to optimize query.
