Centos6.0 64位版本上安装oracle11g

 

Centos6.064位版本上安装oracle11g

 

Centos6.4X64位版本上安装oracle11g.1

一.      安装前准备...1

1.准备文件...1

2.环境检测...2

3.环境配置...3

二.      安装oracle11g  64位... 7

三.      建库和用户...18

四.状态检测和各项服务启动...19

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

一.安装前准备

1.准备文件

操作系统:CentOS-6.4-x86_64位

数据库安装文件:

下载地址

http://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_1of2.zip

http://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_2of2.zip

 

2.环境检测

2.1安装依赖的包

yum-y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-develglibc glibc-common glibc-devel gcc- gcc-c++ libaio-devel libaio libgcclibstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh

2.2系统环境性能检测

 

//查看内存及swap

[[email protected]~]# grep MemTotal /proc/meminfo

[[email protected]~]# grep SwapTotal /proc/meminfo

//查看内核

[[email protected]~]#uname  -r

//查看内存与交换空间的使用情况

[[email protected]~]# free

 

3.环境配置

3.1 修改系统内核参数

[[email protected]~]# vim /etc/sysctl.conf

 

#修改如下两个参数

kernel.shmmax= 2147483648

kernel.shmall= 2097152

#增加如下参数

fs.file-max= 6815744

fs.aio-max-nr= 1048576

kernel.shmmni= 4096

kernel.sem= 250 32000 100 128

net.ipv4.ip_local_port_range= 9000 65500

net.core.rmem_default= 4194304

net.core.rmem_max= 4194304

net.core.wmem_default= 262144

net.core.wmem_max= 1048576

3.3 修改完后,让其立即生效

[[email protected]~]#/sbin/sysctl -p

3.4 添加用户组及用户

groupadd oinstall

groupadddba

useraddoracle -g oinstall -G dba         

passwdoracle                              

 

 

3.5 新建目录并设置权限

//新建目录权限

mkdir-p /u01/app/oracle
mkdir -p /u01/app/oralnventory
chown -R oracle:dba /u01
chmod -R 755 /u01

 

3.6为oracle 用户设置Shell                  //这一步很重要

[[email protected] ~]# vi/etc/security/limits.conf

#oracle11gr2
oracle              soft    nproc  2047
oracle              hard    nproc  16384
oracle              soft    nofile 1024
oracle              hard    nofile 65536

3.7修改login

[[email protected] ~]# vi/etc/pam.d/login

session    required    pam_limits.so

[[email protected] ~]# vi/etc/profile

if [ $USER ="oracle" ]; then

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

ulimit -p 16384

ulimit -n 65536

else

ulimit -u 16384 -n65536

fi

fi

 

3.8修改login

[[email protected] ~]# vi/etc/csh.login

if ( $USER ="oracle" ) then

limit maxproc 16384

limit deors 65536

endif

3.9配置root用户自动启动oracle

[[email protected] ~]# vi/etc/oratab 

#修改为

ORCL:/u01/app/oracle/product/11.2.0/db_1:Y

3.10关闭SELINUX的工作模式               

[[email protected] ~]# vi/etc/selinux/config

# 设置SELINUX为disabled

SELINUX=disabled

3.11修改环境变量

vim/etc/profile

添加

TMP=/tmp

export TMP

TMPDIR=$TMP

export TMPDIR

ORACLE_BASE=/u01/app/oracle

export ORACLE_BASE

ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1

export ORACLE_HOME

ORACLE_SID=orcl

export ORACLE_SID

ORACLE_TERM=xterm

export ORACLE_TERM

PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH

export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib

export LD_LIBRARY_PATH

CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

export CLASSPATH

umask 022

 

 

二.安装oracle11g  64位

执行如下两条命令:

unzip /home/linux.x64_11gR2_database_1of2.zip -d /home/oracle

unzip /home/linux.x64_11gR2_database_2of2.zip-d /home/oracle

 

Xmanager,但在装之前,要service  iptables stop 将防火墙关掉.

 

PS:安装Oracle 11gR2报错INS-06101 IP address of localhost could not be determined 出现这种错误是因为主机名和/etc/hosts 文件不一致只需要把主机名和其IP 写入。

 

 

[[email protected]]$su  oracle

[[email protected]~]$cd /home/oracle/database/

[[email protected]~]$./runIstaller

//进入安装界面,以下界面里参数与上述配置可以不一样,仅供步骤参考

 

 

第一步:填写email信息,以便得到支持,需要联网。(这里跳过不选)

 Centos6.0 64位版本上安装oracle11g

第二步:选择只安装数据库软件

Centos6.0 64位版本上安装oracle11g

第三步:选择单实例数据库安装

Centos6.0 64位版本上安装oracle11g

第四步:选择产品的语言

Centos6.0 64位版本上安装oracle11g

 

第五步:选择要安装的oracle版本

 Centos6.0 64位版本上安装oracle11g

 

第六步:选择安装路径

Centos6.0 64位版本上安装oracle11g

第七步,选择Inventory directory

Centos6.0 64位版本上安装oracle11g

第八步,选择数据库管理员和操作员所属的组

Centos6.0 64位版本上安装oracle11g

第九步:系统依赖检查,这里选择忽略所有

Centos6.0 64位版本上安装oracle11g

如下几个组件没有安装

libio-0.3.105

glibc-2.3.4-2.4.1

compat-libstdc++-33-3.2.3

libio-devel-0.3.105

libgcc-3.4.6

libstdc++-3.4.6

unixODBC-2.2.11

unixODBC-devel-2.2.11

pdksksh-5.5.14

 Centos6.0 64位版本上安装oracle11g

第十步:确认安装信息,注意保存详细的配置文件(点击SaveResponse File)

Centos6.0 64位版本上安装oracle11g

 

第十一步:安装进行中

 

Centos6.0 64位版本上安装oracle11g

安装过程中,提示以root用户执行脚本

Centos6.0 64位版本上安装oracle11g

[[email protected]]# sh  /u01/app/oraInventory/orainstRoot.sh

[[email protected]]#sh /u01/app/oracle/product/11.2.0/db_1/root.sh

第十二步:安装完成

 Centos6.0 64位版本上安装oracle11g

三.建库和用户

3.1 建库orcl

Oralce用户下:

$netca     //按默认配置监听

Centos6.0 64位版本上安装oracle11g

Centos6.0 64位版本上安装oracle11g

Centos6.0 64位版本上安装oracle11g

Centos6.0 64位版本上安装oracle11g

Centos6.0 64位版本上安装oracle11g

Centos6.0 64位版本上安装oracle11g

Centos6.0 64位版本上安装oracle11g

Centos6.0 64位版本上安装oracle11g

Centos6.0 64位版本上安装oracle11g

$dbca     //建库orcl

Centos6.0 64位版本上安装oracle11g

 

Centos6.0 64位版本上安装oracle11g

Centos6.0 64位版本上安装oracle11g

Centos6.0 64位版本上安装oracle11g

Centos6.0 64位版本上安装oracle11g

 

 

 

 

 

3.2 建用户test并授权

//Oralce用户下:

sqlplus/nolog                //也可以sqlplus“/ as sysdba”

connect  / as dba             //进去后运行以下命令

 

createuser test identified by test default tablespace users temporary tablespacetemp;

grantconnect,resource,unlimited tablespace to test;

grantcreate view to test;

grantCREATE SYNONYM to test;

grantexecute on dbms_job to test;

 

 

四.状态检测和各项服务启动

4.1 状态检测

通过这个命令:netstat–tnl | grep 1521;

              netstat –tnl | grep 1158

查看1521端口和1158端口状态。

 

4.2各项服务的启动方式

数据库服务启动 | 关闭

[[email protected] bin]$dbstart | dbshut 

 

监听器 启动 | 关闭 

[[email protected] bin]$lsnrctl start | stop

 

em 控制台 启动 | 关闭

[[email protected] bin]$emctl start | stop dbconsole

访问https://localhost:1158/em

 

iSQL*Plus 启动 | 关闭 

[[email protected] bin]$isqlplusctl start | stop 

访问http://localhost:5560/isqlplus

 

无法在任意目录下使用dbstart启动数据库

报错:

[[email protected]~]# dbstart

ORACLE_HOME_LISTNERis not SET, unable to auto-start Oracle Net Listener

Usage:/u01/app/oracle/product/11.2.0/db_1/bin/dbstart ORACLE_HOME

ProcessingDatabase instance "ORCL": log file/u01/app/oracle/product/11.2.0/db_1/startup.log

解决办法:

解决方案就算将$ORACLE_HOME赋值给$ORACLE_HOME_LINTNER,保存,退出

Vim /u01/app/oracle/product/11.2.0/db_1/bin/dbstart

#First argument is used to bring up Oracle Net Listener

把ORACLE_HOME_LISTNER=$1

修改为

ORACLE_HOME_LISTNER=$ORACLE_HOME

 

再次启动,不报错

[[email protected]~]# dbstart

ProcessingDatabase instance "ORCL": log file /u01/app/oracle/product/11.2.0/db_1/startup.log

 

同理,修改/u01/app/oracle/product/11.2.0/db_1/bin/dbshut

 

 

#The  this to bring down Oracle NetListener

ORACLE_HOME_LISTNER=$ORACLE_HOME

 

[[email protected]~]# dbshut

ProcessingDatabase instance "ORCL": log file /u01/app/oracle/product/11.2.0/db_1/shutdown.log

 

 

将Oracle服务添加到Linux开机启动项,以root用户建立/etc/rc.d/init.d/oradb脚本文件,文件内容如下:

#!/bin/bash 

#chkconfig: 2345 90 10  

exportORACLE_BASE=/u01/app/oracle

exportORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1

exportORACLE_SID=orcl 

exportPATH=$PATH:$ORACLE_HOME/bin 

ORCL_OWN="oracle"

# ifthe executables do not exist -- display error  

if [! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ] 

then 

   echo "Oracle startup: cannotstart" 

   exit 1 

fi 

# dependingon parameter -- start, stop, restart 

# ofthe instance and listener or usage display  

case"$1" in 

start) 

#Oracle listener and instance startup  

echo-n "Starting Oracle: " 

su -$ORCL_OWN -c "$ORACLE_HOME/bin/dbstart" 

su - $ORCL_OWN -c "lsnrctl start"

touch/var/lock/subsys/oradb 

su -$ORCL_OWN -c "$ORACLE_HOME/bin/emctl start dbconsole" 

echo"OK" 

;; 

stop) 

#Oracle listener and instance shutdown  

echo-n "Shutdown Oracle: " 

su -$ORCL_OWN -c "$ORACLE_HOME/bin/emctl stop dbconsole" 

su -$ORCL_OWN -c "$ORACLE_HOME/bin/dbshut" 

su - $ORCL_OWN -c "lsnrctl stop"

rm -f/var/lock/subsys/oradb 

echo"OK" 

;; 

reload|restart) 

$0stop 

$1start 

;; 

*) 

echo"Usage: 'basename $0' start|stop|restart|reload" 

exit1 

esac 

exit0 

#!/bin/bash

#chkconfig: 2345 90 10

exportORACLE_BASE=/u01/app/oracle

exportORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1

exportORACLE_SID=orcl

exportPATH=$PATH:$ORACLE_HOME/bin

ORCL_OWN="oracle"

# ifthe executables do not exist -- display error

if [! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]

then

   echo "Oracle startup: cannotstart"

   exit 1

fi

#depending on parameter -- start, stop, restart

# ofthe instance and listener or usage display

case"$1" in

start)

#Oracle listener and instance startup

echo-n "Starting Oracle: "

su -$ORCL_OWN -c "$ORACLE_HOME/bin/dbstart"

touch/var/lock/subsys/oradb

su -$ORCL_OWN -c "$ORACLE_HOME/bin/emctl start dbconsole"

echo"OK"

;;

stop)

#Oracle listener and instance shutdown

echo-n "Shutdown Oracle: "

su -$ORCL_OWN -c "$ORACLE_HOME/bin/emctl stop dbconsole"

su -$ORCL_OWN -c "$ORACLE_HOME/bin/dbshut"

rm -f/var/lock/subsys/oradb

echo"OK"

;;

reload|restart)

$0stop

$1start

;;

*)

echo"Usage: 'basename $0' start|stop|restart|reload"

exit1

esac

exit0

 

将该文件添加到开机启动

 

#chmod755 /etc/rc.d/init.d/oradb 

#chkconfig --add oradb 

# chmod755 /etc/rc.d/init.d/oradb

#chkconfig --add oradb

 

重启服务

 

#serviceoradb stop 

#service oradb start 

#service oradb stop

#service oradb start

 

开机启动监听

linux的oracle如何开机启动监听器?

先将/ect/oratab中
ora9i:/opt/ora9/product/9.2:N 中的N改成Y
然后在/ETC/rc.local 中加下面一行
su - oracle -c 'lsnrctl start'
这样,机器一起来,监听器就自动起来了

 

 

 

错误 ora 12560 linux

TNS-12560: TNS:protocoladapter error

出错原因

在/etc/hosts中设置错误

[[email protected]~]# cat /etc/hosts

127.0.0.1   localhostlocalhost.localdomain localhost4 localhost4.localdomain4

#::1         localhost localhost.localdomainlocalhost6 localhost6.localdomain6

 

 

10.88.123.46DataNode2

[[email protected]~]#

 

缺少127.0.0.1,对本机域名的解析,导致oracle监听程序无法启动