环境搭建:
软件包括 VMware-server-2.0.2-203138
RHEL AS 4.7
Oracle 10g
一 VMware-server-2.0.2 的安装
安装很简单,一路next之后需要注意的是进入VMware-server 需要用户名和密码 此时是你当前操作系统的用户名和密码
我这部分安装是基于windows XP 的,对VMware-server感兴趣的朋友还可以参照基于linux平台去搭建VMware server
创建一个虚拟主机环境
虚拟机命名-->选择操作系统 redhat 4 64bit-->分配内存和CPU 内存2G cpu 2-->分配硬盘大小 disk 20G
分配网络模式-->桥接模式即可-->配置CD/DVD
完成之后,给虚拟机加电后 power on 就可以安装 RHEL AS 4.7 系统了
二 RHEL AS 4.7 的安装
Linux 的安装最重要的我认为是空间的划分,这个阶段部署好了为后来的oracle 10g安装起到关键的作用。否则的话,很可能导致你的数据库软件无法安装或者影响性能。
这部分我还没有研究透彻,就先把我的划分空间贴出来 注:好的习惯是成功的基础 空间分配不妥直接会影响你系统的性能
[root@localhost /]# fdisk -l
Disk /dev/sda: 19.3 GB, 19327352832 bytes
255 heads, 63 sectors/track, 2349 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 131 1052226 83 Linux
/dev/sda2 132 1151 8193150 83 Linux
/dev/sda3 1152 1412 2096482+ 82 Linux swap
/dev/sda4 1413 2349 7526452+ 5 Extended
/dev/sda5 1413 1425 104391 83 Linux
/dev/sda6 1426 2000 4618656 83 Linux
/dev/sda7 2001 2349 2803311 83 Linux
[root@localhost /]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 8064304 6072672 1581976 80% /
/dev/sda1 1035660 42180 940872 5% /boot
none 1028044 0 1028044 0% /dev/shm
/dev/sda5 101086 6324 89543 7% /opt
/dev/sda6 4546016 2835712 1479372 66% /u01
/dev/hdc 2605978 2605978 0 100% /media/cdrom
哈哈 我的根目录空间所剩无几,看来得需要清理一下了 ^_^
安装过程主要是选择文件包 需要注意选择完安装包后,后面有detail 你要打开看看,有的服务和安装包需要安装上。
安装完linux系统后,此时的系统是无法接受root用户telnet的。要想让root用户telnet需要操作:
1、首先确认是否安装了telnet telnet-server的rpm包
[root@localhost /]# rpm -qa telnet*
telnet-server-0.17-31.EL4.5
telnet-0.17-31.EL4.5
2、修改telnet服务的配置文件
vi /etc/xinetd.d/telnet
service telnet
{
disable = yes
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
}
将disable=yes行前加#,或者改为disable=no
3、重新启动xinetd守护进程
[root@localhost root]#service xinetd restart
由于telnet服务也是由xinetd守护的,所以安装完telnet-server,要启动telnet服务就必须重新启动xinetd
4、关闭系统防火墙
linux系统默认的防火墙是“high”
[root@localhost root]# setup
选择:“firewall configuration”
选择:security level——“no firewall”
5、vi /etc/pam.d/login
在 auth required /lib/security/pam_securetty.so 这行前加 # ,即把这行注释掉就行啦!
6、vi /etc/securetty
加入下面几行:
pts/0
pts/1
pts/2
pts/3
开启linux的ftp服务功能:
[root@localhost root]#service vsftpd start
留下的疑问是:root用户的ftp功能如何开启 在网上找了不少资料 通过验证发现都是失败的 。有空接着研究!
在linux系统下我建了一个初始用户admin 现在用他来上传我的oracle10g安装包
在/下 mkdir oracle mkdir oracle10g之后
在本机OS下 运行cmd
ftp linux_ip_address
user:admin
password:admin
ftp> pwd
257 "/home/admin"
ftp> cd ..
250 Directory successfully changed.
ftp> cd /
250 Directory successfully changed.
ftp> cd oracle/oracle10g
250 Directory successfully changed.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
lost+found
226 Directory send OK.
ftp: 收到 12 字节,用时 0.00Seconds 12000.00Kbytes/sec.
ftp> pwd
257 "/oracle/oracle10g"
ftp> cd oracle10g
250 Directory successfully changed.
ftp> put 10201_database_linux_x86_64.cpio.gz
200 PORT command successful. Consider using PASV.
150 Ok to send data.
> Netout :软件造成连接终止
451 Failure writing to local file.
ftp: 发送 92142210 字节,用时 16.02Seconds 5753.13Kbytes/sec.
ftp>
造成这个现象的问题是 系统空间不足 需要扩系统空间
执行root#fdisk -l
执行root#fdisk /dev/sda
p print the partition table
w write table to disk and exit
root#shutdown -r
[root@localhost /]# mke2fs -j -L 'logical' /dev/sda6
mkdir /u01
要想系统重启后mount /u01 需要修改操作:
vi /etc/fstab
root@db1 /]# vi /etc/fstab
# This file is edited by fstab-sync - see 'man fstab-sync' for details
LABEL=/ / ext3 defaults 1 1
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
LABEL=SWAP-sda2 swap swap defaults 0 0
/dev/sda6 /u01 ext3 defaults 0 0
安装xmanager后无法连接linux 需要设置如下操作: (xmanager工具安装oracle10g时需要修改的操作)
通过xmanager管理linux(本文RHL AS4 )需要在linux下做相应的设置以启动服务。
1. 打开 /etc/inittab文件,将 runlevel 变为5, 即id:5:initdefault: 如果原来就是5,则不用修改。
2. 打开 /etc/X11/gdm/gdm.conf 文件,对于Fedora Core 5 是/etc/gdm/custom.conf文件 找到 [xdmcp] 部分,将 Enabled 选项设为true或1。
3. 打开 /etc/X11/xdm/xdm-config 文件, 找到DisplayManager.requestPort: 0, 然后在前面加!。
4. 打开/etc/X11/xdm/Xaccess文件 找到#*#any host can get a login window,将第一个#去掉。
5. 打开 /etc/X11/xdm/kdmrc /usr/share/config/kdm/kdmrc 或 /etc/opt/kde2/share/config/kdm/kdmrc文件(根据你的操作系统不同而打开不同的文件)。找到[xdmcp]部分, 修改 Enable为true。
6. 如果你的机器上配置了防火墙
7. 重新启动操作系统,以使系统生效
如何扩展swap 空间 (在安装oracle10g过程中提示swap空间不足,此处参见swap分配原则)
[oracle@localhost ~]$ kill 6435
[oracle@localhost ~]$ exit
logout
[root@localhost ~]# pwd
/root
[root@localhost ~]# cd /
[root@localhost /]# fdisk -l
Disk /dev/sda: 19.3 GB, 19327352832 bytes
255 heads, 63 sectors/track, 2349 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 131 1052226 83 Linux
/dev/sda2 132 1151 8193150 83 Linux
/dev/sda3 1152 1412 2096482+ 82 Linux swap
/dev/sda4 1413 2349 7526452+ 5 Extended
/dev/sda5 1413 1425 104391 83 Linux
/dev/sda6 1426 2000 4618656 83 Linux
/dev/sda7 2001 2349 2803311 83 Linux
[root@localhost /]# fdisk /dev/sda
The number of cylinders for this disk is set to 2349.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help):
Command (m for help):
Command (m for help):
Command (m for help):
Command (m for help):
Command (m for help):
Command (m for help): q
[root@localhost /]# free
total used free shared buffers cached
Mem: 2056092 498372 1557720 0 22184 330532
-/+ buffers/cache: 145656 1910436
Swap: 2096472 0 2096472
[root@localhost /]# pwd
/
[root@localhost /]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 8064304 5037324 2617324 66% /
/dev/sda1 1035660 42180 940872 5% /boot
none 1028044 0 1028044 0% /dev/shm
/dev/sda5 101086 5666 90201 6% /opt
/dev/sda6 4546016 41996 4273088 1% /u01
/dev/hdc 2605978 2605978 0 100% /media/cdrom
[root@localhost /]# pwd
/
[root@localhost /]# pwd
/
[root@localhost /]# mkdir swap
[root@localhost /]# cd swap
[root@localhost swap]# dd if=/dev/zero of=swapfile bs=128k count=8192 128k*8192=1G
8192+0 records in
8192+0 records out
[root@localhost swap]# ls -al
total 1049616
drwxr-xr-x 2 root root 4096 Oct 26 03:47 .
drwxr-xr-x 27 root root 4096 Oct 26 03:41 ..
-rw-r--r-- 1 root root 1073741824 Oct 26 03:47 swapfile
[root@localhost swap]# mkswap swapfile
Setting up swapspace version 1, size = 1073737 kB
[root@localhost swap]# swapon swapfile
[root@localhost swap]# ls -l
total 1049604
-rw-r--r-- 1 root root 1073741824 Oct 26 03:48 swapfile
[root@localhost swap]# free
total used free shared buffers cached
Mem: 2056092 1574468 481624 0 23904 1379208
-/+ buffers/cache: 171356 1884736
Swap: 3145040 0 3145040
[root@localhost swap]#
到此为止,linux系统的调整就到这里 从中发现数据库是应用软件,需要建立在一个性能良好的系统下运行,对于linux操作系统的了解,到目前我还是一知半解。因此有必要在闲暇之余补补功课了 哈哈 各位同仁见笑了!
三 oracle10g 的安装
oracle10g安装分为三种: dbca 自动安装 ; 手工建库 ; 模板建库
本次安装采用的是自动安装,以后还要对手工建库和模板建库做一个分类操作!
上传10201_database_linux_x86_64.cpio.gz并解压
ftp >prompt off
ftp >cd oracle/oracle10g
ftp >mput 10201_database_linux_x86_64.cpio.gz
root#gunzip 10201_database_linux_x86_64.cpio.gz
root#cpio -idmv < 10201_database_linux_x86_64.cpio
[oracle@localhost ~]$ sqlplus /nolog
-bash: sqlplus: command not found
环境变量/home/oracle/.bash_profile
vi .bash_profile
在 path= 加入$ORACLE_HOME/bin
exit 后再次su - oracle 方生效
/home/oracle
vi .bash_profile
umask 022
export ORACLE_HOME=/u01/oracle10g/app/product/10.2.0/db_1;
export ORACLE_BASE=/u01/oradata
export ORACLE_SID=orcl
PATH=$PATH:$ORACLE_HOME/bin
export PATH
unset USERNAME
DISPLAY=172.16.10.7:0.0;export DISPLAY
为了ORACLE有更好的性能。建议关掉以下的服务:
chkconfig cups off
chkconfig sendmail off
chkconfig isdn off
chkconfig smartd off
chkconfig iptables off
chkconfig pcmcia off
检查ORACLE在REDHAT Linux的安装所需要的软件包是否已经装上
binutils
compat-db
compat-libstdc++
control-centre
gcc
gcc-c++
glibc
glibc-common
gnome-libs
libstdc++
libstdc++-devel
make
pdksh
sysstat
xscreensaver
setarch
rpm -qa binutils compat-* control-centre gcc* glibc* gnome-libs libstdc* make pdksh sysstat xscreensaver setarch
如缺少上述软件包,可在redhat安装盘上找相应的文件安装。例如:
rpm –ihv sysstat-5.0.5-1.rhel4.i386.rpm
创建Oracle组和用户帐户
用root执行以下语句:
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/useradd -m -g oinstall -G dba oracle
id oracle
passwd oracle
创建目录 用root执行以下语句
mkdir -p /oracle/u01/app/
mkdir -p /oracle/u01/oradata
chown -R oracle:oinstall /oracle/u01/app/ /oracle/u01/oradata
chmod -R 775 /oracle/u01/app/ /oracle/u01/oradata
配置Linux内核参数
下面的配置是oracle10g需要的最小值,如果你的电脑配置比这个大,就不用更改了:
cat >> /etc/sysctl.conf <<EOF
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=1048576
net.core.wmem_default=262144
net.core.rmem_max=1048576
net.core.wmem_max=262144
EOF
/sbin/sysctl –p
对每个参数值做个简要的解释和说明:
(1) shmmax:该参数定义了共享内存段的最大尺寸(以字节为单位)。缺省为32M,对于oracle来说,该缺省值太低了,通常将其设置为2G。
(2) shmmni:这个内核参数用于设置系统范围内共享内存段的最大数量。该参数的默认值是 4096 。通常不需要更改。
(3) shmall:该参数表示系统一次可以使用的共享内存总量(以页为单位)。缺省值就是2097152,通常不需要修改。
(4) sem:该参数表示设置的信号量。
(5) file-max:该参数表示文件句柄的最大数量。文件句柄设置表示在linux系统中可以打开的文件数量。
为oracle用户设置Shell限制
cat >> /etc/security/limits.conf <<EOF
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
EOF
cat >> /etc/pam.d/login <<EOF
session required /lib/security/pam_limits.so
EOF
cat >> /etc/profile <<EOF
if [ /$USER = "oracle" ]; then
if [ /$SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
EOF
cat >> /etc/csh.login <<EOF
if ( /$USER == "oracle" ) then
limit maxproc 16384
limit descriptors 65536
umask 022
endif
EOF
拷贝安装文件,并解压,然后执行
./runInstaller
[root@localhost oraInventory]# ./orainstRoot.sh
Changing permissions of /u01/oradata/oraInventory to 770.
Changing groupname of /u01/oradata/oraInventory to oinstall.
The execution of the script is complete
[root@localhost oraInventory]# cd ..
[root@localhost oradata]# cd ..
[root@localhost u01]# ls
lost+found oracle10g oradata
[root@localhost u01]# cd oracle10g
[root@localhost oracle10g]# ls
app
[root@localhost oracle10g]# cd app
[root@localhost app]# cd pr*
[root@localhost product]# cd 10*
[root@localhost 10.2.0]# cd db_1
[root@localhost db_1]# ./root.sh
Running Oracle10 root.sh script...
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/oracle10g/app/product/10.2.0/db_1
Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...
Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
[root@localhost db_1]# cd /
[root@localhost /]# su - oracle
[oracle@localhost ~]$ vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
umask 022
export ORACLE_HOME=/u01/oracle10g/app/product/10.2.0/db_1;
export ORACLE_BASE=/u01/oradata
export ORACLE_SID=orcl
PATH=$PATH:$HOME/bin
export PATH
unset USERNAME