本文标识 : O00001
本文编辑 : 严小样儿 编程工具 : Oracle、Linux、Xstart、CRT或Xshell 阅读时长 : 15分钟
ORACLE 11g 数据库的安装与配置
本文讲述的是基于Oracle Linux 5 update 2下 Oracle 11g 数据库的安装与配置,Linux系统是由VMWare虚拟机创建的,可以查看本公众号历史文章进行学习。查看文档之前,请确保你已经学会了基本的Linux命令。安装所需要的所有介质,可以通过阅读原文来获取。大家可以跟着我的教程一步步进行。
一、Checking the Hardware Requirements
1. Memory Requirements
(1) RAM 要求
Minimum RAM:1GB of RAM
Recommended:2GB of RAM or more
查看当前系统的内存信息,可以使用
# grep MemTotal /proc/meminfo
MemTotal:2035792 kb
(2) Swap 要求
查看当前系统的 Swap 空间信息,可以使用
# grep SwapTotal /proc/meminfo
SwapTotal:2064376 kb
2. Disk Space Requirements
(1)硬盘要求
At least 1GB of disk space in the /tmp directory
查看当前系统的磁盘信息,可以使用
# df –h /tmp
二、Checking the Software Requirements
1. Operating System Requirements
Oracle Linux 5 update 2(with Red Hat Compatible Kernel)
查看当前操作系统情况,可以使用
# cat /proc/version
2.Kernel Requirements
On Oracle Linux 5 Update 2
2.6.18 or later (with Red Hat Compatible Kernel)
查看内核情况,可以使用
# uname –r
3. Package Requirements
图形化安装时,安装包可以在安装过程中缺少什么装什么,如果是静默安装,必须提前安装好所需安装包。
4. Creating Required Operating System Groups and Users
# groupadd [-g gid] oinstall (oinstall管理系统文件)
# groupadd [-g gid] dba (dba管理数据库)-g gid 自己指定groupid
# useradd -g gid -G gid [-u uid] oracle –直接写组名即可
# id oracle
# passwd oracle 修改密码
三、Configuring Kernel Parameters
配置内核参数
Using any text editor, create or edit the /etc/sysctl.conf file, and add or edit lines similar to the following:
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
If necessary, update the resource limits in the /etc/security/limits.conf configuration file for the installation owner.
For example, add the following lines to the /etc/security/limits.conf file:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
四、Creating Required Directories
# mkdir -p /u01/app/oracle/product/11204/db_1/
# mkdir -p /u01/soft/
# chown -R oracle:oinstall /u01/
# chmod -R 775 /u01/
# su - oracle
$ cd /u01/soft/
使用连接SFTP标签页,与Windows系统连接,上传压缩包
如果使用的是Xshell可以直接拖拽上传。
sftp> lpwd
C:/Users/Administrator/Documents
sftp>pwd
/root
sftp>cd /u01/soft/
sftp> put C:\Users\Administrator\Desktop\Database\p13390677_112040_Linux-x86-64_1of7.zip
Uploading p13390677_112040_Linux-x86-64_1of7.zip to /root/p13390677_112040_Linux-x86-64_1of7.zip //linux的当前目录在哪里,一般会安装在哪里
100% 1362873KB 12278KB/s 00:01:51
C:/Users/Administrator/Desktop/Database/p13390677_112040_Linux-x86-64_1of7.zip: 1395582860 bytes transferred in 111 seconds (12278 KB/s)
sftp> put C:\Users\Administrator\Desktop\Database\p13390677_112040_Linux-x86-64_2of7.zip /u01/soft //指定路径是没用的
Uploading p13390677_112040_Linux-x86-64_2of7.zip to /root/p13390677_112040_Linux-x86-64_2of7.zip
C:/Users/Administrator/Desktop/Database/p13390677_112040_Linux-x86-64_2of7.zip: 1151304589 bytes transferred in 96 seconds (11711 KB/s)
#注意权限问题!传上去的文件,应该是属于root的,注意查看~
同时:我们也可以用scp file_name oracle@192.168.112.2:/u01/soft进行文件的上传、拷贝。
上传上去的压缩包使用unzip file_name解压到/u01/soft,它会自动建立一个目录/u01/soft/database
五、Configuring the Oracle User Environment
图形化安装时,解压之后,使用小xstart工具调试小闹钟
调试好后切记在xstart里面运行脚本sh runInstaller
如下图,打开Xstart软件、连接、运行,并进行如下的操作:
运行报错bash: /usr/bin/xterm: No such file or directory
解决: yum install -y xterm
bash: xclock: command not found...
解决:yum install xorg-x11-apps*
[root@root ~]# xhost
access control disabled, clients can connect from any host INET6:fe80::c190:df39:d623:2c5d
INET:192.168.1.102 INET6:fe80::84b9:1d0f:29e3:3223 INET:192.168.112.1 INET6:fe80::d935:51cf:9289:80a1
INET:192.168.74.1
INET6:localhost6.localdomain6 INET:root
INET6:2001:0:d389:aaf6:2069:c:3f57:fe99 INET6:fe80::2069:c:3f57:fe99
LOCAL:
[root@root ~]# xclock
[root@root ~]# su - oracle
[oracle@root ~]$ xclock
X connection to localhost:10.0 broken (explicit kill or server shutdown).
[oracle@root ~]$ export DISPLAY=192.168.112.1:0.0
[oracle@root ~]$ xclock
[oracle@root ~]$
出现如下图样式的小闹钟就说明可以进行安装了。
六、Installing Oracle Database
第一种安装oracle软件的方式——图形化安装
在Xstart上进行操作,步骤如下:
# su - oracle
$ cd /u01/soft/database/
$ sh runInstaller
如果在安装软件时,缺少必需的程序包,需要使用yum源来安装程序包;
使用yum之前,需要挂载光盘(光盘充当的是安装linux时的虚拟硬盘mount /dev/sr0 /mnt/cdrom
然后修改配置文件
vi /etc/yum.repos.d/local.repo
[Server]
name=Server
baseurl=file:///mnt/cdrom/Server
enabled=1
gpgcheck=0
注意:这里比较关键!!!
需要把每一个安装包/依赖包安装上,如果通过yum install XXX不可以的话,直接去网站
wget http://vault.centos.org/5.11/os/x86_64/CentOS/XXX ,rpm -ivh xxx.rpm 更方便
安装完成,如果出现如下目录,表示成功:
七、数据库配置
操作步骤如下:
1. 启动 xstart
2. #su – oracle
3. $source .bash_profile
4. $dbca
八、网络服务配置
在Xstart里面
1.$ su - oracle
2.$ Netca
运行$sqlplus / as sysdba,查看是否显示如下信息:
Connectedto:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options.
若有,说明 Oracle 安装成功!
九、环境变量配置
在oracle用户家目录下进行编辑环境变量
$ vi .bash_profile
export TMP=/tmp
export TMPDIR=/tmp
export ORACLE_SID=oracle
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11204/db_1
export PATH=$ORACLE_BASE/bin:$ORACLE_HOME/bin:$PATH
把以上内容加入到.bash_profile文件中即可,记得source以后才生效哦~
写在最后:
Oracle数据库的安装的确有点烦人,熟练的人安装Oracle也得两到三个小时,小白或者初学者估计需要更久。但是,作为关系型数据库的老大,还是有必要进行学习的。如果你能把Oracle学会,那么学习任何其他数据库都会觉得So Easy~
Oracle数据库的安装比较复杂,小样儿特别贴心的给大家把需要的安装包准备好了。关注公众号后,发送Oracle安装即可获取阅读原文里面的链接密码。大家一定要亲自动手尝试安装一下,如果有哪里不懂的,请留言反馈给我们。
(下期再会)
期待一起成长