1.官网下载oracle安装包:
两个都要下载,先下载到本地。
下载的时候需要创建一个账户:
2.创建运行oracle数据库的用户和用户组:
在root账户下执行命令:
[root@localhost ~]# groupadd oinstall
[root@localhost ~]# groupadd dba
[root@localhost ~]# useradd -g oinstall -g dba -m oracle
[root@localhost ~]# passwd oracle
更改用户 oracle 的密码 。
新的 密码:
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@localhost ~]# id oracle
uid=1000(oracle) gid=1001(dba) 组=1001(dba)
3.创建oracle安装目录:
[root@localhost ~]# mkdir -p /data/oracle #oracle安装目录
[root@localhost ~]# mkdir -p /data/oraInventory #oracle配置文件目录
[root@localhost ~]# mkdir -p /data/database #oracle软件包解压目录
[root@localhost ~]# cd /data
[root@localhost data]# ll
总用量 0
drwxr-xr-x. 2 root root 6 3月 30 18:38 database
drwxr-xr-x. 2 root root 6 3月 30 18:37 oracle
drwxr-xr-x. 2 root root 6 3月 30 18:37 oraInventory
[root@localhost data]# chown -R oracle:oinstall /data/oracle #将以上目录的权限赋给oinstall组中的oracle用户
[root@localhost data]# chown -R oracle:oinstall /data/oraInventory
[root@localhost data]# chown -R oracle:oinstall /data/database
4.修改操作系统标识:
这一步是因为oracle默认不支持在centos上安装。
查看/etc下的redhat-release:
[root@localhost etc]# cat redhat-release
是这个:
把它修改为redhat-7。
[root@localhost etc]# vi redhat-release
esc--------:wq!
修改之后再查看:
[root@localhost etc]# cat redhat-release
redhat-7
5.安装oracle所需要依赖的包:
[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*
安装完毕。
6.关闭防火墙:
先查看一下防火墙状态:
[root@localhost etc]# status firewalld.service
关闭防火墙:
[root@localhost etc]# systemctl stop firewalld.service
设置禁止使用防火墙:
[root@localhost etc]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
7.关闭selinux:
vi 修改/etc/selinux/config文件:
修改之后需要重启才能生效。
重启之后可以查看一下状态已改成disabled:
[root@localhost ~]# sestatus -v
SELinux status: disabled
8.修改内核参数(/etc/sysctl.conf):
添加下面没有注释的部分。
# sysctl settings are defined through files in
# /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
执行如下命令使参数生效:
[root@localhost ~]# sysctl -p
9.设置oracle用户的限制:
[root@localhost ~]# vi /etc/security/limits.conf
添加如下内容:
要使配置生效,需要编辑文件/etc/pam.d/login,添加如下配置:
然后编辑/etc/profile文件,添加如下配置:
10.切换到刚才创建的oracle用户,编辑/home/oracle/.bash_profile配置环境变量:
[root@localhost ~]# su oracle
[oracle@localhost ~]$ vi /home/oracle/.bash_profile
添加如下内容:
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_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安装时设置的字符集保持一致
切回root,执行以下命令使配置生效:
[oracle@localhost ~]$ su root
密码:
[root@localhost oracle]# source /home/oracle/.bash_profile
11.正式开始安装oracle,通过SSHClient将本地下载好的安装包,我放到了/home/oracle下:
进入到/home/oracle下将这两个安装包解压至/data/database目录下:
在解压的时候遇到“-bash: unzip: 未找到命令”问题,执行如下命令安装:
[root@localhost ~]# yum install -y unzip zip
然后重试解压oracle安装包:
[root@localhost oracle]# unzip linux.x64_11gR2_database_1of2.zip -d /data/database/
[root@localhost oracle]# unzip linux.x64_11gR2_database_2of2.zip -d /data/database/
12.以root的身份给oracel用户授权:
[root@localhost oracle]# chown -R oracle:oinstall /data/database/database/
13.切换到oracle用户,进入到/data/database/database下,执行安装命令:
[root@localhost oracle]# su oracle
[oracle@localhost ~]$ cd /data/database/database
[oracle@localhost database]$ ls
doc install response rpm runInstaller sshsetup stage welcome.html
[oracle@localhost database]$ ./runInstaller
启动成功:
启动过程中遇到的问题
14.安装界面:
点击next之后,提示邮箱信息未填,点击yes:
next之后:
使用root账户安装缺少的包,那个OS Kernel Parameter.semmi不用管:
[root@localhost ~]# yum -y install libaio* glibc* compat-libstdc++-* libaio-devel-* libgcc-* libstdc++-* unixODBC-* unixODBC-devel* pdksh-*
安装完之后,再去oracle图形界面中check again:
check again的结果还是有错,这是因为系统中已经安装了高版本,比检测的版本高,无法识别,所以此处我们选择右上角的ignore all:
next:
点击finish:
安装中。。。出现错误:
先在root下查看一下/usr/lib64下是否有libc.a:
然后进入ORACLE_HOME(之前我们设置了)下:
[root@localhost /]# cd /data/oracle/product/11.2.0/db_1
[root@localhost db_1]# cd ctx/lib
修改该目录下的ins_ctx.mk这个文件:
将文件中的:
修改为:
保存退出。
然后在oracle图形界面中retry一下,又报错误:
解决方法:
进入ORACLE_HOME下:
[root@localhost lib]# cd /data/oracle/product/11.2.0/db_1
[root@localhost db_1]# cd sysman/lib
修改文件ins_emagent.mk:
将里面的:
修改为:
保存退出,retry。
用root账户执行两个上述脚本:
出现第三个红框的时候直接回车就行。
终于安装成功了。。。
然后我们创建一个数据库实例:
15.先要创建监听:
以oracle账户执行:
[oracle@localhost ~]$ netca
这时监听界面启动:
然后以oracle身份查看监听状态:
[oracle@localhost ~]$ lsnrctl status
说明监听没有启动。
启动监听:
[oracle@localhost ~]$ lsnrctl start
启动成功。
16.以Oracle用户进入到ORACLE_HOME下:
[oracle@localhost db_1]$ cd /data/oracle/product/11.2.0/db_1
进入bin目录下执行:
[oracle@localhost bin]$ ./dbca
进入到oracle实例安装界面:
next
设置所有账户使用相同密码,这个密码要和最开始创建的oracle用户身份的登陆密码一样:
设置的密码不符合规则:
重新设置。
使用默认,next:
next.
开始创建数据库。。。
解锁需要使用的用户。也可以直接exit。
数据库创建成功后,通过如下命令进行测试:
[oracle@localhost db_1]$ sqlplus / as sysdba
测试成功。
至此,linux下安装oracle的过程已完成。