从安装操作系统到完成oracle安装

1、安装centos7

下载CentOS7 iso安装包,配置虚拟机,由于只进行oracle安装练习,随便配置20G空间。选择安装文件。

CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第1张

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

开机,开始安装系统:

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第2张

直接选择安装选项:

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第3张

等待加载:

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第4张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第5张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第6张

选择英文:

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第7张

直接选自动分配磁盘:

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第8张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第9张

选择进行最小化安装,节约空间。

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第10张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第11张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第12张

设置root密码

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第13张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第14张

 还需要创建一个用户吗,先创建一个吧?

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第15张

耐心等待安装成功!登录系统!现在系统安装完成,下一步先把ip地址找出来,方便后面操作。

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第16张

 我的centos版本

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第17张

2、虚拟机ip地址

输入ip查询命名 ip addr  , centos的ip地址是ens33条目中的inet值。

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第18张

现在可以看到 ens33 没有 inet 这个属性,那么就没法通过IP地址连接虚拟机。

来查看ens33网卡的配置: vi /etc/sysconfig/network-scripts/ifcfg-ens33

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第19张

发现 CentOS 7 默认是不启动网卡的(ONBOOT=no)。

把这一项改为YES(ONBOOT=yes)

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第20张

 然后重启网络服务: sudo service network restart

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第21张

再次查看ip地址,可以看到192.168.1.11就是虚拟机的ip了。下面就不直接在虚拟机界面操作了。

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第22张

3、使用putty和WinSCP连接

 Putty连接

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第23张

CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第24张

Winscp连接

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第25张

4、修改yum阿里云源

改一下yum源。

1、打开centos的yum文件夹

输入命令cd  /etc/yum.repos.d/

下载阿里云centos7 repo文件

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第26张

发现没有wget命令,安装wget。

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第27张

2、用wget下载repo文件

输入命令wget  http://mirrors.aliyun.com/repo/Centos-7.repo

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第28张

 3、备份系统原来的repo文件

mv  CentOS-Base.repo CentOS-Base.repo.bak

即是重命名 CentOs-Base.repo -> CentOs-Base.repo.bak

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第29张

4、替换系统原来的repo文件

mv Centos-7.repo CentOs-Base.repo

即是重命名 Centos-7.repo -> CentOs-Base.repo

5、执行yum源更新命令

yum clean all

yum makecache

yum update

依次执行上述三条命令即配置完毕。

5、安装oracle

系统安装好了,开始安装oracle:

5.1、创建目录来准备安装oracle

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第30张

5.2上传oracle安装包

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第31张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第32张

解压安装包

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第33张

需要安装 zip unzip工具

CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第34张

解压完毕两个压缩包

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第35张

5.3修改一下主机名

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第36张

5.4、Hosts文件加上ip和主机名

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第37张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第38张

 查看SELinux的状态

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第39张

5.5关闭selinux 

编辑 /etc/selinux/config文件,设置SELINUX= enforcing 为SELINUX=disabled

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第40张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第41张

5.6、关闭防火墙

查看防火墙状态:systemctl status firewalld

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第42张

停止防火墙:systemctl stop firewalld

关闭自启动防火墙服务:systemctl disable firewalld

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第43张

 5.7安装Oracle 11g依赖包

 yum -y install gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel elfutils-libelf-devel-static elfutils-libelf-devel ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第44张

5.8、添加oinstall 、dba 组,新建oracle用户并加入oinstall、dba组中;

设置oracle用户登录密码;

Oracle用户密码在这设置为oracle

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第45张

查看oracle信息

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第46张

试试密码登录看看

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第47张

换回root

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第48张

5.9、修改内核参数:编辑 /etc/sysctl.conf

添加以下设置:

io-max-nr = 1048576

fs.file-max = 6815744

kernel.shmall = 2097152

kernel.shmmax = 1073741824

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 9000 65500

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第49张

让参数生效

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第50张

5.10、修改用户的限制文件,编辑 /etc/security/limits.conf

添加以下配置:

oracle           soft    nproc         2047

oracle           hard   nproc          16384

oracle           soft    nofile          1024

oracle           hard   nofile          65536

oracle           soft    stack           10240

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第51张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第52张

5.11、修改/etc/pam.d/login文件,添加:

session  required   /lib64/security/pam_limits.so

session  required   pam_limits.so

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第53张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第54张

5.12、修改/etc/profile文件:

[root@xiejian /]# vim /etc/profile

添加:

if [ $USER = "oracle" ]; then

  if [ $SHELL = "/bin/ksh" ]; then

   ulimit -p 16384

   ulimit -n 65536

  else

   ulimit -u 16384 -n 65536

  fi

fi

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第55张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第56张

5.13、创建安装目录、修改文件权限

[root@xiejian /]# mkdir -p /data0/app/oracle/product/11.2.0

[root@xiejian /]# mkdir /data0/app/oracle/oradata

[root@xiejian /]# mkdir /data0/app/oracle/inventory

[root@xiejian /]# mkdir /data0/app/oracle/fast_recovery_area

[root@xiejian /]# chown -R oracle:oinstall /data0/app/oracle

[root@xiejian /]# chmod -R 775 /data0/app/oracle

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第57张

5.14、切换到oracle用户,设置oracle用户环境变量

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第58张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第59张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第60张

5.15、编辑静默安装响应文件

(1)切换到root 用户进入oracle安装包解压后的目录 /data0/database/response/下备份db_install.rsp文件。

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第61张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第62张

 (1)     编辑 /tmp/database/response/db_install.rsp文件

 oracle.install.option=INSTALL_DB_SWONLY

ORACLE_HOSTNAME=xiejian

UNIX_GROUP_NAME=oinstall

INVENTORY_LOCATION=/data0/app/oracle/inventory

SELECTED_LANGUAGES=en,zh_CN

ORACLE_HOME=/data0/app/oracle/product/11.2.0

ORACLE_BASE=/data0/app/oracle

oracle.install.db.InstallEdition=EE

oracle.install.db.DBA_GROUP=dba

oracle.install.db.OPER_GROUP=dba

DECLINE_SECURITY_UPDATES=true

5.16、根据响应文件安装oracle 11g

【注意使用oracle用户安装】

[oracle@xiejian database]# ./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /data0/database/response/db_install.rsp

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第63张

注意用户

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第64张

开始Oracle在后台静默安装。安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在后台进行,如果出现[FATAL],则安装程序已经停止了,等待安装完成。

CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第65张

 

 开一个新的终端

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第66张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第67张

5.17、用oracle用户登录配置监听

[oracle@xiejian database]$ netca -silent -responseFile /data0/database/response/netca.rsp

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第68张

可能需要配置DISPLAY变量,配完之后重新netca

[oracle@xiejian database]$ export DISPLAY=localhost:0.0

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第69张

报错了

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第70张

安装libXext.i686

yum install libXext.i686

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第71张

改用root用户安装

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第72张

安装完成,切回oracle继续。

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第73张

 同样报错。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

继续安装

yum install libXext.x86_64

yum install libXrender.x86_64

yum install libXtst.x86_64

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第74张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第75张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第76张

安装完毕后切回继续

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第77张

成功

成功运行后,会在/data0/app/oracle/product/11.2.0/network/admin/ 中生成listener.ora和sqlnet.ora两个文件。

查看监听端口:

[root@xiejian ~]$ netstat -tnulp | grep 1521

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第78张

没有netstat命令,安装一下:

[root@xiejian ~]# yum -y install net-tools

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第79张

查看监听没有启动,启动监听

lsnrctl start  -- 启动监听

lsnrctl stop   -- 停止监听

lsnrctl status -- 查看状态

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第80张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第81张

5.18、设置监听开机自动启动

5.18.1、配置oratab

以root身份登录

[root@xiejian ~]# vim /etc/oratab

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第82张

orcl:/data0/app/oracle/product/11.2.0:N

将N改为Y

Orcl:实例

/data0/app/oracle/product/11.2.0 安装目录

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第83张

5.18.2、配置rc.local

[root@xiejian ~]# vim /etc/rc.d/rc.local

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第84张

添加下面两行

su oracle -lc "/data0/app/oracle/product/11.2.0/bin/lsnrctl start"

su oracle -lc /data0/app/oracle/product/11.2.0/bin/dbstart

其中第一行因为lsnrctl之后有空格,需要引号,第二行加不加引号都可以。修改完保存退出即可。

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第85张

注意注释

#这个文件是为了兼容性的问题而添加的。

#强烈建议创建自己的systemd服务或udev规则来在开机时运行脚本而不是使用这个文件。

#与以前的版本引导时的并行执行相比较,这个脚本将不会在其他所有的服务后执行。

#请记住,你必须执行“chmod +x /etc/rc.d/rc.local”来确保确保这个脚本在引导时执行。

确认一下该文件的权限

[root@xiejian bin]# ll /etc/rc.local

[root@xiejian bin]# ll /etc/rc.d/rc.local

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第86张

发现/etc/rc.d/rc.local没有执行权限,按说明的内容执行

[root@xiejian bin]# chmod +x /etc/rc.d/rc.local

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第87张

重启系统后查看一下

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第88张

5.19、建立新库,同时建立对应的实例

切换到root用户,编辑 /data0/database/response/dbca.rsp

修改以下参数:

GDBNAME = "orcl"

SID = "orcl"

SYSPASSWORD = "system"

SYSTEMPASSWORD = "system"

SYSMANPASSWORD = "system"

DBSNMPPASSWORD = "system"

DATAFILEDESTINATION =/data0/app/oracle/oradata

RECOVERYAREADESTINATION=/data0/app/oracle/fast_recovery_area

CHARACTERSET = "ZHS16GBK"

TOTALMEMORY = "1638"

静默建库

[oracle@xiejian ~]$ dbca -silent -responseFile /data0/database/response/dbca.rsp

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第89张

完成建库后进行实例检查

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第90张

查看监听状态

CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第91张

尝试登录一下,看能否登录,能否查询 

CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第92张

5.20、在实体机使用plsql连接试试

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第93张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第94张

 CentOS 7安装Oracle (CentOS Linux release 7.5.1804) Oracle 第95张

连接成功,安装完成。

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄