Centos 7.6 服务器安装oracle 11gR2
说来气人,项目需要所以得在服务器上安装Oracle。
像往常一样,打开浏览器 -> 搜索 - > 找博客 -> 安装。
但是我的经历并不像博客上写的那么轻松,期间出现了无数的、反反复复的错误。
每次碰到错误就上网搜,但是解决了一个就会出现第二个。终于,经过了将近六七个小时的挣扎,我放弃了
第二天,我重置了服务器的操作系统,准备开始安装。
不一样的是这次直接看Oracle官方的安装文档,阅读加上理解花费了大概一个多小时,终于搞成功了。故整理了这篇,希望能帮助大家少走弯路。
软件需求篇
-
需要至少 256M内存(推荐512M)、1.5G磁盘空间
-
依赖要求:
// 下面这段话摘自官方文档
glibc should be greater than or equal to 2.3.4-2.41
make should be greater than or equal to 3.80
binutils should be greater than or equal to 2.16.91.0.5
gcc should be greater than or equal to 4.1.2
libaio should be greater than or equal to 0.3.104
使用如下命令安装依赖
yum install glibc make binutils gcc libaio
-
设置内存交换空间:Oracle要求至少2G 或者 两倍于内存的linux交换空间
操作系统磁盘上交换空间的作用就是,当内存多于一定程度后,可以把部分内存里面的数据转移到磁盘的交换空间上。以此来扩展内存容量。
swap空间的设置可以参考 => centos 设置交换空间swap
[root@iZuf61ii8wkx9sushpgjj8Z ~]# free -m total used free shared buff/cache available Mem: 1837 87 1111 0 639 1592 Swap: 0 0 0 [root@iZuf61ii8wkx9sushpgjj8Z ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 40G 2.1G 36G 6% / devtmpfs 909M 0 909M 0% /dev tmpfs 919M 0 919M 0% /dev/shm tmpfs 919M 460K 919M 1% /run tmpfs 919M 0 919M 0% /sys/fs/cgroup tmpfs 184M 0 184M 0% /run/user/0 [root@iZuf61ii8wkx9sushpgjj8Z ~]# fallocate -l 4G /swapfile [root@iZuf61ii8wkx9sushpgjj8Z ~]# ls -lh /swapfile -rw-r--r-- 1 root root 4.0G Jun 1 16:23 /swapfile [root@iZuf61ii8wkx9sushpgjj8Z ~]# chmod 600 /swapfile [root@iZuf61ii8wkx9sushpgjj8Z ~]# ls -lh /swapfile -rw------- 1 root root 4.0G Jun 1 16:23 /swapfile [root@iZuf61ii8wkx9sushpgjj8Z ~]# mkswap /swapfile Setting up swapspace version 1, size = 4194300 KiB no label, UUID=809a7f70-b6b4-4e06-b38c-0adf4fb6591b [root@iZuf61ii8wkx9sushpgjj8Z ~]# swapon /swapfile [root@iZuf61ii8wkx9sushpgjj8Z ~]# free -m total used free shared buff/cache available Mem: 1837 89 1106 0 641 1589 Swap: 4095 0 4095 // 这一步吧 /swapfile swap swap sw 0 0 放到文件的末尾,表示设置开机启动就把这个文件作为swap交换空间 [root@iZuf61ii8wkx9sushpgjj8Z ~]# vi /etc/fstab
-
操作系统内核参数:这一步不需要多少操作,因为oracle官方文档说如果这些参数不合要求,他会修改。具体如下(有需求的可以自己修改)
The Oracle Database XE installation checks your system for the following kernel parameter settings. If the kernel parameters of your system are less than the values listed in Table, then the installation will modify the kernel parameter setting to use the values in this table.
Kernel Parameter Setting semmsl
250 semmns
32000 semopm
100 semmni
128 shmmax
4294967295 shmmni
4096 shmall
2097152 file-max
6815744 VERSION
2.4.21 ip_local_port_range
9000–65500 -
oracle的安装必须得是 root 权限!这非常重要!
OracleXE的限制
- 只能使用单个CPU核心
- 最多只能存储11G的数据,多了会报错
- 最多只会只用1G的内存
- 不支持HTTPS
- 想要支持以上条件需要花钱升级
- 上面这五条是我从官方文档总结出来的
Oracle安装
-
卸载计算机上所有有关oracleXE数据库或者SID使用了xe的数据库
-
用root权限登录服务器
-
从下载链接选择11.2版本的oracle(版本不对可以找一找),并下载linux版本的安装包
-
下载完成并解压后用FTP传到你的服务器上面(这一步我用的是FileZilla这个软件)
-
cd
进入传上来的目录,可以看到[root@iZuf61ii8wkx9sushpgjj8Z Disk1]# ls oracle-xe-11.2.0-1.0.x86_64.rpm response upgrade
-
使用rpm进行安装
# rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
-
如果上一步安装失败了,则根据提示使用如下命令
# /etc/init.d/oracle-xe configure
-
下面会做一些Oracle的配置
Oracle Database 11g Express Edition Configuration ------------------------------------------------- This will configure on-boot properties of Oracle Database 11g Express Edition. The following questions will determine whether the database should be starting upon system boot, the ports it will use, and the passwords that will be used for database accounts. Press <Enter> to accept the defaults. Ctrl-C will abort. // 配置HTTP端口 Specify the HTTP port that will be used for Oracle Application Express [8080]:8000 // 配置Oracle服务所在端口 Specify a port that will be used for the database listener [1521]:1521 // 设置sys和system账户的密码 Specify a password to be used for database accounts. Note that the same password will be used for SYS and SYSTEM. Oracle recommends the use of different passwords for each database account. This can be done after initial configuration: Confirm the password: // 是否设置开机自启动 Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:y Starting Oracle Net Listener...Done Configuring database...Done Starting Oracle Database 11g Express Edition instance...Done Installation completed successfully.
NOTE! Oracle官方还提供了一种无声安装方式(就是通过配置文件来进行上一步的设置),这里不赘述了。
-
手动启动Oracle
# 启动Oracle /etc/init.d/oracle-xe start # 关闭Oracle /etc/init.d/oracle-xe stop
-
设置Oracle环境变量:这一步网上会让你编辑 /etc/profile这个文件,但Oracle其实有现成脚本,运行一下就好了
// 进入目录,这个目录是Oracle自动生成的 cd /u01/app/oracle/product/11.2.0/xe/bin // 在该目录下有两个脚本 oracle_env.csh (对C类型的shell中使用) 和 oracle_env.sh (Bash类型中的shell中使用) // 我们是centos 是bash类型的shell,所以执行该脚本 . ./oracle_env.sh
-
远程连接数据库(激动人心的一步)
# 服务器本地连接数据库 sqlplus system Enter password: # 如果你希望远程访问服务器(前提是你的本机有安装sqlplus工具) sqlplus system@xe_server_host_name Enter password: # 连上来以后禁止本地监听(不知道为什么这么做,官网应该是出于安全建议这么干) EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);
-
本地图形界面链接(navicat为例)