CentOS安装Oracle教程


 

一、安装centos5.4

二、安装oracle11g R2

         1. 前提是安装好所有rpm包:rpm -q binutils   compat-libstdc++-33   elfutils-libelf   elfutils-libelf-devel gcc   gcc-c++   glibc   glibc-common   glibc-devel   libaio   libaio-devel libgcc libstdc++   libstdc++-devel   make   sysstat   vixie-cron unixODBC unixODBC-devel glibc-headers

如果哪个没有安装就安装哪个:yum intall binutils compat-libstdc++-33……

         2. 配置用户:

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

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

           [root@localhost /]# mkdir –p /data/oracle 

           [root@localhost /]# useraddg oinstallG dbad / data /oracle oracle(添加oracle用户到oinstalldba副组到/ data /oracle目录中 )

           [root@localhost /]# passwd oracle(设置密码)

           [root@localhost /]# chown -R oracle:oinstall data(改目录组)

         3. 设置域名:

           [root@localhost /]# cat /etc/hosts  (留意黑体字)

           # Do not remove the following line, or various programs

           # that require network functionality will fail.

           127.0.0.1               localhost.localdomain localhost

           192.168.1.106           localhost.localdomain localhost

           #::1             localhost6.localdomain6 localhost6

         4. 配置文件:

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

           kernel.shmall = 2097152

           kernel.shmmax = 2147483648

           kernel.shmmni = 4096

           kernel.sem = 250 32000 100 128

           net.ipv4.ip_local_port_range = 1024 65000

           net.core.rmem_default = 4194304

           net.core.rmem_max = 4194304

           net.core.wmem_default = 262144

           net.core.wmem_max = 262144

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

           oracle              soft    nproc   2047

           oracle              hard    nproc   16384

           oracle              soft    nofile  1024

           oracle              hard    nofile  65536

           [root@localhost /]# cat >> /etc/profile

           if [ $USER = "oracle" ]; then

                   if [ $SHELL = "/bin/ksh" ]; then

           ulimit -p 16384

                         ulimit -n 65536

                   else

                         ulimit -u 16384 -n 65536

                   fi

           fi

         5. 设置环境变量:

           [root@localhost /]# su - oracle

           [oracle@localhost ~]$ vi .bash_profile

           export PATH

           ORACLE_BASE=/data

           ORACLE_HOME=$ORACLE_BASE/oracle

           ORACLE_SID=orcl

           PATH=$ORACLE_HOME/bin:$PATH

           export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH

           export NLS_LANG=AMERICAN_AMERICA.UTF8

           [oracle@localhost ~]$ . .bash_profile

        6.解压oracle/data目录下面:

           [root@localhost /data]# chown -R oracle:oinstall database/  #修改所有者(R表示递归)

        7.安装oracle(在centos界面下,因为需要UI操作):

           [root@localhost ~]# xhost local:oracle

           non-network local connections being added to access control list

           [root@localhost ~]# su - oracle

           [oracle@localhost ~]$ cd / data

           [oracle@localhost data]$ ls

           database oracle

           [oracle@localhost data]$ cd database

           [oracle@localhost database]$ ls

           doc install  README  runInstaller  stage  welcome.html

           [oracle@localhost database]$ ./runInstaller

           然后随机应变、基本和在windows里面安装时一样的。

        8.创建数据库:

           [oracle@localhost database] $netca    #配置监听器

           [oracle@localhost database] $ ps -ef | grep oracle   #看监听器是否正常。

        9.连接数据库:

           [oracle@localhost database] vi /etc/sysconfig/selinux     #修改 SELINUX=permissive

三、启动数据库:

        1.打开监听器(如果是刚刚安装完,配置完监听器,就无需再次打开):lsnrctl start

        2.连接数据库:sqlplus /nolog

                                              conn  /as sysdba

        3.启动数据库:startup

以上是oracle部分安装完毕,使用sqlplus一般不会有问题。

 

如果要使用perl连接数据库,需要安装DBIDBD

一、安装DBI

         [root@localhost]~ $ yum install perl-DBI

        Loaded plugins: fastestmirror

        Loading mirror speeds from cached hostfile

         * base: mirrors.163.com

         * extras: mirrors.163.com

         * updates: mirrors.163.com

        Setting up Install Process

        Package perl-DBI-1.52-2.el5.i386 already installed and latest version

        Nothing to do

二、安装DBD

        1.上网下载DBDhttp://search.cpan.org/dist/DBD-Oracle/  目前最新是1.50版本

        2.放到centos中解压:tar –xvf DBD-Oracle-1.50.tar.gz.tar并进入目录

        3.安装:

         [root@localhost]~# export ORACLE_HOME=/data/oracle

         [root@localhost]~# export ORACLE_SID=orcl

         [root@localhost]~# perl Makefile.PL

         [root@localhost]~# make               #前提是上一步没有报错,警告啥的就忽略吧。

         [root@localhost]~# make test      #前提是上一步没有报错,警告啥的就忽略吧。

         [root@localhost]~# make intall     #前提是上一步没有报错,警告啥的就忽略吧。

然后就可以了。

 

 

 

常见报错:

1.运行perl的时候出现:

install_driver(Oracle) failed: Can't locate DBD/Oracle.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at (eval 3) line 3.

Perhaps the DBD::Oracle perl module hasn't been fully installed,

or perhaps the capitalisation of 'Oracle' isn't right.

Available drivers: DBM, ExampleP, File, Proxy, Sponge.

 at /data/usr/oracle/bin/test1 line 10

 

这是因为DBD没有安装好。

解决办法:安装好DBDok了。

 

2.运行perl的时候出现:

install_driver(Oracle) failed: Can't load '/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libclntsh.so.11.1:无法打开共享对象文件:没有那个文件或目录 at /usr/lib/perl5/5.8.8/i386-linux-thread-multi/DynaLoader.pm line 230.

 at (eval 3) line 3

Compilation failed in require at (eval 3) line 3.

Perhaps a required shared library or dll isn't installed where expected

 at /data/usr/oracle/bin/test1 line 10

 

这是由于DBD安装过程中so库文件没有被搜索到。

解决办法:添加路径到 /etc/ld.so.conf文件

[root@localhost]~ $ldd /home/Root/setup_file/DBD-Oracle-1.50/blib/arch/auto/DBD/Oracle/Oracle.so

       linux-gate.so.1 =>  (0x00175000)

       libclntsh.so.11.1 => not found

       libdl.so.2 => /lib/libdl.so.2 (0x0049b000)

       libm.so.6 => /lib/libm.so.6 (0x008e5000)

        libpthread.so.0 => /lib/libpthread.so.0 (0x00d23000)

       libnsl.so.1 => /lib/libnsl.so.1 (0x00b52000)

       libc.so.6 => /lib/libc.so.6 (0x00176000)

       /lib/ld-linux.so.2 (0x00737000)

[root@localhost]~ $find / -name libclntsh.so.11.1

/data/database/stage/ext/lib/libclntsh.so.11.1

/data/oracle/lib/libclntsh.so.11.1

/data/oracle/inventory/Scripts/ext/lib/libclntsh.so.11.1

/data/oracle/inventory/backup/2012-09-15_04-28-26AM/Scripts/ext/lib/libclntsh.so.11.1

/tmp/OraInstall2012-09-15_04-22-26AM/ext/lib/libclntsh.so.11.1

[root@localhost]~ $cat >> /etc/ld.so.conf

/data/oracle/lib/

[root@localhost]~ $ldconfig

ldconfig: File /data/oracle/lib/libnmevc.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmefsql.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmefsqlt.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmefvr.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmefos.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmefpfa.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmcfhc.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmefsp.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmeoci.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmalk.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmcfsga.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmadbg.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmemso.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmefport.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmefut.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmevsp.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmefud.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmarl.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmasf.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmastk.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmevq.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmefw.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmadm.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmefojmx.so.0 is empty, not checked.

ldconfig: File /data/oracle/lib/libnmefdms.so.0 is empty, not checked.

ldconfig: /data/oracle/lib/libexpat.so.1 is not a symbolic link

[root@localhost]~ $ldd /home/Root/setup_file/DBD-Oracle-1.50/blib/arch/auto/DBD/Oracle/Oracle.so

       linux-gate.so.1 =>  (0x0036e000)

       libclntsh.so.11.1 => /data/oracle/lib/libclntsh.so.11.1 (0x00753000)

       libdl.so.2 => /lib/libdl.so.2 (0x00110000)

       libm.so.6 => /lib/libm.so.6 (0x00114000)

       libpthread.so.0 => /lib/libpthread.so.0 (0x00434000)

       libnsl.so.1 => /lib/libnsl.so.1 (0x0013b000)

       libc.so.6 => /lib/libc.so.6 (0x00152000)

       libnnz11.so => /data/oracle/lib/libnnz11.so (0x0044b000)

       libaio.so.1 => /usr/lib/libaio.so.1 (0x00297000)

       /lib/ld-linux.so.2 (0x00737000)

 

 

-------------------------------------------------------------------------------------------------------------------

参考文献:

1.http://search.cpan.org/dist/DBD-Oracle/

2.http://wenku.baidu.com/view/4ebf6b6ca98271fe910ef9bf.html

3.http://fantlam.iteye.com/blog/612110

 

你可能感兴趣的:(oracle,centos,File,perl,database)