Speedtest in terminal

This is how to test speed in terminal:

wget -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip

MacPorts “selfupdate” error on OS X Mavericks

Recently I tried to update macports and got error:

$ sudo port install MySQL
...
Error: Error installing new MacPorts base: command execution failed
Please run `port -v selfupdate' for details.
Error: /opt/local/bin/port: port selfupdate failed: Error installing new MacPorts base: command execution failed

The fix is:

$ sudo xcode-select --install

Result:

The ports tree has been updated. To upgrade your installed ports, you should run
  port upgrade outdated

Get date with nanoseconds on MacOS

Recently I tried to run my own simple bash script (written on Linux) on my Mac and I found that results are bad because a “date” function.

So the problem is – date on MacOS doesn’t have nanoseconds option.

Solution is simple: install “coreutils” from MacPorts

$ sudo port install coreutils

that’s it!

Now GNU version of the date is available as gdate:

$ gdate +%s%N
1379413863366167000

Percona XtraDB Cluster and SELinux

Today I tried to setup Percona XtraDB Cluster, but got permission denied error:

130709 16:15:35 [Note] WSREP: gcomm: connecting to group 'cluster0', peer ''
130709 16:15:35 [ERROR] WSREP: Permission denied
130709 16:15:35 [ERROR] WSREP: failed to open gcomm backend connection: 13: error while trying to listen 'tcp://0.0.0.0:4567?socket.non_blocking=1', asio error 'Permission denied': 13 (Permission denied)
	 at gcomm/src/asio_tcp.cpp:listen():813
130709 16:15:35 [ERROR] WSREP: gcs/src/gcs_core.c:gcs_core_open():195: Failed to open backend connection: -13 (Permission denied)
130709 16:15:35 [ERROR] WSREP: gcs/src/gcs.c:gcs_open():1289: Failed to open channel 'cluster0' at 'gcomm://': -13 (Permission denied)
130709 16:15:35 [ERROR] WSREP: gcs connect failed: Permission denied
130709 16:15:35 [ERROR] WSREP: wsrep::connect() failed: 6
130709 16:15:35 [ERROR] Aborting

Continue reading

Quick hint: analyzing mysql general query log

I had a long running transaction and general log enabled.
So I wanted to check which queries caused transaction to be running for a long time.

If you have thread id for a long running transaction:
(you can get it from “mysql> show engine innodb status;” or pt-deadlock-logger in case of deadlock)
then you can grep log by thread id and then use pt-query-digest and analyze log

sudo grep -i " <thread id> " <genera-log-filename> > somefile.txt
sudo pt-query-digest --type genlog  somefile.txt

Syncing MySQL tables by pt-table-checksum when there is no unique key

Today I needed to checksum and sync tables in simple master-slave replication.
So I used percona-toolkit for this.

Following checksumming (command should be running on master) of tables shows that repl.t9 and repl.t1 tables have differences:

$ pt-table-checksum --replicate=percona.checksums --create-replicate-table --empty-replicate-table --ask-pass h=localhost,u=root
            TS ERRORS  DIFFS     ROWS  CHUNKS SKIPPED    TIME TABLE
05-26T01:50:30      0      1        4       1       0   0.016 repl.t1
05-26T01:50:30      0      1        6       1       0   0.016 repl.t9

Let’s run sync and check result:
Continue reading