Archivi del mese: novembre 2010

Disabilitare/abilitare Spotlight

Disabilitare…

sudo mdutil -a -i off

Abilitare…

sudo mdutil -a -i on

Change request counter ::: Ultima change request creata

Il contatore delle change request è contenuto nella tabella E070L, liberamente modificabile.

 

Oracle & Jobs

Per ottenere l’elenco dei job:

select job_name,state from DBA_SCHEDULER_JOBS;

JOB_NAME STATE

—————————— —————
PURGE_LOG                                  SCHEDULED
FGR$AUTOPURGE_JOB             DISABLED
GATHER_STATS_JOB                 SCHEDULED
AUTO_SPACE_ADVISOR_JOB SCHEDULED
MGMT_CONFIG_JOB                   SCHEDULED
MGMT_STATS_CONFIG_JOB    SCHEDULED

Per disabilitare un job:

Exec DBMS_SCHEDULER.DISABLE(‘AUTO_SPACE_ADVISOR_JOB’);

Per abilitare un job:

Exec DBMS_SCHEDULER.enable(‘AUTO_SPACE_ADVISOR_JOB’);

Query con le istruzioni più pesanti

SELECT *
FROM (SELECT RANK () OVER (PARTITION BY “Snap Day” ORDER BY “CPU Time”
+ “Disk Reads”
+ “Buffer Gets”
+ “Writes”
+ “Sorts”
+ “Parses” DESC) AS “Rank”,
i1.*
FROM (SELECT TO_CHAR (hs.begin_interval_time,
‘MM/DD/YY’
) “Snap Day”,
shs.sql_id “Sql id”,
REPLACE
(CAST
(DBMS_LOB.SUBSTR (sht.sql_text, 40) AS VARCHAR (40)
),
CHR (10),

) “Sql”,
SUM (shs.executions_delta) “Execs”,
ROUND ( (SUM (shs.elapsed_time_delta) / 1000000)
/ SUM (shs.executions_delta),
1
) “Time Ea Sec”,
ROUND ( (SUM (shs.cpu_time_delta) / 1000000)
/ SUM (shs.executions_delta),
1
) “CPU Ea Sec”,
ROUND ( (SUM (shs.iowait_delta) / 1000000)
/ SUM (shs.executions_delta),
1
) “IO/Wait Ea Sec”,
SUM (shs.cpu_time_delta) “CPU Time”,
SUM (shs.disk_reads_delta) “Disk Reads”,
SUM (shs.buffer_gets_delta) “Buffer Gets”,
SUM (shs.direct_writes_delta) “Writes”,
SUM (shs.parse_calls_delta) “Parses”,
SUM (shs.sorts_delta) “Sorts”,
SUM (shs.elapsed_time_delta) “Elapsed”
FROM dba_hist_sqlstat shs INNER JOIN dba_hist_sqltext sht
ON (sht.sql_id = shs.sql_id)
INNER JOIN dba_hist_snapshot hs
ON (shs.snap_id = hs.snap_id)
HAVING SUM (shs.executions_delta) > 0
GROUP BY shs.sql_id,
TO_CHAR (hs.begin_interval_time, ‘MM/DD/YY’),
CAST (DBMS_LOB.SUBSTR (sht.sql_text, 40) AS VARCHAR (40)
)
ORDER BY “Snap Day” DESC) i1
ORDER BY “Snap Day” DESC)
WHERE “Rank” <= 20 AND “Snap Day” = TO_CHAR (SYSDATE, ‘MM/DD/YY’);

Antivirus per Mac? …a cosa servono?

Vi segnalo l’esistenza di due antivirus per Mac.  In teoria non ce ne sarebbe bisogno, il Mac di suo è molto meno vulnerabile rispetto a Windows,  sono interessanti anche per chi usa Boot Camp o applicazioni di virtualizzazione quali Parallels Desktop o VMware, ma anche per chi riceve e invia file da e verso utenti Windows; gli utenti Mac, infatti, potrebbero essere sfruttati come “portatori sani” di virus e malware: file eseguibili o altri documenti infetti che hanno come target i PC, benché non possano attaccare Mac OS X, potrebbero essere a insaputa dell’ignaro utente Mac inviati a utenti di PC con Windows .

Questi due sono quelli provati: Sophos e ClamXav

http://www.sophos.com/products/free-tools/free-mac-anti-virus/tech-specs.html

http://www.clamxav.com/

 

 

 

Oracle hot-stand-by how-to

Come attivare un sistema Oracle hot-stand-by? Ecco come fare.

1. Install a target SAP instance on serverTGT with same sid XYZ.  This can be done either by a fresh install, or by copying over SAP/Oracle executables.

2. Create a standby controlfile on serverSRC to be used on serverTGT:
a)    sqlplus “/ as sysdba”
b)    alter database create standby controlfile as ‘cntrlXYZ.stdby’;

Copy standby controlfile to serverTGT and rename as cntrlXYZ.dbf.  Ensure it is copied to all 3 locations.

3. Make Net8 configuration and Oracle Instance adjustments:
a)    $ORACLE_HOME/network/admin/

tnsnames.ora 

The standby instance needs to be able to communicate with the SRC so add a section with a new SID that points to serverSRC and the correct listener port ons erverTGT i.e. ABC.

The new SID can be anything you want it to be, it’s only used by Oracle net8 to communication with the SRC instance and is not used anywhere else.

For example, primary database is called DTS.  This is actually the Source database on source server:

DTS.WORLD=
(DESCRIPTION =
(SDU = 32768)
(ADDRESS_LIST =
(ADDRESS =
(COMMUNITY = SAP.WORLD)
(PROTOCOL = IPC)
(KEY = DTS)
)
(ADDRESS =
(COMMUNITY = SAP.WORLD)
(PROTOCOL = TCP)
(HOST = <source-server-name>)
(PORT = 1527)
)
)
(CONNECT_DATA =
(SID = <SOURCE SID>)
(GLOBAL_NAME = <SOURCE SID>.WORLD)
)
)

b)    $ORACLE_HOME /dbs/initZYX.sap
Add line primary_db = ABC (if ABC was the SID added to tnsnames.ora)
This will be used by brarchive to communicate with serverSRC when it applies logfiles to serverTGT.

4. Start up standby database:
a)    sqlplus “/ as sysdba”
b)    startup nomount;
c)     alter database mount standby database;

The standby database should now be in active standby mode.

5. The next step is to automatically get offline redolog files from serverSRC and apply to serverTGT.
This is done using brarchive on both serverSRC and serverTGT, with serverSRC sending files across an NFS mount (serverd from serverTGT).

Alternatively, they could be FTP’d automatically with brarchive.

On serverTGT:
a)    export /oracle/XYZ/saparch ensuring serverSRC is in access list.

On serverSRC:
a)    mount /oracle/XYZ/saparch from serverTGT onto a local mount point i.e. /usr/redolog/saparchXYZ.
b)     adjust initXYZ.sap as follows:

a.     archive_copy_dir = /usr/redolog/saparchXYZ (see step a)
b.     archive_stage_dir = /usr/redolog/saparchXYZ (see step a)

Test this as user oraxyz by typing: brarchive -s -d disk -w -c force -u /

This should start brarchive and will save and offline redolog files to /usr/redolog/saparchXYZ.  Once all files have been saved the brarchive command exits as normal.

Another similar command is: brarchive -s -d disk –f -w -c  force -u /

This command will perform the same as the command above but will then wait, after all files have been saved, for the next offline file and perform the same action.

The only way to abort this cleanly is to issue another command on another terminal session as follows: brarchive –c –u / -f stop

6. The final step is to ensure that the files are applied to the standby database, and removed from the file-system on serverTGT.  This is done as follows:
a)    Read oss note 216108 and make appropriate changes to initXYZ.sap.
b)    Create a script called recovery.ksh containing:

#!/bin/ksh

export SID=XYZ
export ORACLE_SID=$SID
export ORACLE_HOME=/oracle/$SID/102_64
export SAPDATA_HOME=/oracle/$SID
export ORACLE_BASE=/oracle
export BR_RSH_CMD=true
export BR_RCP_CMD=true

checkfile=/oracle/$SID/saparch/.lock.bra
if [ ! -e $checkfile ]
then
/sapmnt/$SID/exe/brarchive -sd -d disk -m 1 -f -c force -u /
else
echo “`date` – brarchive currently running”
fi

Run this script.  It will apply redologs to the standby instance and will then delete any logs it has successfully applied from serverTGT.  This way, no manual cleanup is required.

After applying/deleting logs, the script will wait for more logs.

The brarchive command will fail if /oracle/<SID>/saparch contains any offline log files that are older than is necessary.

7. Activation is easy.
All this is done on serverTGT.
Ensure all available logs have been applied, or at least up to the point you need.
Then brarchive needs to be killed:  brarchive –c –u / -f stop
Ensure the recovery.ksh script is no longer going to run from crontab.

Check the directories required for PSAPTEMP datafiles exist.
Otherwise, the database creation will work but there will be a missing datafile and using the normal method of adding PSAPTEMP after a refresh will not work.

The simple solution, if this situation happens, is to create the directories and stop/restart database.

Alternatively, add another datafile to PSAPTEMP using the normal PSAPTEMP SQL statement, but giving a new datafile name.

Remove the reference to primary_db in $ORACLE_HOME/dbs/init<SID>.sap.
As ora<sid>, activate as follows:
a)    sqlplus “/ as sysdba”
b)    alter database activate standby database;
This will create controlfiles, online logfiles etc.
c)     alter database open;
d)    recreate PSAPTEMP if necessary

Once activated, start the oracle listener and check brconnect or sapdba can connect to the database.

[Ringrazio Stephen Kerr per questi preziosi appunti]