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

Way to check what mysql config used

Recently I needed to know if mysql is using any config (.cfg) except default one (/etc/my.cfg).
This command allows to check things quickly:

strace mysql ";" 2>&1 | grep cnf

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

Linux Mint: easy way to fix bootloader (grub) after windows installation

Today I had an issue with grub after I installed windows on my laptop in addition to Linux.
And I found a really easy way to fix grub after that.
Here it is:

sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update
sudo apt-get install -y boot-repair && (boot-repair &)

That’s it!

fstab options for ntfs partitions in Linux Mint

I gor errors while tried to mount ntfs partitions in linux mint.
So I checked fstab and fixed things.

This is output from fstab:

# /windows was on /dev/sda3 during installation
UUID=B86E55A46E555C66 /media/windows ntfs   defaults,nls=utf8,umask=000,uid=1000

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

How to change hostname in Linux Mint

Recently I changed hostname in my Linux Mint desktop and then I got the error each I tried to run something with “sudo”, for example:

$ sudo sed -i 's/maya/nadia/g' /etc/apt/sources.list
sudo: unable to resolve host garage

It means that I didn’t change hostname appropriately.
Continue reading

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