环境配置
1docker rm -f ub22oracle11g
2docker run -itd --name ub22oracle11g -h ub22oracle11g \
3 -p 33392:3389 \
4 -v /sys/fs/cgroup:/sys/fs/cgroup \
5 --privileged=true lhrbest/lhrubuntu2204:3.0 \
6 /bin/bash
7
8docker exec -it ub22oracle11g bash
9
10
11cat >> /etc/apt/sources.list << EOF
12deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
13deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
14deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
15deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
16deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
17deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
18deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
19deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
20deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
21deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
22deb http://mirrors.aliyuncs.com/ubuntu/ jammy main restricted universe multiverse
23deb http://mirrors.aliyuncs.com/ubuntu/ jammy-security main restricted universe multiverse
24deb http://mirrors.aliyuncs.com/ubuntu/ jammy-updates main restricted universe multiverse
25deb http://mirrors.aliyuncs.com/ubuntu/ jammy-proposed main restricted universe multiverse
26deb http://mirrors.aliyuncs.com/ubuntu/ jammy-backports main restricted universe multiverse
27deb-src http://mirrors.aliyuncs.com/ubuntu/ jammy main restricted universe multiverse
28deb-src http://mirrors.aliyuncs.com/ubuntu/ jammy-security main restricted universe multiverse
29deb-src http://mirrors.aliyuncs.com/ubuntu/ jammy-updates main restricted universe multiverse
30deb-src http://mirrors.aliyuncs.com/ubuntu/ jammy-proposed main restricted universe multiverse
31deb-src http://mirrors.aliyuncs.com/ubuntu/ jammy-backports main restricted universe multiverse
32deb http://dk.archive.ubuntu.com/ubuntu/ xenial main
33deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe
34EOF
35
36
37
38
39apt-get update
40
41
42cat > /tmp/b.sh <<"EOF"
43sudo apt-get install bzip2
44sudo apt-get install elfutils
45sudo apt-get install automake
46sudo apt-get install autotools-dev
47sudo apt-get install binutils
48sudo apt-get install expat
49sudo apt-get install gawk
50sudo apt-get install gcc
51sudo apt-get install gcc-multilib
52sudo apt-get install g++-multilib
53sudo apt-get install ia32-libs
54sudo apt-get install ksh
55sudo apt-get install less
56sudo apt-get install lesstif2
57sudo apt-get install lesstif2-dev
58sudo apt-get install lib32z1
59sudo apt-get install libaio1
60sudo apt-get install libaio-dev
61sudo apt-get install libc6-dev
62sudo apt-get install libc6-dev-i386
63sudo apt-get install libc6-i386
64sudo apt-get install libelf-dev
65sudo apt-get install libltdl-dev
66sudo apt-get install libmotif4
67sudo apt-get install libodbcinstq4-1 libodbcinstq4-1:i386
68sudo apt-get install libpth-dev
69sudo apt-get install libpthread-stubs0
70sudo apt-get install libpthread-stubs0-dev
71sudo apt-get install libstdc++5
72sudo apt-get install lsb-cxx
73sudo apt-get install make
74sudo apt-get install openssh-server
75sudo apt-get install pdksh
76sudo apt-get install rlwrap
77sudo apt-get install rpm
78sudo apt-get install sysstat
79sudo apt-get install unixodbc
80sudo apt-get install unixodbc-dev
81sudo apt-get install unzip
82sudo apt-get install x11-utils
83sudo apt-get install zlibc
84EOF
85
86
87/tmp/b.sh
88
89
90
91
92
93-- 注意 /etc/apt/sources.list 最后2行,可以安装gcc-4.8
94
95sudo apt-get update
96sudo apt-get -y install gcc-4.8 g++-4.8 cpp-4.8
97
98
99
100
101#gcc、g++降级
102ll /usr/bin/gcc*
103ll /usr/bin/g++*
104ll /usr/bin/cpp*
105
106
107sudo mv /usr/bin/gcc /usr/bin/gcc-7
108sudo mv /usr/bin/g++ /usr/bin/g++-7
109sudo mv /usr/bin/cpp /usr/bin/cpp-7
110sudo ln -sf /usr/bin/g++-4.8 /usr/bin/g++
111sudo ln -sf /usr/bin/gcc-4.8 /usr/bin/gcc
112sudo ln -sf /usr/bin/cpp-4.8 /usr/bin/cpp
113sudo chmod 755 /usr/bin/g++
114sudo chmod 755 /usr/bin/gcc
115sudo chmod 755 /usr/bin/cpp
116
117gcc -v
118g++ -v
119cpp -v
120dpkg -l | grep libstdc
121
122
123
124
125
126-- Oracle默认不支持ubuntu需要欺骗一下Oracle安装程序,执行以下命令:
127sudo mkdir -p /usr/lib64
128sudo ln -sf /etc /etc/rc.d
129sudo ln -sf /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib64/
130sudo ln -sf /usr/bin/awk /bin/awk
131sudo ln -sf /usr/bin/basename /bin/basename
132sudo ln -sf /usr/bin/rpm /bin/rpm
133sudo ln -sf /usr/lib/x86_64-linux-gnu/libc_nonshared.a /usr/lib64/
134sudo ln -sf /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a /usr/lib64/
135sudo ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /lib64/
136sudo ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib64/复制
环境配置
1groupadd -g 502 oinstall
2groupadd -g 503 dba
3groupadd -g 504 oper
4groupadd -g 505 asmadmin
5useradd -u 502 -g oinstall -G dba,asmadmin,oper -s /bin/bash -m oracle
6echo "oracle:lhr" | chpasswd
7
8
9mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1
10chown -R oracle:oinstall /u01
11chmod -R 775 /u01
12
13cat > /etc/oraInst.loc <<"EOF"
14inventory_loc=/u01/app/oraInventory
15inst_group=oinstall
16EOF
17
18chown oracle:oinstall /etc/oraInst.loc
19chmod 664 /etc/oraInst.loc
20
21source /etc/oralnst.loc
22
23
24
25
26
27echo "oracle ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
28
29
30
31cat >> /home/oracle/.bash_profile <<"EOF"
32
33export TMP=/tmp
34export TMPDIR=$TMP
35export ORACLE_SID=lhrdb
36export ORACLE_BASE=/u01/app/oracle
37export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
38export PATH=/usr/sbin:$PATH
39export PATH=$ORACLE_HOME/bin:$PATH
40export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
41export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
42
43export NLS_DATE_FORMAT='YYYY-MM-DD HH24:mi:ss'
44
45alias sqlplus='rlwrap sqlplus'
46alias rman='rlwrap rman'
47alias sas='sqlplus / as sysdba'
48
49EOF
50
51
52
53
54 echo 'fs.file-max = 6815744
55kernel.sem = 250 32000 100 128
56kernel.shmmni = 4096
57kernel.shmall = 1073741824
58kernel.shmmax = 4398046511104
59kernel.panic_on_oops = 1
60net.core.rmem_default = 262144
61net.core.rmem_max = 4194304
62net.core.wmem_default = 262144
63net.core.wmem_max = 1048576
64net.ipv4.conf.all.rp_filter = 2
65net.ipv4.conf.default.rp_filter = 2
66fs.aio-max-nr = 1048576
67net.ipv4.ip_local_port_range = 9000 65500
68 ' >> /etc/sysctl.conf && sysctl -p
69
70 echo 'oracle soft nofile 1024
71oracle hard nofile 65536
72oracle soft nproc 16384
73oracle hard nproc 16384
74oracle soft stack 10240
75oracle hard stack 32768
76 ' >> /etc/security/limits.conf
77
78 echo 'session required /lib64/security/pam_limits.so
79session required pam_limits.so
80 ' >> /etc/pam.d/login
81
82 echo 'if [ $USER = "oracle" ]; then
83 if [ $SHELL = "/bin/ksh" ]; then
84 ulimit -p 16384
85 ulimit -n 65536
86 else
87 ulimit -u 16384 -n 65536
88 fi
89 fi
90 ' >> /etc/profile复制
静默安装和建库
1echo xfce4-session > /home/oracle/.xsession
2chmod +x /home/oracle/.xsession
3service xrdp restart
4
5
6
7unzip p13390677_112040_Linux-x86-64_1of7.zip && unzip p13390677_112040_Linux-x86-64_2of7.zip
8
9
10su - oracle
11
12/soft/database/runInstaller -silent -force -noconfig -IgnoreSysPreReqs -ignorePrereq \
13oracle.install.option=INSTALL_DB_SWONLY \
14DECLINE_SECURITY_UPDATES=true \
15UNIX_GROUP_NAME=oinstall \
16INVENTORY_LOCATION=/u01/app/oraInventory \
17SELECTED_LANGUAGES=en \
18ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 \
19ORACLE_BASE=/u01/app/oracle \
20oracle.install.db.InstallEdition=EE \
21oracle.install.db.isCustomInstall=false \
22oracle.install.db.DBA_GROUP=dba \
23oracle.install.db.OPER_GROUP=dba \
24oracle.install.db.isRACOneInstall=false \
25oracle.install.db.config.starterdb.type=GENERAL_PURPOSE \
26SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \
27oracle.installer.autoupdates.option=SKIP_UPDATES
28
29-- 日志:/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log
30
31-- root用户执行
32/u01/app/oraInventory/orainstRoot.sh
33/u01/app/oracle/product/11.2.0/dbhome_1/root.sh
34
35
36
37-- 解决错误
38ll $ORACLE_HOME/rdbms/lib/config.o
39ll $ORACLE_HOME/bin/oracle
40mv $ORACLE_HOME/rdbms/lib/config.o $ORACLE_HOME/rdbms/lib/config.o.bad
41-- 此时执行sqlplus / as sysdba会报错:ORA-12547: TNS:lost contact
42-- 解决
43sed -i 's/^\(\s*\$(MK_EMAGENT_NMECTL)\)\s*$/\1 -lnnz11/g' $ORACLE_HOME/sysman/lib/ins_emagent.mk
44sed -i "s/KFOD_LINKLINE=\$(LINK) \$(S0MAIN)/& -Wl,--no-as-needed/g" $ORACLE_HOME/rdbms/lib/env_rdbms.mk
45sed -i "s/AMDU_LINKLINE=\$(LINK) \$(S0MAIN)/& -Wl,--no-as-needed/g" $ORACLE_HOME/rdbms/lib/env_rdbms.mk
46sed -i "s/\$LD \$LD_RUNTIME \$LD_OPT/& -Wl,--no-as-needed/g" $ORACLE_HOME/bin/genorasdksh
47sed -i "s/KFNDG_LINKLINE=\$(LINK) \$(S0MAIN)/& -Wl,--no-as-needed/g" $ORACLE_HOME/rdbms/lib/env_rdbms.mk
48sed -i 's/^\(\$LD \$LD_RUNTIME\) \(\$LD_OPT\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/bin/genorasdksh
49sed -i 's/^\(\s*\)\(\$(OCRLIBS_DEFAULT)\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/srvm/lib/ins_srvm.mk
50sed -i 's/^\(TNSLSNR_LINKLINE.*\$(TNSLSNR_OFILES)\) \(\$(LINKTTLIBS)\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/network/lib/env_network.mk
51sed -i 's/^\(ORACLE_LINKLINE.*\$(ORACLE_LINKER)\) \(\$(PL_FLAGS)\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/rdbms/lib/env_rdbms.mk
52
53
54-- 重新编译,编译完成后sqlplus正常
55cd $ORACLE_HOME/rdbms/lib
56relink all
57
58
59
60-- 调试安装
61./runInstaller -debug -logLevel finest
62strace ./runInstaller
63
64
65
66
67
68
69-- 静默建库
70-- dbca -silent -deleteDatabase -sourceDB lhrdb
71
72dbca -silent -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE \
73-gdbname lhrdb -sid lhrdb \
74-sysPassword lhr -systemPassword lhr \
75-datafileDestination '/u01/app/oracle/oradata' \
76-recoveryAreaDestination '/u01/app/oracle/flash_recovery_area' \
77-redoLogFileSize 50 \
78-storageType FS \
79-characterset AL32UTF8 -nationalCharacterSet AL16UTF16 \
80-sampleSchema true \
81-totalMemory 512 \
82-databaseType OLTP \
83-emConfiguration NONE
84
85日志:/u01/app/oracle/cfgtoollogs/dbca/silent.log_2023-03-16_08-52-06-AM
86报错:ORA-29516: Aurora assertion failure: Assertion failure at joez.c:3422,可以忽略
87在76%时卡住,其实数据库已经创建完了!!!可以直接执行如下的SQL:
88-- 创建spfile
89create spfile from memory;
90startup force
91
92-- 其它修改
93lsnrctl start复制
报错处理
报错1:
1root@lhrubuntu2004:/# more /u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log | grep -i error | grep -v INFO
2collect2: error: ld returned 1 exit status
3Exception String: Error in invoking target 'client_sharedlib' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
4Exception String: Error in invoking target 'links proc gen_pcscfg' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/precomp/lib/ins_precomp.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
5Error in invoking target 'links proc gen_pcscfg' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/precomp/lib/ins_precomp.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
6collect2: error: ld returned 1 exit status
7Exception String: Error in invoking target 'idg4odbc' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
8Error in invoking target 'idg4odbc' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
9Exception String: Error in invoking target 'itnsping' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/network/lib/ins_net_client.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
10Error in invoking target 'itnsping' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/network/lib/ins_net_client.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
11Exception String: Error in invoking target 'install' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/ctx/lib/ins_ctx.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
12Error in invoking target 'install' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/ctx/lib/ins_ctx.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
13Exception String: Error in invoking target 'install' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/plsql/lib/ins_plsql.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
14Error in invoking target 'install' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/plsql/lib/ins_plsql.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
15collect2: error: ld returned 1 exit status
16Exception String: Error in invoking target 'agent nmhs' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
17Error in invoking target 'agent nmhs' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
18collect2: error: ld returned 1 exit status
19Exception String: Error in invoking target 'all_no_orcl' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
20Error in invoking target 'all_no_orcl' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
21collect2: error: ld returned 1 exit status
22Exception String: Error in invoking target 'install' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/network/lib/ins_net_client.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
23Error in invoking target 'install' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/network/lib/ins_net_client.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
24collect2: error: ld returned 1 exit status
25Exception String: Error in invoking target 'install' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/sqlplus/lib/ins_sqlplus.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
26Error in invoking target 'install' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/sqlplus/lib/ins_sqlplus.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
27collect2: error: ld returned 1 exit status
28Exception String: Error in invoking target 'clientonlyinstall' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/ldap/lib/ins_ldap.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
29Error in invoking target 'clientonlyinstall' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/ldap/lib/ins_ldap.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
30Exception String: Error in invoking target 'ioklist' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/network/lib/ins_nau.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
31Error in invoking target 'ioklist' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/network/lib/ins_nau.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
32Exception String: Error in invoking target 'install' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/srvm/lib/ins_srvm.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
33Error in invoking target 'install' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/srvm/lib/ins_srvm.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
34Exception String: Error in invoking target 'utilities' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
35Error in invoking target 'utilities' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
36collect2: error: ld returned 1 exit status
37Exception String: Error in invoking target 'iokdstry iokinit' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/network/lib/ins_nau.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
38Error in invoking target 'iokdstry iokinit' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/network/lib/ins_nau.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
39collect2: error: ld returned 1 exit status
40Exception String: Error in invoking target 'install' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/network/lib/ins_net_server.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
41Error in invoking target 'install' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/network/lib/ins_net_server.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
42Exception String: Error in invoking target 'itrcroute' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/network/lib/ins_net_client.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
43Error in invoking target 'itrcroute' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/network/lib/ins_net_client.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
44collect2: error: ld returned 1 exit status
45Exception String: Error in invoking target 'irman ioracle' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
46Error in invoking target 'irman ioracle' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk'. See '/u01/app/oraInventory/logs/installActions2023-03-15_01-13-46PM.log' for details.
47root@lhrubuntu2004:/#
48复制
解决:
1sed -i 's/^\(\s*\$(MK_EMAGENT_NMECTL)\)\s*$/\1 -lnnz11/g' $ORACLE_HOME/sysman/lib/ins_emagent.mk
2sudo sed -i "s/KFOD_LINKLINE=\$(LINK) \$(S0MAIN)/& -Wl,--no-as-needed/g" $ORACLE_HOME/rdbms/lib/env_rdbms.mk
3sudo sed -i "s/AMDU_LINKLINE=\$(LINK) \$(S0MAIN)/& -Wl,--no-as-needed/g" $ORACLE_HOME/rdbms/lib/env_rdbms.mk
4sudo sed -i "s/\$LD \$LD_RUNTIME \$LD_OPT/& -Wl,--no-as-needed/g" $ORACLE_HOME/bin/genorasdksh
5sudo sed -i "s/KFNDG_LINKLINE=\$(LINK) \$(S0MAIN)/& -Wl,--no-as-needed/g" $ORACLE_HOME/rdbms/lib/env_rdbms.mk
6sed -i 's/^\(\$LD \$LD_RUNTIME\) \(\$LD_OPT\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/bin/genorasdksh
7sed -i 's/^\(\s*\)\(\$(OCRLIBS_DEFAULT)\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/srvm/lib/ins_srvm.mk
8sed -i 's/^\(TNSLSNR_LINKLINE.*\$(TNSLSNR_OFILES)\) \(\$(LINKTTLIBS)\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/network/lib/env_network.mk
9sed -i 's/^\(ORACLE_LINKLINE.*\$(ORACLE_LINKER)\) \(\$(PL_FLAGS)\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/rdbms/lib/env_rdbms.mk
10
11
12#'agent nmhs',修改ins_emagent.mk 176行,在$(MK_EMAGENT_NMECTL)后添加 -lnnz11
13
14sudo sed -i 's/^\s∗$(MKEMAGENTNMECTL)\s∗$(MKEMAGENTNMECTL)\s*$/\1 -lnnz11/g' $ORACLE_HOME/sysman/lib/ins_emagent.mk
15
16# 'all_no_orcl'的kfod问题,修改env_rdbms.mk的KFOD_LINKLINE变量(2913行),添加 -Wl,--no-as-needed
17
18sudo sed -i "s/KFOD_LINKLINE=\$(LINK) \$(S0MAIN)/& -Wl,--no-as-needed/g" $ORACLE_HOME/rdbms/lib/env_rdbms.mk
19
20# 'all_no_orcl'的amdu问题,修改env_rdbms.mk的AMDU_LINKLINE变量(2922行),添加 -Wl,--no-as-needed
21
22sudo sed -i "s/AMDU_LINKLINE=\$(LINK) \$(S0MAIN)/& -Wl,--no-as-needed/g" $ORACLE_HOME/rdbms/lib/env_rdbms.mk
23
24# 'all_no_orcl'的genorasdksh问题,修改genorasdksh (289行),添加 -Wl,--no-as-needed
25
26sudo sed -i "s/\$LD \$LD_RUNTIME \$LD_OPT/& -Wl,--no-as-needed/g" $ORACLE_HOME/bin/genorasdksh
27
28# 'all_no_orcl'的renamedg问题,修改env_rdbms.mk的KFNDG_LINKLINE变量(2918行),添加 -Wl,--no-as-needed
29
30sudo sed -i "s/KFNDG_LINKLINE=\$(LINK) \$(S0MAIN)/& -Wl,--no-as-needed/g" $ORACLE_HOME/rdbms/lib/env_rdbms.mk
31
32# 'install'的ins_srvm.mk问题,修改env_srvm.mk的GETCRSHOME_LINKLINE变量(1899行),添加 -Wl,--no-as-needed
33
34sudo sed -i "s/GETCRSHOME_LINKLINE=\$(LINK)/& -Wl,--no-as-needed/g" $ORACLE_HOME/srvm/lib/env_srvm.mk
35
36# 'install'的ins_net_server.mk问题,修改env_network.mk的TNSLSNR_LINKLINE变量(2232行),添加 -Wl,--no-as-needed
37
38sudo sed -i "s/TNSLSNR_LINKLINE=\$(LINK)/& -Wl,--no-as-needed/g" $ORACLE_HOME/network/lib/env_network.mk
39
40# 'irman ioracle'的ins_rdbms.mk问题,修改env_rdbms.mk的ORACLE_LINKLINE变量(2759行),添加 -Wl,--no-as-needed
41
42sudo sed -i "s/ORACLE_LINKLINE=\$(ORACLE_LINKER) \$(PL_FLAGS)/& -Wl,--no-as-needed/g" $ORACLE_HOME/rdbms/lib/env_rdbms.mk复制
报错2:
1信息: be used when making a PIE object; recompile with -fPIC
2/usr/bin/ld: final link failed: Nonrepresentable section on output
3collect2: error: ld returned 1 exit status
4make: *** [/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/rman] Error 1
5
6信息: 终止从衍生进程输出。
7信息: ----------------------------------
8严重: oracle.sysman.oii.oiil.OiilActionException: Error in invoking target 'irman ioracle' of makefile '/u01/app/o
9racle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk'. See '/u01/app/oracle/product/11.2.0/dbhome_1/install/relink
10Actions2023-03-15_09-24-40-AM.log' for details.
11
12/usr/bin/ld: /u01/app/oracle/product/11.2.0/dbhome_1/lib//libgx11.a(gxzsus.o): relocation R_X86_64_32 against `_2__STRING.0.0' can not be used when making a PIE object; recompile with -fPIC
13
14/usr/bin/ld: /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/opimai.o: relocation R_X86_64_32 against `_2__STRING.0.0' can not be used when making a PIE object; recompile with -fPIC复制
主要原因:gcc版本问题
1gcc -v
2g++ -v复制
1oracle@lhrubuntu2004:~$ gcc -v
2Using built-in specs.
3COLLECT_GCC=gcc
4COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
5OFFLOAD_TARGET_NAMES=nvptx-none:hsa
6OFFLOAD_TARGET_DEFAULT=1
7Target: x86_64-linux-gnu
8Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.4.0-1ubuntu1~20.04.1' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-Av3uEd/gcc-9-9.4.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
9Thread model: posix
10gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
11oracle@lhrubuntu2004:~$ g++ -v
12Using built-in specs.
13COLLECT_GCC=g++
14COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
15OFFLOAD_TARGET_NAMES=nvptx-none:hsa
16OFFLOAD_TARGET_DEFAULT=1
17Target: x86_64-linux-gnu
18Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.4.0-1ubuntu1~20.04.1' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-Av3uEd/gcc-9-9.4.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
19Thread model: posix
20gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
21oracle@lhrubuntu2004:~$复制
卸载
1rm -rf /etc/ora*
2rm -rf /var/tmp/.oracle
3rm -rf /tmp/*
4rm -rf /u01/app/grid/*
5rm -rf /u01/app/oracle/*
6rm -rf /u01/app/oraInventory/*
7rm -rf /u01/app/*
8
9
10userdel oracle
11userdel grid
12groupdel oinstall
13groupdel dba
14groupdel oper
15groupdel asmadmin
16groupdel asmoper
17groupdel asmdba
18复制
总结
1、我自己尝试了Ubuntu 14.04,Ubuntu 16.04,Ubuntu 18.04,Ubuntu 20.04,Ubuntu 22.04,这几个版本安装Oracle 11.2.0.4,都能安装成功,基本步骤一样,在Ubuntu 14.04,Ubuntu 16.04安装过程一样;在Ubuntu 18.04,Ubuntu 20.04,Ubuntu 22.04安装过程一样,不过需要把gcc进行降级处理,其它过程都一样;。
2、Ubuntu 14.04的gcc -v、g++ -v和cpp -v
都是4.8.4版本,而Ubuntu 16.04都是5.4.0版本,而Ubuntu 20.04都是7.5.0版本,而Ubuntu 20.04都是9.4.0版本,而Ubuntu 22.04都是11.3.0版本,只有4.8.4和5.4.0可以成功,这个很重要:
1root@ub14oracle11g:/# gcc -v
2Using built-in specs.
3COLLECT_GCC=gcc
4COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
5Target: x86_64-linux-gnu
6Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.4' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
7Thread model: posix
8gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.4)
9root@ub14oracle11g:/# g++ -v
10Using built-in specs.
11COLLECT_GCC=g++
12COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
13Target: x86_64-linux-gnu
14Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.4' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
15Thread model: posix
16gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.4)
17root@ub14oracle11g:/# cpp -v
18Using built-in specs.
19COLLECT_GCC=cpp
20Target: x86_64-linux-gnu
21Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.4' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
22Thread model: posix
23gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.4)
24COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=x86-64'
25 /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1 -E -quiet -v -imultiarch x86_64-linux-gnu - -mtune=generic -march=x86-64 -fstack-protector -Wformat -Wformat-security
26ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
27ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../x86_64-linux-gnu/include"
28#include "..." search starts here:
29#include <...> search starts here:
30 /usr/lib/gcc/x86_64-linux-gnu/4.8/include
31 /usr/local/include
32 /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
33 /usr/include/x86_64-linux-gnu
34 /usr/include
35End of search list.复制
3、并不建议在Ubuntu上安装Oracle,不过自己测试可以玩。企业里边不会把数据库安装在Ubuntu上的。
4、另外,测试的话,也可以使用麦老师的docker镜像,快速又方便,参考:https://www.xmmup.com/wsl2zhonganzhuangdockerbingkuaisugoujianduozhongshujukuceshihuanjing.html#Oracle_shu_ju_ku
1# oracle
2nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle21c_ee_db_21.3.0.0 &
3nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle19clhr_asm_db_12.2.0.3:2.0 &
4nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle19clhr_rpm_db_12.2.0.3:2.0 &
5nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle18clhr_rpm_db_12.2.0.2:2.0 &
6nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:2.0 &
7nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr1_ee_lhr_12.1.0.2:2.0 &
8nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_11g_ee_lhr_11.2.0.4:2.0 &
9nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_11g_ee_lhr_11.2.0.3:2.0 &
10nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_10g_ee_lhr_10.2.0.5:2.0 &
11nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_10g_ee_lhr_10.2.0.1:2.0 &复制
5、Ubuntu源的配置很重要,请参考:https://www.xmmup.com/ubuntu-gebanbendaihaojianjie.html
参考
https://blog.csdn.net/airwolfzhao34/article/details/128182951
https://www.cnblogs.com/pxg950110/p/793909492_2.html
https://blog.csdn.net/feinifi/article/details/121793945
https://blog.csdn.net/2004v2004/article/details/116118968
https://huaweicloud.csdn.net/6335648bd3efff3090b554c2.html
https://blog.csdn.net/qq_40254144/article/details/82669649