Oracle installation and basic operation

In the field of computer security information, the database system undoubtedly has a pivotal position. For example, Microsoft SQL server, IBM's DB2, and Oracle's Oracle, MySQL, etc., are relatively well-known database management software, Oracle database is has the absolute leader in the telecommunications, banking, securities, transportation and other large applications The advantages.
Here we are concerned that Oracle 12c installation.
Oracle 12c explicitly supported Linux operating systems, including Oracle Linux 7, Oracle Linux 6. Oracle Linux 5. Red Hat Enterprise Linux 7, Red Hat Enterprise Linux 6. Red Hat Enterprise Linux 5. SUSE Linux Distributions .NeoKylin Linux Advanced Server Distributions. Because Red Hat Enterprise and CentOS part of the operating system released simultaneously, so Oracle 12c is also supported CentOS7. CentOS6. CentOS5 operating system. When installed in other Linux systems, individual software or configuration files may need to make the appropriate adjustments.

Linux System requirements:

  • Physical memory: must be higher than 1GB, VMware Virtual Machine Recommendations for no less than 2GB.
  • Swap space: the physical memory is 2GB, swap 1.5 to 2 times the physical memory 1 ~; physical memory is 2 ~ 16GB, the same swap partition the physical memory size: when 16GB physical memory exceeds swap using 16GB can a.

First, the preparatory work
the system requirements
for Oracle 12c database, if the program files and data files are installed on the same partition, the minimum required disk space for the partition Enterprise Edition 6.4GB. Standard 6.1GB, in addition, should also ensure that / tmp directory of free space less than 1GB. generally
, it is recommended to prepare at least 15GB of hard disk space for the Oracle 12c.
Under the experimental environment, if you do not create a separate partition for Oracle, then at least to ensure that the root partition has 15GB of available disk space. If the current disk space, consider adding a hard disk in a virtual machine, formatted to XFS file system. While creating / u01 directory, mount the newly created partition to the / u01 directory. Also remember to modify / etc / fstab file, let it boot automatically mount.
Before installing the Oracle database, requires good planning and a host name and IP. Server's host name, IP address, should be determined in advance and correct. Once the Oracle database installation is complete, it is recommended not to modify the host name, otherwise it will lead to database failed to start. Check the host name can be achieved by the hostname command, modify the host name of the configuration file / etc / hosts achieved by

[root@oracle /]# hostname
oracle
[root@oracle /]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.10    oracle

Software environment requires
Oracle 12c installation process is usually carried out in a graphical interface, it is recommended to use CentOS server has been installed Chinese GNOME desktop environment. Software development tools, of course, is also essential, such as gcc. Glibc, binutils and other packages

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

Core Requirements
To ensure stable operation of the database, Oracle 12c for Linux kernel parameters. Process session limit made some requests, some of which can be set to automatically detect and repair during the installation process, but not necessarily very complete, so the best approach is based on installation documentation configured in advance.
Adjusting kernel parameters reflected in the / etc / sysctl .conf file, including scheduling and memory. Port range, the number of open files.
Some other related settings VO request, the correlation value is not less than the installation requirements. After modification, the new configuration by executing the "sysctl -p" command take effect immediately.

[root@oracle /]# vim /etc/sysctl.conf                # 编辑
...................           // 省略部分内容
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4294967295
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
...................           //省略部分内容
[root@oracle /]# sysctl -p                     # 重新加载配置文件
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4294967295
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

Oracle user environment requires
Oracle 12c need to run a fixed user oracle. Installation Group oinsall. Management group dba, these accounts should be completed in advance. With
basic procedures and a directory to store Oracle database files (such as / u01 / app / oracle) should be created in advance

[root@oracle /]# groupadd -g 54321 oinstall                          # 创建安装组
[root@oracle /]# groupadd -g 54322 dba                         # 创建管理组
[root@oracle /]# useradd -u 54321 -g oinstall -G dba oracle             # 创建运行用户
[root@oracle /]# passwd oracle                # 配置密码
更改用户 oracle 的密码 。
新的 密码:
无效的密码: 密码未通过字典检查 - 过于简单化/系统化
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@oracle /]# mkdir -p /u01/app/oracle               # 创建基本目录
[root@oracle /]# chown -R oracle:oinstall /u01/app/
[root@oracle /]# chmod -R 775 /u01/app/oracle/

Oracle 12c installation tasks should be performed to run the oracle user's identity, the need to adjust the oracle user's environment configuration to meet the requirements:

[root@oracle /]# vim /home/oracle/.bash_profile 
........................           // 省略部分内容
umask  022
ORACLE_BASE=/u01/app/oracle                       # 定义基本目录
ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1/                  # 定义安装家目录
ORACLE_SID=orcl                 # 定义数据库实例名称
NLS_LANG="SIMPLIFIED CHINESE_CHINA".UTF8                   # 确定使用何种语言环境
PATH=$PATH:$ORACLE_HOME/bin
LANG=zh_CN.UTF-8
export PATH LANG NLS_LANG ORACLE_BASE ORACLE_HOME ORACLE_SID
export  DISPLAY=:0.0

Oracle user resource limits
process session limit can be used pam. Jimits authentication module is achieved by modifying the login program login of PAM settings to enable the authentication, and then modify / etc / security / imits. Conf file, the user oracle to open the process number file process used to increase the number of

[root@oracle /]# vim /etc/pam.d/login 
...................             // 省略部分内容
session   required  /lib/security/pam_limits.so
session   required  pam_limits.so

[root@oracle /]# vim /etc/security/limits.conf 
................                // 省略部分内容
oracle   soft    nproc   2047                      # 进程数软限制
oracle   hard    nproc   16384               # 进程数硬限制
oracle   soft   nofile   1024                    # 文件数软限制
oracle   hard   nofile    65536             # 文件数硬限制
oracle   soft  stack    10240                  # Oracle 软堆栈限制

[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

Do not configure the oracle user resource limits section, it will not affect the successful installation of the Oracle database, but if bad SQL statement against the occupation unlimited server resources, resulting in a long time no response to user requests, it is recommended to limit the advance oralce user resources, after the completion of preparations to restart the operating system, before the configuration is checked again after the restart to take effect, it is recommended not to do temporary configuration.
Second, install the Oracle
the Oracle of Chinese official site at https:. // www oracle .com / cn It supports Oracle 12c installation files for free download (registration required account) to select the correct platform used (such as Linux x86-64.. ), then download linuxx64 .12201 .database the ZP .zip archive to / tmp / abc folder (create your own). after extracting the folder available database, Oracle installation script. product manuals and other documents are located in this folder
You can also download the installation package provided:
start the installation

[root@oracle /]# mkdir /tmp/abc                    # 为什么要在tmp下创个目录呢,因为tmp的权限都放开了,一会需要切换Oracle用户来进行安装
[root@oracle /]# cd /tmp/abc/
[root@oracle abc]# ls
flash-player-npapi-26.0.0.131-release.x86_64.rpm  linuxx64_12201_database.zip
[root@oracle abc]# unzip linuxx64_12201_database.zip 
[root@oracle abc]# ls  database/
install  response  rpm  runInstaller  sshsetup  stage  welcome.html

Oracle 12c mainly through runlsaller installation script, visit the page welcome .html may consult the product manual, including product descriptions, release notes, installation guides and other documents, provides a very rich help information for the administrator.
After all the pre-conditions are ready, we can officially start the installation. If the current graphical desktop environment based on the identity of other users (such as root) to log in, it should also add authorized to allow the user oracle using a graphical terminal. For example, "xhost +
oracle @ localhost" allows user to oracle access from the machine, perform, xhost + "removes all restrictions.
As user oracle log on to the CentOS graphical desktop environment, runstaller script file in the startup database / directory

[root@oracle abc]# xhost +                      # 一定要以root用户在图形环境中操作
access control disabled, clients can connect from any host
[root@oracle abc]# su - oracle                  # 切换为 Oracle用户
[oracle@oracle ~]$ cd /tmp/abc/database/
[oracle@oracle database]$ ./runInstaller 
正在启动 Oracle Universal Installer...

检查临时空间: 必须大于 500 MB。   实际为 28334 MB    通过
检查交换空间: 必须大于 150 MB。   实际为 2047 MB    通过
检查监视器: 监视器配置至少必须显示 256 种颜色。    实际为 16777216    通过
准备从以下地址启动 Oracle Universal Installer /tmp/OraInstall2019-12-11_09-32-31PM. 请稍候...

Oracle installation and basic operation
Oracle installation and basic operation
Oracle installation and basic operation
Oracle installation and basic operation
Oracle installation and basic operation
Oracle installation and basic operation
Oracle installation and basic operation
Oracle installation and basic operation
Oracle installation and basic operation
Oracle installation and basic operationOracle installation and basic operation

[root@oracle /]# /u01/app/oraInventory/orainstRoot.sh            # 直接执行即可
更改权限/u01/app/oraInventory.
添加组的读取和写入权限。
删除全局的读取, 写入和执行权限。

更改组名/u01/app/oraInventory 到 oinstall.
脚本的执行已完成。
[root@oracle /]# /u01/app/oracle/product/12.2.0/dbhome_1/root.sh            # 执行后出现提示直接回车即可
Performing root user operation.

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/oracle/product/12.2.0/dbhome_1

Enter the full pathname of the local bin directory: [/usr/local/bin]:     # 回车

Oracle installation and basic operation
Install flash player

[root@oracle /]# cd /tmp/abc/
[root@oracle abc]# ls
database                                          linuxx64_12201_database.zip
flash-player-npapi-26.0.0.131-release.x86_64.rpm
[root@oracle abc]# rpm -ivh flash-player-npapi-26.0.0.131-release.x86_64.rpm 
准备中...                          ################################# [100%]
正在升级/安装...
   1:flash-plugin-26.0.0.131-release  ################################# [100%]

Oracle installation and basic operation
下图就是Oracle 的企业管理器
Oracle installation and basic operation
Oracle 12c 数据库的创建

[oracle@oracle /]$ sqlplus / as sysdba            # 登录数据库

SQL*Plus: Release 12.2.0.1.0 Production on 星期三 12月 11 22:00:15 2019

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

连接到: 
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> 
sys用户是Oracle的最高管理员,以sys用户登录的时候一般要加上as sysdba,
而其他用户则不需要。
SQL> help index            # ketongguy可通过此命令来查看支持的指定列表

创建数据库:

[oracle@oracle /]$ dbca               # shuru输入此命令可弹出创建数据库的向导

Oracle installation and basic operation
Oracle installation and basic operation
Oracle installation and basic operation
Oracle installation and basic operation

Oracle 12c 数据库的启动与关闭
1. 数据库的启动
启动(STARTUP) 一个数据库需要三个步骤,①启动Oracle实例(非装 载阶段);②由实例装载
数据库(装载阶段);③打开数据库(打开阶段)。
在STARTUP命令中,可以通过不同的选项来控制数据库的不同启动步骤。
1) STARTUP NOMOUNT
NOMOUNT选项仅仅启动一个Oracle实例,读取init ora初始化参数文件、启动后台进程、初始
化SGA.当实例启动后,系统将显示一个SGA内存结构和大小的列表,如下所示.

SQL> startup nomount
ORACLE instance started.
Total System G1obal Area 2516582400 bytes
Fixed Size            8795904 bytes
Variable Size        671090944 bytes
Database Buffers 1828716544 bytes
Redo Buffers         7979008 bytes

2) STARTUP MOUNT
STARTUP MOUNT命令启动实例并且装载数据库,但没有打开数据库。Oracle 系统读取控制文件中关于数据文件和重做日志文件的内容,但并不打开该文件。这种打开方式常在数据库维护操作中使用,如对数据文件的更名,改变重做日志及打开归档模式等,在这种打开方式下,除了可以看到SGA系统列表以外,系统还会给出“数据库装载完毕 ”的提示。
3) STARTUP
STARTUP命令完成启动实例、装载数据库和打开数据库三个步骤。此时,数据库使数据文件和重做日志文件在线,通常还会请求一个或者多个回滚段;系统除了可以看到前STARTUP MOUNT方式下的所有提示外,还会给出一个‘数据库已经打开” 的提示: 数据库系统处于正常工作状态,可以接收用户请求。
如果采用STARTUP NOMOUNT或者STARTUP MOUNT的数据库打开方式,必须采用ALTER DATABASE命令来执行装载或打开数据库的操作。例如,如果以STARTUP NOMOUNT方式打开数据库,也就是说实例已经启动,但是数据库没有装载和打开。这时必须运行下面的两条命令,数据库才能正确启动。

ALTER DATABASE MOUNT;
ALTER DATABASE OPEN;

如果以STARTUP MOUNT方式启动数据库,只需要运行下面-条命令即可以打开数据库。

ALTER DATABASE OPEN;

2.数据库的关闭
对于数据库的关闭(SHUTDOWN), 有四种不同的关闭选项.
1) SHUTDOWN NORMAL
SHUTDOWN NORMAL是SHUTDOWN命令的默认选项。也就是说,如果用户发出SHUTDOWN命令,即执行SHUTDOWN NORMAL命令。
发出该命令后,任何新的连接都将不再允许连接到数据库。在数据库关闭之前,Oracle 将等待目前连接的所有用户都从数据库中退出后才开始关闭数据库。采用这种方式关闭数据库,在下一-次启动时不需要进行任何的实例恢复。但需要注意的是.采用这种方式时,也许关闭一个数据库需要几天或更长的时间。
2) SHUTDOWN IMEDIATE
SHUTDOWN IMEDIATE是常用的一种关闭数据库的方式。若既想很快地关闭数据库,又想让数据库“干净”地关闭,则常采用这种方式。
发出该命令后,当前正在被Oracle处理的SaL语句立即中断,系统中任何没有提交的事务全部回滚。如果系统中存在-个很长的未提交的事务,那么采用这种方式关闭数据库也需要一段时间 (该事务回滚时间)。系统不会等待连接到数据库的所有用户退出系统,而会强行回滚当前所有的活动事务,然后断开所有的连接用户。
3) SHUTDOWN TRANSACTIONAL
SHUTDOWN TRANSACTIONAL命令常用来计划关闭数据库,它会等待当前连接到系统且正在活动的事务执行完毕,运行该命令后 ,任何新的连接和事务都是不允许的。在所有活动的事务执行完成后,数据库将以和SHUTDOWN IMEDIATE同样的方式关闭数据库.
4) SHUTDOWN ABORT
SHUTDOWN ABORT is a way to shut down the database last choice is the way without any way to close the case had to use the database, - - like not to use. In the following cases can be considered in this way to close the database.
(1) A non-database in normal operation, the database can not be closed with SHUTDOWN NORMAL or SHUTDOWN IMEDIATE command.
(2) require immediate closure of the database.
(3) have problems when starting a database instance.
After issuing the command, all running SQL statements will suspend immediately all uncommitted transactions are not rolled back, Oracle does not wait for users currently connected to the database to exit the system, under - need to start the database instance recovery times, therefore, the next - start times may require more time than usual.

When closing the database SHUTDOWN IMMEDIATE embodiment is preferably used, because this way safe and relatively fast. Not a last resort do not use SHUTDOWN ABORT way, because in this way will result in loss of data and also take a long time to recover the database.

Guess you like

Origin blog.51cto.com/14227204/2457885