Linux下安装Oracle12c R2

安装Oracle前需要先安装JDK:
https://yq.aliyun.com/articles/653373?spm=a2c4e.11155435.0.0.c92b3312NrGMmg
1.Oracle官网下载安装包
https://www.oracle.com/technetwork/database/enterprise-edition/downloads/oracle12c-linux-12201-3608234.html
Linux下安装Oracle12c R2
2.操作系统硬件检查
检查运行总内存是否大于1G:grep MemTotal /proc/meminfo
查询系统位数:uname -m
查询系统版本:cat /proc/version
查询系统内核版本:uname -r
磁盘空间可用大小:df -h
/tmp文件夹至少1G:df -h /tmp
Linux下安装Oracle12c R2
3.安装前系统配置,安装依赖包
①检查Oracle需要的rmp安装情况

rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXext libXtst libX11 libXau libxcb libXi make sysstat

Linux下安装Oracle12c R2
②安装缺失的rpm

yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*.i686 elfutils-libelf-devel gcc gcc-c++ glibc*.i686 glibc glibc-devel glibc-devel*.i686 ksh libgcc*.i686 libgcc libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.i686 libaio libaio*.i686 libaio-devel libaio-devel*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686 libXp

Linux下安装Oracle12c R2
Red Hat Enterprise Linux Server(RHEL) 的yum服务是付费的,因为没有付费,所以无法使用yum安装软件,如RHEL想安装LNMP必须要先按此教程设置好yum,并可以正常使用后才可以安装LNMP一键安装包,会提示如下错误:This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 或如下错误信息:This system is not registered with RHN. RHN support will be disabled.
解决方法:
rpm -qa|grep yum|xargs rpm -e --nodeps 将yum卸载掉
Linux下安装Oracle12c R2
不报错说明卸载成功
uname -a 看一下系统版本号和系统位数
Linux下安装Oracle12c R2
http://mirrors.kernel.org/centos/找到对应的系统版本
我的系统是el6.x86_64,选择这个路径下的Packages
https://mirrors.edge.kernel.org/centos/6/os/x86_64/Packages/
找到这3个包的路径
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
下载这3个包
wget https://mirrors.edge.kernel.org/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
wget https://mirrors.edge.kernel.org/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm
wget https://mirrors.edge.kernel.org/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
下载完成
安装yum,进入文件路径下,执行rpm-ivh yum-*
Linux下安装Oracle12c R2
新建repo 配置文件
touch /etc/yum.repos.d/CentOS-Base.repo
vim /etc/yum.repos.d/CentOS-Base.repo

# remarked out baseurl= line instead.
[base]
name=CentOS-$6 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$6&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-$6 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$6&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-$6 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$6&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$6 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6

源文件修改后需要更新yum源
yum makecache:生成缓存
Linux下安装Oracle12c R2
yum update:系统更新(包括程序和内核)
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
更新完成,以上是全部的安装和更新内容
重新安装缺失的rpm

yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*.i686 elfutils-libelf-devel gcc gcc-c++ glibc*.i686 glibc glibc-devel glibc-devel*.i686 ksh libgcc*.i686 libgcc libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.i686 libaio libaio*.i686 libaio-devel libaio-devel*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686 libXp

又报错了。。。不要慌,慢慢来
Linux下安装Oracle12c R2
该错误是说openssl这个包冲突了,按理说应该先卸载openssl,再进行安装,但是通过查阅资料openssl依赖的包很多,卸载系统自带的openssl容易出现这样那样的问题,所以我这的思路是排查一下尚未安装的包中,哪个包依赖了openssl
检查Oracle需要的rmp安装情况
rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXext libXtst libX11 libXau libxcb libXi make sysstat 
Linux下安装Oracle12c R2
unixODBC*.i686中依赖了openssl,添加参数--skip-broken,会跳过有依赖问题的包
yum -y install unixODBC*.i686 --skip-broken
Linux下安装Oracle12c R2
4.创建用户,用户组和安装目录
安装和运行Oracle数据软件都需要使用指定的用户组内的用户(Oracle),处于安全考虑,用户组建为oinstall,dba,oinstall组中的成员用于管理Oracle数据库物理软件,dba组中的成员用于管理、操作数据库,具有sysdba权限

//创建Oracle用户组oinstall
[root@localhost file]# groupadd oinstall
//创建Oracle用户组dba
[root@localhost file]# groupadd dba
//将oracle用户加入到新建的2个用户组
[root@localhost file]# useradd -g oinstall -G dba oracle
//修改oracle用户密码
[root@localhost file]# passwd oracle
Changing password for user oracle.
New password: 
BAD PASSWORD: it is WAY too short
BAD PASSWORD: is too simple
Retype new password: 
passwd: all authentication tokens updated successfully.
//创建oracle安装目录
[root@localhost file]# mkdir -p /usr/oracle
//创建oracle安装文件目录
[root@localhost file]# mkdir -p /opt/oracle/orainstall
//更改oracle安装目录用户组
[root@localhost file]# chown -R oracle:oinstall /usr/oracle/
//更改oracle安装目录权限
[root@localhost file]# chmod -R 775 /usr/oracle/
//更改oracle安装文件目录用户组
[root@localhost file]# chown -R oracle:oinstall /opt/oracle/orainstall/
//更改oracle安装文件目录操作权限
[root@localhost file]# chmod -R 755 /opt/oracle/orainstall/
[root@localhost file]#

5.配置系统参数,root用户修改
①编辑内核参数:vim /etc/sysctl.conf
Linux下安装Oracle12c R2

# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and
# sysctl.conf(5) for more details.
#
# Use '/sbin/sysctl -a' to list all possible parameters.
# Controls IP packet forwarding
net.ipv4.ip_forward = 0
# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0
# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0
# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1
# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1
# Controls the default maxmimum size of a mesage queue
kernel.msgmnb = 65536
# Controls the maximum size of a message, in bytes
kernel.msgmax = 65536
# Controls the maximum shared segment size, in bytes
kernel.shmmax = 2147483648
# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 2097152
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
fs.file-max = 6815744

②生效新配置的内核参数:sysctl -p
Linux下安装Oracle12c R2
③配置oracle用户的shell limit:vim /etc/security/limits.conf
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2

//noproc - 进程的最大数目
//stack - 最大栈大小
//nofile - 打开文件的最大数目
//soft 指的是当前系统生效的设置值
//hard 表明系统中所能设定的最大值
//soft 的限制不能比har 限制高。用 - 就表明同时设置了 soft 和 hard 的值。
//oracle:被限制的用户名,组名前面加@和用户名区别
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 10240

④编辑登录配置文件:vi /etc/pam.d/login
Linux下安装Oracle12c R2
在文本最后添加:session required pam_limits.so或者session required /lib/security/pam_limits.so使shell limit生效
Linux下安装Oracle12c R2
⑤oracle用户环境变量配置
要成功安装并使用Oracle数据库软件,必须在Oracle用户的.bash_profile文件中设置ORACLE_BASE、ORACLE_HOME、ORACLE_SID和PATH环境变量,其他的根据需要来设置。ORACLE_HOME可以在安装前手动配置,另外,Oracle安装过程中会根据ORACLE_BASE的值自动指定的ORACLE_HOME,所以也可以在安装后将这个ORACLE_HOME写入.bash_profile
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2

# .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH

# use for oracle  
export  ORACLE_BASE=/usr/oracle
export  ORACLE_HOME=$ORACLE_BASE/product
export  ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib  
#防止Oracle安装界面乱码,先把语言环境改为英文
export LANG=en_US
if [ $USER = "oracle" ];then
 if [ $SHELL = "/bin/ksh" ];then
     ulimit -p 16384
     ulimit -n 65536
   else
    ulimit -u 16384 -n 65536
fi
 fi

⑥生效环境变量
source .bash_profile
Linux下安装Oracle12c R2
⑦xhost + 参考链接:https://www.linuxidc.com/Linux/2012-11/74874.htm

xhost 命令用途:控制什么人可以访问当前主机上的增强 X-Windows。
语法:xhost [ + | - ] [ Name ] ,"+"表示增加,"-"表示去除
描述:xhost 是用来控制X server访问权限的。
通常当你从hostA登陆到hostB上运行hostB上的应用程序时,做为应用程序来说,hostA是client,但是对图形来说,是在hostA上显示的,
需要使用hostA的Xserver,所以hostA是server。因此在登陆到hostB前,需要在hostA上运行xhost +来使其它用户能够访问hostA的Xserver。

Linux下安装Oracle12c R2
解决方法:安装tigervnc-server
安装:yum -y install tigervnc-server
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
启动:vncserver
Linux下安装Oracle12c R2
export DISPLAY=localhost:1
Linux下安装Oracle12c R2
安装xterm
Linux下安装Oracle12c R2
yum -y install xterm
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
6.安装Oracle
①将Oracle安装包放到/opt/oracle/oinstall目录下
Linux下安装Oracle12c R2
②切换到oracle用户,解压:unzip ./linuxx64_12201_database.zip(大约等待1-2分钟)
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
③使用Xmanager的Xstart运行脚本runInstaller开始安装
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
④oracle可视化界面安装步骤
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
这里创建目录/usr/oraInventory时会报无写权限的异常,这里手动创建目录并分配权限
Linux下安装Oracle12c R2
切换到root用户
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
这里会提示用root用户执行两个脚本
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
点OK继续安装
Linux下安装Oracle12c R2
oracle安装完成
我们登录网址验证一下:因为我的oracle是安装到虚拟机,所以地址是https://192.168.43.61:5500/em
Linux下安装Oracle12c R2
你会发现无法访问,检查防火墙是否开启,这里暂时把防火墙关闭,也可以配置防火墙入站和出站规则
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
使用该平台修改管理员密码
Linux下安装Oracle12c R2
选中需要修改的用户
Linux下安装Oracle12c R2
选择 变更账户
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
注销重新登录,密码修改完成
创建oracle用户:create user oracle identified by oracle;
Linux下安装Oracle12c R2
创建用户时,用户名要以C##或c##开头
create user c##oracle identified by c##oracle;
grant dba to c##oracle;
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
出现这种问题原因在官网上有提到:https://docs.oracle.com/database/121/DBSEG/users.htm#DBSEG754
Linux下安装Oracle12c R2
常用sql命令
切换到oracle用户:su - oracle
连接到dba用户:
sqlplus /nolog
connect / as sysdba
关闭oracle实例:
shutdown immediate
启动oracle实例:
startup
Linux下安装Oracle12c R2
监听开启停止
lsnrctl status
lsnrctl stop
lsnrctl start
Linux下安装Oracle12c R2
Linux下安装Oracle12c R2
结束

上一篇:Linux下安装WebLogic 12c


下一篇:Linux下yum安装MySQL