0

OPTIMIZE all MySQL database tables via ColdFusion

ColdFusion, MySQL

Ever want to run a script that does an OPTIMIZE of all tables in your database? First off, you can do this with a shell script or cron job with something like: "

mysqlcheck -u root -p --auto-repair --check --optimize --all-databases
"

But what if you, say, don't have a full-time DBA on staff, and want to run these on a schedule which you can easily control with ColdFusion? That was our situation, and so here's what I came up with. We ran it last weekend during our scheduled "maintenance window" and it took about 90 minutes with no downtime on a MySQL 5.1 18G database

(disclaimer: the speed of this process may vary, depending on numerous variables such as hardware, memory, version of MySQL, etc.)


<!--- set these according to your database size: 14400 and 1800 were used after extensive testing
	on a system with 8G ram and quad core in 2009 for an 18G database; you can easily try different
	values here by trying them in the URL
	(ex: /OPTIMIZE_ALL_DB_tables.cfm?queryTimeout=5&numOfTables=5) --->
<cfparam name="URL.RequestTimeout" default="14400">
<cfparam name="URL.queryTimeout" default="1800">
<cfparam name="URL.myDatasource" default="my_database">
<cfparam name="URL.numOfTables" default="1000000">

<!--- set u/p to one that has permissions to run OPTIMIZE & FLUSH on your tables --->
<cfset Variables.myUsername = "db_user">
<cfset Variables.myPass = "my_password">
<cfset Variables.toAddresses = "webmaster@mydomain.com;aaron@mydomain.com">
<cfset Variables.fromAddress = "webmaster@mydomain.com">

<cfsetting requesttimeout="#URL.RequestTimeout#">


<!--- get host and instance if they don't already exist --->
<cfif NOT IsDefined("Server.hostName")>

	<cftry>
		<cfset local.oInetAddress = CreateObject("java", "java.net.InetAddress")>
		<cfset Server.hostName = local.oInetAddress.getLocalHost().getHostName()>

		<cfcatch type="application">
			<cfset Server.hostName = "Could not determine with java.net.InetAddress">
		</cfcatch>
	</cftry>

</cfif>

<cfif NOT IsDefined("Server.instanceName")>

	<cftry>
		<cfset local.oJRun = CreateObject("Java", "jrunx.kernel.JRun")>
		<cfset Server.instanceName = local.oJRun.getServerName()>

		<cfcatch type="application">
			<cfset Server.instanceName = "Could not determine with jrunx.kernel.JRun">
		</cfcatch>
	</cftry>

</cfif>



<cfquery name="rsAllTables"
		datasource="#URL.myDatasource#"
		username="#Variables.myUsername#"
		password="#Variables.myPass#">
	SHOW TABLES IN peoplexs_test;
</cfquery>

<!--- <cfdump var="#rsAllTables#" format="text"> --->
<cfset processInfo = "">

<cfoutput query="rsAllTables" maxrows="#URL.numOfTables#">

	<cfset dbErrorInfo = "">
	<cfset anyErrorInfo = "">
	<cfset beginProcessInfo = "">
	<cfset endProcessInfo = "">

	<cfsavecontent variable="beginProcessInfo">
	--- <strong>"OPTIMIZE TABLE #rsAllTables.TABLES_IN_PEOPLEXS_TEST#" started</strong>... <br/>
	</cfsavecontent>
	<cfset processInfo &= beginProcessInfo>

	#beginProcessInfo#
	<cfflush>

	<cftry>

		<cfquery name="qOptimizeTable"
				datasource="peoplexs_test"
				username="#Variables.myUsername#"
				password="#Variables.myPass#"
				timeout="#URL.queryTimeout#">
			OPTIMIZE TABLE #rsAllTables.TABLES_IN_PEOPLEXS_TEST#;
		</cfquery>

		<cfquery name="qFlushTable"
				datasource="peoplexs_test"
				username="#Variables.myUsername#"
				password="#Variables.myPass#">
			FLUSH TABLE #rsAllTables.TABLES_IN_PEOPLEXS_TEST#;
		</cfquery>

		<cfcatch type="database">
			<cfsavecontent variable="dbErrorInfo">
			<span style="color:red;">
				Database ERROR: "#cfcatch.Cause.Message#" on
				"#cfcatch.SQL#"
			</span><br/>
			</cfsavecontent>
			<cfset processInfo &= dbErrorInfo>
			#dbErrorInfo#
		</cfcatch>

		<cfcatch type="any">
			<cfsavecontent variable="anyErrorInfo">
			<span style="color:red;">
			<cfdump var="#cfcatch#" format="text">
			</span><br/>
			</cfsavecontent>
			<cfset processInfo &= anyErrorInfo>
			#anyErrorInfo#
		</cfcatch>

	</cftry>

	<cfsavecontent variable="endProcessInfo">
	------ done with #rsAllTables.TABLES_IN_PEOPLEXS_TEST#. <br/><br/>
	</cfsavecontent>

	<cfset processInfo &= endProcessInfo>
	#endProcessInfo#
	<cfflush>

</cfoutput>

<cfmail to="#Variables.toAddresses#"
        from="#Variables.fromAddress#"
        subject="OPTIMIZE_ALL_DB_tables.cfm on #Server.hostName#/#Server.instanceName# at #DateFormat(Now(), 'yyyy-mm-dd')#"
        type="HTML"
        server="localhost">
<cfoutput>#Trim(processInfo)#</cfoutput>
</cfmail>

tags:
ColdFusion, MySQL
0

MultiCFAdmin Alpha 0.007 is on RIAForge.org now

ColdFusion, Software, MultiCFAdmin

Here's the link: http://multicfadmin.riaforge.org/

Description:

In this Alpha version 0.007, which allows connection to CF Admin API on local and remote CF instances, there are only a few features:

1) jQuery UI
2) ability to see basic stats of each CF8 Server Monitor API
3) ability to clear Template Cache for all instances
4) ability to toggle Trusted Cache for all instances
5) can configure multiple CF Admin URLs, passwords, and a sleep() time for how long MultiCFAdmin waits after Trusted Cache is changed

Requirements:

* ColdFusion 8.01 Enterprise or Developer, Multi-server
* multiple CF instances other than cfusion (default)
* access to jrun-web.xml configuration files on each instance
0

Multi-CF Admin Alpha 0.02

ColdFusion, Software, MultiCFAdmin

Okay, this is pretty cool (at least I think so). Here's the zip.

How many of us with multiple instances in a cluster have wanted to be able to do things like clear the template cache for every instance in the cluster with *one* button?

Well, I have.

Now, I have an early alpha that is not much more than a proof-of-concept, but does exactly that.

and in a few seconds, it's all cleared (see below)...

Here's the readme.txt:

Requirements:
* ColdFusion 8.01 Enterprise or Developer, Multi-server
* multiple CF instances other than cfusion (default)

Installation:
1.) put /MultiCFAdmin folder at www root
2.) open jrun-web.xml file at [jrun_root]\servers\[instance_name]\cfusion.ear\cfusion.war\WEB-INF (you may need to create it by copying over from cfusion instance if it doesn't exist)
3.) add a line within the XML block that points to where your WS files are, like this:

��� /Webservices
��� /opt/jrun4/servers/cfusion/cfusion-ear/cfusion-war/MultiCFAdmin/Webservices


4.) NOTE: don't attempt to connect to the cfusion instance because it causes errors with the Web Service calls to try and connect from the same instance
5.) set environment info for Application.Environment in config/Environment.cfm
6.) set instance info in config/CFInstances.cfm

Here's the zip again.

Send me a tweet if you're interested in helping with the code: http://twitter.com/aqlong

tags:
MultiCFAdmin
0

Verity "java.io.IOException: Read timed out" error?

ColdFusion, Verity

Hi anyone,

On CF 8.01 (CHF 2), Enterprise 64-bit, multi-server on Red Hat 5.3 I'm getting the following error whenever I try to do any action with a Verity collection:

An error occurred while performing an operation in the Search Engine library.
Error switching collection offline.: com.verity.api.administration.ConfigurationException: java.io.IOException: Read timed out
  1. By "anything", I mean creating, optimizing, deleteing, reindexing, etc. from the CF Admin or regular CF code.
  2. I've restarted CF and Verity multiple times to make sure it wasn't that
  3. I tried on 2 different machines, each with the same exact setup and config, and it happens on both, so I don't think it's specific to a machine
  4. I tried using the /tmp directory, which has pretty much full rights, as the path for creating some brand new indexes, but still get the error
  5. The strange thing is that this wasn't happening about 4 weeks ago, so I'm thinking this is probably an O/S (RHEL 5.3, 64-bit) update issue, or perhaps occurred when I applied CHF 2 for CF 8.01 a few weeks ago, though there's nothing about Verity in it.

Any ideas what it could be or what to try next?  I'll be calling Adobe support shortly, but wanted to see if any of my blog followers had an idea?


TIA

I'm on twitter now: aqlong

ColdFusion, Software

If you care to follow me on twitter now, my account is aqlong

tags:
twitter

anyone use Nirvanix CloudNAS?

ColdFusion, Software, cloud

I'm looking for feedback, good or bad, on Nirvanix.

When looking at potential "cloud providers", I was amazed to read about the CloudNAS solution that Nirvanix has, which gives your servers a way to mount Nirvanix cloud storage as a drive... too cool! 

It has the traditional advantages of "Global Virtualization, Unlimited Scalability, Continuous Availability, and a Usage Based Service Model." - http://www.nirvanix.com/resources.aspx#documentation.

Anyone used the CloudNAS or heard of it?


Search

Aaron  Longnion

The Hague, NL