PlanetMySQL Voting: Vote UP / Vote DOWN
Archive for the ‘unix’ Category
zfs Snapshot Commands Example
Август 20th, 2011PlanetMySQL Voting: Vote UP / Vote DOWN
zfs Snapshot Commands Example
Август 20th, 2011PlanetMySQL Voting: Vote UP / Vote DOWN
Not excited about paying for MySQL monitoring for your enterprise?
Ноябрь 8th, 2010PlanetMySQL Voting: Vote UP / Vote DOWN
dbbenchmark.com – MySQL benchmarking now supports multiple threads!
Август 31st, 2010We had a very successful weekend of Planet.mysql users submitting their database statistics so I’ve pushed some code into a new release today so that everyone can benefit from some new features. The biggest change is to the threading logic. Previously the benchmarking script was serializing MySQL operations and only making use of a secondary thread (not the invoking thread) to query the database. Now you have the option of running with “–threads=x” to make use of your multi-core server. A good example of this improvement was on my Macbook Pro; before the threading change it was inserting ~700/sec, after the code change I tried –threads=4 and saw an improvement to ~900/sec. Rather significant.
Download the new script now and see how your server compares to the ones in the central database!
PlanetMySQL Voting: Vote UP / Vote DOWN
How to get colored output from ‘ls’ on Solaris10
Апрель 27th, 2010For all of those linux users out there that have moved over to, or tried out, Solaris10 or OpenSolaris because they heard the tales of how MySQL is faster on Solaris… or perhaps you wanted to learn how to use Sol10 for the great features of Zones or the ZFS filesystem? Regardless of why you’re on it you are probably wondering why Linux has colored output of filenames and directories but Solaris does not. The question of ‘why?’ isn’t important, but how to enable colors is. It’s very simple, and here’s how I fixed it. This is a result of digging through multiple semi-related links on Google.
- Download all packages from SunFreeware.com
- dependency: libintl-3.4.0-sol10-x86-local
- dependency: libiconv-1.13.1-sol10-x86-local
- dependency: gmp-4.2.1-sol10-x86-local
- dependency: gcc-3.4.6-sol10-x86-local or libgcc-3.4.6-sol10-x86-local depending on your system needs
- coreutils-8.4-sol10-x86-local
- Install ‘coreutils’ dependency packages using the command “pkgadd -d [package_name]
- Install ‘coreutils’ packages using the command “pkgadd -d coreutils-8.4-sol10-x86-local
- Enable color aliases in your rc file: “alias ls=’/usr/local/bin/ls –color=auto’”
PlanetMySQL Voting: Vote UP / Vote DOWN
Reviewed: Python Testing by Daniel Arbuckle
Апрель 20th, 2010I’ve recently had the pleasure of reading “Python Testing: An easy and convenient approach to testing your python projects” from Packt Publishing. It’s been a quick read but a solid set of instructions on the different methods for the subject.
The book starts out very quickly with details about the various methods that are available, the means of automation for testing, and of course the environment you’d want to be in for working on the subjects that the book covers. It then, in the second chapter, moves into the guts of testing by describing the basics of doctest via syntax and some simple examples, and then moves on to a real world example via the AVL tree. It’s all very basic testing until chapter three where the author gets into unit testing, which is probably the most useful method in my opinion, and he goes to prove it’s usefulness with examples of it’s use in different parts and stages of the development process. Later in the book the python mocker is used to separate unit sections, and then the actual unittest framework is discussed with more examples and a enough details that if you don’t understand it by then, you may never. By chapter six we are into the Nose app that drives the unittest, which is very useful of course.
The most useful part of the book comes toward the end where the author discusses and the walks through the method used to create a test-driven application and then even shows examples via the whole chapter dedicated towards making a testable web application frontend. Very impressive for such a quick read. Integration testing and System testing is also covered, thankfully. The final chapter covers some useful tools and techniques of which I particularly enjoyed the section on version control hooks. If you are not using version control in your development process you need to start now, as such the hooks for integration with the test framework are rather useful to know.
Overall this is a very nice book that discusses python application testing from the ground up. It’s perfect for a beginner or an intermediate python programmer that has little to no experience in automated testing methods. More advanced programmers that have already used these methods will probably not find the book too useful except for the last chapter that covers extra tools and techniques that they might not have seen before. If I didn’t have this book and needed to learn about python testing, it would be my first choice and my only recommendation so far. Well written and very useful.
If there is one thing I do not like about the book, it would be the reliance on the python CLI for running commands. I am a CLI kind of person and I keep lots of terminals open at the same time, so I prefer to write my code in an editor or IDE in one term tab, then switch to another and execute the script; I do not use the python command line to do much of anything. So following some of the steps in the book require that you follow the CLI method and that gets old for me. It’s a personal preference but one worth noting as there is a lot of it in the book. That’s the only thing I did not enjoy in a book that was otherwise basically perfect for the subject.
PlanetMySQL Voting: Vote UP / Vote DOWN
Kontrollkit – new backup script is partition space aware
Март 31st, 2010PlanetMySQL Voting: Vote UP / Vote DOWN
Kontrollcomm – remote database and system command execution webapp
Март 22nd, 2010PlanetMySQL Voting: Vote UP / Vote DOWN
Installing Midnight Commander 4.7 on Mac OS X
Февраль 3rd, 2010Another short post just to remember the procedure for the next time I’ll be setting up a new mac. For those of my readers who do not know what Midnight Commander (aka mc) is, GNU Midnight Commander is a visual file manager, created under a heavy influence of Norton Commander file manager from dark DOS ages
For more information, you can visit their web site. Now, get to the installation topic itself.
To install mc on a Mac OS X machine, you need macports installed and then first thing you’ll need to do is to install some prerequisite libraries:
1 | $ sudo port install libiconv slang2 |
Next thing, download the sources from their web site and unpack them. When the sources are ready, you can configure the build:
1 2 3 4 5 6 7 8 | $ ./configure \ --prefix=/opt/mc \ --with-screen=slang \ --enable-extcharset \ --enable-charset \ --with-libiconv-prefix=/opt/local \ --with-slang-includes=/opt/local/include \ --with-slang-libs=/opt/local/lib |
Then, normal GNU-style build and install procedure:
1 2 3 | $ make ........ $ sudo make install |
And the last thing would be to add /opt/mc/bin to your PATH environment variable.
PlanetMySQL Voting: Vote UP / Vote DOWN
awk and mysqldump
Декабрь 30th, 2009One feature which is missing on the current mysqldump command is to separate dump files per DB or table. It can store all data into a large single file only, whether we run the command with --result-file option or redirect the output to some file. Of course it is possible to run mysqldump command several times per DB or table, but it cannot produce a consistent snapshot at a certain time, each dump may be time-shifted in other words, unless all involved tables are locked during dump. So, we need to backup database using a single mysqldump instance if we need a consistent data.
Now, you can make use of awk! It is a really powerful text processor. As an output of mysqldump is text, you can process the output using awk. See the following awk script:
#!/usr/bin/awk -fSave the script into a file named separate-dump.awk etc, and make it exectable (chmod u+rx). You can separate dump files per DB by using the script like below:
function is_new_db(db_name) {
for (i = 1; i <= num_db; i++) {
if (db_name == db[i]) {
return 0;
}
}
return 1;
}
BEGIN {
num_db = 0
num_prelines = 0
num_postlines = 0
current_file = "/dev/null"
}
/^\-\-/ {
if ($2 == "Current" && $3 == "Database:") {
close(current_file);
db_name = $4
gsub("`", "", db_name);
current_file = db_name ".sql";
if (is_new_db(db_name)) {
db[++num_db] = db_name;
print "--\n" $0 "\n--\n" > current_file;
for (i = 1; i <= num_prelines; i++)
print prelines[i] >> current_file;
}
} else if (num_db == 0) {
num_prelines++;
prelines[num_prelines] = $0;
} else if ($2 == "Dump" && $3 == "completed") {
num_postlines++;
postlines[num_postlines] = "";
num_postlines++;
postlines[num_postlines] = $0;
} else {
print $0 >> current_file
}
next;
}
/^\/\*.+\*\/;/ {
if (match($0, "character|collation")) {
print $0 >> current_file;
} else if (match($0, "SET")) {
if (num_db == 0) {
if (match(prelines[num_prelines], "^\-\-")) {
num_prelines++;
prelines[num_prelines] = "";
}
num_prelines++;
prelines[num_prelines] = $0;
} else {
num_postlines++;
postlines[num_postlines] = $0;
}
} else {
print $0 >> current_file;
}
next;
}
{ print $0 >> current_file }
END {
for (i = 1; i <= num_db; i++) {
current_file = db[i] ".sql";
print "" >> current_file
for (j = 1; j <= num_postlines; j++) {
print postlines[j] >> current_file;
}
}
}
shell> mysqldump -A --single-transaction --master-data=2 --flush-logs | ./separate-dump.awkThen, dump files named like "database_name.sql" are created under your current directory! Of course, you can also process an existing dump file like below:
shell> ./separate-dump.awk < dump.sqlMaking use of "good old fashioned" unixy command tools will make us happy ;)
Enjoy!!
PlanetMySQL Voting: Vote UP / Vote DOWN
