Oracle: Unterschied zwischen den Versionen
| (5 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 6: | Zeile 6: | ||
=== Konfiguration === | === Konfiguration === | ||
==== SAP* löschen ==== | |||
sqlplus / as sysdba | |||
<syntaxhighlight lang="sql" line="1"> | |||
DELETE FROM SAPSR3.USR02 WHERE MANDT = '000' AND BNAME = 'SAP*'; | |||
COMMIT; | |||
</syntaxhighlight> | |||
==== Tablespaces und Files anzeigen lassen ==== | |||
<syntaxhighlight lang="sql" line="1"> | |||
SELECT file_name, bytes/1024/1024 AS size_mb FROM dba_data_files WHERE tablespace_name = 'PSAPSR3' ORDER BY file_name; | |||
</syntaxhighlight> | |||
====Tablespace anlegen==== | ====Tablespace anlegen==== | ||
CREATE TABLESPACE PSAPSR3740X DATAFILE '/oracle/PZ0/sapdata1/sr3740x_1' SIZE 10M; | CREATE TABLESPACE PSAPSR3740X DATAFILE '/oracle/PZ0/sapdata1/sr3740x_1' SIZE 10M; | ||
====Tablespace erweitern==== | |||
alter database datafile '/oracle/ | = Erweiterung ohne ASM = | ||
== Tablespace-Belegung ermitteln == | |||
Belegung aller Tablespaces in Prozent ermitteln: | |||
<syntaxhighlight lang="sql"> | |||
with MBYTES as( | |||
select tablespace_name, | |||
SUM(bytes)/1024/1024 as Akt, | |||
SUM(decode(maxbytes,0,bytes,maxbytes))/1024/1024 as ZMax | |||
from dba_data_files | |||
group by tablespace_name | |||
), | |||
MFREE as( | |||
select tablespace_name, | |||
SUM(bytes)/1024/1024 as Free | |||
from dba_free_space | |||
group by tablespace_name | |||
) | |||
select MBYTES.tablespace_name, | |||
ROUND((AKT-FREE)/ZMAX*100,2) as BelegtProz | |||
from MBYTES, MFREE | |||
where MFREE.tablespace_name = MBYTES.tablespace_name | |||
order by ROUND((AKT-FREE)/ZMAX*100,2) desc; | |||
</syntaxhighlight> | |||
'''Beispiel-Ergebnis:''' | |||
<pre> | |||
TABLESPACE_NAME BELEGTPROZ | |||
------------------------------ ---------- | |||
PSAPSR3 89.43 | |||
PSAPSR3702 33.32 | |||
PSAPSR3USR 20.26 | |||
PSAPUNDO 6.55 | |||
SYSTEM 5.05 | |||
SYSAUX 4.05 | |||
</pre> | |||
== Verfügbaren Speicherplatz ermitteln == | |||
Im Betriebssystem ermitteln, in welchem data-Laufwerk am meisten Platz für die Erweiterung vorhanden ist: | |||
<syntaxhighlight lang="bash"> | |||
df -h | grep oracle | |||
</syntaxhighlight> | |||
'''Beispiel-Ausgabe:''' | |||
<pre> | |||
p11data01/data01 98G 68G 30G 70% /oracle/P11/data01 | |||
p11data02/data02 215G 172G 43G 81% /oracle/P11/data02 | |||
p11data03/data03 98G 51G 47G 52% /oracle/P11/data03 | |||
</pre> | |||
== An der Datenbank anmelden == | |||
<syntaxhighlight lang="sql"> | |||
sqlplus / as sysdba | |||
</syntaxhighlight> | |||
=== Ausgabe formatieren === | |||
Für eine übersichtlichere Darstellung: | |||
<syntaxhighlight lang="sql"> | |||
set pages 9999 | |||
set lin 180 | |||
col file_name for a60 | |||
</syntaxhighlight> | |||
== Datafiles anzeigen == | |||
Datafiles zum Tablespace anzeigen: | |||
<syntaxhighlight lang="sql"> | |||
select file_name, bytes/1024/1024 | |||
from dba_data_files | |||
where tablespace_name = '<TABLESPACE>'; | |||
</syntaxhighlight> | |||
{{Hinweis|Der Name des Tablespaces ist in der E-Mail von Icinga zu finden.}} | |||
'''Beispiel-Ausgabe:''' | |||
<pre> | |||
FILE_NAME BYTES/1024/1024 | |||
------------------------------------------------------------ --------------- | |||
/oracle/P11/data01/beispiel_data_01.dbf 20480 | |||
/oracle/P11/data02/beispiel_data_02.dbf 20480 | |||
/oracle/P11/data03/beispiel_data_03.dbf 30720 | |||
/oracle/P11/data02/beispiel_data_04.dbf 20480 | |||
</pre> | |||
== Datafile erweitern == | |||
=== Existierendes Datafile vergrößern === | |||
Wenn ein Datafile erweitert werden kann: | |||
<syntaxhighlight lang="sql"> | |||
alter database datafile '/oracle/P11/data02/beispiel_04.dbf' resize 30G; | |||
</syntaxhighlight> | |||
{{Hinweis|Der Prozess dauert ca. 1 GB pro Minute.}} | |||
'''Überwachung auf OS-Ebene:''' | |||
<syntaxhighlight lang="bash"> | |||
du -h <FILENAME> | |||
</syntaxhighlight> | |||
'''Kontrolle:''' | |||
<syntaxhighlight lang="sql"> | |||
select file_name, bytes/1024/1024 | |||
from dba_data_files | |||
where tablespace_name = '<TABLESPACE>'; | |||
</syntaxhighlight> | |||
'''Beispiel nach Erweiterung:''' | |||
<pre> | |||
FILE_NAME BYTES/1024/1024 | |||
------------------------------------------------------------ --------------- | |||
/oracle/P11/data01/beispiel_data_01.dbf 20480 | |||
/oracle/P11/data02/beispiel_data_02.dbf 20480 | |||
/oracle/P11/data03/beispiel_data_03.dbf 30720 | |||
/oracle/P11/data02/beispiel_data_04.dbf 30720 | |||
</pre> | |||
=== Neues Datafile anlegen === | |||
Falls kein existierendes Datafile erweitert werden kann: | |||
<syntaxhighlight lang="sql"> | |||
alter tablespace BEISPIEL add datafile '/oracle/P11/data03/beispiel.dbf' size 100M; | |||
</syntaxhighlight> | |||
{{Hinweis|Der Prozess dauert ca. 1 GB pro Minute.}} | |||
'''Überwachung auf OS-Ebene:''' | |||
<syntaxhighlight lang="bash"> | |||
du -h <FILENAME> | |||
</syntaxhighlight> | |||
'''Kontrolle:''' | |||
<syntaxhighlight lang="sql"> | |||
select file_name, bytes/1024/1024 | |||
from dba_data_files | |||
where tablespace_name = '<TABLESPACE>'; | |||
</syntaxhighlight> | |||
'''Beispiel nach Anlegen:''' | |||
<pre> | |||
FILE_NAME BYTES/1024/1024 | |||
------------------------------------------------------------ --------------- | |||
/oracle/P11/data01/beispiel_data_01.dbf 20480 | |||
/oracle/P11/data02/beispiel_data_02.dbf 20480 | |||
/oracle/P11/data03/beispiel_data_03.dbf 30720 | |||
/oracle/P11/data02/beispiel_data_04.dbf 20480 | |||
/oracle/P11/data03/beispiel_data_05.dbf 100 | |||
</pre> | |||
== Tempfile erweitern == | |||
'''Tempfiles anzeigen:''' | |||
<syntaxhighlight lang="sql"> | |||
select file_name, bytes/1024/1024 | |||
from dba_temp_files; | |||
</syntaxhighlight> | |||
'''Tempfile hinzufügen:''' | |||
<syntaxhighlight lang="sql"> | |||
alter tablespace <TABLESPACE> add tempfile '+DATA' size 25G; | |||
</syntaxhighlight> | |||
====Tablespace mit neuer Datei erweitern==== | ====Tablespace mit neuer Datei erweitern==== | ||
alter tablespace PSAPSR3740X add datafile '/oracle/PZ0/sapdata1/sr3740x_2' size 30G; | alter tablespace PSAPSR3740X add datafile '/oracle/PZ0/sapdata1/sr3740x_2' size 30G; | ||
| Zeile 20: | Zeile 208: | ||
SQL> ALTER DATABASE END BACKUP; | SQL> ALTER DATABASE END BACKUP; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==== SYSTEM Passwort ändern ==== | |||
sqlplus / as sysdba | |||
ALTER USER system IDENTIFIED BY "<PASSWORT>"; | |||
=== PSAPUNDO - Undo Tablespace === | === PSAPUNDO - Undo Tablespace === | ||
<syntaxhighlight lang="" line="1"> | <syntaxhighlight lang="sql" line="1"> | ||
SELECT file_name, | SELECT file_name, | ||
tablespace_name, | tablespace_name, | ||
Aktuelle Version vom 1. November 2025, 20:09 Uhr
Beschreibung
Download
Installation
Konfiguration
SAP* löschen
sqlplus / as sysdba
DELETE FROM SAPSR3.USR02 WHERE MANDT = '000' AND BNAME = 'SAP*';
COMMIT;Tablespaces und Files anzeigen lassen
SELECT file_name, bytes/1024/1024 AS size_mb FROM dba_data_files WHERE tablespace_name = 'PSAPSR3' ORDER BY file_name;Tablespace anlegen
CREATE TABLESPACE PSAPSR3740X DATAFILE '/oracle/PZ0/sapdata1/sr3740x_1' SIZE 10M;
Erweiterung ohne ASM
Tablespace-Belegung ermitteln
Belegung aller Tablespaces in Prozent ermitteln:
with MBYTES as(
select tablespace_name,
SUM(bytes)/1024/1024 as Akt,
SUM(decode(maxbytes,0,bytes,maxbytes))/1024/1024 as ZMax
from dba_data_files
group by tablespace_name
),
MFREE as(
select tablespace_name,
SUM(bytes)/1024/1024 as Free
from dba_free_space
group by tablespace_name
)
select MBYTES.tablespace_name,
ROUND((AKT-FREE)/ZMAX*100,2) as BelegtProz
from MBYTES, MFREE
where MFREE.tablespace_name = MBYTES.tablespace_name
order by ROUND((AKT-FREE)/ZMAX*100,2) desc;Beispiel-Ergebnis:
TABLESPACE_NAME BELEGTPROZ ------------------------------ ---------- PSAPSR3 89.43 PSAPSR3702 33.32 PSAPSR3USR 20.26 PSAPUNDO 6.55 SYSTEM 5.05 SYSAUX 4.05
Verfügbaren Speicherplatz ermitteln
Im Betriebssystem ermitteln, in welchem data-Laufwerk am meisten Platz für die Erweiterung vorhanden ist:
df -h | grep oracleBeispiel-Ausgabe:
p11data01/data01 98G 68G 30G 70% /oracle/P11/data01 p11data02/data02 215G 172G 43G 81% /oracle/P11/data02 p11data03/data03 98G 51G 47G 52% /oracle/P11/data03
An der Datenbank anmelden
sqlplus / as sysdbaAusgabe formatieren
Für eine übersichtlichere Darstellung:
set pages 9999
set lin 180
col file_name for a60Datafiles anzeigen
Datafiles zum Tablespace anzeigen:
select file_name, bytes/1024/1024
from dba_data_files
where tablespace_name = '<TABLESPACE>';Beispiel-Ausgabe:
FILE_NAME BYTES/1024/1024 ------------------------------------------------------------ --------------- /oracle/P11/data01/beispiel_data_01.dbf 20480 /oracle/P11/data02/beispiel_data_02.dbf 20480 /oracle/P11/data03/beispiel_data_03.dbf 30720 /oracle/P11/data02/beispiel_data_04.dbf 20480
Datafile erweitern
Existierendes Datafile vergrößern
Wenn ein Datafile erweitert werden kann:
alter database datafile '/oracle/P11/data02/beispiel_04.dbf' resize 30G;Überwachung auf OS-Ebene:
du -h <FILENAME>Kontrolle:
select file_name, bytes/1024/1024
from dba_data_files
where tablespace_name = '<TABLESPACE>';Beispiel nach Erweiterung:
FILE_NAME BYTES/1024/1024 ------------------------------------------------------------ --------------- /oracle/P11/data01/beispiel_data_01.dbf 20480 /oracle/P11/data02/beispiel_data_02.dbf 20480 /oracle/P11/data03/beispiel_data_03.dbf 30720 /oracle/P11/data02/beispiel_data_04.dbf 30720
Neues Datafile anlegen
Falls kein existierendes Datafile erweitert werden kann:
alter tablespace BEISPIEL add datafile '/oracle/P11/data03/beispiel.dbf' size 100M;Überwachung auf OS-Ebene:
du -h <FILENAME>Kontrolle:
select file_name, bytes/1024/1024
from dba_data_files
where tablespace_name = '<TABLESPACE>';Beispiel nach Anlegen:
FILE_NAME BYTES/1024/1024 ------------------------------------------------------------ --------------- /oracle/P11/data01/beispiel_data_01.dbf 20480 /oracle/P11/data02/beispiel_data_02.dbf 20480 /oracle/P11/data03/beispiel_data_03.dbf 30720 /oracle/P11/data02/beispiel_data_04.dbf 20480 /oracle/P11/data03/beispiel_data_05.dbf 100
Tempfile erweitern
Tempfiles anzeigen:
select file_name, bytes/1024/1024
from dba_temp_files;Tempfile hinzufügen:
alter tablespace <TABLESPACE> add tempfile '+DATA' size 25G;Tablespace mit neuer Datei erweitern
alter tablespace PSAPSR3740X add datafile '/oracle/PZ0/sapdata1/sr3740x_2' size 30G;
Backupmodus einstellen
Wird benötigt um ggf. die sapdata online kopieren zu können
SQL> ALTER DATABASE BEGIN BACKUP;
To find if database or any tablespace is in backup mode, the status in V$BACKUP is ACTIVE
SQL> select * from v$backup;
SQL> ALTER DATABASE END BACKUP;SYSTEM Passwort ändern
sqlplus / as sysdba ALTER USER system IDENTIFIED BY "<PASSWORT>";
PSAPUNDO - Undo Tablespace
SELECT file_name,
tablespace_name,
autoextensible,
bytes/1024/1024 AS size_mb,
maxbytes/1024/1024 AS max_size_mb
FROM dba_data_files
WHERE tablespace_name = 'PSAPUNDO';
ALTER DATABASE DATAFILE '/oracle/R08/sapdata1/undo_1/undo.data1' AUTOEXTEND ON NEXT 100M MAXSIZE 20G;Update
Test
Freien Speicherplatz anzeigen
select a.tablespace_name, a.free_bytes*100/b.total_bytes as "Free(%)"
from
(select tablespace_name, sum(bytes) free_bytes
from dba_free_space
group by tablespace_name) a,
(select tablespace_name, sum(bytes) total_bytes
from dba_data_files
group by tablespace_name) b
where a.tablespace_name=b.tablespace_name;