資料庫環境
- Database version:
- ORACLE_HOME: /u01/app/oracle/product/26/db
準備檔案
- 資料庫軟體: LINUX.X64_2326100_db_home.zip
- sha256sum : 5419f613af80477403edbd12f6ce038f3dba5da535b619d3928aee340f0d9ed6
- database-preinstall RPM: oracle-ai-database-preinstall-26ai-1.0-0.1.el8.x86_64.rpm
Download Page: https://www.oracle.com/database/technologies/oracle26ai-linux-downloads.html
環境準備
- OS: Oracle Linux Server release 8.10
- Oracle Linux 8.8 with the Unbreakable Enterprise Kernel 8:
- 5.15.0-313.189.5.1.el8uek.x86_64
- CPU: 8 vCore
- RAM: 16G
- SWAP: 16G
- Disk: 50 Gib Total
安裝步驟
Preinstallation
dnf install oracle-ai-database-preinstall-26ai
執行結果
Configuring HugePages on Linux
設定前
[root@db124-oracle-26ai ~]# grep Huge /proc/meminfo
AnonHugePages: 26624 kB
ShmemHugePages: 0 kB
FileHugePages: 2048 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 0 kB
設定公式如下
$HugePages_Total = \frac{SGA_SIZE}{Hugepagesize} + 少量緩衝$
$$\text{HugePages_Total} = \frac{\text{SGA_TARGET (MB)}}{2 \text{ MB}} + \text{Margin (少量緩衝)}$$
- /etc/sysctl.d/99-oracle-hugepages.conf
vm.nr_hugepages = 4096
sysctl -p /etc/sysctl.d/99-oracle-hugepages.conf
設定結果
[root@db124-oracle-26ai ~]# grep Huge /proc/meminfo
AnonHugePages: 26624 kB
ShmemHugePages: 0 kB
FileHugePages: 2048 kB
HugePages_Total: 4096
HugePages_Free: 4096
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 8388608 kB
Transparent HugePages madvise is Recommand
26ai 之後建議有更動,改為 madvise 在 19c 是 never
[root@db124-oracle-26ai ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
always [madvise] never
虛擬機檢查事項 - Clock Source = tsc (Time Stamp Counter)
Oracle 建議將時鐘源設定為 tsc (Time Stamp Counter),因為它的讀取延遲最低,能顯著減少系統呼叫的開銷。
設定前
[root@db124-oracle-26ai ~]# cat /sys/devices/system/clocksource/clocksource0/available_clocksource
kvm-clock tsc acpi_pm
設定後
[root@db124-oracle-26ai ~]# cat /sys/devices/system/clocksource/clocksource0/current_clocksource
tsc
操做紀錄如下
[root@db124-oracle-26ai ~]# cat /sys/devices/system/clocksource/clocksource0/available_clocksource
kvm-clock tsc acpi_pm
[root@db124-oracle-26ai ~]# echo "tsc" > /sys/devices/system/clocksource/clocksource0/current_clocksource
[root@db124-oracle-26ai ~]# cat /sys/devices/system/clocksource/clocksource0/current_clocksource
tsc
[root@db124-oracle-26ai ~]# vim /etc/default/grub
[root@db124-oracle-26ai ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
done
[root@db124-oracle-26ai ~]# cat /etc/default/grub
# ...[內容忽略]
GRUB_CMDLINE_LINUX="... transparent_hugepage=madvise clocksource=tsc"
# ...[內容忽略]
建立目錄
mkdir -p /u01/app/oracle
mkdir -p /u01/app/oraInventory
chown -R oracle:oinstall /u01/app/oracle
chown -R oracle:oinstall /u01/app/oraInventory
chmod -R 775 /u01/app
建立 $ORACLE_HOME
su - oracle
mkdir -p /u01/app/oracle/product/26/db
設定環境參數
- 設定文件:
/home/oracle/scripts/setEnv.sh
# Oracle Settings
export TMP=/tmp;
export TMPDIR=$TMP;
export ORACLE_BASE=/u01/app/oracle;
export ORACLE_UNQNAME=db124
export ORACLE_HOME=$ORACLE_BASE/product/26/db;
export ORACLE_HOSTNAME=db124-oracle-26ai;
export ORACLE_SID=db124;
export PATH=/usr/sbin:$PATH;
export PATH=$ORACLE_HOME/bin:$PATH;
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
echo ". /home/oracle/scripts/setEnv.sh" >> /home/oracle/.bash_profile
安裝資料庫軟體
su - oracle
mkdir -p ${ORACLE_HOME}
unzip -q /mnt/nfs/oracle-source/Oracle-AI-database-26ai/LINUX.X64_2326100_db_home.zip -d ${ORACLE_HOME}
[oracle@db124-oracle-26ai db]$ ./runInstaller -help
Usage: runInstaller [<flag>] [<command> <option>]
Following are the possible flags:
-help - display help.
-silent - run in silent mode. The inputs can be a response file or a list of command line variable value pairs.
[-ignorePrereqFailure - ignore all prerequisite checks failures.]
-responseFile < specify the complete path of the response file to use >
-executePrereqs | -executeConfigTools | -createGoldImage
-executeConfigTools - run the config tools for an installed home if applicable.
[-skipStackCheck - skip the stack status check.]
-debug - run in debug mode.
-applyOneOffs < value > - specify one or more paths of one-off patches to apply to the Oracle home.
-nApplyOneOffs < specify a path to a location that contains multiple one-off patches to apply to the Oracle home >
-executeRootScript - specify this flag to run the root script automatically if applicable.
-configMethod < ROOT | SUDO > - specify the configuration method to be used for automatic root script execution.
[-sudoPath < specify the absolute path of the sudo program >]
[-sudoUserName < specify the name of the user who is in the sudoers list >]
Following are the possible commands:
-setupDBHome - install the Oracle Database software home (Oracle home).
-setupDBHomeAs < sourceHome > - install the software with Oracle base and privileged O/S groups similar to the specified Oracle home.
-createDatabase - install the Oracle Database software (Oracle home) and create a new Single Instance Database.
-extendDBHome - extend the Oracle Database software home.
-createGoldImage - create a gold image from the current Oracle home.
-deployDBGoldImage - deploy the given Oracle Database gold image into the specified target home as the root OS user.
-deployDBGoldImageAsHomeUser - deploy the given Oracle Database gold image into the specified target home as the home owner OS user.
設定 db_install.rsp
設定文件: install/response/db_install_INSTALL_DB_SWONLY.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v23.0.0
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/u01/app/oracle/product/26/db
ORACLE_BASE=/u01/app/oracle
installEdition=EE
OSDBA=dba
OSOPER=oper
OSBACKUPDBA=dba
OSDGDBA=dba
OSKMDBA=dba
OSRACDBA=dba
cd ${ORACLE_HOME}
./runInstaller -silent -responseFile ${ORACLE_HOME}/install/response/db_install_INSTALL_DB_SWONLY.rsp
su - root
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/26/db/root.sh
安裝紀錄如檔案內容
建立資料庫 instance(CDB,PDB)
- $ORACLE_HOME/assistants/dbca/dbca_pdb.rsp
responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v23.0.0
gdbName=db
sid=db124
templateName=General_Purpose.dbc
sysPassword=P0ssw0rd..
systemPassword=P0ssw0rd..
characterSet=AL32UTF8
createAsContainerDatabase=true
pdbName=pollodb
numberOfPDBs=1
pdbAdminPassword=P0ssw0rd..
dbca -silent -createDatabase -responseFile $ORACLE_HOME/assistants/dbca/dbca_pdb.rsp
安裝紀錄
[oracle@db124-oracle-26ai ~]$ dbca -silent -createDatabase -responseFile $ORACLE_HOME/assistants/dbca/dbca_pdb.rsp
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
39% complete
42% 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/db.
Database Information:
Global Database Name:db
System Identifier(SID):db124
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/db/db3.log" for further details.
[oracle@db124-oracle-26ai ~]$
安裝完成後作業
- 設定註冊文件:
/etc/oratab
db124:/u01/app/oracle/product/26/db:Y
設定資料庫 開機時啟動
- /home/oracle/scripts/start-all.sh
#!/bin/bash
. /home/oracle/scripts/setEnv.sh
export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES
dbstart $ORACLE_HOME
- /home/oracle/scripts/stop-all.sh
#!/bin/bash
. /home/oracle/scripts/setEnv.sh
export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES
dbshut $ORACLE_HOME
chmod 0755 /home/oracle/scripts/*.sh
- /etc/systemd/system/oracle.service
[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
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'
# Set resource limits
LimitNOFILE=65536
LimitNPROC=65536
LimitSTACK=infinity
[Install]
WantedBy=multi-user.target
systemctl start oracle
設定 PDB 開機時啟動
alter session set container=CDB$ROOT;
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 POLLODB MOUNTED
ALTER PLUGGABLE DATABASE POLLODB OPEN READ WRITE;
alter pluggable database POLLODB SAVE STATE;
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 POLLODB READ WRITE NO
啟用 Archive Mode
sqlplus / as sysdba
alter session set container=CDB$ROOT;
shutdown immediate;
STARTUP MOUNT;
alter database archivelog;
ARCHIVE LOG LIST;
alter database open;
新增使用者
檢查當前狀態
SELECT INSTANCE_NAME, STATUS FROM v$instance;
SELECT tablespace_name, file_name FROM dba_data_files;
-- 多租戶環境需要檢查
-- SELECT SYS_CONTEXT('USERENV', 'CON_NAME') AS CONTAINER_NAME FROM DUAL;
alter session set container=POLLODB;
CREATE USER pollo IDENTIFIED BY "P@ssw0rd.." ACCOUNT UNLOCK;
GRANT CONNECT,RESOURCE TO pollo;
ALTER USER pollo QUOTA UNLIMITED ON USERS;
GRANT CREATE TABLE, CREATE VIEW, CREATE PROCEDURE, CREATE SEQUENCE TO pollo;
PolloChang 工作筆記