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
结束

相关文章
|
5天前
|
缓存 Ubuntu Linux
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
通过本文,我们详细了解了 `yum`、`rpm`、`apt-get`和 `wget`的区别、常用命令以及在CentOS和Ubuntu中安装 `wget`的方法。`yum`和 `apt-get`是高层次的包管理器,分别用于RPM系和Debian系发行版,能够自动解决依赖问题;而 `rpm`是低层次的包管理工具,适合处理单个包;`wget`则是一个功能强大的下载工具,适用于各种下载任务。在实际使用中,根据系统类型和任务需求选择合适的工具,可以大大提高工作效率和系统管理的便利性。
54 25
|
21天前
|
Ubuntu Java Linux
Linux 安装 Qualcomm ® SnapdragonTM Profiler
通过本文的详细介绍,您应该已经成功在 Linux 系统上安装并配置了 Qualcomm® Snapdragon™ Profiler,并能够连接 Android 设备进行性能分析。Snapdragon Profiler 提供了丰富的工具和功能,可以帮助开发者深入了解应用程序的性能瓶颈,从而进行优化。希望本文能对您有所帮助,让您在开发过程中更高效地使用 Snapdragon Profiler 进行性能分析和优化。
56 10
|
22天前
|
Linux
Linux安装svn并启动
Linux安装svn并启动
55 10
|
1月前
|
Oracle 关系型数据库 Linux
linux8安装oracle 11g遇到的问题记录
Oracle 11g在Linux 8上安装时会遇到link编译环节的问题。官方建议忽略安装中的链接错误,安装完成后应用DBPSU 11.2.0.4.240716补丁及一次性补丁33991024,再重新编译二进制文件,并配置监听器和数据库。但因11g已退出服务期,这些补丁需付费获取。网上信息显示22年1月的PSU补丁也可解决问题,找到该补丁后按常规方式打补丁即可。如有需求或疑问可咨询我。
83 20
|
1月前
|
弹性计算 运维 Ubuntu
os-copilot在Alibaba Cloud Linux镜像下的安装与功能测试
我顺利使用了OS Copilot的 -t -f 功能,我的疑惑是在换行的时候就直接进行提问了,每次只能写一个问题,没法连续换行更有逻辑的输入问题。 我认为 -t 管道 功能有用 ,能解决环境问题的连续性操作。 我认为 -f 管道 功能有用 ,可以单独创建可连续性提问的task问题。 我认为 | 对文件直接理解在新的服务器理解有很大的帮助。 此外,我还有建议 可以在非 co 的环境下也能进行连续性的提问。
79 7
|
18天前
|
Linux
Linux系统之whereis命令的基本使用
Linux系统之whereis命令的基本使用
54 23
Linux系统之whereis命令的基本使用
|
3月前
|
Linux 网络安全 数据安全/隐私保护
Linux 超级强大的十六进制 dump 工具:XXD 命令,我教你应该如何使用!
在 Linux 系统中,xxd 命令是一个强大的十六进制 dump 工具,可以将文件或数据以十六进制和 ASCII 字符形式显示,帮助用户深入了解和分析数据。本文详细介绍了 xxd 命令的基本用法、高级功能及实际应用案例,包括查看文件内容、指定输出格式、写入文件、数据比较、数据提取、数据转换和数据加密解密等。通过掌握这些技巧,用户可以更高效地处理各种数据问题。
384 8
|
3月前
|
监控 Linux
如何检查 Linux 内存使用量是否耗尽?这 5 个命令堪称绝了!
本文介绍了在Linux系统中检查内存使用情况的5个常用命令:`free`、`top`、`vmstat`、`pidstat` 和 `/proc/meminfo` 文件,帮助用户准确监控内存状态,确保系统稳定运行。
1207 6
|
3天前
|
缓存 Linux
Linux查看内存命令
1. free free命令是最常用的查看内存使用情况的命令。它显示系统的总内存、已使用内存、空闲内存和交换内存的总量。 free -h • -h 选项:以易读的格式(如GB、MB)显示内存大小。 输出示例: total used free shared buff/cache available Mem: 15Gi 4.7Gi 4.1Gi 288Mi 6.6Gi 9.9Gi Swap: 2.0Gi 0B 2.0Gi • to
14 2
|
1月前
|
网络协议 Unix Linux
深入解析:Linux网络配置工具ifconfig与ip命令的全面对比
虽然 `ifconfig`作为一个经典的网络配置工具,简单易用,但其功能已经不能满足现代网络配置的需求。相比之下,`ip`命令不仅功能全面,而且提供了一致且简洁的语法,适用于各种网络配置场景。因此,在实际使用中,推荐逐步过渡到 `ip`命令,以更好地适应现代网络管理需求。
42 11