由 SuKai November 18, 2024
- 安装依赖包
- 创建用户
- 配置系统资源限制
- 配置环境变量
- 配置应答文件
- 静默安装
- 配置系统自动启动
- 配置内存参数
安装依赖包
[centos@ls-nhyc04 ~]$ sudo yum install -y automake autotools-dev binutils bzip2 elfutils expat \
gawk gcc gcc-multilib g++-multilib lib32ncurses5 lib32z1 \
ksh less lib32z1 libaio1 libaio-dev libc6-dev libc6-dev-i386 \
libc6-i386 libelf-dev libltdl-dev libodbcinstq4-1 libodbcinstq4-1:i386 \
libpth-dev libpthread-stubs0-dev libstdc++5 make openssh-server rlwrap \
rpm sysstat unixodbc unixodbc-dev unzip x11-utils zlibc unzip cifs-utils \
libXext.x86_64 glibc.i686
创建用户
[centos@ls-nhyc04 ~]$ sudo groupadd -g 502 oinstall
[centos@ls-nhyc04 ~]$ sudo groupadd -g 503 dba
[centos@ls-nhyc04 ~]$ sudo groupadd -g 504 oper
[centos@ls-nhyc04 ~]$ sudo groupadd -g 505 asmadmin
[centos@ls-nhyc04 ~]$ sudo useradd -u 502 -g oinstall -G oinstall,dba,asmadmin,oper -s /bin/bash -m oracle
[centos@ls-nhyc04 ~]$ sudo passwd oracle
配置系统资源限制
[centos@ls-nhyc04 ~]$ sudo vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
配置环境变量
[centos@ls-nhyc04 ~]$ vim .bash_profile
export ORACLE_BASE=/data/tools/oracle11g
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export ORACLE_UNQNAME=orcl
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export PATH=${PATH}:${ORACLE_HOME}/bin/:$ORACLE_HOME/lib64
配置应答文件
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_AND_CONFIG
ORACLE_HOSTNAME=ls-nhyc07
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data/tools/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/data/tools/oracle11g/product/11.2.0/dbhome_1
ORACLE_BASE=/data/tools/oracle11g
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=false
oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oper
oracle.install.db.CLUSTER_NODES=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=orcl
oracle.install.db.config.starterdb.SID=orcl
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=4096
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=mypassword
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.dbcontrol.emailAddress=ycsk02@hotmail.com
oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/data/tools/oracle11g/oradata
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/data/tools/oracle11g/fast_recovery_area
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
静默安装
[oracle@ls-nhyc04 ~]$ ./runInstaller -silent -ignoreSysPrereqs -responseFile /home/oracle/db_install.rsp
INFO: Number of root scripts to be executed = 2
The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run
/data/tools/oraInventory/orainstRoot.sh
/data/tools/oracle11g/product/11.2.0/dbhome_1/root.sh
To execute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts
4. Return to this window and hit "Enter" key to continue
INFO: Shutting down OUISetupDriver.JobExecutorThread
INFO: Cleaning up, please wait...
INFO: Dispose the install area control object
INFO: Update the state machine to STATE_CLEAN
Successfully Setup Software.
INFO: All forked task are completed at state setup
INFO: Completed background operations
INFO: Moved to state <setup>
INFO: Waiting for completion of background operations
INFO: Completed background operations
INFO: Validating state <setup>
WARNING: Validation disabled for the state setup
INFO: Completed validating state <setup>
INFO: Verifying route success
INFO: Waiting for completion of background operations
INFO: Completed background operations
INFO: Executing action at state finish
INFO: FinishAction Actions.execute called
INFO: Completed executing action at state <finish>
INFO: Waiting for completion of background operations
INFO: Completed background operations
INFO: Moved to state <finish>
INFO: Waiting for completion of background operations
INFO: Completed background operations
INFO: Validating state <finish>
WARNING: Validation disabled for the state finish
INFO: Completed validating state <finish>
INFO: Terminating all background operations
INFO: Terminated all background operations
INFO: Successfully executed the flow in SILENT mode
INFO: Finding the most appropriate exit status for the current application
INFO: Exit Status is -3
INFO: Shutdown Oracle Database 11g Release 2 Installer
INFO: Unloading Setup Driver
[centos@ls-nhyc04 ~]$ sudo /data/tools/oraInventory/orainstRoot.sh
[centos@ls-nhyc04 ~]$ sudo /data/tools/oracle11g/product/11.2.0/dbhome_1/root.sh
[oracle@ls-nhyc04 ~]$ /data/tools/oracle11g/product/11.2.0/dbhome_1/bin/lsnrctl start
[oracle@ls-nhyc04 ~]$ /data/tools/oracle11g/product/11.2.0/dbhome_1/bin/dbstart
配置系统自动启动
[oracle@ls-nhyc04 ~]$ vi /etc/oratab
orcl:/data/tools/oracle11g/product/11.2.0/dbhome_1:Y
[oracle@ls-nhyc04 ~]$ vi /data/tools/oracle11g/product/11.2.0/dbhome_1/bin/dbstart
ORACLE_HOME_LISTNER=$ORACLE_HOME
[oracle@ls-nhyc04 ~]$ vi /data/tools/oracle11g/product/11.2.0/dbhome_1/bin/dbshut
ORACLE_HOME_LISTNER=$ORACLE_HOME
[oracle@ls-nhyc04 ~]$ cat /etc/systemd/system/oracle.service
[Unit]
Description=Oracle Database Startup Service
After=syslog.target network.target
[Service]
LimitMEMLOCK=infinity
LimitNOFILE=65535
Type=oneshot
RemainAfterExit=yes
User=oracle
#Environment="ORACLE_HOME=/data/tools/oracle11g/product/11.2.0/dbhome_1"
ExecStart=/data/tools/oracle11g/product/11.2.0/dbhome_1/bin/dbstart >> /dev/null 2>&1 &
ExecStop=/data/tools/oracle11g/product/11.2.0/dbhome_1/bin/dbshut >> /dev/null 2>&1 &
[Install]
WantedBy=multi-user.target
配置内存参数
[centos@ls-nhyc04 ~]$ sudo df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 32G 0 32G 0% /dev
tmpfs tmpfs 32G 18G 14G 58% /dev/shm
tmpfs tmpfs 32G 17M 32G 1% /run
tmpfs tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/sda1 xfs 93G 28G 65G 30% /
/dev/sdc ext4 484G 5.6G 454G 2% /data
tmpfs tmpfs 6.3G 0 6.3G 0% /run/user/502
tmpfs tmpfs 6.3G 0 6.3G 0% /run/user/0
[centos@ls-nhyc04 ~]$
[oracle@ls-nhyc04 ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Mon Nov 18 06:50:31 2024
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected.
SQL> show parameter memory_target;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
memory_target big integer 30G
SQL> show parameter memory_max_target;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
memory_max_target big integer 30G
SQL> show parameter sga_target;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
sga_target big integer 0
SQL> alter system set memory_tartget=30G scope=spfile;
SQL> alter system set memory_max_target=30G scope=spfile;
报错ora-00845 memory_target not supported时,配置/dev/shm大于memory_target,再启动数据库修改memory_target小于/dev/shm
sudo mount -o remount,size=52G /dev/shm
配置Swap分区
[centos@ls-nhyc04 ~]$ sudo sudo dd if=/dev/zero of=/swapfile bs=1G count=16
[centos@ls-nhyc04 ~]$ sudo sudo chmod 600 /swapfile
[centos@ls-nhyc04 ~]$ sudo sudo mkswap /swapfile
[centos@ls-nhyc04 ~]$ sudo sudo swapon /swapfile
[centos@ls-nhyc04 ~]$ sudo vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Jun 4 09:10:31 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=60d67439-baf0-4c8b-94a3-3f10a362e8fe / xfs defaults 0 0
/swapfile swap swap defaults 0 0
UUID=d7c00f38-3103-4570-8453-67b432426e91 /data ext4 defaults 0 0