martes, 27 de octubre de 2020
ORACLE LINUX REPOSITORIO
lunes, 26 de octubre de 2020
VISTA ARCHIVOS DE TRACE V$DIAG_INFO
VISTA PROCESOS V$BGPROCESS
VISTAS ARCHIVOS ORACLE DBA_DATA_FILES - DBA_TEMP_FILES
viernes, 23 de octubre de 2020
DB_FLASHBACK_RETENTION_TARGET
Configuration Best Practices
- Set DB_FLASHBACK_RETENTION_TARGET correctly. Set DB_FLASHBACK_RETENTION_TARGET initialization parameter to the largest value prescribed by any of the following conditions that apply:
- To leverage flashback database to reinstate your failed primary database after Data Guard failover, for most cases set DB_FLASHBACK_RETENTION_TARGET to a minimum of 60 (minutes) to enable reinstatement of a failed primary.
- Consider cases where there are multiple outages (e.g. first a network outage, followed later by a primary database outage) that may result in a transport lag between primary and standby database at failover time. For such cases set DB_FLASHBACK_RETENTION_TARGET to a value equal to the sum of 60 (mins) plus the maximum transport lag that you wish to accommodate. This will insure that the failed primary database can be flashed back to an SCN that precedes the SCN at which the standby became primary - a requirement for primary reinstatement.
- If using Flashback Database for fast point in time recovery from user error or logical corruptions, set DB_FLASHBACK_RETENTION_TARGET to a value equal to the farthest time in the past that you wish to be able to recover to.
- Set Primary and Standby DB_FLASHBACK_RETENTION_TARGET to be the same.
- Size Fast Recovery Area (FRA). Ensure the fast recovery area has allocated sufficient space to accommodate flashback database flashback logs for the target retention size and for peak batch rates. Sizing the fast recovery area is described in detail in the 10g Database Backup and Recovery Basics guide and the 11g Database Backup and Recovery User's Guide / 12c Database Backup and Recovery User's Guide but the general rule of thumb is the volume of flashback log generation is approximately the same order of magnitude as redo log generation. Use the following conservative formula and approach
Target FRA = Current FRA + DB_FLASHBACK_RETENTION_TARGET x 60 x Peak Redo Rate (MB/sec)
Example:
- Current FRA or DB_RECOVERY_FILE_DEST_SIZE=1000G
- Target DB_FLASHBACK_RETENTION_TARGET=360 (360 minutes)
- From AWR: 1) Peak redo rate for OLTP workload is 3 MB/sec for database. 2) Peak redo rate for batch workload is 30 MB/sec for database and longest duration is 4 hours. 3) worst-case redo generation size for 6 hour window is ( 240 minutes x 30 MB/sec x 60 secs/min) + (120 minutes x 3 MB/sec x 60 secs/min ) = 453,600 MB or approx 443 GB
- Proposed FRA or DB_RECOVERY_FILE_DEST_SIZE= 443 GB +1000 GB = 1443 GB.
An additional method to determine fast recovery area sizing is to enable flashback database and allow the database applications to run for a short period (2-3 hours) and query V$FLASHBACK_DATABASE_STAT.ESTIMATED_FLASHBACK_SIZE.
Note that the DB_FLASHBACK_RETENTION_TARGET is a target and there is no guarantee that you can flashback the database that far. In some cases if there is space pressure in the flash recovery area where the flashback logs are stored then the oldest flashback logs may be deleted. For a detailed explanation of the flash recovery area deletion rules see the Database Backup and Recovery User's Guide, Maintaining the Fast Recovery Area section. To guarantee a flashback point-in-time you must use guaranteed restore points (GRP). With GRP, the required flashback logs will never be recycled or purged until GRP is dropped. You can hang the database if you have a GRP and there’s insufficient space; so you need allocate more space in the FRA depending on the intended duration of the GRP.
- Configure sufficient I/O bandwidth for Fast Recovery Area. Insufficient I/O bandwidth with flashback database on is usually indicated by a high occurrence of the "FLASHBACK BUF FREE BY RVWR" wait event in an Automatic Workload Repository (AWR) report for OLTP workloads and “FLASHBACK LOG FILE WRITE” latency > 30 ms for large insert operations. In general, flashback IOs are 1 MB in size and the overall write throughput will be similar to the redo generation rate if database force logging was enabled or similar to your load rate for direct load operations. For simplicity, configure one large shared storage GRID and configure DATA on the outer portion of the disks or LUNS and RECO (fast recovery area) on the inner portion of the disks or LUNS.
- Recommended LOG_BUFFER settings to give flashback database more buffer space in memory.
Recommend to set the LOG_BUFFER to maximum value for the specific database release and platform.
The previous 8 MB recommendation does not work well in high throughput applications with flashback database enabled.
We now recommend 64 MB for 32-bit systems
and up to 256 MB for 64-bit systems - Set _DB_FLASHBACK_LOG_MIN_SIZE = <redo log size> for any 11.2.0.2 release. In previous releases, the initially flashback log allocations are hindered because the initial file sizes are too small which may impact primary load performance. As of 11.2.0.3, the default min size is the redo log group size which is the prescribed best practice. This enhancement is not available in Oracle 10g so customers may experience some additional performance overhead until DB_FLASHBACK_RETENTION_TARGET is met
Example:
SQL> alter system set "_db_flashback_log_min_size"=4g;
- Set _DB_FLASHBACK_LOG_MIN_TOTAL_SPACE =< projected flashback size> temporarily if you want to pre-allocate flashback logs in the FRA but you must add more space to FRA beforehand. This is normally unnecessary since Oracle will allocate flashback logs as you generate changes. We do recommend enabling flashback database at a non-peak period especially avoiding periods immediately prior to or during your direct load operations. You can then monitor by querying V$FLASHBACK_DATABASE_LOG.FLASHBACK_SIZE. Setting this undocumented parameter may be useful if you want to create a guaranteed restore point or enable flashback database prior to a big load and you want to quickly pre-allocate the necessary flashback logs.
Example:
SQL> alter system set "_db_flashback_log_min_size"=4g;
SQL> alter system set "_db_flashback_log_min_total_space"=50g;
Wait 5 minutes and query “select flashback_size from V$flashback_database_log;” Repeat until flashback target minimum size is met. When completed unset _DB_FLASHBACK_LOG_MIN_TOTAL_SPACE.
Operational Best Practices
- Gather database statistics using Automatic Workload Repository (AWR), Enterprise Manager before and after enabling flashback database so you can measure the impact of enabling flashback database.
- Set the Enterprise Manager monitoring metric, "Recovery Area Free Space (%)" for proactive alerts of space issues with the fast recovery area.
- From 11.2 onward, you can enable flashback database while the database is open. However this operation may fail and signal an error if it fails to get enough contiguous memory. To guarantee success, you can enable flashback in mount mode.
- To monitor the progress of a flashback database operation you can query the V$SESSION_LONGOPS view. An example query to monitor progress is:
select * from v$session_longops where opname like 'Flashback%';
If more detail is required on the flashback database operation then set _FLASHBACK_VERBOSE_INFO=TRUE database parameter which will generate a detailed trace of the flashback database operation in the DIAGNOSTIC_DEST trace directory for the database
- When using flashback database to perform repeated tests on a test database, it is recommended to use Guaranteed Restore Points (GRP) only without explicitly turning on flashback database. To minimize space usage and flashback performance overhead, follow this recommended approach:
Create Guaranteed Restore Point (GRP)
Execute test
loop
Flashback database to GRP
Open resetlogs
Create new GRP
Drop old GRP
Execute test
End loop
- Follow the Data Guard redo apply best practices described in Best Practices for Data Guard and Active Data Guard Redo Apply Performance.
- Also review the 10g Database Backup and Recovery Basics guide or the 11g Release 2 Backup and Recovery User's Guide.
Performance tuning for specific application use cases
lunes, 19 de octubre de 2020
sqlnet.ora BLOQUEAR ACCESO A ORACLE DESDE UNA IP
1. Bloquear el acceso a Oracle desde una IP
En caso de no tener un firewall para bloquear el acceso de ciertas ips a una base de datos lo podemos realizar a través del sqlnet.ora.
El “secreto” para bloquear o restringir el acceso por IP a la base de datos se realiza en el archivo sqlnet.ora. Este archivo lo podemos encontrar en el directorio $ORACLE_HOME/network/admin junto con los archivos tnsnames.ora y listener.ora
Editamos el archivo sqlnet.ora y añadimos las siguientes líneas:
tcp.validnode_checking = yes
Con esto conseguimos chequear los listeners que tengamos activos.
A continuación escribimos lo siguiente:
tcp.invited_nodes = (hostnameA, hostnameB)
tcp.excluded_nodes = (192.168.2.15)
Con tcp.invited_nodes puedo especificar qué máquinas quiero que su conexión sea aceptada por las base de datos.
Con tcp.excluded_nodes excluimos las máquinas que no queremos que se conecten a las bases de datos.
La idea de este mecanismo es realizar una lista de las máquinas que queremos que se conecten o realizar una lista de las máquinas que no queremos que se conecten a nuestra base de datos.
A pesar de este mecanismo de seguridad, no podemos decir que estemos totalmente exentos de recibir ataques.
Algunas reglas a tener en cuenta para generar la lista de IPS / hostnames invitados o excluidos pueden ser la siguiente:
- Poner todos los nodos excluidos en una única línea.
- Poner todos los nodos invitados en una única línea.
- Se debería incluir en el listado de nodos invitados localhost.
Después de introducir estas reglas en nuestro sqlnet.ora debemos de reiniciar los listeners de la máquina.
Con nuestro usuario oracle realizamos lo siguiente:
$ lsnrctl stop nb_listener
$ lsnrctl start nb_listener
TRIGGER AFTER LOGIN RESTRINGIR SQL DEVELOPER
AFTER LOGON ON DATABASE
DECLARE
osUser VARCHAR2(30);
machine VARCHAR2(100);
prog VARCHAR2(100);
ip_user VARCHAR2(15);
BEGIN
SELECT OSUSER, MACHINE, PROGRAM, ora_client_ip_address
INTO osUser, machine, prog, ip_user
FROM v$session
WHERE SID = SYS_CONTEXT('USERENV', 'SID');
IF (osUser = 'APuente' AND prog = 'SQL Developer')THEN
RAISE_APPLICATION_ERROR(-20000,'Denied! You are not allowed to logon from host '||prog|| ' using '|| osUser);
END IF;
END;
/
VMWARE HERRAMIENTAS
Cross vCenter Workload Migration Utility
Vmware Cross Vcenter Vmotion Utility -> Migracion entre Maquinas virtuales Online VCENTERS
Vmware Vcenter Converter
Verificar la version de vmware tools
miércoles, 14 de octubre de 2020
CREATE SEQUENCES CURRVAL NEXTVAL
lunes, 5 de octubre de 2020
ORATAB CONSULTA BASES DE DATOS EXISTENTES
[oracle@localhost etc]$ pwd
/etc
[oracle@localhost etc]$ cat /etc/oratab
#Backup file is /u01/app/oracle/product/12.1.0/grid/srvm/admin/oratab.bak.localhost line added by Agent
#
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third field indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
orcl:/u01/app/oracle/product/12.1.0/db_1:N
+ASM:/u01/app/oracle/product/12.1.0/grid:N: # line added by Agent
acme:/u01/app/oracle/product/12.1.0/db_1:N: # line added by Agent
[oracle@localhost etc]$