Build an Oracle database

Experiment name: Build an Oracle database
Experiment requirements: Complete the
setup of an Oracle database Experiment environment: One Centos7 virtual machine, IP address 192.168.22.100, 4G running, the swap partition needs to be 1.5-2 times the physical memory, and the disk space is not less than 10G. Oracle installation requires 5G
experiment steps:
(1) Configure the experiment environment
1, first check whether the conditions are met
Insert picture description here2, configure the domain name required for the experiment

[root@localhost ~]# vim /etc/hostname                      设置主机名(需要遵循FQDN且不可随意更改)
odb.sevenwin.org
[root@localhost ~]# vim /etc/hosts                           设置本地host缓存文件

Test to see if you can ping
Insert picture description here3, upload and change the java environment of java1.8

[root@localhost ~]# java -version                        查看Java环境
openjdk version "1.8.0_102"
OpenJDK Runtime Environment (build 1.8.0_102-b14)
OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode)
[root@localhost ~]# rz                            上传java1.8的安装包

[root@localhost ~]# tar -zxf jdk-8u161-linux-x64.tar.gz     解包
[root@localhost ~]# mv jdk1.8.0_161/ /usr/local/jdk1.8    移动并更名
[root@localhost ~]# vim /etc/profile                    配置全局环境变量
export JAVA_HOME=/usr/local/jdk1.8
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH
[root@localhost ~]# source /etc/profile                 立即生效
[root@localhost ~]# java -version                     查看Java环境是否配置成功
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

,4, configure the network source yum, download the required dependent programs

[root@localhost ~]# cd /etc/yum.repos.d/               切换工作目录
[root@localhost yum.repos.d]# ls
CentOS-Base.repo       CentOS-Media.repo
CentOS-CR.repo         CentOS-Sources.repo
CentOS-Debuginfo.repo  CentOS-Vault.repo
CentOS-fasttrack.repo
[root@localhost yum.repos.d]# mkdir yum.repos.d.bak    创建yum备份目录
[root@localhost yum.repos.d]# mv C* yum.repos.d.bak/    移动进行备份
[root@localhost yum.repos.d]# ls
yum.repos.d.bak
[root@localhost yum.repos.d]# vim yum.repo           配置网络源yum
#CentOS-Base.repo
#
#unless you are manually picking other mirrors.
#remarked out baseurl= line instead.
#
#

[base]
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[updates]
name=CentOS-$releasever - Updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@localhost yum.repos.d]# yum clean all         清除yum缓存
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base extras updates
Cleaning up everything
[root@localhost yum.repos.d]# yum makecache        加载数据
[root@localhost yum.repos.d]# yum -y install yum-utils     安装yum扩展包
[root@localhost ~]# yum -y install  gcc gcc-c++ glibc glibc-common glibc-devel glibcheaders ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXext libXtst libX11 libXau libXi make sysstat unixODBC unixODBC-devel zlib-devel compat-libcap1 compat-libstdc++-33    安装依赖包

5. User environment configuration

[root@localhost ~]# groupadd oinstall     创建组
[root@localhost ~]# groupadd dba        创建组
[root@localhost ~]# groupadd oper        创建组
[root@localhost ~]# useradd -g oinstall -G dba,oper oracle   创建Oracle用户并指定基本组和附加组
[root@localhost ~]# passwd oracle           设置Oracle用户密码
Changing password for user oracle.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully
[root@localhost ~]# vim /etc/sysctl.conf 
6,设置内核参数
[root@localhost ~]# vim /etc/sysctl.conf 
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500

7. Set Oracle shell limit

[root@localhost ~]# vim /etc/security/limits.conf 
oracle soft nofile 1024                     打开文件数量的软限制
oracle hard nofile 65536                    打开文件数量的硬限制
oracle soft nproc 2047                      工作可以用到的进程数量(软限制)
oracle hard nproc 16384                    工作可以用到的进程数量(硬限制)
oracle soft stack 10240                      堆栈占用的缓冲空间大小(软限制)
oracle hard stack 32768                      堆栈占用的缓冲空间大小(硬限制)
8,设置Oracle的shell启动脚本
[root@localhost ~]# vim /home/oracle/.bashrc 
export TMP=/tmp                         定义一个tmp的变量根下的tmp临时目录
export ORACLE_HOSTNAME=odb.sevenwin.org   定义了Oracle的主机名
export ORACLE_UNQNAME=orcl                定义Oracle的实例名
export ORACLE_BASE=/opt/app/oracle            Oracle的基目录
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1   Oracle的家目录(根据自己实际情况进行调整)
export ORACLE_SID=orcl                      SID和实例名一致
export PATH=/usr/sbin:$PATH:$ORACLE_HOME/bin   追加路径
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;    定义库的路径
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;    定义类库的路径
alias cdob='cd $ORACLE_BASE'                  定义命令的别名,cd到Oracle的基目录
alias cdoh='cd $ORACLE_HOME'                 定义命令的别名cd到Oracle的家目录
alias tns='cd $ORACLE_HOME/network/admin'      定义命令的别名,cd到网络配置admin的主目录
alias envo='env | grep ORACLE'                    定义命令的别名,显示跟Oracle有关的环境变量
umask 022                                    umask值设置为022
envo

(Two), install Oracle
1, install environment configuration

[root@localhost ~]# mkdir /opt/app/oracle/product/12.2.0/db_1 -p   创建Oracle安装路径
[root@localhost ~]# chown -R  oracle:oinstall /opt/app/            授权
[root@localhost ~]# vim /etc/selinux/config                       设置沙河安全等级
SELINUX=permissive

Restart the virtual machine and log in as root
Insert picture description here

[oracle@odb ~]$ rz                上传安装包

[oracle@odb ~]$ ls
Desktop    Downloads                    Music     Public     Videos
Documents  linuxx64_12201_database.zip  Pictures  Templates
[oracle@odb ~]$ unzip linuxx64_12201_database.zip     解包
[oracle@odb ~]$ ls
database  Documents  linuxx64_12201_database.zip  Pictures  Templates
Desktop   Downloads  Music                        Public    Videos
[oracle@odb ~]$ cd database/
[oracle@odb database]$ ls
install  response  rpm  runInstaller  sshsetup  stage  welcome.html
[oracle@odb database]$ ./runInstaller                进行安装

Insert picture description hereInsert picture description hereInsert picture description hereInsert picture description hereInsert picture description hereInsert picture description hereInsert picture description hereInsert picture description hereInsert picture description hereNeed to open a new terminal and run these two scripts as root


[oracle@odb database]$ su - root     切换到root用户来运行脚本
Password: 
Last login: Sun Jan 17 09:19:40 CST 2021 from 192.168.22.1 on pts/2
ABRT has detected 1 problem(s). For more info run: abrt-cli list --since 1610847561
[root@odb ~]# /opt/app/oraInventory/orainstRoot.sh       运行第一个脚本
Changing permissions of /opt/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /opt/app/oraInventory to oinstall.
The execution of the script is complete.
[root@odb ~]# /opt/app/oracle/product/12.2.0/db_1/root.sh    运行第二个脚本
Performing root user operation.

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

Enter the full pathname of the local bin directory: [/usr/local/bin]:   回车
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...


Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Do you want to setup Oracle Trace File Analyzer (TFA) now ? yes|[no] :   回车

Oracle Trace File Analyzer (TFA - User Mode) is available at :
    /opt/app/oracle/product/12.2.0/db_1/suptools/tfa/release/tfa_home/bin/tfactl

OR

Oracle Trace File Analyzer (TFA - Daemon Mode) can be installed by running this script :  回车
    /opt/app/oracle/product/12.2.0/db_1/suptools/tfa/release/tfa_home/install/roottfa.sh

Insert picture description here

[root@odb ~]# whoami                 查看当前用户
root
[root@odb ~]# vim /etc/oratab            进行更改
orcl:/opt/app/oracle/product/12.2.0/db_1:Y    把N改成y,(Oracle运行数据库引擎的时候要运行orcl) 
2,启动、停止、以及查看数据库状态命令

[oracle@odb ~]$ lsnrctl stauus View monitoring and database status
Insert picture description here

[oracle@odb ~]$ lsnrctl start             启动监控

Insert picture description here

[oracle@odb ~]$ lsnrctl stop            停止监控

Insert picture description here

[oracle@odb ~]$ sqlplus sys AS sysdba    以DBA的身份登录Oracle

Insert picture description here
[So far, the Oracle database is built]

Guess you like

Origin blog.csdn.net/lxy123_com/article/details/112751682
Recommended