一、安装的硬件要求
1.内存:
内存最小1G,推荐2G。
2.Swap:
RAW |
Swap |
1G-2G |
1.5倍 |
2G-16G |
1倍 |
大于16G |
16G |
二、安装准备
安装包:
- linux.x64_11gR2_database_1of2.zip
- linux.x64_11gR2_database_2of2.zip
三、Oracle安装前准备
1.创建运行oracle 的系统用户及用户组
1 [root@localhost]# groupadd oinstall #创建用户组oinstall
2 [root@localhost]# groupadd dba #创建用户组dba
3 [root@localhost]# useradd -g oinstall -g dba -m oracle #创建oracle用户,并加入到oinstall和dba用户组
4 [root@localhost]# passwd oracle #设置用户oracle的登陆密码,不设置密码,在CentOS的图形登陆界面没法登陆
5 Changing password for user oracle.
6 New password: # 密码
7 BAD PASSWORD: The password is shorter than 8 characters
8 Retype new password: # 确认密码
9 passwd: all authentication tokens updated successfully.
2.创建oracle数据库安装目录
1 [root@localhost]# cd /. #进入根目录
2 [root@localhost]# mkdir -p /data/oracle #oracle数据库安装目录
3 [root@localhost]# mkdir -p /data/oraInventory #oracle数据库配置文件目录
4 [root@localhost]# mkdir -p /data/database #oracle数据库软件包解压目录
5 [root@localhost]# cd /data
6 [root@localhost data]# ls
7 database oracle oraInventory
8 [root@localhost data]# chown -R oracle:oinstall /data/oracle #设置目录所有者为oinstall用户组的oracle用户
9 [root@localhost data]# chown -R oracle:oinstall /data/oraInventory
10 [root@localhost data]# chown -R oracle:oinstall /data/database
3.修改OS系统标识(oracle默认不支持CentOS系统安装,但是centos其实就是redhat)
1 [root@localhost data]#cp /etc/redhat-release /etc/redhat-release.bak
2 [root@localhost data]# vi /etc/redhat-release
3 [root@localhost data]# cat /etc/redhat-release
4 redhat-7
4.安装oracle数据库依赖
1 [root@localhost data]# yum -y install binutils* compat-libcap1* compat-libstdc++* gcc* gcc-c++* glibc* glibc-devel* ksh* libaio* libaio-devel* libgcc* libstdc++* libstdc++-devel* libXi* libXtst* make* sysstat* elfutils* unixODBC*
安装完后若显示一些error信息,可重复执行上面代码,直至显示全部安装成功。
5.关闭防火墙
1 [root@localhost data]# systemctl stop firewalld.service #关闭防火墙
2 [root@localhost data]# systemctl status firewalld.service #查看防火墙状态(已关闭)
3 ● firewalld.service - firewalld - dynamic firewall daemon
4 Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
5 Active: inactive (dead) since Wed 2017-09-13 09:48:55 CST; 10s ago
6 Docs: man:firewalld(1)
7 Process: 641 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
8 Main PID: 641 (code=exited, status=0/SUCCESS)
9
10 Sep 13 09:22:58 localhost.localdomain systemd[1]: Starting firewalld - dynami...
11 Sep 13 09:23:08 localhost.localdomain systemd[1]: Started firewalld - dynamic...
12 Sep 13 09:48:54 localhost.localdomain systemd[1]: Stopping firewalld - dynami...
13 Sep 13 09:48:55 localhost.localdomain systemd[1]: Stopped firewalld - dynamic...
14 Hint: Some lines were ellipsized, use -l to show in full.
15 [root@localhost data]# systemctl disable firewalld.service #禁止使用防火墙(重启也是禁止的)
16 Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
17 Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
6.关闭selinux(重启生效)
1 [root@localhost ~]# vi /etc/selinux/config
2 [root@localhost ~]# cat /etc/selinux/config
3 # This file controls the state of SELinux on the system.
4 # SELINUX= can take one of these three values:
5 # enforcing - SELinux security policy is enforced.
6 # permissive - SELinux prints warnings instead of enforcing.
7 # disabled - No SELinux policy is loaded.
8 # SELINUX=enforcing
9 SELINUX=disabled
10 # SELINUXTYPE= can take one of three two values:
11 # targeted - Targeted processes are protected,
12 # minimum - Modification of targeted policy. Only selected processes are protected.
13 # mls - Multi Level Security protection.
14 SELINUXTYPE=targeted
7.修改内核参数
1 [root@local++host data]# vi /etc/sysctl.conf
2 [root@localhost data]# cat /etc/sysctl.conf
3 # sysctl settings are defined through files in
4 # /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
5 #
6 # Vendors settings live in /usr/lib/sysctl.d/.
7 # To override a whole file, create a new file with the same in
8 # /etc/sysctl.d/ and put new settings there. To override
9 # only specific settings, add a file with a lexically later
10 # name in /etc/sysctl.d/ and put new settings there.
11 #
12 # For more information, see sysctl.conf(5) and sysctl.d(5).
13 net.ipv4.icmp_echo_ignore_broadcasts = 1
14 net.ipv4.conf.all.rp_filter = 1
15 fs.file-max = 6815744 #设置最大打开文件数
16 fs.aio-max-nr = 1048576
17 kernel.shmall = 2097152 #共享内存的总量,8G内存设置:2097152*4k/1024/1024
18 kernel.shmmax = 2147483648 #最大共享内存的段大小
19 kernel.shmmni = 4096 #整个系统共享内存端的最大数
20 kernel.sem = 250 32000 100 128
21 net.ipv4.ip_local_port_range = 9000 65500 #可使用的IPv4端口范围
22 net.core.rmem_default = 262144
23 net.core.rmem_max= 4194304
24 net.core.wmem_default= 262144
25 net.core.wmem_max= 1048576
8.使内核配置生效
1 [root@localhost data]# sysctl -p
9.对oracle用户设置限制,提高性能
1 [root@localhost data]# vi /etc/security/limits.conf
2 [root@localhost data]# cat /etc/security/limits.conf
...
#@student - maxlogins 4
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
# End of file
10.配置用户环境变量
1 [root@localhost data]# vi /home/oracle/.bash_profile
2 [root@localhost data]# cat /home/oracle/.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
export ORACLE_BASE=/data/oracle #oracle数据库安装目录
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 #oracle数据库路径
export ORACLE_SID=orcl #oracle启动数据库实例名
export ORACLE_UNQNAME=orcl
export ORACLE_TERM=xterm #xterm窗口模式安装
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH #添加系统环境变量
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib #添加系统环境变量
export LANG=C #防止安装过程出现乱码
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK #设置Oracle客户端字符集,必须与Oracle安装时设置的字符集保持一致
11.使用户环境变量生效
1 [root@localhost data]# source /home/oracle/.bash_profile
12.重启系统使配置生效(reboot)
13.解压安装包
1 [oracle@localhost src]$ unzip linux.x64_11gR2_database_1of2.zip -d /data/database/
2 (省略...)
3 [oracle@localhost src]$ unzip linux.x64_11gR2_database_2of2.zip -d /data/database/
4 (省略...)
14.设置解压后目录拥有者及安装
1 [oracle@localhost src]$ su root
2 Password:
3 [root@localhost src]# chown -R oracle:oinstall /data/database/database/
4 [oracle@localhost /]$ cd /data/database/database/
5 [oracle@localhost database]$ ls
6 doc install response rpm runInstaller sshsetup stage welcome.html
7 [oracle@localhost database]$ ./runInstaller
8 Starting Oracle Universal Installer...
9 (省略...)
执行安装文件后,可能出现两个错误:
1.Checking swap space: ... failed (没有swap)
1 [root@localhost src]# dd if=/dev/zero of=/home/swapfile bs=1M count=512
2 [root@localhost src]# mkswap /home/swapfile
3 [root@localhost src]# swapon /home/swapfile
4 [root@localhost src]# vi /etc/fstab
5 [root@localhost src]# cat /etc/fstab
6 # /etc/fstab
7 # Created by anaconda on Fri Sep 11 15:02:38 2015
8 #
9 # Accessible filesystems, by reference, are maintained under '/dev/disk'
10 # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
11 #
12 UUID=daa7f800-7e00-4bbb-9791-93b926d23659 / xfs defaults 0 0
13 /home/swapfile swap swap defaults 0 0
然后重启终端
2.Checking monitor: ... failed
注销后以 oracle 用户直接登录,再执行安装文件即可, (云平台虚拟机一定要用xshell来执行安装,直接用云平台vnc安装会出现必要弹出框折叠情况,安装无法进行)
四、Oracle图形界面选项
1.、==++Configure Security Updates++==
去掉 I wish to receive security updates via My Oracle Support.
点击 "Next >"
2、==++Installation Option++==
选择第一项 Create and configure a database
点击 "Next >"
3、==++System class++==
选择Server class
点击 "Next >"
4、==++Grid Options++==
选择单例模式 Single instance database installation
点击 "Next >"
5、==++Install Type++==
选择"Advanced Install"
点击 "Next >"
6、==++Product Languages++==
选择英语 English(根据系统默认选择好了)
点击 "Next >"
8、==++Database Edition++==
选择第一个企业版
9、==++Installation Location++==
确定数据软件的安装路径,自动读取前面Oracle环境变量中配置的值
点击 "Next >",
之后也是选择默认,不做修改,直接点击"Next >"
10、==++Configuration Options++==
"Character Sets"选择第二项或者第三项中的"Unicode standard UTF-8..."
"Sample Schemas"勾选"Create database with ..."
点击 "Next >"
之后也是选择默认,不做修改,直接点击"Next >"
11、==++Schema Passwords++==
选择第二项,并设置密码
点击 "Next >"
之后也是选择默认,不做修改,直接点击"Next >"
12、==++Prepequisite Checks++==
按照提示信息一个一个解决。
注意:
OS Kernel Parameter 下的semmni的缺失是Oracle没有检测到,其实有,选中缺失的依赖包,如果下方详情栏里Expected value中有括号中标注(i386)或(i686),是在提示缺少32位的依赖包,但是实际上已经安装了64位的依赖包,忽略它们,pdksh包已经安装,就是之前安装的ksh依赖包。
如果还有提示的其他缺少的依赖包没有安装就去安装,按提示解决缺少的依赖包,之后点击 “Check Again”,再检查一遍,没有问题了,勾选ignore all,点击“Next”
13、==++Summary++==
点击 "Finsh"
14、==++Install Product++==
在此过程中,安装界面会变成黑色,有一长条出现(其实是一个提示框),调整高度与宽度查看
安装过程中连接库时,会出现两个错误:
1)ins_ctx.mk编译错误
查看日志有以下错误:
INFO: /lib64/libstdc++.so.5: undefined reference to `memcpy@GLIBC_2.14'
INFO: collect2: error: ld returned 1 exit status
INFO: make: *** [ctxhx] Error 1
网上说是glibc的版本2.17过高所致(高于2.14),解决办法:
进入管理员权限安装glibc-static
1 [oracle@localhost ~]# su - root
2 password
3 [root@localhost ~]# yum -y install glibc-static
该软件包包含一个静态链接库,地址是:/usr/lib64/libc.a
修改/data/oracle/product/11.2.0/db_1/ctx/lib/ins_ctx.mk,将
ctxhx: $(CTXHXOBJ)
$(LINK_CTXHX) $(CTXHXOBJ) $(INSO_LINK)
修改为:
ctxhx: $(CTXHXOBJ)
-static $(LINK_CTXHX) $(CTXHXOBJ) $(INSO_LINK) /usr/lib64/libc.a
点击Retry继续安装。
2)”Error in invoking target 'agent nmhs' of makefile '/data/oracle/product/11.2.0/db_1/sysman/lib/ins_emagent.mk.'
解决方法:在makefile中添加链接libnnz11库的参数
修改/data/oracle/product/11.2.0/db_1/sysman/lib/ins_emagent.mk,将
$(MK_EMAGENT_NMECTL)修改为:$(MK_EMAGENT_NMECTL) -lnnz11
点击Retry继续安装。
有时候安装界面出现的灰色竖线无法拉开,可以重新运行./runInstaller,在重复上述步骤以后,第11步做完直接按照上面两个问题的解决办法修改两个mk文件,修改好安装时就不会报错了。mk文件是makefile文件,要以tab键开头,所以直接复制上面的修改语句会报错,要把
-static $(LINK_CTXHX) $(CTXHXOBJ) $(INSO_LINK) /usr/lib64/libc.a的前面的空格修改成tab键,不然会报错。
3)安装Database Configuration Assistant会需要挺长的时间,当安装完成后会弹出一个对话框,点击"Password management...",将竖线拉成对话框,给SYS、System、Scoot、SH设置密码,它们的默认密码分别是SYS:change_on_install、System:manager、Scoot:tiger、SH:sh,分别输入进对应的密码输入框中,在Scoot、SH设置密码之前,点击对号就可以为它们设置密码了。
4)最后等进度在100%的时候,会出现一个竖线,把它拉开,按照里面的提示以root权限进入提示的地址,运行上面提示的两个sh文件,第二个sh文件要你选地址直接回车就好了
这样就安装完成了。
五、设置开机自启动
1.配置/etc/oratab,使oracle允许自启动
1 [oracle@localhost root]$ vi /etc/oratab
2 [oracle@localhost root]$ cat /etc/oratab
#
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
orcl:/data/oracle/product/11.2.0/db_1:Y
2.配置开机自启
1 [root@localhost root]# vi /etc/rc.d/rc.local
2 [root@localhost root]# cat /etc/rc.d/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
su oracle -lc "/data/oracle/product/11.2.0/db_1/bin/lsnrctl start"
su oracle -lc /data/oracle/product/11.2.0/db_1/bin/dbstart
touch /var/lock/subsys/local
为rc.local 添加执行权限
1 [root@localhost root]# chmod +x /etc/rc.d/rc.local
2 [root@localhost root]# reboot #重启机器,确认结果
总结:安装整个过程算是比较麻烦的,参考了很多好的帖子,最后还算满足了我的需求,组合记录下我需要的内容。安装完成后重启设备,如果想要操作oracle数据库,需要手动激活oracle环境,如下:
1 [root@localhost data]# source /home/oracle/.bash_profile
参考: https://www.cnblogs.com/muhehe/p/7816808.html
https://blog.csdn.net/ffggnfgf/article/details/72972118
https://blog.csdn.net/oaim_zh/article/details/78211399?locationNum=8&fps=1