Ramin Hossaini (blog)

16May/10

Oracle: Recycle listener.log

Oracle stores a log-file (listener.log) under $ORACLE_HOME/network/log that keeps track of all connections made to the database.

Oracle keeps this file as an open file-stream, so even if you rename the file, it still keeps on growing as new connections are made.

This method will let you recycle/truncate/purge listener.log without resorting to taking the listener down which would cause a disruption to users.

The idea is to turn log_status off, create a new file, then turn log_status on again

1
2
3
4
$ lsnrctl set log_status off
$ mv listener.log listener.log.old
$ touch listener.log
$ lsnrctl set log_status on
15May/10

Basic Auditing in Oracle

To check if auditing is enabled:

SHOW parameter AUDIT;

To enable auditing, modify/add the following in your PFILE and restart the database:

audit_trail = db;

To audit SELECTs on an object:

AUDIT SELECT ON object;

To list all Audit data on a database:

SELECT * FROM sys.aud$;

Purge/delete entries from the audit table:

DELETE FROM sys.aud$;

To view audit data:

SELECT * FROM sys.aud$;

To disable auditing:

NOAUDIT SELECT ANY TABLE;
25Apr/10

[MySQL] Batch update of all entries in table that match condition

Lest ye forget.

1
UPDATE <table> SET <column>=<value> WHERE <condition>;
Tagged as: No Comments
21Apr/10

Getting rid of Gmail theme-backgrounds

I love that Gmail added theming functionality, but I would actually like some of the themes more without the backgrounds. This isn't a fancy solution, but it's more of a reference for myself. You could also use plugins that let you modify the CSS, but I'm just using Adblock-plus for Firefox here.

Take for instance the Pebbles theme:

Not my cup of tea, but I love those neutral colours.

The easiest thing to do is to add a Block-rule in Adblock-Plus:

1
2
https://mail.google.com/mail/images/2/5/pebbles/rocks_tile.jpg
*/images/2/5/pebbles/rocks_tile.jpg  /*wildcard version - for Google Apps*/

Refresh Gmail, and it's gone:

Other blockable backgrounds (some of the themes are day-of-the-week specific, so I'll add more to the list as I find them):

1
2
3
4
5
6
7
8
9
10
11
12
*images/2/5/pebbles/rocks_tile.jpg
*images/2/5/mountains/mon/*
*images/2/5/mountains/tue/*
*images/2/5/mountains/wed/*
*images/2/5/mountains/thu/*
*images/2/5/mountains/fri/*
*images/2/5/mountains/sat/*
*images/2/5/mountains/sun/*
*images/2/5/tree/sunny/header_bg.jpg
*images/2/5/ocean/weekdays/weekday_header.jpg
*images/2/5/planets/base/star_tile.gif
*images/2/5/planets/saturn/saturn.jpg
18Apr/10

Migrating WordPress

Here are a couple steps I follow each time I move a WordPress instance from one environment to another. I'll assume you're moving from Development to Production.

Database configuration

A migration usually involves changing the database configuration in wp-config.php.

Instead of having to modify the file every time, you could just modify wp-config.php to include something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
if ($_SERVER['HTTP_HOST'] == 'dev') //could be 'localhost' or anything else
{
	define('DB_NAME', 'dev_db_name');
	define('DB_USER', 'dev_user');
	define('DB_PASSWORD', 'dev_password');
	define('DB_HOST', 'localhost');
	define('DB_CHARSET', 'utf8');
	define('DB_COLLATE', '');
}
else
{
	//production config:
	define('DB_NAME', 'prod_db_name');
	define('DB_USER', 'prod_user');
	define('DB_PASSWORD', 'prod_password');
	define('DB_HOST', 'prod_server');
	define('DB_CHARSET', 'utf8');
	define('DB_COLLATE', '');
}

That's one less thing to worry about.

Database Export and Clean-up

I like using PHPMyAdmin for quickly exporting and importing between databases. But regardless of what tool you use, WordPress stores the full URL in the database (something I find very annoying) so you'll also have to clean-up your database - these SQL commands have served me well:

1
2
3
4
5
6
7
8
9
10
11
--
-- run after doing an import
--
UPDATE wp_options SET option_value = REPLACE(option_value, 'http://dev_host', 'http://www.prod_domain') 
WHERE option_name = 'home' OR option_name = 'siteurl';
 
UPDATE wp_posts SET guid = REPLACE(guid, 'http://dev_host','http://www.prod_domain');
 
UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://dev_host', 'http://www.prod_domain');
 
UPDATE wp_options SET option_value = REPLACE(option_value, 'http://dev_host', 'http://www.prod_domain');

.htaccess

Depending on how your development environment differs from production, you might also have to change your .htaccess file. You could of course just edit the file, but I find the easiest for me is to:

  • Log into the WordPress admin (/wp-admin)
  • Expand the Settings tab, then click on Permalinks
  • Clicking on "Save changes" re-writes the .htaccess file

This is a tried and tested method I've been using a lot - but I'm curious to know how you do it. There might be some great plugins or tools that do all (or most) of this for you.

14Apr/10

Recompile invalid objects in an Oracle schema

To compile all procedures, functions, packages, and triggers in a specific schema:

EXEC DBMS_UTILITY.compile_schema(SCHEMA => 'SCHEMA_NAME');
Tagged as: No Comments
14Apr/10

Cancel Oracle shutdown

You might want to cancel a shutdown if you issued the wrong command when there were connected users.

If you try to shutdown immediate from another session, you’ll get this:

SQL> shutdown IMMEDIATE
ORA-24324: service handle NOT initialized
ORA-24323: VALUE NOT allowed
ORA-01089: IMMEDIATE shutdown IN progress - no operations are permitted

When you issue a shutdown, only the SYS/SYSTEM user will be able to connect, so open another SQL*Plus session and type this:

CONNECT /AS sysdba
startup force
Tagged as: No Comments
Page 2 of 612345Last »
Bear