[20260621]centos 9安装oracle 21c遇到的关于stat的问题.txt
[20260621]centos 9安装oracle 21c遇到的关于stat的问题.txt
--//放假一直在尝试centos 9上安装oracle 21c遇到一大堆问题,最终还是安装完成.重点介绍遇到关于stat的问题.
--//首先centos 9 不在oracle 21c安装列表里面,要定义环境变量export CV_ASSUME_DISTID=RHEL7.6
--//centos 9 存在libnsl,libnsl2 2个rpm包,选择libnsl,没有选择测试libnsl2.而centos 7 libnsl在glibc rpm包中.
--// /usr/lib64/libpthread_nonshared.a 在centos 9没有,下载链接:
--//https://repo.almalinux.org/almalinux/9.8/devel/x86_64/os/Packages/compat-libpthread-nonshared-2.34-270.el9_8.x86_64.rpm
--//libpthread_nonshared.a 是 glibc 的内部实现细节,在新版本中已不再使用。这个兼容包提供的是一个空的静态库文件,仅用于
--//让某些旧版应用程序(如 Oracle 数据库)的链接过程能够成功通过。
--//实际上自己写一个也可以仅仅8个字节.
# cat /usr/lib64/libpthread_nonshared.a
!<arch>
--// compat-openssl10 .centos 9没有,有compat-openssl11的版本,我选择下载旧版本.
--// https://vault.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/compat-openssl10-1.0.2o-4.el8.x86_64.rpm
--//遇到的关于stat的问题,在编译orion时遇到如下问题:
INFO:
- Linking ORacle IO Numbers benchmark (orion)
INFO:
rm -f /u01/app/oracle/product/21.0.0/dbhome_1/rdbms/lib/orion
INFO:
/u01/app/oracle/product/21.0.0/dbhome_1/bin/orald -o /u01/app/oracle/product/21.0.0/dbhome_1/rdbms/lib/orion -m64 -z noexecstack -Wl,--disable-new-dtags -L/u01/app/oracle/product/21.0.0/dbhome_1/rdbms/lib/ -L/u01/app/oracle/product/21.0.0/dbhome_1/lib/ -L/u01/app/oracle/product/21.0.0/dbhome_1/lib/stubs/ /u01/app/oracle/product/21.0.0/dbhome_1/rdbms/lib/orion.o -lorion -lclntsh -lclntshcore -lhasgen -lnnzst -lzt -lxml -lgeneric -locr -locrb -locrutl -lhasgen -lnnzst -lzt -lxml -lgeneric -lasmclnt -lg
INFO:
eneric -lcore -lnnz21 -lnfsodm -lcell -lskgxp -lnls -laio -lcommon `cat /u01/app/oracle/product/21.0.0/dbhome_1/lib/sysliblist` -Wl,-rpath,/u01/app/oracle/product/21.0.0/dbhome_1/lib -lm `cat /u01/app/oracle/product/21.0.0/dbhome_1/lib/sysliblist` -ldl -lm -L/u01/app/oracle/product/21.0.0/dbhome_1/lib
INFO:
/usr/bin/ld: /u01/app/oracle/product/21.0.0/dbhome_1/lib//libnnzst.a(ccme_ck_rand_load_fileS1.o): in function `r_ck_random_load_file':
ck_rand_load_file.c:(.text+0xd4): undefined reference to `stat'
INFO:
make: *** [/u01/app/oracle/product/21.0.0/dbhome_1/rdbms/lib/ins_rdbms.mk:945: /u01/app/oracle/product/21.0.0/dbhome_1/rdbms/lib/orion] Error 1
$ nm -D /lib64/libc.so.6| grep xstat
0000000000110250 T __fxstat@@GLIBC_2.2.5
0000000000110250 T __fxstat64@@GLIBC_2.2.5
0000000000110310 T __fxstatat@@GLIBC_2.4
0000000000110310 T __fxstatat64@@GLIBC_2.4
00000000001102b0 T __lxstat@@GLIBC_2.2.5
00000000001102b0 T __lxstat64@@GLIBC_2.2.5
00000000001101f0 T __xstat@@GLIBC_2.2.5
00000000001101f0 T __xstat64@@GLIBC_2.2.5
--//如果在centos 7.3下执行:
$ nm -D /lib64/libc.so.6| grep xstat
00000000000e85b0 T __fxstat
00000000000e85b0 T __fxstat64
00000000000e8710 T __fxstatat
00000000000e8710 T __fxstatat64
00000000000e8600 T __lxstat
00000000000e8600 T __lxstat64
00000000000e8560 T __xstat
00000000000e8560 T __xstat64
--//这个问题是因为代码使用了 glibc 的内部非公开 API(__xstat, __lxstat, __fxstat 和 _STAT_VER),而这些在较新的 glibc 版本
--//中已被移除或不再暴露。
--//问题根源
--//在较新的 glibc(2.33+)中:
--//__xstat 等内部函数被移除了
--//_STAT_VER 宏不再定义
--//stat() 等函数现在直接是系统调用包装,不再通过 __xstat 分发.
--//使用如下方法欺骗编译器编译通过.
--//建立如下文件:
# cat /tmp/stat_fix.c
#define _GNU_SOURCE
#include <sys/stat.h>
#include <sys/types.h>
#define STAT_VER 3
extern int __xstat(int ver,const char *pathname,struct stat *statbuf);
extern int __lxstat(int ver,const char *pathname,struct stat *statbuf);
extern int __fxstat(int ver,int fd,struct stat *statbuf);
int stat(const char *pathname,struct stat *statbuf){
return __xstat(STAT_VER,pathname,statbuf);
}
int lstat(const char *pathname,struct stat *statbuf){
return __lxstat(STAT_VER,pathname,statbuf);
}
int fstat(int fd ,struct stat *statbuf){
return __fxstat(STAT_VER,fd,statbuf);
}
--//注: kimi给的执行脚本使用宏 _STAT_VER,实际上根本不存在.我直接定义一个宏#define STAT_VER 3.
--//STAT_VER 3来源centos 7.3查询如下:
# cd /usr/include
# grep -R -i stat_ver *
bits/stat.h:# define _STAT_VER_LINUX_OLD 1
bits/stat.h:# define _STAT_VER_KERNEL 1
bits/stat.h:# define _STAT_VER_SVR4 2
bits/stat.h:# define _STAT_VER_LINUX 3
bits/stat.h:# define _STAT_VER_KERNEL 0
bits/stat.h:# define _STAT_VER_LINUX 1
bits/stat.h:#define _STAT_VER _STAT_VER_LINUX
# gcc -shared -fPIC -O2 -o /tmp/stat_fix.so /tmp/stat_fix.c
--//修改/u01/app/oracle/product/21.0.0/dbhome_1/rdbms/lib/ins_rdbms.mk文件,加入如下内容:
$ grep -B4 stat_fix. /u01/app/oracle/product/21.0.0/dbhome_1/rdbms/lib/ins_rdbms.mk
$(ORACLE): $(ALWAYS) $(ORACLE_DEPS) $(INS_CONFIG) $(RDBMS_COLLECT)
$(SILENT)$(ECHO)
$(SILENT)$(ECHO) " - Linking Oracle "
$(RMF) $@
$(ORACLE_LINKLINE) /tmp/stat_fix.so
--
$(ORION) : $(ALWAYS) $(ORION_DEPS)
$(SILENT)$(ECHO)
$(SILENT)$(ECHO) " - Linking ORacle IO Numbers benchmark (orion)"
$(RMF) $@
$(ORION_LINKLINE) /tmp/stat_fix.so
$ cat /home/oracle/scripts/oins.sh
export CV_ASSUME_DISTID=RHEL7.6
#export LD_PRELOAD=/tmp/stat_fix.so
cd $ORACLE_HOME
# Silent mode.
./runInstaller -ignorePrereq -waitforcompletion -silent \
-responseFile ${ORACLE_HOME}/install/response/db_install.rsp \
oracle.install.option=INSTALL_DB_SWONLY \
ORACLE_HOSTNAME=${ORACLE_HOSTNAME} \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=${ORA_INVENTORY} \
SELECTED_LANGUAGES=en,en_GB \
ORACLE_HOME=${ORACLE_HOME} \
ORACLE_BASE=${ORACLE_BASE} \
oracle.install.db.InstallEdition=EE \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSBACKUPDBA_GROUP=dba \
oracle.install.db.OSDGDBA_GROUP=dba \
oracle.install.db.OSKMDBA_GROUP=dba \
oracle.install.db.OSRACDBA_GROUP=dba \
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \
DECLINE_SECURITY_UPDATES=true
--//执行如下:
$ source /home/oracle/scripts/oins.sh
Launching Oracle Database Setup Wizard...
[WARNING] [INS-13001] Oracle Database is not supported on this operating system. Installer will not perform prerequisite checks on the system.
CAUSE: This operating system may not have been in the certified list at the time of the release of this software.
ACTION: Refer to My Oracle Support portal for the latest certification information for this operating system. Proceed with the installation if the operating system has been certified after the release of this software.
The response file for this session can be found at:
/u01/app/oracle/product/21.0.0/dbhome_1/install/response/db_2026-06-21_12-31-56PM.rsp
You can find the log of this install session at:
/tmp/InstallActions2026-06-21_12-31-56PM/installActions2026-06-21_12-31-56PM.log
As a root user, execute the following script(s):
1. /u01/app/oraInventory/orainstRoot.sh
2. /u01/app/oracle/product/21.0.0/dbhome_1/root.sh
Execute /u01/app/oraInventory/orainstRoot.sh on the following nodes:
[centos9]
Execute /u01/app/oracle/product/21.0.0/dbhome_1/root.sh on the following nodes:
[centos9]
Successfully Setup Software.
Moved the install session logs to:
/u01/app/oraInventory/logs/InstallActions2026-06-21_12-31-56PM
--//终于安装成功!!
--//以root用户运行 /u01/app/oraInventory/orainstRoot.sh,/u01/app/oracle/product/21.0.0/dbhome_1/root.sh安装成功。
# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
# /u01/app/oracle/product/21.0.0/dbhome_1/root.sh
Check /u01/app/oracle/product/21.0.0/dbhome_1/install/root_centtest_2024-08-08_17-55-03-025930887.log for the output of root script
--//个人还是不推荐这类安装方式,还是尽可能选择对应oracle支持的对应linux os版本。
--//放假一直在尝试centos 9上安装oracle 21c遇到一大堆问题,最终还是安装完成.重点介绍遇到关于stat的问题.
--//首先centos 9 不在oracle 21c安装列表里面,要定义环境变量export CV_ASSUME_DISTID=RHEL7.6
--//centos 9 存在libnsl,libnsl2 2个rpm包,选择libnsl,没有选择测试libnsl2.而centos 7 libnsl在glibc rpm包中.
--// /usr/lib64/libpthread_nonshared.a 在centos 9没有,下载链接:
--//https://repo.almalinux.org/almalinux/9.8/devel/x86_64/os/Packages/compat-libpthread-nonshared-2.34-270.el9_8.x86_64.rpm
--//libpthread_nonshared.a 是 glibc 的内部实现细节,在新版本中已不再使用。这个兼容包提供的是一个空的静态库文件,仅用于
--//让某些旧版应用程序(如 Oracle 数据库)的链接过程能够成功通过。
--//实际上自己写一个也可以仅仅8个字节.
# cat /usr/lib64/libpthread_nonshared.a
!<arch>
--// compat-openssl10 .centos 9没有,有compat-openssl11的版本,我选择下载旧版本.
--// https://vault.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/compat-openssl10-1.0.2o-4.el8.x86_64.rpm
--//遇到的关于stat的问题,在编译orion时遇到如下问题:
INFO:
- Linking ORacle IO Numbers benchmark (orion)
INFO:
rm -f /u01/app/oracle/product/21.0.0/dbhome_1/rdbms/lib/orion
INFO:
/u01/app/oracle/product/21.0.0/dbhome_1/bin/orald -o /u01/app/oracle/product/21.0.0/dbhome_1/rdbms/lib/orion -m64 -z noexecstack -Wl,--disable-new-dtags -L/u01/app/oracle/product/21.0.0/dbhome_1/rdbms/lib/ -L/u01/app/oracle/product/21.0.0/dbhome_1/lib/ -L/u01/app/oracle/product/21.0.0/dbhome_1/lib/stubs/ /u01/app/oracle/product/21.0.0/dbhome_1/rdbms/lib/orion.o -lorion -lclntsh -lclntshcore -lhasgen -lnnzst -lzt -lxml -lgeneric -locr -locrb -locrutl -lhasgen -lnnzst -lzt -lxml -lgeneric -lasmclnt -lg
INFO:
eneric -lcore -lnnz21 -lnfsodm -lcell -lskgxp -lnls -laio -lcommon `cat /u01/app/oracle/product/21.0.0/dbhome_1/lib/sysliblist` -Wl,-rpath,/u01/app/oracle/product/21.0.0/dbhome_1/lib -lm `cat /u01/app/oracle/product/21.0.0/dbhome_1/lib/sysliblist` -ldl -lm -L/u01/app/oracle/product/21.0.0/dbhome_1/lib
INFO:
/usr/bin/ld: /u01/app/oracle/product/21.0.0/dbhome_1/lib//libnnzst.a(ccme_ck_rand_load_fileS1.o): in function `r_ck_random_load_file':
ck_rand_load_file.c:(.text+0xd4): undefined reference to `stat'
INFO:
make: *** [/u01/app/oracle/product/21.0.0/dbhome_1/rdbms/lib/ins_rdbms.mk:945: /u01/app/oracle/product/21.0.0/dbhome_1/rdbms/lib/orion] Error 1
$ nm -D /lib64/libc.so.6| grep xstat
0000000000110250 T __fxstat@@GLIBC_2.2.5
0000000000110250 T __fxstat64@@GLIBC_2.2.5
0000000000110310 T __fxstatat@@GLIBC_2.4
0000000000110310 T __fxstatat64@@GLIBC_2.4
00000000001102b0 T __lxstat@@GLIBC_2.2.5
00000000001102b0 T __lxstat64@@GLIBC_2.2.5
00000000001101f0 T __xstat@@GLIBC_2.2.5
00000000001101f0 T __xstat64@@GLIBC_2.2.5
--//如果在centos 7.3下执行:
$ nm -D /lib64/libc.so.6| grep xstat
00000000000e85b0 T __fxstat
00000000000e85b0 T __fxstat64
00000000000e8710 T __fxstatat
00000000000e8710 T __fxstatat64
00000000000e8600 T __lxstat
00000000000e8600 T __lxstat64
00000000000e8560 T __xstat
00000000000e8560 T __xstat64
--//这个问题是因为代码使用了 glibc 的内部非公开 API(__xstat, __lxstat, __fxstat 和 _STAT_VER),而这些在较新的 glibc 版本
--//中已被移除或不再暴露。
--//问题根源
--//在较新的 glibc(2.33+)中:
--//__xstat 等内部函数被移除了
--//_STAT_VER 宏不再定义
--//stat() 等函数现在直接是系统调用包装,不再通过 __xstat 分发.
--//使用如下方法欺骗编译器编译通过.
--//建立如下文件:
# cat /tmp/stat_fix.c
#define _GNU_SOURCE
#include <sys/stat.h>
#include <sys/types.h>
#define STAT_VER 3
extern int __xstat(int ver,const char *pathname,struct stat *statbuf);
extern int __lxstat(int ver,const char *pathname,struct stat *statbuf);
extern int __fxstat(int ver,int fd,struct stat *statbuf);
int stat(const char *pathname,struct stat *statbuf){
return __xstat(STAT_VER,pathname,statbuf);
}
int lstat(const char *pathname,struct stat *statbuf){
return __lxstat(STAT_VER,pathname,statbuf);
}
int fstat(int fd ,struct stat *statbuf){
return __fxstat(STAT_VER,fd,statbuf);
}
--//注: kimi给的执行脚本使用宏 _STAT_VER,实际上根本不存在.我直接定义一个宏#define STAT_VER 3.
--//STAT_VER 3来源centos 7.3查询如下:
# cd /usr/include
# grep -R -i stat_ver *
bits/stat.h:# define _STAT_VER_LINUX_OLD 1
bits/stat.h:# define _STAT_VER_KERNEL 1
bits/stat.h:# define _STAT_VER_SVR4 2
bits/stat.h:# define _STAT_VER_LINUX 3
bits/stat.h:# define _STAT_VER_KERNEL 0
bits/stat.h:# define _STAT_VER_LINUX 1
bits/stat.h:#define _STAT_VER _STAT_VER_LINUX
# gcc -shared -fPIC -O2 -o /tmp/stat_fix.so /tmp/stat_fix.c
--//修改/u01/app/oracle/product/21.0.0/dbhome_1/rdbms/lib/ins_rdbms.mk文件,加入如下内容:
$ grep -B4 stat_fix. /u01/app/oracle/product/21.0.0/dbhome_1/rdbms/lib/ins_rdbms.mk
$(ORACLE): $(ALWAYS) $(ORACLE_DEPS) $(INS_CONFIG) $(RDBMS_COLLECT)
$(SILENT)$(ECHO)
$(SILENT)$(ECHO) " - Linking Oracle "
$(RMF) $@
$(ORACLE_LINKLINE) /tmp/stat_fix.so
--
$(ORION) : $(ALWAYS) $(ORION_DEPS)
$(SILENT)$(ECHO)
$(SILENT)$(ECHO) " - Linking ORacle IO Numbers benchmark (orion)"
$(RMF) $@
$(ORION_LINKLINE) /tmp/stat_fix.so
$ cat /home/oracle/scripts/oins.sh
export CV_ASSUME_DISTID=RHEL7.6
#export LD_PRELOAD=/tmp/stat_fix.so
cd $ORACLE_HOME
# Silent mode.
./runInstaller -ignorePrereq -waitforcompletion -silent \
-responseFile ${ORACLE_HOME}/install/response/db_install.rsp \
oracle.install.option=INSTALL_DB_SWONLY \
ORACLE_HOSTNAME=${ORACLE_HOSTNAME} \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=${ORA_INVENTORY} \
SELECTED_LANGUAGES=en,en_GB \
ORACLE_HOME=${ORACLE_HOME} \
ORACLE_BASE=${ORACLE_BASE} \
oracle.install.db.InstallEdition=EE \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSBACKUPDBA_GROUP=dba \
oracle.install.db.OSDGDBA_GROUP=dba \
oracle.install.db.OSKMDBA_GROUP=dba \
oracle.install.db.OSRACDBA_GROUP=dba \
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \
DECLINE_SECURITY_UPDATES=true
--//执行如下:
$ source /home/oracle/scripts/oins.sh
Launching Oracle Database Setup Wizard...
[WARNING] [INS-13001] Oracle Database is not supported on this operating system. Installer will not perform prerequisite checks on the system.
CAUSE: This operating system may not have been in the certified list at the time of the release of this software.
ACTION: Refer to My Oracle Support portal for the latest certification information for this operating system. Proceed with the installation if the operating system has been certified after the release of this software.
The response file for this session can be found at:
/u01/app/oracle/product/21.0.0/dbhome_1/install/response/db_2026-06-21_12-31-56PM.rsp
You can find the log of this install session at:
/tmp/InstallActions2026-06-21_12-31-56PM/installActions2026-06-21_12-31-56PM.log
As a root user, execute the following script(s):
1. /u01/app/oraInventory/orainstRoot.sh
2. /u01/app/oracle/product/21.0.0/dbhome_1/root.sh
Execute /u01/app/oraInventory/orainstRoot.sh on the following nodes:
[centos9]
Execute /u01/app/oracle/product/21.0.0/dbhome_1/root.sh on the following nodes:
[centos9]
Successfully Setup Software.
Moved the install session logs to:
/u01/app/oraInventory/logs/InstallActions2026-06-21_12-31-56PM
--//终于安装成功!!
--//以root用户运行 /u01/app/oraInventory/orainstRoot.sh,/u01/app/oracle/product/21.0.0/dbhome_1/root.sh安装成功。
# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
# /u01/app/oracle/product/21.0.0/dbhome_1/root.sh
Check /u01/app/oracle/product/21.0.0/dbhome_1/install/root_centtest_2024-08-08_17-55-03-025930887.log for the output of root script
--//个人还是不推荐这类安装方式,还是尽可能选择对应oracle支持的对应linux os版本。
浙公网安备 33010602011771号