1.修改linux透明大页(根据Oracle官方说法,此操作可以提升Oracle性能)

要检查是否已启用Transparent HugePage

  1. cat /sys/kernel/mm/redhat_transparent_hugepage/enabled
  2. cat /sys/kernel/mm/transparent_hugepage/enabled

以下是一个示例输出,显示正在使用透明HugePages,因为[always]标志已启用。

  1. [always] never

查看要禁用透明HugePages:

  1. 对于Oracle Linux 7和Red Hat Enterprise Linux 7,在文件中添加或修改transparent_hugepage = never参数/etc/default/grub
    1. transparent_hugepage=never
    例如:
    1. RUB_TIMEOUT=5
    2. GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
    3. GRUB_DEFAULT=saved
    4. GRUB_DISABLE_SUBMENU=true
    5. GRUB_TERMINAL_OUTPUT="console"
    6. GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet numa=off transparent_hugepage=never"
    7. GRUB_DISABLE_RECOVERY="true"
    注意:
    文件名可能因操作系统而异。检查操作系统文档以获取确切的文件名和禁用透明HugePages的步骤。
    运行该grub2–mkconfig命令以重新生成该grub.cfg文件。
    1. # grub2-mkconfig -o /boot/grub2/grub.cfg
    重新启动系统以使更改成为永久更改
    配置标准大页:
    kb为单位
    1. cat /proc/meminfo
    2. Hugepagesize: 2048 kB
    设置启动分配内存大小
    400为800M内存,通过400*上面2048得到 ``` vi /etc/sysctl.d/99-oracle-database-preinstall-19c-sysctl.conf 或者 /etc/sysctl.conf

vm.nr_hugepages = 400

  1. 重启系统生效
  2. 使用oracle推荐脚本计算内存大页大小<br />uname -r 确定操作系统内核,以4.14为例如下下列脚本中没有则'2.6'|'3.8'|'4.14'追加内核选项

4.14.35-2047.500.10.el7uek.x86_64

  1. ```
  2. #!/bin/bash
  3. #
  4. # hugepages_settings.sh
  5. #
  6. # Linux bash script to compute values for the
  7. # recommended HugePages/HugeTLB configuration
  8. #
  9. # Note: This script does calculation for all shared memory
  10. # segments available when the script is run, no matter it
  11. # is an Oracle RDBMS shared memory segment or not.
  12. # Check for the kernel version
  13. KERN=`uname -r | awk -F. '{ printf("%d.%d\n",$1,$2); }'`
  14. # Find out the HugePage size
  15. HPG_SZ=`grep Hugepagesize /proc/meminfo | awk {'print $2'}`
  16. # Start from 1 pages to be on the safe side and guarantee 1 free HugePage
  17. NUM_PG=1
  18. # Cumulative number of pages required to handle the running shared memory segments
  19. for SEG_BYTES in `ipcs -m | awk {'print $5'} | grep "[0-9][0-9]*"`
  20. do
  21. MIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc -q`
  22. if [ $MIN_PG -gt 0 ]; then
  23. NUM_PG=`echo "$NUM_PG+$MIN_PG+1" | bc -q`
  24. fi
  25. done
  26. # Finish with results
  27. case $KERN in
  28. '2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`;
  29. echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;;
  30. '2.6'|'3.8'|'4.14') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
  31. *) echo "Unrecognized kernel version $KERN. Exiting." ;;
  32. esac
  33. # End

2.安装 oracle yum 源 or oracle 预安装rpm

  1. wget http://public-yum.oracle.com/public-yum-ol7.repo -O /etc/yum.repos.d/public-yum-ol7.repo
  2. yum install oracle-database-preinstall-19c
  3. ol7 12cR2
  4. yum install https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackageSource/oracle-database-server-12cR2-preinstall-1.0-5.el7.src.rpm
  5. ol7 19c
  6. yum install https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackageSource/oracle-database-preinstall-19c-1.0-3.el7.src.rpm
  7. ol7 21c
  8. yum install https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackageSource/oracle-database-preinstall-21c-1.0-1.el7.src.rpm
  9. centos8 19c
  10. dnf install https://yum.oracle.com/repo/OracleLinux/OL8/appstream/x86_64/getPackage/oracle-database-preinstall-19c-1.0-2.el8.x86_64.rpm
  11. centos8 21c
  12. dnf install https://yum.oracle.com/repo/OracleLinux/OL8/appstream/x86_64/getPackage/oracle-database-preinstall-21c-1.0-1.el8.x86_64.rpm

3.设置hosts文件ip

  1. [oracle@instance-ej1hspdt ~]$ cat /etc/hosts
  2. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
  3. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  4. 172.16.0.4 instance-ej1hspdt instance-ej1hspdt.novalocal

4.设置防火墙和selinux

  1. [root@instance-ej1hspdt ~]# systemctl stop firewalld
  2. [root@instance-ej1hspdt ~]# cat /etc/selinux/config
  3. # This file controls the state of SELinux on the system.
  4. # SELINUX= can take one of these three values:
  5. # enforcing - SELinux security policy is enforced.
  6. # permissive - SELinux prints warnings instead of enforcing.
  7. # disabled - No SELinux policy is loaded.
  8. SELINUX=disabled
  9. # SELINUXTYPE= can take one of three two values:
  10. # targeted - Targeted processes are protected,
  11. # minimum - Modification of targeted policy. Only selected processes are p
  12. rotected.
  13. # mls - Multi Level Security protection.
  14. SELINUXTYPE=targeted

5.修改oracle账户密码,修改安装目录用户和所属组及权限

  1. chmod 777 /opt/oracle -R
  2. chown oracle:oinstall /opt/oracle -R

6.安装oracle 软件

  1. ./runInstaller

7.安装数据库

  1. /etc/init.d/oracledb_ORCLCDB-18c configure

8.设置环境变量

  1. su - oracle
  2. vi .bash_profile
  3. export ORACLE_BASE=/opt/oracle
  4. export ORACLE_HOME=/opt/oracle/product/18c/dbhome_1
  5. export NLS_DATE_FORMAT = "yyyy-mm-dd:hh24:mi:ss"
  6. PATH=$ORACLE_HOME/bin:$PATH;
  7. export ORACLE_SID=ORCLCDB

9.netmgr设置监听,或者手工设置相关文件

  1. 分别将tsname.ora listener.ora当中的计算机名改为ip地址。
  2. ------------------------------------------------------------------
  3. [oracle@instance-ej1hspdt ~]$ cat /opt/oracle/product/18c/dbhome_1/network/adm
  4. in/listener.ora
  5. # listener.ora Network Configuration File: /opt/oracle/product/18c/dbhome_1/ne
  6. twork/admin/listener.ora
  7. # Generated by Oracle configuration tools.
  8. LISTENER =
  9. (DESCRIPTION_LIST =
  10. (DESCRIPTION =
  11. (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.0.4)(PORT = 1521))
  12. (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
  13. )
  14. )

10.设置缺省账户过期时间

  1. 1.密码180天过期的问题
  2. alter profile default limit password_life_time unlimited;
  3. 2.登录10次密码错误账户锁定
  4. alter profile default limit failed_login_attempts unlimited;
  5. 3.取消段延迟特性
  6. SQL> alter system set deferred_segment_creation=false;
  7. 4.密码大小写
  8. sec_case_sensitive_logon
  9. 12c里面保持默认,不要设置为false,否则会提示密码错误
  10. SQL> show parameter sec_case
  11. NAME TYPE VALUE
  12. ------------------------------------ ----------- -----------------------------
  13. -
  14. sec_case_sensitive_logon boolean TRUE

11.设置rlwrap,下载epel-release yum ,安装rlwrap 设置环境变量

  1. http://download.fedoraproject.org/pub/epel
  2. yum install rlwrap
  3. su - oracle
  4. vi .bash_profile 追加
  5. alias sqlplus='rlwrap sqlplus'
  6. alias rman='rlwrap rman'