Every now and then you’ll see an error like “Packet Too Large” in MySQL, as seen below. When you run into this, you’re trying to shove more information into a given SQL statement than is allowed. So to fix, you have a few different options, starting with the best, which is to make your SQL better.
But not everyone has control of things like source code. So you might need to change the value in mysql itself. To do so, simply run the mysql command with the –max_allowed_packet and then put = followed by the size of the packet. For example, to make it 128:
Now, by default this is 1M so that’s pretty big. You can then change it in the daemon:
And to change it in the my.cnf, simply edit /etc/my.cnf (on OS X) or /etc/mysql/my.cnf or /usr/local/mysql/my.cnf, according to how you installed mysql. From there, search for max_allowed_packet and change it as needed. Once changed, restart MySQL (or the server) and the changes will take effect.
Love it or not, some environments insist on disabling Bonjour, Apple’s implementation of Multicast DNS. Despite the fact that mDNS has been around since 2000 and is widely used by Microsoft, we still look to disable this from time to time. As Arek Dreyer mentioned last week at MacSysAdmin in Gothenburg, Sweden, you can’t just disable the mDNSResponder LaunchDaemon or you will bork DNS (my word I think, not his). Instead, to disable Bonjour you would add the -NoMulticastAdvertisements option into the ProgramArguments array in the /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist file. This can be done manually, or it can be automated with the following command:
defaults write /System/Library/LaunchDaemons/com.apple.mDNSResponder ProgramArguments -array “/usr/sbin/mDNSResponder” “-launchd” “-NoMulticastAdvertisements”
To undo this, you would run:
defaults write /System/Library/LaunchDaemons/com.apple.mDNSResponder ProgramArguments -array “/usr/sbin/mDNSResponder” “-launchd”
If you have other elements in the array you could also use the following to simply append to the end of it:
defaults write /System/Library/LaunchDaemons/com.apple.mDNSResponder ProgramArguments -array-add “-NoMulticastAdvertisements”
When I got home from MacSysAdmin, I had a request to disable Multicast DNS in Debian, which was done by editing the Avahi daemon. The file was avahi-daemon (aptly named) located in the /etc/default directory. The settting to change in there is AVAHI_DAEMON_START which needs to be set to 0.
I have mentioned creating a self destructing script or launchd item a few times in articles on this site. But it was recently pointed out that I never actually showed how to go about doing so. Until recently I would actually use an out-of-band script to remove a script, a launchd agent or a launchd daemon. However, this would invariably leave elements somewhere on a file system of the script. For example, within a script I would echo out another script, fire off that script and then use it to delete (rm) the original script. When I planned out a deployment or a series of scripts I would always have one deploy the next, which would remove the first (I like being granular with my scripts rather than monolithic;). On top of leaving trace elements this was terribly inefficient.
Then I discovered that I could just put a line at the end of a script and it would erase itself when it was done running. So if I have a bind script with a password in the script and I want it to be removed when it is complete, I can just put the following line at the very end:
The same logic can be applied to launchd items. Let’s say I kick off a script called myscript using a launchd item called com.krypted.myscript with the following contents:
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
Now at the end of this script (assuming a payload above these lines with a bunch of stuff you actually want to accomplish) you can use the following commands to stop the LaunchAgent and finally delete the script itself (the first line is not always required):
launchctl stop com.krypted.myscript
launchctl unload /Library/LaunchAgents/com.krypted.myscript.plist
launchctl remove com.krypted.myscript
Now when I have a series of scripts that kicks off, I can either have each remove itself or have a cleanup script that removes all of my installation items and then, like a cartoon pencil, erases itself.