https://www.mssqltips.com/sqlservertip/1715/scheduling-a-sql-server-profiler-trace/
gyrfalcon.bi_test.trc_dexter
job
SqlTrace
https://www.mssqltips.com/sqlservertip/1715/scheduling-a-sql-server-profiler-trace/
gyrfalcon.bi_test.trc_dexter
job
SqlTrace
FINAL ACTION PLAN
###################https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=446100599746504&id=759225.1&_afrWindowMode=0&_adf.ctrl-state=ewe2g0oce_53
https://abduulwasiq.blogspot.com/2013/09/if-we-lost-contextfile.html
--List of Sysadmin
SELECT 'Name' = sp.NAME
,sp.is_disabled AS [Is_disabled]
FROM sys.server_role_members rm
,sys.server_principals sp
WHERE rm.role_principal_id = SUSER_ID('Sysadmin')
AND rm.member_principal_id = sp.principal_id;
--List of role members
SELECT DP1.name AS DatabaseRoleName,
isnull (DP2.name, 'No members') AS DatabaseUserName
FROM sys.database_role_members AS DRM
RIGHT OUTER JOIN sys.database_principals AS DP1
ON DRM.role_principal_id = DP1.principal_id
LEFT OUTER JOIN sys.database_principals AS DP2
ON DRM.member_principal_id = DP2.principal_id
WHERE DP1.type = 'R'
--dumps
select * from sys.server_role_members;
select * from sys.server_principals;
select * from sys.database_role_members;
select * from sys.database_principals;
There was this situation when our oracle audit log suddenly exploded when one of the users ran a procedure. This caused the system tablespace to grow from 1G to 32G in a span of 8 hours.
This was caused by the audit table is in the system tablespace.
Below are the following steps to move the default audit log to a different tablespace.
Migrate the AUDIT tables to a dedicated tablespace
STEP 1
TABLE_NAME TABLESPACE_NAME
-------------------- ------------------------------
AUD$ SYSTEM
FGA_LOG$ SYSTEM
STEP 2
CREATE TABLESPACE
CREATE TABLESPACE ORA_AUDIT
DATAFILE '/logs/oradata/EPWEBP/ora_audit1.dbf'
SIZE 3G;
CREATE TABLESPACE ORA_AUDIT_ARCHIVE
DATAFILE '/logs/oradata/EPWEBP/audit_archive1.dbf'
SIZE 3G;
STEP 3
--this moves table FGA_LOG$
Run as system
STEP 4 ARCHIVE CURRENT AUDIT LOG
CREATE TABLE AUDIT_10272020 TABLESPACE ORA_AUDIT_ARCHIVE as select * from SYS.AUD$;
TRUNCATE TABLE sys.aud$;
ALTER DATABASE
TEMPFILE '/logs/oradata/EPCHRS/temp01.dbf'
AUTOEXTEND ON
NEXT 10M
MAXSIZE UNLIMITED;
This happened to me when I cloned a VM.
[oracle@serpentcustom logs]$ lsnrctl status
LSNRCTL for Linux: Version 18.0.0.0.0 - Production on 21-OCT-2020 20:19:59
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=serpentcustom.ecp.priv)( PORT=1521)))
TNS-01189: The listener could not authenticate the user
portalgun:/dbapps/webapps/reports/Loader>load_ep_delivery_documents.sh
-bash: load_ep_delivery_documents.sh: command not found
portalgun:/dbapps/webapps/reports/Loader>
CREATE USER READ_ONLY IDENTIFIED BY "password";
GRANT CREATE SESSION TO READ_ONLY;
SET HEADING OFF
SET PAGES 9999 LINES 400
SPOOL TABLE_GRANTS.sql
SELECT 'GRANT READ ON ' || OWNER || '.' || TABLE_NAME || ' TO READ_ONLY;'
FROM DBA_TABLES
WHERE OWNER IN ('PRESS')
ORDER BY 1;
SELECT 'CREATE SYNONYM RO_CAPEX.'||TABLE_NAME|| ' FOR ' || OWNER || '.' || TABLE_NAME || ';'
FROM DBA_TABLES
WHERE OWNER IN ('PRESS')
ORDER BY 1;
SPOOL OFF
@TABLE_GRANTS.sql
!rm TABLE_GRANTS.sql
--Password History
select
name,
password_date
from
sys.user$,
sys.user_history$
where
user$.user# = user_history$.user#;
--Password Expired
select name,type#,ptime,exptime,ltime, lcount from sys.user$ where type#=1;
select name,type#,ptime,exptime from sys.user$ where type#=1 order by exptime;
--Password history
select
name,
password_date
from
sys.user$,
sys.user_history$
where
name='DAV4635'
and
user$.user# = user_history$.user#;
--show logon failures
select dbusername,client_program_name,terminal,os_username,action_name, unified_audit_policies from unified_audit_trail
where unified_audit_policies='ORA_LOGON_FAILURES' order by event_timestamp desc ;
Dennis asked me to help in connection POWER BI to Nagios
Follow this steps
1.
Download MariaDB connector https://downloads.mariadb.com/Connectors/odbc/connector-odbc-3.1.9/ or use the attached one.
2.
Install mariadb
3.
Choose typical >Install>finish
4.
Open ODBC 64 bit
5.
Add> Maria DB ODBC> Finish
6.
Name: Nagios_Test
7.
8.
9.
User:ro_chow/dropwater
10.
Click Next until finish
11.
Connect using Power BI
12.
13.
Have fun!!!
mysql -u root -p'nagiosxi'
MariaDB [nagiosxi]> create user 'ro_chow'@'%' identified by 'dropwater';
Query OK, 0 rows affected (0.05 sec)
MariaDB [nagiosxi]> grant select on nagiosxi.* to 'ro_chow'@'%';
Query OK, 0 rows affected (0.00 sec)
MariaDB [nagiosxi]> flush privileges;
Type CREATE USER 'troy'@'%' IDENTIFIED BY 'troypassword'; and press Enter
o Type GRANT ALL PRIVILEGES ON *.* TO 'troy'@'%' WITH GRANT OPTION; and press Enter
o Type CREATE USER 'troy'@'localhost' IDENTIFIED BY 'troy'; and press Enter
o Type GRANT ALL PRIVILEGES ON *.* TO 'troy'@'localhost' WITH GRANT OPTION; and press Enter
o Type exit and press Enter
CREATE USER 'tony'@'%' IDENTIFIED BY 'Password'; and press Enter
o Type GRANT ALL PRIVILEGES ON *.* TO 'tony'@'%' WITH GRANT OPTION; and press Enter
o Type CREATE USER 'tony'@'localhost' IDENTIFIED BY Password'; and press Enter
o Type GRANT ALL PRIVILEGES ON *.* TO 'tony'@'localhost' WITH GRANT OPTION; and press Enter
o Type exit and press Enter
Open a command prompt
C:\WINDOWS\system32>runas /user:ecp\admdvelasco cmd.exe
this will open another window
Microsoft Windows [Version 10.0.16299.1087]
(c) 2017 Microsoft Corporation. All rights reserved.
C:\WINDOWS\system32>sqlcmd -S spectre
1> select name from sys.databases
2> go
name
--------------------------------------------------------------------------------------------------------------------------------
master
tempdb
model
msdb
eTraceOneToOne
While playing with the DB, I was curious what will happen if I set the max memory of the sql server instance to 10mb.
So it crashed.
Now I cannot restart it.
This is how I fixed it.
Step 1 start the sqlserver instance with minimum settings.
1. open a command prompt as an administrator
select 'drop '||object_type||' &owner..'|| object_name || ';' from dba_objects WHERE OWNER=UPPER('&owner') and object_type in ('TABLE','VIEW','PACKAGE','SEQUENCE', 'PROCEDURE', 'FUNCTION', 'INDEX');
CREATE USER READ_ONLY IDENTIFIED BY "password";
GRANT CREATE SESSION TO READ_ONLY;
SET HEADING OFF
SET PAGES 9999 LINES 400
SPOOL TABLE_GRANTS.sql
SELECT 'GRANT READ ON ' || OWNER || '.' || TABLE_NAME || ' TO READ_ONLY;'
FROM DBA_TABLES
WHERE OWNER IN ('ZEDDBA')
ORDER BY 1;
SPOOL OFF
@TABLE_GRANTS.sql
!rm TABLE_GRANTS.sql
10 Mistakes We Are Doing
; WITH bus AS (
SELECT database_name, machine_name, backup_finish_date, media_set_id, type,msdb.dbo.backupset.software_vendor_id,
msdb.dbo.backupset.user_name,
row_number () OVER(PARTITION BY database_name ORDER BY backup_finish_date DESC) AS rowno
FROM msdb.dbo.backupset
)
SELECT bus.machine_name AS ServerName, sdb.Name AS DatabaseName,
COALESCE(convert(varchar(23), bus.backup_finish_date), 'No backup') AS BackupTime ,
CASE bus.type
WHEN 'D' THEN 'Database'
WHEN 'L' THEN 'Log File'
WHEN 'I' THEN 'Differential'
END AS BackupType,software_vendor_id,user_name,
busf.physical_device_name AS Location
FROM sys.databases sdb
LEFT OUTER JOIN bus ON bus.database_name = sdb.name AND rowno <= 2
LEFT OUTER JOIN msdb.dbo.backupmediafamily busf ON busf.media_set_id = bus.media_set_id
WHERE database_id > 4
ORDER BY bus.machine_name
cd tomcat/lib
java -cp catalina.jar org.apache.catalina.util.ServerInfo
! HPRD:atlas.ecp.priv:/dbapps/oracle> sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Tue Aug 18 02:40:33 2020
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> audit create session whenever not successful;
select os_username, username, userhost, to_char(timestamp,'mm/dd/yyyy hh24:mi:ss')
logon_time, action_name, returncode from dba_audit_session order by 4 desc;
sudo visudo
oracle ALL=(root) ALL
admrcavan ALL=(applmgr) NOPASSWD:ALL
admrcavan@apollo's password:
Last login: Mon Aug 10 18:02:52 2020 from 10.162.91.247
[admrcavan@apollo ~]$ sudo -iu applmgr
apollo:/dbapps/applmgr/HRD2/apps/apps_st/appl>
You should periodically archive and then purge the audit trail to prevent it from growing too large.
Archiving and purging both frees audit trail space and facilitates the purging of the database audit trail.
You can create an archive of the unified and traditional database audit trail by using Oracle Audit Vault and Database Firewall. You install Oracle Audit Vault and Database Firewall separately from Oracle Database.
After you complete the archive, you can purge the database audit trail contents.
To archive the unified, traditional standard, and traditional fine-grained audit records, copy the relevant records to a normal database table.
For example:
INSERT INTO table SELECT ... FROM UNIFIED_AUDIT_TRAIL ...; INSERT INTO table SELECT ... FROM SYS.AUD$ ...; INSERT INTO table SELECT ... FROM SYS.FGA_LOG$ ...;
DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL
PL/SQL procedure:DBMS_AUDIT_MGMT
package does not support cleanup of Windows Event Viewer, setting the AUDIT_TRAIL_TYPE
property to DBMS_AUDIT_MGMT.AUDIT_TRAIL_OS
has no effect. This is because operating system audit records on Windows are written to Windows Event Viewer. The DBMS_AUDIT_MGMT
package does not support this type of cleanup operation.AUDIT_SYSLOG_LEVEL
initialization parameter to a valid value as listed in Oracle Database Reference, then Oracle Database writes the operating system log files to syslog files. If you set the AUDIT_TRAIL_TYPE
property to DBMS_AUDIT_MGMT.AUDIT_TRAIL_OS
, then the procedure only removes .aud
files under audit directory (This directory is specified by the AUDIT_FILE_DEST
initialization parameter).AUDIT_TRAIL_TYPE
parameter is set to DBMS_AUDIT_MGMT.AUDIT_TRAIL_XML
, this procedure only cleans up XML audit files (.xml
) in the current audit directory. Oracle Database maintains an index file, called adx_
$ORACLE_SID
.txt
, which lists the XML files that were generated by the XML auditing. The cleanup procedure does not remove this file.DBMS_AUDIT_MGMT.INIT_CLEANUP
procedure, and then purging the database audit trail by using the method described in "Purging a Subset of Records from the Database Audit Trail".DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL
PL/SQL procedure.BEGIN DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL( AUDIT_TRAIL_TYPE => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD, USE_LAST_ARCH_TIMESTAMP => TRUE ); END; /
AUDIT_TRAIL_TYPE
: Enter one of the following values:DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD
: Standard audit trail table, AUD$
DBMS_AUDIT_MGMT.AUDIT_TRAIL_FGA_STD
: Fine-grained audit trail table, FGA_LOG$
DBMS_AUDIT_MGMT.AUDIT_TRAIL_DB_STD
: Both standard and fine-grained audit trail tablesDBMS_AUDIT_MGMT.AUDIT_TRAIL_OS
: Operating system audit trail files with the .aud
extension. (This setting does not apply to Windows Event Log entries.)DBMS_AUDIT_MGMT.AUDIT_TRAIL_XML
: XML audit trail filesDBMS_AUDIT_MGMT.AUDIT_TRAIL_FILES
: Both operating system and XML audit trail filesDBMS_AUDIT_MGMT.AUDIT_TRAIL_ALL
: All audit trail records, that is, both database audit trail and operating system audit trail typesUSE_LAST_ARCH_TIMESTAMP
: Enter either of the following settings:TRUE
: Deletes audit records created before the last archive timestamp. To set the archive timestamp, see "Step 4: Optionally, Set an Archive Timestamp for Audit Records". The default (and recommended) value is TRUE
. Oracle recommends that you set USE_LAST_ARCH_TIMESTAMP
to TRUE
.FALSE
: Deletes all audit records without considering last archive timestamp. Be careful about using this setting, in case you inadvertently delete audit records that should have been deleted.SYSTEM
tablespace.DELETE FROM SYS.AUD$ WHERE NTIMESTAMP# > TO_TIMESTAMP ('28-FEB-09 09.07.59.907000 PM') AND NTIMESTAMP# < TO_TIMESTAMP ('28-MAR-09 09.07.59.907000 PM');
DELETE FROM SYS.AUD$;
SYS
or a user to whom SYS
granted the DELETE
privilege on SYS.AUD$
can delete records from the database audit trail.