我的centos7是在VMware下安装的,安装Oracle安装了好久好久,最开始的时候在网上找的两个文章,按照步骤装,有一篇写着装的时候有灰色的竖线,直接按space键或者鼠标右键closed关闭掉就OK,我想着这多好,安装了好几次,都失败了,而且,在安装之前我也没有备份,我又有强迫症,稍有和步骤不一样,或者安装依赖包失败了,就又要从头再来,有时候会很生气,真的就把它们统统卸载了,又重新安装virtualbox,centos,安装Oracle之前的准备工作,安装Oracle,折腾了特别久,我要写一个安装步骤记录下来我经过惨痛的教训之后得到的经验。
一、安装的硬件要求
1.内存:
RAW
|
Swap |
1G至2G | 1.5倍 |
2G至16G | 同RAW相等 |
16G以上 | 16G |
二、环境准备
安装包:- linux.x64_11gR2_database_1of2.zip
- linux.x64_11gR2_database_2of2.zip
1 [cindyma@localhost ~]$ su root #切换到root 2 Password: 3 [root@localhost]# groupadd oinstall #创建用户组oinstall 4 [root@localhost]# groupadd dba #创建用户组dba 5 [root@localhost]# useradd -g oinstall -g dba -m oracle #创建oracle用户,并加入到oinstall和dba用户组 6 [root@localhost]# passwd oracle #设置用户oracle的登陆密码,不设置密码,在CentOS的图形登陆界面没法登陆 7 Changing password for user oracle. 8 New password: # 密码 9 BAD PASSWORD: The password is shorter than 8 characters 10 Retype new password: # 确认密码 11 passwd: all authentication tokens updated successfully. 12 [root@localhost]# id oracle # 查看新建的oracle用户 13 uid=1001(oracle) gid=1002(dba) groups=1002(dba)
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 11 [root@localhost data]#
1 [root@localhost data]# cat /proc/version 2 Linux version 3.10.0-514.26.2.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Tue Jul 4 15:04:05 UTC 2017 3 [root@localhost data]# cat /etc/redhat-release 4 CentOS Linux release 7.3.1611 (Core) 5 [root@localhost data]# vi /etc/redhat-release 6 [root@localhost data]# cat /etc/redhat-release 7 redhat-7
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*
我的版本当然对应的是这个版本:Oracle Linux 7 and Red Hat Enterprise Linux 7
它没有要求说要安装elfutils和unixODBC包,但是等安装Oracle检查安装前准备时,会提示说缺少这两个包,所以一并安装
有时候使用yum安装的时候,会提示another app is currently holding the yum lock,这个时候打开另外一个terminal,在root用户下输入
#rm -f /var/run/yum.pid
强制关掉yum进程
1 [root@localhost data]# systemctl status firewalld.service #查看防火墙状态(运行中) 2 ● firewalld.service - firewalld - dynamic firewall daemon 3 Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) 4 Active: active (running) since Wed 2017-09-13 09:23:08 CST; 25min ago 5 Docs: man:firewalld(1) 6 Main PID: 641 (firewalld) 7 CGroup: /system.slice/firewalld.service 8 └─641 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid 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 Hint: Some lines were ellipsized, use -l to show in full. 13 [root@localhost data]# systemctl stop firewalld.service #关闭防火墙 14 [root@localhost data]# systemctl status firewalld.service #查看防火墙状态(已关闭) 15 ● firewalld.service - firewalld - dynamic firewall daemon 16 Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) 17 Active: inactive (dead) since Wed 2017-09-13 09:48:55 CST; 10s ago 18 Docs: man:firewalld(1) 19 Process: 641 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS) 20 Main PID: 641 (code=exited, status=0/SUCCESS) 21 22 Sep 13 09:22:58 localhost.localdomain systemd[1]: Starting firewalld - dynami... 23 Sep 13 09:23:08 localhost.localdomain systemd[1]: Started firewalld - dynamic... 24 Sep 13 09:48:54 localhost.localdomain systemd[1]: Stopping firewalld - dynami... 25 Sep 13 09:48:55 localhost.localdomain systemd[1]: Stopped firewalld - dynamic... 26 Hint: Some lines were ellipsized, use -l to show in full. 27 [root@localhost data]# systemctl disable firewalld.service #禁止使用防火墙(重启也是禁止的) 28 Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. 29 Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
1 [root@localhost data]# vi /etc/selinux/config 2 [root@localhost data]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.7、修改内核参数(加入斜体部分)
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled #此处修改为disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
1 [root@local++host data]# vi /etc/sysctl.conf 2 [root@localhost data]# cat /etc/sysctl.conf
# sysctl settings are defined through files in8、使配置修改内核的参数生效
# /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).
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.conf.all.rp_filter = 1
fs.file-max = 6815744 #设置最大打开文件数
fs.aio-max-nr = 1048576
kernel.shmall = 2097152 #共享内存的总量,8G内存设置:2097152*4k/1024/1024
kernel.shmmax = 2147483648 #最大共享内存的段大小
kernel.shmmni = 4096 #整个系统共享内存端的最大数
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500 #可使用的IPv4端口范围
net.core.rmem_default = 262144
net.core.rmem_max= 4194304
net.core.wmem_default= 262144
net.core.wmem_max= 1048576
1 [root@localhost data]# sysctl -p
net.ipv4.icmp_echo_ignore_broadcasts = 19、对oracle用户设置限制,提高软件运行性能(斜体为添加部分)
net.ipv4.conf.all.rp_filter = 1
sysctl: setting key "fs.file-max": Invalid argument
fs.file-max = 6815744 #设置最大打开文件数
fs.aio-max-nr = 1048576
sysctl: setting key "kernel.shmall": Invalid argument
kernel.shmall = 2097152 #共享内存的总量,8G内存设置:2097152*4k/1024/1024
sysctl: setting key "kernel.shmmax": Invalid argument
kernel.shmmax = 2147483648 #最大共享内存的段大小
sysctl: setting key "kernel.shmmni": Invalid argument
kernel.shmmni = 4096 #整个系统共享内存端的最大数
kernel.sem = 250 32000 100 128
sysctl: setting key "net.ipv4.ip_local_port_range": Invalid argument
net.ipv4.ip_local_port_range = 9000 65500 #可使用的IPv4端口范围
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
1 [root@localhost data]# vi /etc/security/limits.conf 2 [root@localhost data]# cat /etc/security/limits.conf
10、配置用户的环境变量(斜体部分为添加代码)@student - maxlogins 4
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
End of
file
1 [root@localhost data]# vi /home/oracle/.bash_profile 2 [root@localhost data]# cat /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
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安装时设置的字符集保持一致
1 [root@localhost data]# source /home/oracle/.bash_profile
1 [root@localhost ~]# cd /. 2 [root@localhost /]# cd /home/anzerong/Desktop/ 3 [root@localhost Desktop]# ls 4 linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip 5 [root@localhost Desktop]# mv linux.x64_11gR2_database_1of2.zip /usr/local/src 6 [root@localhost Desktop]# ls 7 linux.x64_11gR2_database_2of2.zip 8 [root@localhost Desktop]# mv linux.x64_11gR2_database_2of2.zip /usr/local/src
1 [root@localhost Desktop]# reboot
1 [oracle@localhost /]$ cd /usr/local/src 2 [oracle@localhost src]$ ls 3 linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip
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 (省略...)
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 (省略...)
四、Oracle图形界面选项
去掉 I wish to receive security updates via My Oracle Support.
点击 "Next >"
选择第一项 Create and configure a database
点击 "Next >"
点击 "Next >"
选择英语 English(根据系统默认选择好了)
点击 "Next >"
选择第一个企业版
确定数据软件的安装路径,自动读取前面Oracle环境变量中配置的值
点击 "Next >",
"Character Sets"选择第二项或者第三项中的"Unicode standard UTF-8..."
点击 "Next >"
选择第二项,并设置密码
点击 "Next >"
按照提示信息一个一个解决。
点击 "Finsh"
在此过程中,安装界面会变成黑色,有一长条出现(其实是一个提示框),调整高度与宽度查看
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
修改/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继续安装。
修改/data/oracle/product/11.2.0/db_1/sysman/lib/ins_emagent.mk,将
$(MK_EMAGENT_NMECTL)修改为:$(MK_EMAGENT_NMECTL) -lnnz11
点击Retry继续安装。
安装完成后的两个小问题
1.Linux下sqlplus不能使用光标箭头
解决办法:安装rlwrap包
1)下载rlwrap压缩包(我下载的是rlwrap-0.37.tar.gz);
2)yum安装readline
[root@localhost oracle]#yum -y install readline*
3)解压,安装
[root@localhost oracle]#tar -xzvf rlwrap-0.37.tar.gz [root@localhost oracle]#cd rlwrap-0.37.tar.gz [root@localhost oracle]#./configure [root@localhost oracle]#make [root@localhost oracle]#make install
4)切换到oracle用户下,编辑bash_profile文件
[oracle@localhost ~]vi .bash_profile
在最后添加
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
保存退出,执行source .bash_profile使其生效。
或者直接不修改bash_profile文件,直接在输入sqlplus命令前加上rlwrap即可(我修改了bash_profile文件,重启系统还是要重新输入source命令使其生效,我之后直接在sqlplus命令前加rlwrap)。
这样在sqlplus中就可以使用上下左右键来查看历史纪录了。
2.vim中文乱码
设置~下或者oracle用户下的.vimrc文件,加上fileencodings、enc、fencs,代码如下:
vim ~/.vimrc #或者vim /home/oracle(用户名)/.vimrc
#添加如下代码
set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1
set enc=utf8
set fencs=utf8,gbk,gb2312,gb18030
参考:
1.http://www.cnblogs.com/anzerong2012/p/7528311.html
2.http://www.jb51.net/article/105102.htm
3.https://www.cnblogs.com/xi52qian/p/4187039.html
4.https://jingyan.baidu.com/article/90808022edddf0fd91c80fdd.html
5.https://www.zhihu.com/question/22363620