Centos 7 64位 安装 Oracle 11g 详细过程总结
Oracle数据库安装过程总结 - Centos 7 64位 && Oracle 11g
环境说明:Centos 7 64位操作系统,内存约为17.5GB,/目录50G、/home150G,准备安装Oracle 11g数据库。
更多安装详情详细参阅 Oracle Database Quick Installation Guide for Linux x86-64
###I. 安装前准备
-
以root用户登录
-
配置交换分区
-
查看交换分区大小
[root@datanode1 ~]# swapon -s Filename Type Size Used Priority /dev/dm-1 partition 12517372 0 -1
- 1
- 2
- 3
-
查看内存大小
[root@datanode1 ~]# grep MemTotal /proc/meminfo MemTotal: 18315208 kB
- 1
- 2
-
增加交换分区(关键)
Oracle 官网上的文档给出了内存大小和对应要求交换空间大小的表格,如下:
Available RAM Swap Space Required Between 1 GB and 2 GB 1.5 times the size of the RAM Between 2 GB and 16 GB Equal to the size of the RAM More than 16 GB 16 GB 那么在我当前的环境下,交换空间至少要达到16GB。
-
确定要添加的交换分区大小
按照Oracle要求来即可,这里定的目标是超过内存大小。
18315208-12517372=5797836,所以补充6000000KB交换空间。
-
添加交换文件
[root@datanode1 swaps]# dd if=/dev/zero of=/home/swaps/swapfile bs=1024 count=6000000 6000000+0 records in 6000000+0 records out 6144000000 bytes (6.1 GB) copied, 174.731 s, 35.2 MB/s
-
格式化为交换文件系统
[root@datanode1 swaps]# mkswap /home/swaps/swapfile Setting up swapspace version 1, size = 5999996 KiB no label, UUID=0ba4a9f6-c14f-49d4-a926-c0f490353b15
-
启用交换文件
[root@datanode1 swaps]# swapon /home/swaps/swapfile swapon: /home/swaps/swapfile: insecure permissions 0644, 0600 suggested.
-
查看效果
[root@datanode1 swaps]# swapon -s Filename Type Size Used Priority /dev/dm-1 partition 12517372 0 -1 /home/swaps/swapfile file 5999996 0 -2
-
使交换分区在引导时启用
[root@datanode1 swaps]# vi /etc/fstab # # /etc/fstab # Created by anaconda on Mon Mar 19 16:39:39 2018 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/cl-root / xfs defaults 0 0 UUID=6ff20dbe-4789-4936-adcc-857215605628 /boot xfs defaults 0 0 /dev/mapper/cl-home /home xfs defaults 0 0 /dev/mapper/cl-swap swap swap defaults 0 0 /home/swaps/swapfile swap swap defaults 0 0
-
-
-
修改内核参数
[root@datanode1 swaps]# vi /etc/sysctl.conf # sysctl settings are defined through files in # /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/. # # Vendors settings live in /usr/lib/sysctl.d/. # To override a whole file, create a new file with the same in # /etc/sysctl.d/ and put new settings there. To override # only specific settings, add a file with a lexically later # name in /etc/sysctl.d/ and put new settings there. # # For more information, see sysctl.conf(5) and sysctl.d(5). kernel.shmall=2097152 kernel.shmmax=4294967295 kernel.shmmni=4096 kernel.sem=250 32000 100 128 fs.file-max=6815744 fs.suid_dumpable=1 fs.aio-max-nr=1048576 net.ipv4.ip_local_port_range=1024 65500 net.core.rmem_default=4194304 net.core.rmem_max=4194304 net.core.wmem_default=262144 net.core.wmem_max=1048576
修改完毕后,执行如下命令使之生效:
[root@datanode1 swaps]# sysctl -p /etc/sysctl.conf kernel.shmall = 2097152 kernel.shmmax = 4294967295 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 fs.file-max = 6815744 fs.suid_dumpable = 1 fs.aio-max-nr = 1048576 net.ipv4.ip_local_port_range = 1024 65500 net.core.rmem_default = 4194304 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576
-
安装必要的RPM软件包
官网上已经给列出一份清单:
binutils-2.23.52.0.1-12.el7.x86_64 compat-libcap1-1.10-3.el7.x86_64 compat-libstdc++-33-3.2.3-71.el7.i686 X compat-libstdc++-33-3.2.3-71.el7.x86_64 X gcc-4.8.2-3.el7.x86_64 gcc-c++-4.8.2-3.el7.x86_64 glibc-2.17-36.el7.i686 X glibc-2.17-36.el7.x86_64 glibc-devel-2.17-36.el7.i686 X glibc-devel-2.17-36.el7.x86_64 ksh libaio-0.3.109-9.el7.i686 X libaio-0.3.109-9.el7.x86_64 libaio-devel-0.3.109-9.el7.i686 X libaio-devel-0.3.109-9.el7.x86_64 libgcc-4.8.2-3.el7.i686 X libgcc-4.8.2-3.el7.x86_64 libstdc++-4.8.2-3.el7.i686 X libstdc++-4.8.2-3.el7.x86_64 libstdc++-devel-4.8.2-3.el7.i686 X libstdc++-devel-4.8.2-3.el7.x86_64 libXi-1.7.2-1.el7.i686 X libXi-1.7.2-1.el7.x86_64 libXtst-1.2.2-1.el7.i686 X libXtst-1.2.2-1.el7.x86_64 make-3.82-19.el7.x86_64 sysstat-10.1.5-1.el7.x86_64
一般情况下这些包应该能在Centos 7的安装镜像中找到,只是版本会比清单中的略高,直接用就可以了。上面清单中除了画X的都是可以从镜像中找到的,将这些包放到系统中某路径下,执行:
yum install *.rpm
即可同时利用yum解决依赖问题。安装过程中可能会出现错误提示某些包已经安装,不必理会。
再看看上面这些清单,乍一看没找到的包还不少,而且基本上都是i686(32位)的。然而Oracle官网给了这样一句说明:
Starting with Oracle Database 11g Release 2 (11.2.0.2), all the 32-bit packages, except for
gcc-32bit-4.3
, listed in the following table are no longer required for installing a database on Linux x86-64. Only the 64-bit packages are required.真是“柳暗花明又一村”啊,这样就只剩下
compat-libstdc++-33-3.2.3-71.el7.x86_64
这一个包没有安装了,使用yum -y install compat-libstdc++-33.x86_64
进行安装即可! -
创建必要的用户组和用户
-
创建oinstall/dba用户组
[root@datanode1 rpms]# groupadd oinstall [root@datanode1 rpms]# groupadd dba
-
创建oracle用户
[root@datanode1 rpms]# useradd -g oinstall -G dba oracle
-
指定oracle口令
[root@datanode1 rpms]# passwd oracle Changing password for user oracle. New password: Retype new password: passwd: all authentication tokens updated successfully.
-
配置oracle用户的.bash_profile
[root@datanode1 oracle]# vi /home/oracle/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/.local/bin:$HOME/bin export PATH #Oracle 11g export LANG=en_US.UTF-8 umask 022
-
-
创建必要的目录并重新指定权限
-
创建基目录
[root@datanode1 oracle]# mkdir -p OracleDB [root@datanode1 oracle]# ls OracleDB OracleDBInstall [root@datanode1 oracle]# pwd /home/oracle
-
修改访问权限
[root@datanode1 oracle]# chown -R oracle:oinstall /home/oracle [root@datanode1 oracle]# chmod -R 775 /home/oracle [root@datanode1 oracle]# chown -R oracle:oinstall OracleDB [root@datanode1 oracle]# chmod -R 775 OracleDB
-
-
配置环境变量
[root@datanode1 oracle]# vi /etc/profile ...... #Oracle 11g ORACLE_BASE=/home/oracle/OracleDB ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db ORACLE_SID=orcl PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin LD_LIBRARY_PATH=$ORACLE_HOME/lib export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH LD_LIBRARY_PATH
-
解压安装文件,准备安装
将下载下来的两个压缩文件解压到同一目录,然后重启准备安装。
II. 安装过程
-
配置DISPLAY
以root用户登录,执行:
[root@datanode1 ~]# export DISPLAY=:0.0 [root@datanode1 ~]# echo $DISPLAY :0.0 [root@datanode1 ~]# xhost + access control disabled, clients can connect from any host
然后切换到oracle用户并执行:
[oracle@datanode1 ~]$ export DISPLAY=:0.0 [oracle@datanode1 ~]$ echo $DISPLAY :0.0
-
执行安装过程
-
切换到Oracle安装包解压出来的目录,并执行:
[oracle@datanode1 ~]$ cd /home/oracle/OracleDBInstall/database/
[oracle@datanode1 database]$ ls
doc install response rpm runInstaller sshsetup stage welcome.html
[oracle@datanode1 database]$ ./runInstaller
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB. Actual 33670 MB Passed
Checking swap space: must be greater than 150 MB. Actual 12223 MB Passed
Checking monitor: must be configured to display at least 256 colors. Actual 16777216 Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-04-04_03-28-24PM. Please wait ...
此时会出现Oracle 11g图形安装界面。
- 1
-
按照图形界面步骤进行安装。
-
Configure Security Updates,取消勾选I wish to receive…。
-
Select Installation Option,保持默认设定Create and configure a database.
-
System Class,选择Server Class。
-
Node Selection,选择Single instance database installation。
-
Select Install Type,选择Advanced Install。
-
Select Product Languages,选择需要添加的语言,这里直接下一步。
-
Select Database Edition,选择Enterprise Edition。
-
Specify Installation Location,由于之前已经配置了环境变量,直接下一步。
-
Create Inventory,直接下一步。
-
Select Configuration Type,下一步。
-
Specity Database Identifiers。
-
Specify Configuration Options,这里要注意,在Memory tab下设置给Oracle数据库分配的内存,这里我给了5G多一点;在Character sets tab下设置Unicode字符集。
-
Specify Management Options。
-
Specify Database Storage Options。
-
Specify Recovery Options。
-
Specify Schema Passwords,这里可以选Use the same password for all accounts,这里的所有用户应该是管理员层面的用户而非普通用户;设定密码时一定要设一个稍微复杂点的,否则会提示The password entered does not conform to the Oracle recommended standards甚至无法继续进行安装。
-
Privileged Operating System Groups。
-
Perform Prerequisite Checks,如果前面的配置有哪个有问题,这里都会检测出来。
这里出现的问题解决方法:
-
Packages:一般的i386/i686直接忽略,比较重要的如elfutils/gcc-c++使用
yum -y install (name)
来安装。 -
Swap Size:按照前面的步骤重新开启即可,应该是配置问题导致引导时没有自动开启。
-
Hard Limit:执行:
[root@datanode1 ~]# vi /etc/security/limits.conf ..... # End of file * hard nofile 65536 "/etc/security/limits.conf" 62L, 2442C written [root@datanode1 ~]# ulimit -a #使修改生效 core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 71419 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 71419 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited
-
OS Kernel Parameters:semmni已经设置;ip_local_port_range还要改成9000到65500,不改不改。
还剩一些遗留问题,勾选Ignore All继续下一步。你也可以尝试点Fix & Check Again执行他提供的脚本,不过用处也不大。
-
-
Summary,总结了本次安装的配置信息。
-
Install Product,正式进行安装。
安装过程中界面可能变灰,查资料有人说是Centos GUI的问题,这是在等待输入,可能敲个回车就好了,或者还能拖动把实际的窗口找回来。可以肯定的是,界面变灰确实是在等待什么东西,而并非执行安装的时候界面卡了,曾经试过让他运行一段时间,结果发现界面没变,把进程kill掉后想启动监听服务,但是监听服务的脚本里面根本什么都没有,所以这里肯定是在等待某些东西。
-
配置服务器
执行:
[root@datanode1 db]# cd $ORACLE_HOME/bin [root@datanode1 bin]# ./netmgr
会启动Oracle Net Manager图形界面程序,在这里可以配置监听。
选择Local - Listeners - LISTENER,并在上方下拉列表中选择Database Services,选择Add Database,并将Global Database Name、SID改为orcl,如图:
保存配置,重新启动。
-
###III. 安装后操作
安装完成后还不能马上使用,需要进行一些额外的操作。
-
启动监听器
切换到oracle用户并执行:
[root@datanode1 ~]# su - oracle Last login: Wed Apr 4 15:26:15 CST 2018 on pts/0 [oracle@datanode1 ~]$ lsnrctl start LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 04-APR-2018 16:49:58 Copyright (c) 1991, 2009, Oracle. All rights reserved. Starting /home/oracle/OracleDB/product/11.2.0/db/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 11.2.0.1.0 - Production System parameter file is /home/oracle/OracleDB/product/11.2.0/db/network/admin/listener.ora Log messages written to /home/oracle/OracleDB/diag/tnslsnr/datanode1/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=datanode1)(PORT=1521))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 04-APR-2018 16:50:00 Uptime 0 days 0 hr. 0 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /home/oracle/OracleDB/product/11.2.0/db/network/admin/listener.ora Listener Log File /home/oracle/OracleDB/diag/tnslsnr/datanode1/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=datanode1)(PORT=1521))) Services Summary... Service "orcl" has 1 instance(s). Instance "orcl", status UNKNOWN, has 1 handler(s) for this service... The command completed successfully
-
启动Oracle 数据库实例
执行:
[oracle@datanode1 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Wed Apr 4 16:51:04 2018 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to an idle instance. SQL> startup ORACLE instance started. Total System Global Area 5478350848 bytes Fixed Size 2213216 bytes Variable Size 3019901600 bytes Database Buffers 2415919104 bytes Redo Buffers 40316928 bytes Database mounted. Database opened. SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
-
激活Scott用户
[root@datanode1 ~]# sqlplus SQL*Plus: Release 11.2.0.1.0 Production on Wed Apr 4 16:53:00 2018 Copyright (c) 1982, 2009, Oracle. All rights reserved. Enter user-name: system Enter password: Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> alter user scott account unlock; User altered. SQL> alter user scott identified by (your setting); User altered. SQL> select username,account_status from dba_users where username='scott'; no rows selected SQL> select username,account_status from dba_users where username='SCOTT'; USERNAME ACCOUNT_STATUS ------------------------------ -------------------------------- SCOTT OPEN