ToB企服应用市场:ToB评测及商务社交产业平台

标题: 银河麒麟系统静默安装19c数据库 [打印本页]

作者: 知者何南    时间: 2024-8-8 23:48
标题: 银河麒麟系统静默安装19c数据库
  1. 作者介绍:老苏,10余年DBA工作运维经验,擅长Oracle、MySQL、PG数据库运维(如安装迁移,性能优化、故障应急处理等)
  2. 公众号:老苏畅谈运维
  3. 欢迎关注本人公众号,更多精彩与您分享。
复制代码
一、概述

本文将介绍银河麒麟操纵系统V10下静默安装oracle 19c单机数据库的过程。
1.1 主机信息

|系统版本|Kylin Linux Advanced Server release V10 (Lance)|
|-|-|-|
|主机名|oracle-19c|
|IP地址|192.168.12.110|
1.2 数据库信息

|数据库版本|oracle 19.22|
|-|-|-|
|数据库实例名|oracle|
|数据库服务名|oracle|
|数据库字符集|ZHS16GBK|
|数据文件目次|/data/ORACLE|
|归档目次|/arch|
二、麒麟系统配置

2.1 关闭防火墙

  1. [root@oracle-19c ~]# systemctl stop firewalld.service
  2. [root@oracle-19c ~]# systemctl disable firewalld.service
  3. [root@oracle-19c ~]# systemctl status firewalld.service
  4. ● firewalld.service - firewalld - dynamic firewall daemon
  5.    Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
  6.    Active: inactive (dead)
  7.      Docs: man:firewalld(1)
复制代码
2.2 关闭selinux

  1. [root@oracle-19c ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
  2. [root@oracle-19c ~]# setenforce 0
  3. setenforce: SELinux is disabled
  4. [root@oracle-19c ~]# getenforce
  5. Disabled
复制代码
2.3 配置yum源

  1. [root@oracle-19c yum.repos.d]# yum repolist -v
  2. 加载插件:builddep, changelog, config-manager, copr, debug, download, generate_completion_cache, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync
  3. YUM version: 4.2.23
  4. cachedir: /var/cache/dnf
复制代码
2.4 安装依靠包

  1. yum install -y bc  \
  2. binutils \
  3. elfutils-libelf \
  4. elfutils-libelf-devel \
  5. fontconfig-devel \
  6. glibc \
  7. glibc-devel \
  8. ksh \
  9. libaio \
  10. libaio-devel \
  11. libXrender \
  12. libX11 \
  13. libXau \
  14. libXi \
  15. libXtst \
  16. libgcc \
  17. libnsl \
  18. librdmacm \
  19. libstdc++ \
  20. libstdc++-devel \
  21. libxcb \
  22. libibverbs \
  23. make \
  24. policycoreutils \
  25. policycoreutils-python-utils \
  26. smartmontools \
  27. sysstat
复制代码
2.5 配置hosts

  1. [root@oracle-19c ~]# cat <<EOF>>/etc/hosts
  2. 192.168.12.110        oracle-19c
  3. EOF
复制代码
2.6 配置内核参数

  1. [root@oracle-19c yum.repos.d]# cat /etc/sysctl.conf
  2. # sysctl settings are defined through files in
  3. # /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
  4. #
  5. # Vendors settings live in /usr/lib/sysctl.d/.
  6. # To override a whole file, create a new file with the same in
  7. # /etc/sysctl.d/ and put new settings there. To override
  8. # only specific settings, add a file with a lexically later
  9. # name in /etc/sysctl.d/ and put new settings there.
  10. #
  11. # For more information, see sysctl.conf(5) and sysctl.d(5).
  12. kernel.sysrq=0
  13. net.ipv4.ip_forward=0
  14. net.ipv4.conf.all.send_redirects=0
  15. net.ipv4.conf.default.send_redirects=0
  16. net.ipv4.conf.all.accept_source_route=0
  17. net.ipv4.conf.default.accept_source_route=0
  18. net.ipv4.conf.all.accept_redirects=0
  19. net.ipv4.conf.default.accept_redirects=0
  20. net.ipv4.conf.all.secure_redirects=0
  21. net.ipv4.conf.default.secure_redirects=0
  22. net.ipv4.icmp_echo_ignore_broadcasts=1
  23. net.ipv4.icmp_ignore_bogus_error_responses=1
  24. net.ipv4.conf.all.rp_filter=1
  25. net.ipv4.conf.default.rp_filter=1
  26. net.ipv4.tcp_syncookies=1
  27. kernel.dmesg_restrict=1
  28. net.ipv6.conf.all.accept_redirects=0
  29. net.ipv6.conf.default.accept_redirects=0
  30. fs.aio-max-nr = 1048576
  31. fs.file-max = 6815744
  32. kernel.shmall = 7903699
  33. kernel.shmmax = 32373555199
  34. kernel.shmmni = 4096
  35. kernel.sem = 250 32000 100 128
  36. net.ipv4.ip_local_port_range = 9000 65500
  37. net.core.rmem_default = 262144
  38. net.core.rmem_max = 4194304
  39. net.core.wmem_default = 262144
  40. net.core.wmem_max = 1048576
  41. vm.min_free_kbytes=126459
  42. net.ipv4.conf.ens192.rp_filter = 1
  43. vm.swappiness = 10
  44. kernel.panic_on_oops = 1
  45. kernel.randomize_va_space = 2
  46. kernel.numa_balancing = 0
  47. --生效
  48. sysctl -p
复制代码
2.7 配置资源限定

  1. [root@oracle-19c ]# vi /etc/security/limits.conf
  2. oracle soft nofile 1024
  3. oracle hard nofile 65536
  4. oracle soft stack 10240
  5. oracle hard stack 32768
  6. oracle soft nproc 2047
  7. oracle hard nproc 16384
  8. oracle hard memlock unlimited
  9. oracle soft memlock unlimited
复制代码
2.8 创建用户和组

  1. ## 创建 oinstall dba oper 组
  2. /usr/sbin/groupadd -g 54321 oinstall
  3. /usr/sbin/groupadd -g 54322 dba
  4. /usr/sbin/groupadd -g 54323 oper
  5. /usr/sbin/groupadd -g 54324 backupdba
  6. /usr/sbin/groupadd -g 54325 dgdba
  7. /usr/sbin/groupadd -g 54326 kmdba
  8. /usr/sbin/groupadd -g 54330 racdba
  9. ## 创建 oracle 用户
  10. /usr/sbin/useradd -u 54321 -g oinstall -G asmdba,dba,backupdba,dgdba,kmdba,racdba,oper oracle
  11. ## 修改 oracle 用户密码为 oracle
  12. echo "oracle" |passwd oracle --stdin
  13. ## 检查 oracle 用户
  14. [root@oracle-19c ~]# id oracle
  15. 用户id=54321(oracle) 组id=54321(oinstall) 组=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)
复制代码
2.9 创建安装目次

  1. [root@oracle-19c ~]# mkdir -p /u01/app/oracle/product/19.3.0/db
  2. [root@oracle-19c ~]# mkdir -p /u01/app/oraInventory
  3. [root@oracle-19c ~]# mkdir -p /home/oracle/scripts
  4. [root@oracle-19c ~]# chown -R oracle:oinstall /u01/
  5. [root@oracle-19c ~]# chown -R oracle:oinstall /home/oracle/scripts
  6. [root@oracle-19c ~]# chmod -R 775 /u01/
  7. [root@oracle-19c ~]# chmod -R oracle:oinstall /arch
复制代码
2.10 配置环境变量

  1. [root@oracle-19c ~]#  cat >> ~oracle/.bash_profile <<EOF
  2. umask 022
  3. export TMP=/tmp
  4. export TMPDIR=$TMP
  5. export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
  6. export ORACLE_BASE=/u01/app/oracle
  7. export ORACLE_HOME=/u01/app/oracle/product/19.3.0/db
  8. export ORACLE_TERM=xterm
  9. export TNS_ADMIN=$ORACLE_HOME/network/admin
  10. export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
  11. export ORACLE_SID=orcl
  12. export PATH=/usr/sbin:$PATH
  13. export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/perl/bin:$PATH
  14. export PERL5LIB=$ORACLE_HOME/perl/lib
  15. alias sas='sqlplus / as sysdba'
  16. alias awr='sqlplus / as sysdba @?/rdbms/admin/awrrpt'
  17. alias ash='sqlplus / as sysdba @?/rdbms/admin/ashrpt'
  18. alias alert='vi $ORACLE_BASE/diag/rdbms/*/$ORACLE_SID/trace/alert_$ORACLE_SID.log'
  19. export PS1="[`whoami`@`hostname`:"'$PWD]$ '
  20. export CV_ASSUME_DISTID=OL7
  21. EOF
复制代码
三、安装oracle软件

3.1 上传安装介质

  1. [oracle@oracle-19c:/soft]$ ll
  2. -rw-r--r-- 1 oracle oinstall 2.9G Apr 20 14:13 LINUX.X64_193000_db_home.zip
  3. -rw-r--r-- 1 oracle oinstall 122M Apr 20 17:08 p35926646_190000_Linux-x86-64.zip
  4. -rw-r--r-- 1 oracle oinstall 1.7G Apr 20 17:08 p35943157_190000_Linux-x86-64.zip
  5. -rw-r--r-- 1 oracle oinstall     122M Apr 20 20:13 p6880880_190000_Linux-x86-64.zip
复制代码
3.2 静默安装数据库

  1. [oracle@oracle-19c:/u01/app/oracle/product/19.3.0/db]$ unzip /soft/LINUX.X64_193000_db_home.zip
  2. [oracle@oracle-19c:/u01/app/oracle/product/19.3.0/db]$ unzip /soft/p6880880_12.2.0.1.41-122010_LINUX.zip
  3. [oracle@oracle-19c:/u01/app/oracle/product/19.3.0/db]$ ./runInstaller -silent -force -responseFile /soft/db.rsp -ignorePrereq -waitForCompletionLaunching Oracle Database Setup Wizard...
  4. [WARNING] [INS-13014] Target environment does not meet some optional requirements.
  5.    CAUSE: Some of the optional prerequisites are not met. See logs for details. installActions2024-04-20_07-59-37PM.log
  6.    ACTION: Identify the list of failed prerequisite checks from the log: installActions2024-04-20_07-59-37PM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.
  7. The response file for this session can be found at:
  8. /u01/app/oracle/product/19.3.0/db/install/response/db_2024-05-27_07-59-37PM.rsp
  9. You can find the log of this install session at:
  10. /tmp/InstallActions2024-05-27_07-59-37PM/installActions2024-05-27_07-59-37PM.log
  11. As a root user, execute the following script(s):
  12.         1. /u01/app/oraInventory/orainstRoot.sh
  13.         2. /u01/app/oracle/product/19.3.0/db/root.sh
  14. Execute /u01/app/oraInventory/orainstRoot.sh on the following nodes:
  15. [oracle-19c]
  16. Execute /u01/app/oracle/product/19.3.0/db/root.sh on the following nodes:
  17. [oracle-19c]
  18. Successfully Setup Software with warning(s).
  19. Moved the install session logs to:
  20. /u01/app/oraInventory/logs/InstallActions2024-05-27_07-59-37PM
复制代码
3.3 安装数据库补丁

  1. [oracle@oracle-19c:/soft]$ unzip p35926646_190000_Linux-x86-64.zip
  2. [oracle@oracle-19c:/soft]$ unzip p35943157_190000_Linux-x86-64.zip
  3. [oracle@oracle-19c:/soft]$ cd 35943157/
  4. [oracle@oracle-19c:/soft/35943157]$ opatch apply
  5. Patch 35943157 successfully applied.
  6. Sub-set patch [29517242] has become inactive due to the application of a super-set patch [35943157].
  7. Please refer to Doc ID 2161861.1 for any possible further required actions.
  8. Log file location: /u01/app/oracle/product/19.3.0/db/cfgtoollogs/opatch/opatch2024-05-27_20-14-23PM_1.log
  9. OPatch succeeded.
  10. [oracle@oracle-19c:/soft]$ cd 35926646/
  11. [oracle@oracle-19c:/soft/35926646]$ opatch apply
  12. Oracle Interim Patch Installer version 12.2.0.1.41
  13. Copyright (c) 2024, Oracle Corporation.  All rights reserved.
  14. Oracle Home       : /u01/app/oracle/product/19.3.0/db
  15. Central Inventory : /u01/app/oraInventory
  16.    from           : /u01/app/oracle/product/19.3.0/db/oraInst.loc
  17. OPatch version    : 12.2.0.1.41
  18. OUI version       : 12.2.0.7.0
  19. Log file location : /u01/app/oracle/product/19.3.0/db/cfgtoollogs/opatch/opatch2024-05-27_20-22-03PM_1.log
  20. Verifying environment and performing prerequisite checks...
  21. OPatch continues with these patches:   35926646  
  22. Do you want to proceed? [y|n]
  23. y
  24. User Responded with: Y
  25. All checks passed.
  26. Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
  27. (Oracle Home = '/u01/app/oracle/product/19.3.0/db')
  28. Is the local system ready for patching? [y|n]
  29. y
  30. User Responded with: Y
  31. Backing up files...
  32. Applying interim patch '35926646' to OH '/u01/app/oracle/product/19.3.0/db'
  33. Patching component oracle.javavm.server, 19.0.0.0.0...
  34. Patching component oracle.javavm.server.core, 19.0.0.0.0...
  35. Patching component oracle.rdbms.dbscripts, 19.0.0.0.0...
  36. Patching component oracle.rdbms, 19.0.0.0.0...
  37. Patching component oracle.javavm.client, 19.0.0.0.0...
  38. Patch 35926646 successfully applied.
  39. Log file location: /u01/app/oracle/product/19.3.0/db/cfgtoollogs/opatch/opatch2024-05-27_20-22-03PM_1.log
  40. OPatch succeeded.
复制代码
3.4 配置监听

  1. [oracle@oracle-19c:/u01/app/oracle/product/19.3.0/db/network/admin]$ lsnrctl start
  2. LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 27-APR-2024 20:31:33
  3. Copyright (c) 1991, 2023, Oracle.  All rights reserved.
  4. Starting /u01/app/oracle/product/19.3.0/db/bin/tnslsnr: please wait...
  5. TNSLSNR for Linux: Version 19.0.0.0.0 - Production
  6. Log messages written to /u01/app/oracle/diag/tnslsnr/oracle-19c/listener/alert/log.xml
  7. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle-19c.itgfinance.com.cn)(PORT=1521)))
  8. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
  9. STATUS of the LISTENER
  10. ------------------------
  11. Alias                     LISTENER
  12. Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
  13. Start Date                27-APR-2024 20:31:33
  14. Uptime                    0 days 0 hr. 0 min. 15 sec
  15. Trace Level               off
  16. Security                  ON: Local OS Authentication
  17. SNMP                      OFF
  18. Listener Log File         /u01/app/oracle/diag/tnslsnr/oracle-19c/listener/alert/log.xml
  19. Listening Endpoints Summary...
  20.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle-19c.itgfinance.com.cn)(PORT=1521)))
  21. The listener supports no services
  22. The command completed successfully
  23. [oracle@oracle-19c:/u01/app/oracle/product/19.3.0/db/network/admin]$ lsnrctl status
  24. LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 20-APR-2024 20:31:54
  25. Copyright (c) 1991, 2023, Oracle.  All rights reserved.
  26. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
  27. STATUS of the LISTENER
  28. ------------------------
  29. Alias                     LISTENER
  30. Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
  31. Start Date                27-APR-2024 20:31:33
  32. Uptime                    0 days 0 hr. 0 min. 21 sec
  33. Trace Level               off
  34. Security                  ON: Local OS Authentication
  35. SNMP                      OFF
  36. Listener Log File         /u01/app/oracle/diag/tnslsnr/oracle-19c/listener/alert/log.xml
  37. Listening Endpoints Summary...
  38.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle-19c.itgfinance.com.cn)(PORT=1521)))
  39. The listener supports no services
  40. The command completed successfully
  41. [oracle@oracle-19c:/u01/app/oracle/product/19.3.0/db/network/admin]$
复制代码
3.5 创建数据库

  1. [oracle@oracle-19c:/soft]$
  2. dbca -silent -createDatabase \
  3. -templateName General_Purpose.dbc \
  4. -gdbname oracle -sid oracle -responseFile NO_VALUE \
  5. -characterSet ZHS16GBK \
  6. -sysPassword oracle \
  7. -systemPassword oracle \
  8. -createAsContainerDatabase false\
  9. -databaseType MULTIPURPOSE \
  10. -automaticMemoryManagement false \
  11. -totalMemory 24567 \
  12. -storageType FS \
  13. -datafileDestination "/data" \
  14. -redoLogFileSize 1024 \
  15. -emConfiguration NONE \
  16. -ignorePreReqs \
  17. -archiveLogDest "/arch" \
  18. -enableArchive true \
  19. -useOMF true  \
  20. -initParams processes=3000,undo_retention=86400,audit_trail=none
复制代码
四、配置oracle

4.1 设置开机启动

####配置oratab
  1. [oracle@oracle-19c:/arch/backup/rman]$ cat /etc/oratab
  2. oracle:/u01/app/oracle/product/19.3.0/db:Y
复制代码
####配置启停脚本
  1. [root@oracle-19c ~]# cat /usr/local/bin/startOracle.sh
  2. #!/bin/bash
  3. # Load Oracle environment variables
  4. . /home/oracle/.bash_profile
  5. # Start Oracle Database
  6. $ORACLE_HOME/bin/dbstart $ORACLE_HOME > /dev/null 2>&1 &
  7. $ORACLE_HOME/bin/lsnrctl start > /dev/null 2>&1 &
  8. [root@oracle-19c ~]# cat /usr/local/bin/stopOracle.sh
  9. #!/bin/bash
  10. # Load Oracle environment variables
  11. . /home/oracle/.bash_profile
  12. # Stop Oracle Database
  13. $ORACLE_HOME/bin/dbshut $ORACLE_HOME > /dev/null 2>&1 &
  14. $ORACLE_HOME/bin/lsnrctl stop > /dev/null 2>&1 &
复制代码
####配置systemd
  1. [root@oracle-19c ~]# su - oracle
  2. [oracle@oracle-19c~]$ cd $ORACLE_HOME/bin
  3. [oracle@oracle-19c bin]$ vi dbstart
  4. ORACLE_HOME_LISTNER=$1  
  5. 修改:   
  6. ORACLE_HOME_LISTNER=/u01/app/oracle/product/19.3.0/db
  7. [root@oracle-19c ~]# su - oracle
  8. [oracle@oracle-19c ~]$ cd $ORACLE_HOME/bin
  9. [oracle@oracle-19c bin]$ vi dbshut
  10. ORACLE_HOME_LISTNER=$1  
  11. -->
  12. ORACLE_HOME_LISTNER=/u01/app/oracle/product/19.3.0/db
  13. [root@oracle-19c ~]# cat /usr/lib/systemd/system/oracle.service
  14. [Unit]
  15. Description=Oracle Database 19c
  16. After=syslog.target network.target
  17. [Service]
  18. Type=forking
  19. User=oracle
  20. Group=oinstall
  21. ExecStart=/usr/local/bin/startOracle.sh
  22. ExecStop=/usr/local/bin/stopOracle.sh
  23. Environment=ORACLE_HOME=/u01/app/oracle/product/19.3.0/dbhome_1
  24. Environment=ORACLE_SID=ORACLE
  25. [Install]
  26. WantedBy=multi-user.target
  27. --重新加载systemd
  28. [root@oracle-19c ~]# systemctl daemon-reload
  29. --启动数据库
  30. [root@ oracle-19c~]# systemctl start oracle
  31. --停止数据库
  32. [root@oracle-19c ~]# systemctl stop oracle
  33. --允许自启动
  34. [root@oracle-19c ~]# systemctl enable oracle
  35. Created symlink from /etc/systemd/system/multi-user.target.wants/oracle.service to /usr/lib/systemd/system/oracle.service.
复制代码
4.2 配置备份

  1. Rman配置
  2. [oracle@oracle-19c:/arch/backup/rman]$ rman target /
  3. RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 7;
  4. RMAN> CONFIGURE CONTROLFILE AUTOBACKUP OFF;
  5. Rman全备脚本,当前配置保留7天全备
  6. [oracle@oracle-19c:/home/oracle/scripts]$ cat fulldbbackup.sh
  7. #!/bin/bash
  8. source ~/.bash_profile
  9. backtime=`date +"20%y%m%d%H%M%S"`
  10. rman target / log=/home/oracle/scripts/log/level0_backup_${backtime}.log<<EOF
  11. run {
  12. allocate channel c1 device type disk;
  13. allocate channel c2 device type disk;
  14. allocate channel c3 device type disk;
  15. allocate channel c4 device type disk;
  16. crosscheck backup;
  17. crosscheck archivelog all;
  18. sql"alter system archive log current";
  19. delete noprompt expired backup;
  20. delete noprompt obsolete device type disk;
  21. backup as compressed backupset incremental level 0 database include current controlfile format '/arch/backup/rman/backlv0_%d_%T_%t_%s_%p';
  22. BACKUP AS COMPRESSED BACKUPSET ARCHIVELOG ALL NOT BACKED UP FORMAT '/arch/backup/rman/arch_%d_%T_%t_%s_%p';
  23. backup as compressed backupset spfile format '/arch/backup/rman/spfile_%d_%T_%t_%s_%p';
  24. release channel c1;
  25. release channel c2;
  26. release channel c3;
  27. release channel c4;
  28. }
  29. EOF
复制代码


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4