1 安装

root用户下

wget https://yum.oracle.com/repo/OracleLinux/OL8/developer/x86_64/getPackage/oracle-database-preinstall-23c-1.0-1.el8.x86_64.rpm
wget https://download.oracle.com/otn-pub/otn_software/db-free/oracle-database-free-23c-1.0-1.el8.x86_64.rpm

dnf -y localinstall oracle-database-preinstall-23c-1.0-1.el8.x86_64.rpm
dnf -y localinstall oracle-database-free-23c-1.0-1.el8.x86_64.rpm

2 配置建库

交互式安装

/etc/init.d/oracle-free-23c configure

结果需要记录下,库名、端口都在这里

Connect to Oracle Database using one of the connect strings:
     Pluggable database: VM-130-23-tencentos:1539/FREEPDB1
     Multitenant container database: VM-130-23-tencentos:1539

如果使用slient安装需要改配置文件/etc/sysconfig/oracle-free–23c.confd

然后再执行/etc/init.d/oracle-free-23c configure

3 环境变量

切到oracle用户下或root用户下配置

export ORACLE_SID=FREE 
export ORAENV_ASK=NO 
. /opt/oracle/product/23c/dbhomeFree/bin/oraenv

4 启停

-- oracle用户 连sys
sqlplus / as sysdba

-- root用户 连sys
sqlplus sys@VM-130-23-tencentos:1539/FREEPDB1 as sysdba

-- 其他用户执行
sqlplus system@VM-130-23-tencentos:1539/FREEPDB1

-- 停 需要连sys
SHUTDOWN IMMEDIATE

-- 启 需要连sys
STARTUP
ALTER PLUGGABLE DATABASE ALL OPEN;

oracle服务进程的/proc/xxxx/fd

0 -> /dev/null
1 -> /dev/null
16 -> 'socket:[1403776518]'
2 -> /dev/null
256 -> /opt/oracle/oradata/FREE/FREEPDB1/undotbs01.dbf
257 -> /opt/oracle/oradata/FREE/FREEPDB1/system01.dbf
3 -> /dev/null
4 -> /opt/oracle/product/23c/dbhomeFree/rdbms/mesg/oraus.msb
5 -> /proc/553076/fd
6 -> 'anon_inode:[eventpoll]'
7 -> /proc/553076/schedstat

创建存储过程

CREATE OR REPLACE PROCEDURE PC123 AS
i simple_integer := 0;
v_number simple_integer := 0;
BEGIN
LOOP
v_number := i + 1000;
i := i + 1;
exit when i > 1000000000;
END LOOP;
END;
/
pread64(7, "13536596324 333903 152\n", 80, 0) = 23
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=523637}, ru_stime={tv_sec=0, tv_usec=12997}, ...}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=523797}, ru_stime={tv_sec=0, tv_usec=12997}, ...}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=524096}, ru_stime={tv_sec=0, tv_usec=12997}, ...}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=526023}, ru_stime={tv_sec=0, tv_usec=12997}, ...}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=526218}, ru_stime={tv_sec=0, tv_usec=12997}, ...}) = 0
pread64(7, "13539241765 333903 164\n", 80, 0) = 23
openat(AT_FDCWD, "/opt/oracle/oradata/FREE/FREEPDB1/system01.dbf", O_RDWR|O_DSYNC) = 8
fcntl(8, F_SETFD, FD_CLOEXEC)           = 0
prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=64*1024, rlim_max=64*1024}) = 0
fcntl(8, F_DUPFD, 256)                  = 257
fcntl(257, F_SETFD, FD_CLOEXEC)         = 0
close(8)                                = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=526423}, ru_stime={tv_sec=0, tv_usec=12997}, ...}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=526423}, ru_stime={tv_sec=0, tv_usec=13345}, ...}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=526423}, ru_stime={tv_sec=0, tv_usec=13418}, ...}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=526423}, ru_stime={tv_sec=0, tv_usec=13501}, ...}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=526423}, ru_stime={tv_sec=0, tv_usec=13592}, ...}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=527005}, ru_stime={tv_sec=0, tv_usec=13996}, ...}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=527076}, ru_stime={tv_sec=0, tv_usec=13996}, ...}) = 0
semop(27, [{sem_num=26, sem_op=1, sem_flg=0}], 1) = 0
pread64(7, "13541568039 333903 194\n", 80, 0) = 23
semtimedop(27, [{sem_num=55, sem_op=-1, sem_flg=0}], 1, {tv_sec=0, tv_nsec=100000000}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=527678}, ru_stime={tv_sec=0, tv_usec=13996}, ...}) = 0
pread64(7, "13541702360 333903 201\n", 80, 0) = 23
write(16, "\0\0\0\306\6\0\0\0 \0\10\6\0\212\344 \0\0\0\0\0\4\0\0\0\0\0\0\0\0\0\0"..., 198) = 198

alter session set plsql_code_type = native;

pread64(7, "13541846178 333903 208\n", 80, 0) = 23
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=527889}, ru_stime={tv_sec=0, tv_usec=13996}, ...}) = 0
write(16, "\0\0\0\306\6\0\0\0 \0\10\6\0\267\344 \0\0\0\0\0\2\0\0\0\0\0\0\0\0\0\0"..., 198) = 198

native编译alter procedure test_speed_14 compile;

pread64(7, "13542161098 333903 217\n", 80, 0) = 23
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=527889}, ru_stime={tv_sec=0, tv_usec=14427}, ...}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=528341}, ru_stime={tv_sec=0, tv_usec=14995}, ...}) = 0
statfs("/dev/shm/", {f_type=TMPFS_MAGIC, f_bsize=4096, f_blocks=8197749, f_bfree=8192566, f_bavail=8192566, f_files=8197749, f_ffree=8197708, f_fsid={val=[0, 0]}, f_namelen=255, f_frsize=4096, f_flags=ST_VALID|ST_NOSUID|ST_NODEV}) = 0
futex(0x7fe8268ea3b0, FUTEX_WAKE_PRIVATE, 2147483647) = 0
openat(AT_FDCWD, "/dev/shm/PESLD_FREE_148021_1081aa9100000000", O_RDWR|O_CREAT|O_TRUNC|O_NOFOLLOW|O_CLOEXEC, 0700) = 8
ftruncate(8, 712)                       = 0
write(8, "\10", 1)                      = 1
mmap(NULL, 712, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED, 8, 0) = 0x7fe828ecc000
close(8)                                = 0
munmap(0x7fe828ecc000, 712)             = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=530444}, ru_stime={tv_sec=0, tv_usec=15995}, ...}) = 0
pread64(7, "13546923666 333903 241\n", 80, 0) = 23
mmap(0x7fe8228bb000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fe8228bb000
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=531359}, ru_stime={tv_sec=0, tv_usec=15996}, ...}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=531479}, ru_stime={tv_sec=0, tv_usec=15997}, ...}) = 0
mmap(0x7fe8228cb000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fe8228cb000
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=531479}, ru_stime={tv_sec=0, tv_usec=16958}, ...}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=531540}, ru_stime={tv_sec=0, tv_usec=16996}, ...}) = 0
pread64(7, "13549514915 333903 255\n", 80, 0) = 23
mmap(0x7fe8228db000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fe8228db000
mmap(0x7fe8228eb000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fe8228eb000
openat(AT_FDCWD, "/dev/shm/PESLD_FREE_148021_1081aa9100000000", O_RDONLY|O_NOFOLLOW|O_CLOEXEC) = 8
mmap(NULL, 712, PROT_READ|PROT_EXEC, MAP_PRIVATE, 8, 0) = 0x7fe828ecc000
close(8)                                = 0
mmap(0x7fe8226fb000, 131072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fe8226fb000
mmap(0x7fe82271b000, 196608, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fe82271b000
mmap(0x7fe82274b000, 196608, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fe82274b000
munmap(0x7fe828ecc000, 712)             = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=533166}, ru_stime={tv_sec=0, tv_usec=16996}, ...}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=534144}, ru_stime={tv_sec=0, tv_usec=16996}, ...}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=535124}, ru_stime={tv_sec=0, tv_usec=16996}, ...}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=535247}, ru_stime={tv_sec=0, tv_usec=16996}, ...}) = 0
semop(27, [{sem_num=26, sem_op=1, sem_flg=0}], 1) = 0
pread64(7, "13552441594 333903 285\n", 80, 0) = 23
semtimedop(27, [{sem_num=55, sem_op=-1, sem_flg=0}], 1, {tv_sec=0, tv_nsec=100000000}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=535518}, ru_stime={tv_sec=0, tv_usec=16996}, ...}) = 0
pread64(7, "13552538646 333903 292\n", 80, 0) = 23
write(16, "\0\0\0\306\6\0\0\0 \0\10\6\0\341\344 \0\0\0\0\0\5\0\0\0\0\0\0\0\0\0\0"..., 198) = 198

运行exec PC123;

pread64(7, "13552679150 333903 299\n", 80, 0) = 23
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=535717}, ru_stime={tv_sec=0, tv_usec=16996}, ...}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=13, tv_usec=536940}, ru_stime={tv_sec=0, tv_usec=16996}, ...}) = 0
openat(AT_FDCWD, "/dev/shm/PESLD_FREE_148021_1081aa9100000000", O_RDONLY|O_NOFOLLOW|O_CLOEXEC) = 8
mmap(NULL, 712, PROT_READ|PROT_EXEC, MAP_PRIVATE, 8, 0) = 0x7fe828ecc000
close(8)                                = 0
pread64(7, "13628475958 342660 312\n", 80, 0) = 23
pread64(7, "13729415638 342660 314\n", 80, 0) = 23
pread64(7, "13830271711 342660 316\n", 80, 0) = 23
pread64(7, "13931201975 342660 318\n", 80, 0) = 23
pread64(7, "14032064432 342660 320\n", 80, 0) = 23
pread64(7, "14132997050 348150 323\n", 80, 0) = 23
pread64(7, "14233856420 360664 326\n", 80, 0) = 23
pread64(7, "14334756366 360664 328\n", 80, 0) = 23
pread64(7, "14435619012 360664 330\n", 80, 0) = 23
pread64(7, "14536513829 360664 332\n", 80, 0) = 23
pread64(7, "14637402884 360664 334\n", 80, 0) = 23
pread64(7, "14738330462 360664 336\n", 80, 0) = 23
pread64(7, "14839235880 360664 338\n", 80, 0) = 23
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=14, tv_usec=870068}, ru_stime={tv_sec=0, tv_usec=17996}, ...}) = 0
getrusage(RUSAGE_THREAD, {ru_utime={tv_sec=14, tv_usec=898632}, ru_stime={tv_sec=0, tv_usec=17997}, ...}) = 0
pread64(7, "14916731193 360664 344\n", 80, 0) = 23
mmap(0x7fe82273b000, 262144, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0x231000) = 0x7fe82273b000
write(16, "\0\0\0\306\6\0\0\0 \0\10\6\0\260\350 \0\0\0\0\0\2\0\0\0\0\0\0\0\0\0\0"..., 198) = 198
04-03 13:52