Linux下安装Oracle12c R2

简介: 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
image
2.操作系统硬件检查
检查运行总内存是否大于1G:grep MemTotal /proc/meminfo
查询系统位数:uname -m
查询系统版本:cat /proc/version
查询系统内核版本:uname -r
磁盘空间可用大小:df -h
/tmp文件夹至少1G:df -h /tmp
image
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

image
②安装缺失的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

image
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卸载掉
image
不报错说明卸载成功
uname -a 看一下系统版本号和系统位数
image
http://mirrors.kernel.org/centos/找到对应的系统版本
我的系统是el6.x86_64,选择这个路径下的Packages
https://mirrors.edge.kernel.org/centos/6/os/x86_64/Packages/
找到这3个包的路径
image
image
image
下载这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
image
image
下载完成
安装yum,进入文件路径下,执行rpm-ivh yum-*
image
新建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:生成缓存
image
yum update:系统更新(包括程序和内核)
image
image
image
更新完成,以上是全部的安装和更新内容
重新安装缺失的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

又报错了。。。不要慌,慢慢来
image
该错误是说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 
image
unixODBC*.i686中依赖了openssl,添加参数--skip-broken,会跳过有依赖问题的包
yum -y install unixODBC*.i686 --skip-broken
image
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
image

# 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
image
③配置oracle用户的shell limit:vim /etc/security/limits.conf
image
image

//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
image
在文本最后添加:session required pam_limits.so或者session required /lib/security/pam_limits.so使shell limit生效
image
⑤oracle用户环境变量配置
要成功安装并使用Oracle数据库软件,必须在Oracle用户的.bash_profile文件中设置ORACLE_BASE、ORACLE_HOME、ORACLE_SID和PATH环境变量,其他的根据需要来设置。ORACLE_HOME可以在安装前手动配置,另外,Oracle安装过程中会根据ORACLE_BASE的值自动指定的ORACLE_HOME,所以也可以在安装后将这个ORACLE_HOME写入.bash_profile
image
image

# .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
image
⑦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。

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

相关文章
|
3天前
|
Linux 开发工具 C语言
Linux 安装 gcc 编译运行 C程序
Linux 安装 gcc 编译运行 C程序
21 0
|
3天前
|
Ubuntu Linux Python
Linux(15)Ubuntu安装ninja构建工具
Linux(15)Ubuntu安装ninja构建工具
13 0
|
6天前
|
NoSQL Linux 测试技术
Redis的安装(Linux版)
Redis的安装(Linux版)
149 1
|
2天前
|
监控 安全 Linux
Linux系统之安装ServerBee服务器监控工具
【4月更文挑战第22天】Linux系统之安装ServerBee服务器监控工具
39 2
|
2天前
|
Linux 开发工具 Android开发
Docker系列(1)安装Linux系统编译Android源码
Docker系列(1)安装Linux系统编译Android源码
5 0
|
2天前
|
Ubuntu Linux 开发工具
WSL2(3)安装Linux headers完美解决方案
WSL2(3)安装Linux headers完美解决方案
4 0
|
3天前
|
Ubuntu Linux 数据安全/隐私保护
Linux(7)Ubuntu20.04 arm64安装Docker
Linux(7)Ubuntu20.04 arm64安装Docker
15 0
|
6天前
|
Linux
ZooKeeper的安装(Linux版)
ZooKeeper的安装(Linux版)
17 1
|
6天前
|
应用服务中间件 Linux 网络安全
Tomcat的安装(Linux版)
Tomcat的安装(Linux版)
17 0
|
9天前
|
关系型数据库 MySQL Linux
Linux联网安装MySQL Server
Linux联网安装MySQL Server
21 0