vault backup: 2026-01-05 13:03:55

This commit is contained in:
windyboy
2026-01-05 13:03:55 +08:00
parent 21460fc35d
commit be7c6cdcc9
589 changed files with 396508 additions and 27 deletions
@@ -0,0 +1,161 @@
**Summary of the Problem and Solution**
---
### **Problem Overview**
You were attempting to run an Oracle 11g Docker container using the command:
```bash
docker run -idt --name oracle -h oracle --privileged=true -p 1521:1521 -p 2222:22 \
lhrbest/oracle_11g_ee_lhr_11.2.0.4:2.0 init
```
- **Issue Experienced:**
- The Docker container exited immediately after starting, without any error messages.
- The exit code was **139**, indicating a **segmentation fault (SIGSEGV)**.
- The issue occurred on a **Debian** system but not on **OpenSUSE**.
---
### **Root Cause**
The segmentation fault was due to the way modern Linux kernels handle **`vsyscall`** (virtual system call):
- **`vsyscall` Deprecation:**
- Modern kernels have deprecated `vsyscall` in favor of **vDSO** (virtual dynamic shared object) for security reasons.
- By default, `vsyscall` might be disabled or set to a mode incompatible with older applications.
- **Impact on Oracle 11g:**
- Oracle 11g, being legacy software, relies on the old `vsyscall` mechanism for certain operations.
- Without proper `vsyscall` support, Oracle binaries can crash with a segmentation fault.
- **Difference Between Systems:**
- **OpenSUSE** may have `vsyscall` support enabled or set to emulate by default.
- **Debian**, especially with newer kernels, has `vsyscall` disabled or set to a mode that doesn't support the required legacy behavior.
---
### **Solution**
**Enable `vsyscall` Emulation on the Debian System:**
1. **Verify Current `vsyscall` Mapping:**
```bash
sudo grep vsyscall /proc/self/maps
```
- If no output is returned, `vsyscall` is not currently mapped.
2. **Edit GRUB Configuration:**
- Open the GRUB configuration file:
```bash
sudo nano /etc/default/grub
```
- Locate the line starting with `GRUB_CMDLINE_LINUX_DEFAULT`.
- Append `vsyscall=emulate` to the existing parameters within the quotes.
**Example:**
```bash
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash vsyscall=emulate"
```
3. **Update GRUB Settings:**
- Apply the changes by updating GRUB:
```bash
sudo update-grub
```
4. **Reboot the System:**
- Restart your machine to apply the new kernel parameter:
```bash
sudo reboot
```
5. **Confirm `vsyscall` is Enabled:**
- After rebooting, check if `vsyscall` is now mapped:
```bash
sudo grep vsyscall /proc/self/maps
```
- You should see an output similar to:
```
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
```
6. **Run the Docker Container Again:**
- With `vsyscall` emulation enabled, attempt to start the Oracle container:
```bash
docker run -idt --name oracle -h oracle --privileged=true --shm-size=2g \
-p 1521:1521 -p 2222:22 lhrbest/oracle_11g_ee_lhr_11.2.0.4:2.0 init
```
- The container should now start successfully without exiting.
---
### **Explanation of the Solution**
- **`vsyscall=emulate` Kernel Parameter:**
- Tells the kernel to emulate the old `vsyscall` behavior, allowing legacy applications to function correctly.
- Balances compatibility with security, as emulation is safer than direct mapping.
- **Why It Works:**
- Restores the expected environment for Oracle 11g, preventing segmentation faults caused by missing `vsyscall` support.
---
### **Additional Considerations**
- **Security Implications:**
- Enabling `vsyscall` emulation is generally safe but reintroduces some legacy code paths.
- The risk is minimal for most users, but it's important to keep the system updated.
- **Alternate Solutions:**
- **Upgrade Oracle Version:**
- Consider using a newer version of Oracle that doesn't rely on `vsyscall`.
- **Use an Older Kernel:**
- Downgrading the kernel to a version where `vsyscall` is enabled by default.
- Not recommended due to potential security vulnerabilities.
- **Documentation and References:**
- Similar issues and solutions have been documented in various repositories:
- [JiscSD/rdss-archivematica Issue #65](https://github.com/JiscSD/rdss-archivematica/issues/65)
- [Enalean/docker-tuleap-aio Issue #57](https://github.com/Enalean/docker-tuleap-aio/issues/57)
- [moby/moby Issue #28705](https://github.com/moby/moby/issues/28705)
---
### **Summary**
- **Problem:**
- The Oracle 11g Docker container was exiting with a segmentation fault on Debian due to `vsyscall` being disabled in the kernel.
- **Solution:**
- Enabling `vsyscall` emulation by adding `vsyscall=emulate` to the kernel boot parameters in GRUB.
- Updating GRUB and rebooting the system applied the changes.
- The container then started successfully.
---
**By adjusting the kernel parameter to enable `vsyscall` emulation, you resolved the compatibility issue between Oracle 11g and the modern Debian kernel, allowing the Docker container to run without errors.**
---
If you have any further questions or need assistance with other issues, feel free to ask!
@@ -0,0 +1,372 @@
http://211.23.61.114/ISO/OracleDB/Ora11g11.2.0.4/
```db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=oradb
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=false
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=
oracle.install.db.racOneServiceName=
oracle.install.db.config.starterdb.type=
oracle.install.db.config.starterdb.globalDBName=
oracle.install.db.config.starterdb.SID=
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=oracle
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.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
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=
PROXY_REALM=
COLLECTOR_SUPPORTHUB_URL=
oracle.installer.autoupdates.option=
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
```
Dockerfile-inst
```Dockerfile
FROM oralcelinux:6.10
ARG NLS_LANG
ARG ORACLE_SID
ADD rlwrap-0.42.tar.gz /tmp/
ADD p13390677_112040_Linux-x86-64_1of7.zip /tmp/
ADD p13390677_112040_Linux-x86-64_2of7.zip /tmp/
ADD db_install.rsp /tmp/
RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle && \
yum -y install oracle-rdbms-server-11gR2-preinstall unzip readline-devel.x86_64 lrzsz && \
cd /tmp/rlwrap-0.42 && ./configure && make && make install && \
echo "Create /u01/app dir..." && \
mkdir -p -m 755 /u01/app/dumpdir && \
mkdir -p -m 755 /u01/app/oradata && \
mkdir -p -m 755 /u01/app/oraInventory && \
mkdir -p -m 755 /u01/app/oracle && \
mkdir -p -m 755 /u01/app/oracle/product/11.2.0/db_1 && \
chown -R oracle:oinstall /u01 && \
unzip -oq /tmp/p13390677_112040_Linux-x86-64_1of7.zip -d /tmp/ && \
unzip -oq /tmp/p13390677_112040_Linux-x86-64_2of7.zip -d /tmp/ && \
chown -R oracle:oinstall /tmp/database && \
printf "%s\n" 'export ORACLE_SID=${ORACLE_SID:orcl}' \
'export ORACLE_BASE=/u01/app/oracle' \
'export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1' \
'export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32' \
'export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch' \
'export NLS_LANG=${NLS_LANG:-AMERICAN_AMERICA.ZHS16GBK}' \
'export NLS_DATE_FORMAT="yyyy-mm-dd hh24:mi:ss"' \
'alias sqlplus="rlwrap sqlplus"' \
'alias rman="rlwrap rman"' \
>>/home/oracle/.bash_profile && \
cat /etc/security/limits.conf | grep -v oracle | tee /etc/security/limits.conf && \
su oracle -c "/tmp/database/runInstaller -ignorePrereq -ignoreSysPrereqs -waitforcompletion -silent -responseFile /tmp/db_install.rsp 2>&1" && \
/u01/app/oraInventory/orainstRoot.sh && \
/u01/app/oracle/product/11.2.0/db_1/root.sh && \
yum clean all && \
rm -rf /tmp/* && rm -rf /var/log/* && rm -rf /var/cache/*
```
build-inst.sh:
```bash
#!/usr/bin/env bash
imagetag="oracle:11.2.0.4-inst"
dockerfile="Dockerfile-inst"
docker build --rm \
--force-rm \
--no-cache \
--memory=4g \
--shm-size=4g \
-t ${imagetag} \
-f ${dockerfile} .
```
Dockerfile-db
```Dockerfile
FROM oracle:11.2.0.4-inst
# Set environment variables
ENV ORACLE_BASE=/u01/app/oracle
ENV ORACLE_HOME=${ORACLE_BASE}/product/11.2.0/db_1
ENV PATH=$PATH:${ORACLE_HOME}/bin
# Build arguments with default password values
ARG SYSPASSWORD=admingzzn
ARG SYSTEMPASSWORD=admingzzn
ARG ORACLE_SID=orcl
# Set environment variables for oracle user
RUN printf "%s\n" \
'export ORACLE_BASE=/u01/app/oracle' \
'export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1' \
'export ORACLE_SID=$ORACLE_SID' \
'export PATH=$PATH:$ORACLE_HOME/bin' \
>> /home/oracle/.bash_profile
RUN printf "%s\n" '[GENERAL]' \
'RESPONSEFILE_VERSION="11.2"' \
'CREATE_TYPE="CUSTOM"' \
'[oracle.net.ca]' \
'INSTALLED_COMPONENTS={"server","net8","javavm"}' \
'INSTALL_TYPE=""typical""' \
'LISTENER_NUMBER=1' \
'LISTENER_NAMES={"LISTENER"}' \
'LISTENER_PROTOCOLS={"TCP;1521"}' \
'LISTENER_START=""LISTENER""' \
'NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}' \
'NSN_NUMBER=1' \
'NSN_NAMES={"EXTPROC_CONNECTION_DATA"}' \
'NSN_SERVICE={"PLSExtProc"}' \
'NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}' \
>>/tmp/netca.rsp && \
su oracle -c "/u01/app/oracle/product/11.2.0/db_1/bin/netca -silent -responseFile /tmp/netca.rsp" && \
printf "%s\n" '[GENERAL]' \
'RESPONSEFILE_VERSION = "11.2.0"' \
'OPERATION_TYPE = "createDatabase"' \
'[CREATEDATABASE]' \
'GDBNAME = "${ORACLE_SID}"' \
'DATABASECONFTYPE = "SI"' \
'SID = "orcl"' \
'TEMPLATENAME = "General_Purpose.dbc"' \
'SYSPASSWORD = \"${SYSPASSWORD}\"' \
'SYSTEMPASSWORD = \"${SYSTEMPASSWORD}\"' \
'DATAFILEDESTINATION=/u01/app/oradata' \
'RECOVERYAREADESTINATION=/u01/app/oradata' \
'STORAGETYPE=FS' \
'CHARACTERSET="ZHS16GBK"' \
'INITPARAMS = "java_jit_enabled=false,memory_target=0,sga_target=2048,pga_aggregate_target=300,processes=300,open_cursors=300"' \
'AUTOMATICMEMORYMANAGEMENT="False"' \
> /tmp/dbca.rsp && chown oracle:oinstall /tmp/dbca.rsp && chmod +x /tmp/dbca.rsp && \
su oracle -c "/u01/app/oracle/product/11.2.0/db_1/bin/dbca -silent -responseFile /tmp/dbca.rsp" && \
sed -i "s/#PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config && \
echo "export LANG=en_US.utf8" >> /etc/profile
# Cleanup
RUN yum clean all && \
rm -rf /tmp/* /var/log/* /var/cache/*
```
build-db.sh
```bash
imagetag="oracle:11.2.0.4-db"
dockerfile="Dockerfile-db"
docker build --rm \
--force-rm \
--no-cache \
--memory=4g \
--shm-size=4g \
-t ${imagetag} \
-f ${dockerfile} .
```
entrypoint_oracle.sh:
```bash
#!/usr/bin/env bash
set -e
source ~/.bashrc
alert_log="$ORACLE_BASE/diag/rdbms/orcl/$ORACLE_SID/trace/alert_$ORACLE_SID.log"
listener_log="$ORACLE_BASE/diag/tnslsnr/$HOSTNAME/listener/trace/listener.log"
pfile=$ORACLE_HOME/dbs/init$ORACLE_SID.ora
# monitor $logfile
monitor() {
tail -F -n 0 $1 | while read line; do echo -e "$2: $line"; done
}
trap_db() {
trap "echo 'Caught SIGTERM signal, shutting down...'; stop_db" SIGTERM;
trap "echo 'Caught SIGINT signal, shutting down...'; stop_db" SIGINT;
}
# Check shared memory
check_shm() {
echo ""
echo "Checking shared memory..."
df -h | grep "Mounted on" && df -h | egrep --color "^.*/dev/shm" || echo "Shared memory is not mounted."
}
# Reconfig listener
reconfig_lsnr() {
echo ""
echo "Reconfig listener for hostname : [$HOSTNAME]..."
sed -i "s/(HOST.*)(/(HOST = $HOSTNAME)(/g" /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
sed -i "s/(HOST.*)(/(HOST = $HOSTNAME)(/g" /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
echo "Show tnsnames.ora..."
cat /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
echo "Show listener.ora..."
cat /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
}
# Start listener
start_lsnr() {
echo ""
echo "Starting listener..."
monitor $listener_log listener &
lsnrctl start | while read line; do echo -e "lsnrctl: $line"; done
MON_LSNR_PID=$!
}
# Start database
start_db() {
echo ""
echo "Starting database..."
trap_db
monitor $alert_log alertlog &
MON_ALERT_PID=$!
sqlplus / as sysdba <<-EOF |
pro Starting with pfile='$pfile' ...
startup;
alter system register;
exit 0
EOF
while read line; do echo -e "sqlplus: $line"; done
change_dpdump_dir
change_profile_default_limit
wait $MON_ALERT_PID
}
# Stop database
stop_db() {
trap '' SIGINT SIGTERM
shut_immediate
echo "Shutting down listener..."
lsnrctl stop | while read line; do echo -e "lsnrctl: $line"; done
kill $MON_ALERT_PID $MON_LSNR_PID
exit 0
}
shut_immediate() {
ps -ef | grep ora_pmon | grep -v grep > /dev/null && \
echo "Shutting down the database..." && \
sqlplus / as sysdba <<-EOF |
set echo on
shutdown immediate;
exit 0
EOF
while read line; do echo -e "sqlplus: $line"; done
}
# change_dpdump_dir
change_dpdump_dir () {
echo ""
echo "Changing dpdump dir to /u01/app/dumpdir"
sqlplus / as sysdba <<-EOF |
create or replace directory data_pump_dir as '/u01/app/dumpdir';
commit;
exit 0
EOF
while read line; do echo -e "sqlplus: $line"; done
}
# change profile default limit
change_profile_default_limit() {
echo ""
echo "Changing profile default limit : password_life_time/failed_login_attempts"
sqlplus / as sysdba <<-EOF |
alter profile default limit password_life_time unlimited;
alter profile default limit failed_login_attempts unlimited;
commit;
exit 0
EOF
while read line; do echo -e "sqlplus: $line"; done
}
# Check shared memory
check_shm
# Reconfig listener
reconfig_lsnr
# Start listener
start_lsnr
# Start database
start_db
```
entrypoint.sh :
```bash
#!/usr/bin/env bash
set -e
/etc/init.d/sshd start
find /u01 ! -user oracle -o ! -group oinstall -exec chown oracle:oinstall {} +
su - oracle -c "/usr/sbin/entrypoint_oracle.sh"
```
Dockerfile-run
```Dockerfile
# Use Oracle Database 11.2.0.4 as the base image
FROM oracle:11.2.0.4-db
# Set the timezone to Shanghai
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Set environment variables
ENV LANG=en_US.utf8
# Copy entry point scripts
ADD entrypoint.sh /usr/sbin/entrypoint.sh
ADD entrypoint_oracle.sh /usr/sbin/entrypoint_oracle.sh
# Make scripts executable
RUN chmod +x /usr/sbin/entrypoint.sh /usr/sbin/entrypoint_oracle.sh
# Modify SSH configuration (with security considerations)
# It's recommended to create a non-root user and use SSH keys
# RUN sed -i "s/#PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config
# Set the root password securely (not recommended to hardcode)
# ARG ROOT_PASSWORD
# RUN echo "root:${ROOT_PASSWORD}" | chpasswd
EXPOSE 1521
# Set the entry point
ENTRYPOINT ["/usr/sbin/entrypoint.sh"]
CMD [""]
```
```
```
debain can't run oraclelinux
```
I believe this is the vsyscall=emulate problem:
If `sudo grep vsyscall /proc/1/maps` prints nothing, then edit `/etc/default/grub` and append `vsyscall=emulate` to the variable `GRUB_CMDLINE_LINUX_DEFAULT`. Then run a `sudo update-grub` and reboot.
Additional references: [https://github.com/JiscSD/rdss-archivematica/issues/65](https://github.com/JiscSD/rdss-archivematica/issues/65) , [Enalean/docker-tuleap-aio#57](https://github.com/Enalean/docker-tuleap-aio/issues/57) , [moby/moby#28705](https://github.com/moby/moby/issues/28705)
👍8
```
@@ -0,0 +1,154 @@
--XBOS資料庫設定值取得SQL Script如下:
-- 1. 收集資料庫版本資訊
select banner from v$version
union all
select distinct banner from (select 'Oracle Client version '||client_version banner FROM v$session_connect_info WHERE sid = SYS_CONTEXT('USERENV', 'SID'))
union all
select 'Database CharacterSet: '||value from v$nls_parameters where parameter='NLS_CHARACTERSET'
union all
select 'Database archive mode: '||log_mode from v$database
union all
select 'Database Global Name: '||GLOBAL_NAME from GLOBAL_NAME
union all
select 'Database Server Name: '||host_name from v$instance
union all
select 'Database Startup Time: '||to_char(startup_time, 'YYYY/MM/DD HH:MI:SS') from v$instance
union all
select 'Database Client IP: '||sys_context('USERENV', 'IP_ADDRESS') from dual
union all
select 'Database Trace Log: '||value from v$diag_info where name='Diag Trace';
-- 2. 收集資料庫參數設定資訊
select name, value from v$parameter2 where name in (
'audit_file_dest',
'audit_trail',
'cluster_database',
'cluster_database_instances',
'control_files',
'control_management_pack_access',
'cpu_count',
'db_block_size',
'db_files',
'db_name',
'instance_mode',
'memory_max_target',
'memory_target',
'optimizer_features_enable',
'pga_aggregate_target',
'processes',
'remote_login_passwordfile',
'service_names',
'sessions',
'sga_max_size',
'sga_target',
'spfile',
'statistics_level',
'user_dump_dest',
'utl_file_dir'
)
order by name;
-- 3. 收集Tablespace使用空間大小資訊
SELECT df.tablespace_name "Tablespace",
df.bytes / (1024 * 1024) "Size (MB)",
SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "% Free",
Round((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) "% Used"
FROM dba_free_space fs,
(SELECT tablespace_name,SUM(bytes) bytes FROM dba_data_files
GROUP BY tablespace_name) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY df.tablespace_name,df.bytes
UNION ALL
SELECT df.tablespace_name tspace,
fs.bytes / (1024 * 1024),
SUM(df.bytes_free) / (1024 * 1024),
Nvl(Round((SUM(fs.bytes) - df.bytes_used) * 100 / fs.bytes), 1),
Round((SUM(fs.bytes) - df.bytes_free) * 100 / fs.bytes)
FROM dba_temp_files fs,
(SELECT tablespace_name,bytes_free,bytes_used FROM v$temp_space_header
GROUP BY tablespace_name,bytes_free,bytes_used) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
ORDER BY 1;
-- 4. 收集Data Files使用空間大小資訊
select file_name,tablespace_name, bytes/1048576 "SizeMB", bytes/blocks "BLOCK", autoextensible from dba_data_files
union all
select file_name,tablespace_name, bytes/1048576 "SizeMB", bytes/blocks "BLOCK", autoextensible from dba_temp_files;
-- 5. 收集主機名稱資訊
select instance_name,host_name,version,startup_time,status from v$instance;
-- 6. 收集資料庫名稱狀態
select dbid, db_unique_name, name, log_mode, open_mode, database_role, guard_status, platform_name, flashback_on from v$database;
-- 7. 收集表格(tables)使用空間大小資訊
select OWNER,TABLE_NAME,NUM_ROWS,BLOCKS,round(BLOCKS/128) as SizeMB,AVG_ROW_LEN,round(AVG_ROW_LEN*NUM_ROWS/1048576) as LenMB
from all_tables where owner in ('FBOSPROD', 'XBOSWRNT', 'XBOSPROD') and blocks is not null order by 1, 5 desc;
-- 8. 收集索引(indexes)使用空間大小資訊
select owner, segment_name, bytes/1024/1024 "SizeMB" from dba_segments
where owner in ('FBOSPROD', 'XBOSWRNT', 'XBOSPROD') and segment_type = 'INDEX' order by 3 desc;
-- 9. 收集Partition Table設定資訊
select table_name, partition_name, num_rows, round(blocks/128, 2) SizeMB, last_analyzed
from dba_tab_statistics where owner in ('FBOSPROD', 'XBOSWRNT', 'XBOSPROD');
--10. 收集資料表空間使用額度
select tablespace_name,username,max_bytes,max_blocks from dba_ts_quotas where username in ('FBOSPROD', 'XBOSWRNT', 'XBOSPROD');
--11. 收集資料庫SYS權限設定
select * from dba_sys_privs where grantee in ('FBOSPROD', 'WRNTPROD', 'XBOSPROD')
union all
select * from dba_sys_privs where grantee in ('FBOSLOAD', 'WRNTLOAD', 'XBOSLOAD')
union all
select * from dba_sys_privs where grantee in ('FBOSLOAD_ROLE', 'WRNTLOAD_ROLE', 'XBOSLOAD_ROLE')
order by 1, 2;
--12. 收集資料庫ROLE權限設定
select * from dba_role_privs where grantee in ('FBOSPROD', 'WRNTPROD', 'XBOSPROD')
union all
select * from dba_role_privs where grantee in ('FBOSLOAD', 'WRNTLOAD', 'XBOSLOAD')
union all
select * from dba_role_privs where grantee in ('FBOSLOAD_ROLE', 'WRNTLOAD_ROLE', 'XBOSLOAD_ROLE')
order by 1, 2;
--14. 收集資料庫User Objects Count
select owner, object_type, count(*) from dba_objects
where owner in ('FBOSPROD', 'WRNTPROD', 'XBOSPROD')
group by owner, object_type, object_type order by 1, 2;
select owner, object_type, count(*) from dba_objects
where owner in ('FBOSLOAD', 'WRNTLOAD', 'XBOSLOAD')
group by owner, object_type, object_type order by 1, 2;
--15. 收集物件授權Scripts語法
select 'GRANT DELETE, INSERT, SELECT, UPDATE ON XBOSPROD.' || object_name || ' TO XBOSLOAD;' GRANT_TEXT
from dba_objects where owner = 'XBOSPROD' and object_type = 'TABLE'
union all
select 'GRANT EXECUTE ON XBOSPROD.' || object_name || ' TO XBOSLOAD;' GRANT_TEXT
from dba_objects where owner = 'XBOSPROD' and object_type in('FUNCTION','PACKAGE','PACKAGE BODY','PROCEDURE')
union all
select 'GRANT ALTER, SELECT ON XBOSPROD.' || object_name || ' TO XBOSLOAD;' GRANT_TEXT
from dba_objects where owner = 'XBOSPROD' and object_type = 'SEQUENCE'
union all
select 'GRANT SELECT ON XBOSPROD.' || object_name || ' TO XBOSLOAD;' GRANT_TEXT
from dba_objects where owner = 'XBOSPROD' and object_type = 'VIEW'
order by GRANT_TEXT;
--16. 收集Create Synonym Scripts語法
select 'create or replace synonym XBOSLOAD.' || object_name || ' for XBOSPROD.'||object_name||';'
from dba_objects where owner = 'XBOSPROD';
--17. Schema OWNER & Table統計值收集Scripts語法
select table_name, last_analyzed from user_tab_statistics where table_name = 'TRANSFER_SEND';
exec dbms_stats.gather_table_stats(ownname => 'XBOSPROD' , tabname => 'TRANSFER_SEND',cascade => true);
exec dbms_stats.gather_schema_stats(ownname => 'XBOSPROD', degree => 4, cascade => true);
select table_name, last_analyzed from user_tab_statistics where table_name = 'TRANSFER_SEND';
--18. Tablespaces & datafiles list
select * from v$tablespace; -- NAME, BIGFILE, FLASHBACK_ON
select * from v$datafile; -- NAME, BYTES, BLOCKS, BLOCK_SIZE
select * from v$tempfile; -- NAME, BYTES, BLOCKS, BLOCK_SIZE
select * from dba_tablespaces; -- TABLESPACE_NAME, BIGFILE, BLOCK_SIZE
select * from dba_data_files; -- FILE_NAME, TABLESPACE_NAME, BYTES, BLOCKS, AUTOEXTENSIBLE, MAXBYTES, MAXBLOCKS
select * from dba_temp_files; -- FILE_NAME, TABLESPACE_NAME, BYTES, BLOCKS, AUTOEXTENSIBLE, MAXBYTES, MAXBLOCKS