Theory + experiment: Oracle database deployment on Linux

1. About the Oralce database

■ The most popular large-scale relational database

  • Produced by Oracle, the latest version is Oracle 12c
  • This course takes the 64-bit Enterprise Edition Oracle 12c as an example
  • Official website: https://www.oracle.com/cn
  • Adopt C/S mode, support SQL query language
  • It is superior to other databases in terms of stability, high performance, and security,
  • So it is often used in government and enterprises
    Insert picture description here
    Insert picture description here

1.1 Features of Oracle Database

  1. Complete data management functions
    1) Mass of
    data 2) Persistence of data storage
    3) Data sharing
    4) Data reliability

  2. Complete relational products
    1) Information criteria—all information of a relational DBMS should be logically expressed in a way, that is, the values ​​in the table are explicitly expressed;
    2) Guidelines to ensure access
    3) View update criteria—as long as the view is formed The data in the table changes, and the data in the corresponding view changes at the same time.
    4) Data physical and logical independence criteria

2.2. Advantages

  • Strong availability
  • Strong scalability
  • Strong data security
  • Strong stability

2. Precautions for installing Oracle on Linux

2.1. Requirements for installing CentOS operating system

  • Firewall configuration options: disabled
  • SELinux setting: disabled
  • Kernel: 3.10.0.54.0.1.el7.x86_64 and above
  • View the core version command: uname -r
  • The kernel version of mysql7.0 is 3.1
  • The kernel version of mysql6.0 is 2.6

2.2. System and configuration requirements

  • Physical memory: no less than 1GB
  • The swap partition is not less than (not less than 4GB)
    1) When the physical memory is 1 ~ 2GB, set it to 1.5 ~ 2 times the virtual memory
    2) When the physical memory is 2 ~ 16GB, the setting is the same size as the virtual memory
  • Disk space: no less than 15GB
  • Have a fixed FQDN (fully qualified domain name) name, it is not recommended to change it after installation

2.3, software environment requirements

  • GNOME Chinese Desktop Environment
  • Chinese Java support
  • Install required packages

2.4, Oracle 12c installation conditions

■ Kernel requirements

  • Modify memory scheduling parameters, port range I/O requests...

■ User environment requirements

  • Create group accounts oinstall, dba, user account oracle
  • Create oracle base directory
  • Set environment variables for user oracle and allow the use of x terminal

■ Process session requirements

  • Increase the number of user oracle processes and file limit
    soft: soft limit
    hard: hard limit

2.5, Oracle 12c installation process

■ Allow runlnstaller installer

  • Unzip the downloaded zip package
  • Open graphic terminal authorization
  • Enter the database directory and perform the installation by the user oracle

Three, install Oracle

3.1, installation and configuration

-------------关闭防火墙自启动,以及相关功能和增强性安全功能
systemctl disable firewalld.service
systemctl stop firewalld.service
[root@localhost ~]# iptables -F  ###清空防火墙规则
[root@localhost ~]# setenforce 0      ###查看核心防护状态
setenforce: SELinux is disabled
[root@localhost ~]# hostnamectl  set-hostname oracle  ###更改名称
[root@localhost ~]# su      ###刷新
[root@oracle ~]# vim /etc/hosts  ###映射 ,把服务器ip地址和名称对应起来
20.0.0.3 oracle
[root@oracle ~]# ping oracle    ###ping一下看看
  • Software Environment Pack
yum -y install binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel
  • Adjust kernel parameters
[root@oracle ~]# vim /etc/sysctl.conf   ###在最后插入这些,把命令后面的解释都去掉

fs.aio-max-nr = 1048576   #异步IO请求数目 推荐值是:1048576 其实它等于 1024*1024 也就是 1024K 个
fs.file-max = 6815744   #打开的文件句柄的最大数量,防止文件描述符耗尽的问题
kernel.shmall = 2097152 #共享内存总量 页为单位,内存除以4K所得
kernel.shmmax = 4294967295  
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128  #SEMMSL: 每个信号集的最大信号数量 SEMMNS:用于控制整个 Linux 系统中信号的最大数 SEMOPM: 内核参数用于控制每个 semop 系统调用可以执行的信号操作的数量 SEMMNI :内核参数用于控制整个 Linux 系统中信号集的最大数量
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   #套接字发送缓冲区大小的最大值

[root@oracle ~]# sysctl -p   //重新加载配置文件
  • User environment configuration
[root@oracle ~]# groupadd oinstall    ###建立oinstall组
[root@oracle ~]# groupadd dba          ###建立dba组
[root@oracle ~]# useradd -g oinstall -G dba oracle     ###oinstall基本组 ,dba附加组
[root@oracle ~]# passwd oracle  ###设置密码123123
  • Can add a hard drive
    Insert picture description here
  • Configure a new hard drive
[root@oracle ~]# init 6    ###然后重启

[root@oracle ~]# fdisk -l   ###重启后就可以查看有一块新硬盘

[root@oracle ~]# fdisk /dev/sdb    ###进行分区
输入n,输入p,回车,回车,w保存退出

[root@oracle ~]# mkfs -t xfs /dev/sdb1    ###把dev下面的sdb1进行格式化

[root@oracle ~]# vim /etc/fstab    ###挂载
/dev/sdb1       /orc  xfs defaults  0 0 

[root@oracle ~]#[root@oracle ~]# mkdir /orc     ###先建一个orc目录
[root@oracle ~]# mount -a                              ###重新加载fstab文件,也就是把刚刚里面挂载信息挂载上去
[root@oracle ~]# df -Th                                   ###可以查看一下磁盘情况
  • Configure user environment
[root@oracle ~]# mkdir -p /orc/app/oracle   ###创建/app/oracle文件
[root@oracle ~]# chown -R oracle:oinstall /orc/app/    ###目录的属组权限要给
[root@oracle ~]# chmod -R 755 /orc/app/oracle/         ###目录的权限也要给足

[root@oracle ~]# vim /home/oracle/.bash_profile   ###oracle用户环境配置
注意:进去后先把最后两行命令删除,因为下面的环境配置已经包含了,原来的那两行多余了!!!
umask 022
ORACLE_BASE=/orc/app/oracle
ORACLE_HOME=/orc/app/oracle/product/12.2.0/dbhome_1/
ORACLE_SID=orcl
NLS_LANG="SIMPLIFIED CHINESE_CHINA".UTF8
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$ORACLE_HOME/bin
LANG=zh_CN.UTF-8

export PATH LANG NLS_LANG ORACLE_BASE ORACLE_HOME ORACLE_SID
------------------------上面用户环境配置解释--------------------
umask 022     ###反掩码,如果默然创建的目录是755,如果默认创建的文件就是644
ORACLE_BASE=/orc/app/oracle    ###数据库默认的工作目录
ORACLE_HOME=/orc/app/oracle/product/12.2.0/dbhome_1/  ###产品的家目录
ORACLE_SID=orcl     ###实例id
NLS_LANG="SIMPLIFIED CHINESE_CHINA".UTF8   ###字符集
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$ORACLE_HOME/bin  ###便于Oracle命令被系统所识别
LANG=zh_CN.UTF-8    ###安装的时候语言用的是简体中文

export PATH LANG NLS_LANG ORACLE_BASE ORACLE_HOME ORACLE_SID
  • oracle user resource limit
使用pam_limits认证模块
[root@oracle ~]# vim /etc/pam.d/login
在第一个# pam_selinux.so下面添加下面两条

session    required     /lib/security/pam_limits.so          ###资源限制模块
session    required     pam_limits.so

[root@oracle ~]# vim /etc/security/limits.conf  ###上面添加了限制模块,但是没有配置文件,现在设置配置文件
注意:在最后添加这五条命令,1、2两条对进程限制、3、4对文件数量限制、5是对内存做的优化
oracle        soft    nproc           2047       #单用户可使用的进程数量
oracle        hard    nproc           16384
oracle        soft    nofile          1024       #用户可打开的文件数量
oracle        hard    nofile          65536
oracle        soft    stack           10240      #堆栈设置

[root@oracle ~]# 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

[root@oracle ~]# source /etc/profile   ###重新加载一下
------------oracle安装---------------------------------
把解压的database包挂载在Linux  /abc中
去服务器图形界面用root账户登录,在终端里面输入下面操作


------------在图形化界面操作------------------------
[root@oracle ~]# xhost +     ###以root用户在图形化界面操作

[root@oracle ~]# su - oracle  ###切换oracle用户

[oracle@oracle ~]# export DISPLAY=:0.0    ###像素初始化

------------用root用户在创建一个/abc目录--------------
[root@oracle ~]# mkdir /abc
[oracle@oracle ~]# cd /abc
把linuxx64_12201_database软件拖进来,比较大,耐心等待一下...

[root@oracle abc]# unzip linuxx64_12201_database.zip   ###解压一下
----------切换到oracle账户---------------------------
[oracle@oracle ~]# cd /abc/database/
[oracle@oracle ~]# ./runInstaller   ###执行一下就可以弹出安装页面
按下面图片步骤把更新去掉,设置一个口令密码,安装就好了,注意下面的弹窗操作!!!

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

  • Installation of pop-up window treatment
注意:在安装进度条到79%的时候会弹出以root身份执行两个文件,这个时候只需要用root用户执行下面两条命令

切换 root  用户
[root@oracle ~]# /orc/app/oraInventory/orainstRoot.sh
[root@oracle ~]# /orc/app/oracle/product/12.2.0/dbhome_1/root.sh
第二条执行的时候会出现互动,回车,输入yes,然后等一下就行了

-----------------------------------------------------------------
再回安装界面点刚刚弹出的弹窗,确定,就会继续安装
  • Test: web interface management
    Mount flash rpm package installation
    Use Firefox to open
    https://Oracle:5500/em
    Login name: sys Password: abc123 Check: as sysdba
 操作步骤:
[root@oracle ~]# mkdir aaa   ###创建目录aaa
[root@oracle ~]# tar zxvf flash_player_npapi_linux.x86_64.tar.gz -C aaa  ###找到压缩文件直接解压到aaa文件夹
[root@oracle ~]# cd aaa/ 
[root@oracle aaa]# cp libflashplayer.so /usr/lib64/mozilla/plugins/   ###复制插件到火狐浏览器插件文件夹
#######因为插件的安装设计到更改权限问题,所以设置下插件的权限########
[root@oracle aaa]# cd /usr/lib64/mozilla/plugins/   ###定位到插件目录
[root@oracle plugins]# chmod 755 libflashplayer.so    ###更改插件权限

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

  • Test: Use the command line interface
---------------------使用oracle用户登录-----------------

[oracle@oracle ~]$ sqlplus / as sysdba  (sys用户是oracle的最高管理员所以要加上as)

如果是普通用户登录   sqlplus 用户名/密码

SQL> help index     (查看命令列表,sql中不区分大写小写)

SQL> show user       (查看当前用户)

Question set:

1. It shows that the swap partition is not enough during installation, so the memory size is increased.

解决方法:
1、free –m  ###查看swap内存大小

2、dd if=/dev/zero of=/home/swap bs=1M count=5024  ###增加5g内存

3、mkswap /home/swap         ###设置交换文件

4、swapon /home/swap         ### 启动交换分区文件

5、free –m     ###检查一下大小

6、vi /etc/fstab    ###启动后自动增加5g内存,添加下面那句
/home/swap swap swap defaults 0 0

2. After adding, execute ./runInstaller, and you will get an error when you want to install it.

Error display: Cannot use the command /usr/bin/xdpyinfo to automatically check the monitor color. Please check if the DISPLAY variable is set.
Insert picture description here

Solution:

  直接登录的时候就Oracle账户登录,不要先登录root用户,在切到Oracle账户里

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44733021/article/details/109225870