全部博文(93)
分类: Oracle
2010-10-12 17:44:54
虚拟机扩容及部署oracle
前段时间安装了一回oracle10g,现整理安装过程如下:
环境:centos 5.5 final
Vmware7
Oracle10.2.0g
参考文档:Centos5安装oracle10g.doc
一、Vmware7添加新的虚拟硬盘:
创建虚拟硬盘
1、关闭VM中正在运行的虚拟系统;
2、在虚拟系统名称上点右键-》Virtual Machine Settings;
3、在Hardware页点“Add”-》Add a hard disk-》Create a new virtual disk-》SCSI(recommended)-》分配空间大小(20G)-》OK;
4、可以看见Hardware中出现了一块新的硬盘Hard Disk 2。
对虚拟硬盘进行分区和格式化
1. 登入系统:
[root@test9 ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 144 1052257+ 82 Linux swap / Solaris
/dev/sda3 145 2610 19808145 83 Linux
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
2. [root@test9 ~]# fdisk /dev/sdb
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610):
Using default value 2610
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
3. mkfs.ext3 /dev/sdb1
4. 建立挂载目录:[root@test9 ~]#mkdir /data1
5. 挂载: [root@test9 /]#mount /dev/sdb1 /data1/
6. 设置开机挂载:
[root@test9 /]# vim /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
LABEL=SWAP-sda2 swap swap defaults 0 0
/dev/sdb1 /data1 ex3 defaults 1 2
7. 至此,虚拟机扩容完成,以后可将其它应用安装到/data1下。
二、oracle10g在centos5.5下的部署
1. 环境配置
查询包是否完整:
gcc-4.1.2-48.el5
make-3.81-3.el5
binutils-2.17.50.0.6-14.el5
setarch-2.0-1.1
libaio-0.3.106-5
compat-libstdc++-33-3.2.3-61.i386.rpm <--必须
libXp-devel-1.0.0-8.i386.rpm
openmotif-devel-2.3.0-0.3.el5.i386.rpm
openmotif22-2.2.3-18.i386.rpm
perl-libxml-perl-0.08-1.2.1.noarch.rpm
可利用yum install来安装这些包,避免包的依赖。
2. 修改内核参数
kernel参数修改vi /etc/sysctl.conf , 在行末添加以下内容,在CentOs5.0上会看到
kernel.shmmax = 4294967295
kernel.shmall = 268435456这些参数已经存在并且默认启用了,
需要将原kernel.shmmax与kernel.shmall参数注释掉。并在文件末尾添加以下内容:
#use for oracle10g
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=262144
net.core.rmem_max=262144
net.core.wmem_default=262144
net.core.wmem_max=262144
另外在安装oracle数据库的时候要注意/etc/hosts与/etc/sysconfig/network文件主机名的一致性,
否则会在后面运行netca和dbca可能出现错误提示。
例如:/etc/hosts文件内容如下:
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
/etc/sysconfig/network内容如下:
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain
3. vi /etc/security/limits.conf
在文件末尾添加以下内容
#use for oracle10g
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
4. vi /etc/pam.d/login 行末添加以下内容
session required /lib/security/pam_limits.so
session required pam_limits.so
5. vi /etc/selinux/config 确保以下内容
SELINUX=disabled
关闭SELIINUX
6. vi /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
7. 因为默认centos5.0不支持10.2,0.1,修改配置文件,使CentOs5.0 支持Oracle10g .
[root@localhost ~]# cp /etc/redhat-release redhat-release.bak
备份要修改的文件 。
直接修改/etc/redhat-release内容为 redhat-4
再运行sysctl -p应用以上参数
8. 创建和配置用户
[root@localhost ~]# groupadd oinstall //创建oracle数据库安装组
[root@localhost ~]# groupadd dba //创建oracle数据库管理组
[root@localhost ~]# useradd -m -g oinstall -G dba oracle //创建oracle用户
[root@localhost ~]# id oracle
uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba)
passwd oracle //为Oracle用户设置密码:(oracle/oracle)
Changing password for user oracle.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
9. 创建安装目录
mkdir -p /u01/oracle //创建oracle的BASE 目录
chown -R oracle:oinstall /u01/oracle //修改BASE目录的属主和属组
chmod -R 775 /u01/oracle
mv /root/10201_database_linux32.zip /u01/
unzip /u01/10201_database_linux32.zip
10. 修改 Oracle 用户 .bash_profile
# su - oracle
$ vi ./.bash_profile
添加
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/10g
export ORACLE_SID=boson //数据库实例的SID,在图形界面安装过程中要求输入SID与这里保持相同
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
11. 开始安装
# su - oralce
$ cd /u01/databases //Oracle解压后产生的目录
$ export LANG=en_US //设置临时环境变量,解决oracle图形界面显示乱码的问题
$ ./runInstaller //可以加参数-ignoreSysPreReqs,跳过对系统安装前的检查
一直下一步就可以了.
然后提升至root用户,运行oracle安装完成后,提示的两个脚本.
三、 故障排除。
1. 执行./runinstaller时报错
[oracle@test9 database]$ Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(Unknown Source)
at java.awt.Window.init(Unknown Source)
at java.awt.Window.
at java.awt.Frame.
at oracle.ewt.popup.PopupFrame.
at oracle.ewt.lwAWT.BufferedFrame.
at oracle.sysman.oio.oioc.OiocOneClickInstaller.
at oracle.sysman.oio.oioc.OiocOneClickInstaller.main(OiocOneClickInstaller.java:2091)
解决方法:
在文本模式下 用root登录
# startx
# xhost +
# su - oracle
$ export DISPLAY="192.168.1.15:0.0"
$ export LANG=en_US
$ cd /tmp/10201_database_linux32/databases
$ ./runInstaller
Swap空间不足的解决方法:
增加swap分区
[root@test9 u01]# dd if=/dev/zero of=/tmp/myswap bs=32k count=24576
[root@test9 u01]# mkswap /tmp/myswap
[root@test9 u01]# swapon /tmp/myswap
设为开机自挂载swap分区:
Vim /etc/fstab
添加:/tmp/myswap swap swap defaults 0 0
192.168.1.9 oracle信息:
Oracle_sid= orcl
Sys/system/sysman的密码:oracle
Server parameter filename: /data1/u01/oracle/10g/dbs/spfileorcl.ora
The following J2EE Applications have been deployed and are accessible at the URLs listed below.
iSQL*Plus URL:
iSQL*Plus DBA URL:
/dba
Enterprise Manager 10g Database Control URL:
四、 卸载oracle
1、运行 $ORACLE_HOME/bin/localconfig delete
2、 rm -rf $ORACLE_BASE/*
3、rm -f /etc/oraInst.loc /etc/oratab
4、rm -rf /etc/oracle
5、rm -f /etc/inittab.cssd
6、rm -f /usr/local/bin/coraenv /usr/local/bin/dbhome /usr/local/bin/oraenv
7、删除oracle用户和组。