Oracle笔记(1)19c databse安装

摘要:
限制。conf文件限制了用户可以使用的文件、线程、内存和其他资源的最大数量。

一、环境

操作系统: CentOs7.6_64
安装源: Oracle Database 19.3.0.0.0 for Linux x86-64.zip
主机名: server
IP地址: 192.168.10.131

二、过程

参考:https://oracle-base.com/articles/19c/oracle-db-19c-installation-on-oracle-linux-7

2.1 准备阶段

1.关闭防火墙
[root@server ~]# systemctl stop firewalld.service
[root@server ~]# systemctl disable firewalld.service
[root@server ~]# systemctl status firewalld.service

2.关闭selinux
[root@server ~]# setenforce 0                  #临时设置SELinux 成为permissive模式, 1为enforcing模式
#[root@server ~]# setenforce Permissive        #或者
[root@server ~]# sed -i "s/^SELINUX=.*/SELINUX=Permissive/" /etc/selinux/config    #重启生效

3.修改hosts文件
[root@server ~]# cat >> /etc/hosts <<'EOF'

#add for oracle 
192.168.10.131 server
EOF

4.修改内核参数文件,添加内容
# Add the following lines to the "/etc/sysctl.conf" file, or in a file called "/etc/sysctl.d/98-oracle.conf".

[root@server ~]# cat >>/etc/sysctl.conf <<'EOF'

# add for oracle by me
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
EOF
[root@server ~]# /sbin/sysctl -p     #重启生效

5.修改vi /etc/security/limits.conf
#linux资源限制配置文件是/etc/security/limits.conf;限制用户进程的数量对于linux系统的稳定性非常重要。limits.conf文件限制着用户可以使用的最大文件数,最大线程,最大内存等资源使用量。
#oracle base写的/etc/security/limits.d/oracle-database-preinstall-19c.conf,操作系统为oracle linux。
[root@server ~]# cat >>/etc/security/limits.conf <<'EOF'

#add for oracle by me
oracle   soft   nofile    1024
oracle   hard   nofile    65536
oracle   soft   nproc    16384
oracle   hard   nproc    16384
oracle   soft   stack    10240
oracle   hard   stack    32768
oracle   hard   memlock    134217728
oracle   soft   memlock    134217728
EOF

6.安装必要的包
[root@server ~]# yum install -y bc binutils compat-libcap1 compat-libstdc++-33 dtrace-utils elfutils-libelf elfutils-libelf-devel fontconfig-devel glibc glibc-devel ksh
yum install -y libaio libaio-devel libdtrace-ctf-devel  libXrender  libXrender-devel libX11 libXau  libXi libXtst libgcc librdmacm-devel  libstdc++ libstdc++-devel 
yum install -y libxcb make net-tools   nfs-utils python python-configshell python-rtslib  python-six targetcli smartmontools sysstat
yum install gcc-c++*

#yum install -y dtrace-modules
#yum install -y dtrace-modules-headers
#yum install -y dtrace-modules-provider-headers

# Added by me.
yum install -y unixODBC

7.创建用户和组
[root@server ~]# groupadd -g 54321 oinstall
groupadd -g 54322 dba
groupadd -g 54323 oper
#groupadd -g 54324 backupdba
#groupadd -g 54325 dgdba
#groupadd -g 54326 kmdba
#groupadd -g 54327 asmdba
#groupadd -g 54328 asmoper
#groupadd -g 54329 asmadmin
#groupadd -g 54330 racdba

useradd -u 54321 -g oinstall -G dba,oper oracle

[root@server ~]# passwd oracle           #修改oracle密码

8.创建安装目录
[root@server ~]# mkdir -p /u01/app/oracle/product/19.0.0/dbhome_1
mkdir -p /u02/oradata
chown -R oracle:oinstall /u01 /u02
chmod -R 775 /u01 /u02                        #u01放软件  u02放数据文件

9.创建设置oracle 环境变量脚本
[root@server ~]# mkdir /home/oracle/scripts
[root@server ~]# cat > /home/oracle/scripts/setEnv.sh <<EOF
# Oracle Settings
export TMP=/tmp
export TMPDIR=$TMP

export ORACLE_HOSTNAME=server
export ORACLE_UNQNAME=cdb1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.0.0/dbhome_1
export ORA_INVENTORY=/u01/app/oraInventory
export ORACLE_SID=cdb1
export PDB_NAME=pdb1
export DATA_DIR=/u02/oradata

export PATH=/usr/sbin:/usr/local/bin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
EOF
[root@server ~]# chmod +x /home/oracle/scripts/setEnv.sh 
[root@server ~]# echo ". /home/oracle/scripts/setEnv.sh" >> /home/oracle/.bash_profile

10.将安装源解压至ORACLE_HOME

[root@server ~]# unzip /root/Oracle Database 19.3.0.0.0 for Linux x86-64.zip -d /u01/app/oracle/product/19.0.0/dbhome_1
[root@server ~]# chown -R oracle:oinstall /u01 /u02          #在root用户解压,需要修改文件权限
[root@server ~]# chmod -R 775 /u01 /u02                        #u01放软件  u02放数据文件

2.2 安装数据库软件

1.启动安装
[root@server ~]# su - oracle
[oracle@server ~]$ cd $ORACLE_HOME


# 图形化安装
[oracle@server dbhome_1]$ ./runInstaller

# 静默安装
[oracle@server dbhome_1]$ ./runInstaller -ignorePrereq -waitforcompletion -silent                        
    -responseFile ${ORACLE_HOME}/install/response/db_install.rsp               
    oracle.install.option=INSTALL_DB_SWONLY                                    
    ORACLE_HOSTNAME=${ORACLE_HOSTNAME}                                         
    UNIX_GROUP_NAME=oinstall                                                   
    INVENTORY_LOCATION=${ORA_INVENTORY}                                        
    SELECTED_LANGUAGES=en,en_GB                                                
    ORACLE_HOME=${ORACLE_HOME}                                                 
    ORACLE_BASE=${ORACLE_BASE}                                                 
    oracle.install.db.InstallEdition=EE                                        
    oracle.install.db.OSDBA_GROUP=dba                                          
    oracle.install.db.OSBACKUPDBA_GROUP=dba                                    
    oracle.install.db.OSDGDBA_GROUP=dba                                        
    oracle.install.db.OSKMDBA_GROUP=dba                                        
    oracle.install.db.OSRACDBA_GROUP=dba                                       
    SECURITY_UPDATES_VIA_MYORACLESUPPORT=false                                 
    DECLINE_SECURITY_UPDATES=true

##########################################################################################################
[oracle@server dbhome_1]$ ./runInstaller -ignorePrereq -waitforcompletion -silent                        
>     -responseFile ${ORACLE_HOME}/install/response/db_install.rsp               
>     oracle.install.option=INSTALL_DB_SWONLY                                    
>     ORACLE_HOSTNAME=${ORACLE_HOSTNAME}                                         
>     UNIX_GROUP_NAME=oinstall                                                   
>     INVENTORY_LOCATION=${ORA_INVENTORY}                                        
>     SELECTED_LANGUAGES=en,en_GB                                                
>     ORACLE_HOME=${ORACLE_HOME}                                                 
>     ORACLE_BASE=${ORACLE_BASE}                                                 
>     oracle.install.db.InstallEdition=EE                                        
>     oracle.install.db.OSDBA_GROUP=dba                                          
>     oracle.install.db.OSBACKUPDBA_GROUP=dba                                    
>     oracle.install.db.OSDGDBA_GROUP=dba                                        
>     oracle.install.db.OSKMDBA_GROUP=dba                                        
>     oracle.install.db.OSRACDBA_GROUP=dba                                       
>     SECURITY_UPDATES_VIA_MYORACLESUPPORT=false                                 
>     DECLINE_SECURITY_UPDATES=true
Launching Oracle Database Setup Wizard...

[WARNING] [INS-32047] The location (/u01/app/oraInventory) specified for the central inventory is not empty.
   ACTION: It is recommended to provide an empty location for the inventory.
[WARNING] [INS-13014] Target environment does not meet some optional requirements.
   CAUSE: Some of the optional prerequisites are not met. See logs for details. installActions2020-03-27_04-49-31PM.log
   ACTION: Identify the list of failed prerequisite checks from the log: installActions2020-03-27_04-49-31PM.log. 
Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.
The response file for this session can be found at:
 /u01/app/oracle/product/19.0.0/dbhome_1/install/response/db_2020-03-27_04-49-31PM.rsp

You can find the log of this install session at:
 /tmp/InstallActions2020-03-27_04-49-31PM/installActions2020-03-27_04-49-31PM.log

As a root user, execute the following script(s):
	1. /u01/app/oraInventory/orainstRoot.sh
	2. /u01/app/oracle/product/19.0.0/dbhome_1/root.sh

Execute /u01/app/oraInventory/orainstRoot.sh on the following nodes: 
[server]
Execute /u01/app/oracle/product/19.0.0/dbhome_1/root.sh on the following nodes: 
[server]


Successfully Setup Software with warning(s).
Moved the install session logs to:
 /u01/app/oraInventory/logs/InstallActions2020-03-27_04-49-31PM

#root用户执行脚本
[oracle@server dbhome_1]$ /u01/app/oraInventory/orainstRoot.sh
[oracle@server dbhome_1]$ /u01/app/oracle/product/19.0.0/dbhome_1/root.sh

2.3 安装数据库实例

# 启动监听
[oracle@server dbhome_1]$ lsnrctl start

# 图形安装
dbca

# 静默安装.
#拓展阅读 https://oracle-base.com/articles/misc/database-configuration-assistant-dbca-silent-mode

dbca -silent -createDatabase                                                   
     -templateName General_Purpose.dbc                                         
     -gdbname ${ORACLE_SID} -sid  ${ORACLE_SID} -responseFile NO_VALUE         
     -characterSet AL32UTF8                                                    
     -sysPassword Ora123456                                            
     -systemPassword Ora123456                                            
     -createAsContainerDatabase true                                           
     -numberOfPDBs 1                                                           
     -pdbName ${PDB_NAME}                                                      
     -pdbAdminPassword Ora123456                                            
     -databaseType MULTIPURPOSE                                                
     -automaticMemoryManagement false                                          
     -totalMemory 2000                                                         
     -storageType FS                                                           
     -datafileDestination "${DATA_DIR}"                                        
     -redoLogFileSize 50                                                       
     -emConfiguration NONE                                                     
     -ignorePreReqs
############################################################################################
[oracle@server dbhome_1]$ dbca -silent -createDatabase                                                   
>      -templateName General_Purpose.dbc                                         
>      -gdbname ${ORACLE_SID} -sid  ${ORACLE_SID} -responseFile NO_VALUE         
>      -characterSet AL32UTF8                                                    
>      -sysPassword Ora123456                                            
>      -systemPassword Ora123456                                            
>      -createAsContainerDatabase true                                           
>      -numberOfPDBs 1                                                           
>      -pdbName ${PDB_NAME}                                                      
>      -pdbAdminPassword Ora123456                                            
>      -databaseType MULTIPURPOSE                                                
>      -automaticMemoryManagement false                                          
>      -totalMemory 2000                                                         
>      -storageType FS                                                           
>      -datafileDestination "${DATA_DIR}"                                        
>      -redoLogFileSize 50                                                       
>      -emConfiguration NONE                                                     
>      -ignorePreReqs
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
43% complete
46% complete
Completing Database Creation
51% complete
53% complete
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
 /u01/app/oracle/cfgtoollogs/dbca/cdb1.
Database Information:
Global Database Name:cdb1
System Identifier(SID):cdb1
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb1/cdb1.log" for further details.


2.4 创建数据库启动、停止脚本

参考:https://oracle-base.com/articles/linux/automating-database-startup-and-shutdown-on-linux
#修改/etc/oratab
#将cdb1:/u01/app/oracle/product/19.0.0/dbhome_1:N这一行最后的N改成Y
[oracle@server dbhome_1]$ sed -i 's/:N/:Y/' /etc/oratab 

#创建启动脚本 start_all.sh
[oracle@server dbhome_1]$ cat > /home/oracle/scripts/start_all.sh <<EOF
#!/bin/bash
. /home/oracle/scripts/setEnv.sh

export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES

dbstart $ORACLE_HOME
EOF

#创建关闭脚本 stop_all.sh
[oracle@server dbhome_1]$ cat > /home/oracle/scripts/stop_all.sh <<EOF
#!/bin/bash
. /home/oracle/scripts/setEnv.sh

export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES

dbshut $ORACLE_HOME
EOF

[oracle@server dbhome_1]$ chown -R oracle:oinstall /home/oracle/scripts
[oracle@server dbhome_1]$ chmod u+x /home/oracle/scripts/*.sh

2.5配置数据库自启动 #使用OL7 systemcl

参考: https://oracle-base.com/articles/linux/linux-services-systemd#creating-linux-services


#注意:在root用户执行

#[root@server ~]$ cat > /lib/systemd/system/dbora.service <<EOF   # oracle base
[root@server ~]$ cat > /etc/systemd/system/dbora.service <<EOF    # modify by me
[Unit]
Description=The Oracle Database Service
After=syslog.target network.target

[Service]
# systemd ignores PAM limits, so set any necessary limits in the service.
# Not really a bug, but a feature.
# https://bugzilla.redhat.com/show_bug.cgi?id=754285
LimitMEMLOCK=infinity
LimitNOFILE=65535

#Type=simple
# idle: similar to simple, the actual execution of the service binary is delayed
#       until all jobs are finished, which avoids mixing the status output with shell output of services.
RemainAfterExit=yes
User=oracle
Group=oinstall
Restart=no
ExecStart=/bin/bash -c '/home/oracle/scripts/start_all.sh'
ExecStop=/bin/bash -c '/home/oracle/scripts/stop_all.sh'
[Install]
WantedBy=multi-user.target
EOF

#
[root@server ~]# systemctl daemon-reload
[root@server ~]# systemctl start dbora.service
[root@server ~]# systemctl enable dbora.service
[root@server ~]# systemctl status dbora.service
[root@server ~]# reboot           #重启验证是否能够自动启动

三、19c基本管理

...

免责声明:文章转载自《Oracle笔记(1)19c databse安装》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇.net 最佳实践一:监测.net代码中的高内存消耗函数&amp;lt;转&amp;gt;vi基本操作下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Weblogic的安装、配置与应用部署

1. Weblogic安装 1.1 Linux下安装过程 安装环境: 操作系统: redhat-release-5Server-5.4.0.3 Weblogic版本: Weblogic 9.24 1)       部署前准备: 创建weblogic用户组. groupadd weblogic useradd –g weblogic weblogic pas...

oracle日期处理函数整理

1.trunc 函数   截断函数既可以截取日期 也可以截取数字   返回今天的日期 select trunc(sysdate)  from dual; --07-6月 -20       返回昨天的日期 select trunc(sysdate-1) from dual;   返回当月第一天 select trunc(sysdate,'mm')  fro...

oracle语句批处理

数据量有40万条,从一个对象table_01一条一条取数到对象table_02,如果用原始的 Statement Statmt =comm.createStatement(); String sql="insert into tb2...."; Statmt.executeUpdate(sql); newCon.commit();//这里是每执行一条sq...

Linux在没有root权限的情况下安装gcc环境

1. 安装gcc 首先下载新版本的gcc:http://ftp.gnu.org/gnu/gcc/ 安装GCC主要依赖三个库:GMP, MPFR 和MP)。之前的旧版本可能需要手动依次安装这些依赖库,但较新的版本其实只需要在GCC目录下运行下面这个命令就可以自动下载这几个组件,好像不用联网也可以。 ./contrib/download_prerequisit...

HAProxy安装文档

HAProxy安装文档 目录 HAProxy安装文档 一、环境说明 二、安装配置 1.创建用户 2.安装 3.创建配置文件和启动文件 三、编辑配置文件 四、启动HAproxy 五、配置日志 1.配置rsyslog 2.创建haprxoy日志配置 3.开启远程日志 4.haproxy开启日志配置 5.重启rsyslog 和 haproxy 6....

Oracle ASM 磁盘组基础知识整理(收藏版)

转至:https://cloud.tencent.com/developer/article/1494403 为什么要写这么一篇基础知识呢?还是有那么一点点原因的,不是胡编乱造还真是有真实存在的事件的,前两周里因一套生产环境数据库磁盘不足无法对其进行表空间扩容,需要向存储岗申请存储资源,当存储岗划好资源加完存储时,操作系统岗对其进行扫盘以及权限处理时忘记对...