Monday, May 14, 2018

CentOS 7 how to fix gearmand

Gearman Not Listening on Right IP? Let's fix it!
Edit the /etc/sysconfig/gearmand and add the following:

    OPTIONS="--listen=127.0.0.1 --port=4730"

Note, the default port is 4730.
Then, run "sudo service gearmand restart" -- and get "gearadmin --status" working!

Wednesday, July 13, 2016

Using exiftool to create Facebook 360 panorama images

Facebook has a wonderful feature to show 360 degree panorama photos. Especially when you use mobile device - you can turn around to show all the uploaded panorama.
However, it is a little bit tricky to create an image that will be recognized as panorama by Facebook. Even if you upload an 6000х3000 image - Facebook thinks it is an ordinal photo. To create a Facebook 360 Panorama - you have to add special meta tags to the image.

Using Photoshop

Create the file panorama.xmp with the following text content (assume your image is 6000x3000):

<rdf:Description rdf:about="" xmlns:GPano="http://ns.google.com/photos/1.0/panorama/">
<GPano:CroppedAreaImageHeightPixels>3000</GPano:CroppedAreaImageHeightPixels>
<GPano:CroppedAreaImageWidthPixels>6000</GPano:CroppedAreaImageWidthPixels>
<GPano:FullPanoHeightPixels>3000</GPano:FullPanoHeightPixels>
<GPano:FullPanoWidthPixels>6000</GPano:FullPanoWidthPixels>
</rdf:Description>

In menu "File" - "File Info" import the metadata for your image from panorama.xmp

Using Exiftool (from console or bash script)

Create the panorama.xmp:
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 9.74'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

 <rdf:Description rdf:about=''
  xmlns:GPano='http://ns.google.com/photos/1.0/panorama/'>
  <GPano:CroppedAreaImageHeightPixels>1182</GPano:CroppedAreaImageHeightPixels>
  <GPano:CroppedAreaImageWidthPixels>5732</GPano:CroppedAreaImageWidthPixels>
  <GPano:CroppedAreaLeftPixels>2866</GPano:CroppedAreaLeftPixels>
  <GPano:CroppedAreaTopPixels>842</GPano:CroppedAreaTopPixels>
  <GPano:FullPanoHeightPixels>5732</GPano:FullPanoHeightPixels>
  <GPano:FullPanoWidthPixels>11464</GPano:FullPanoWidthPixels>
 </rdf:Description>

</rdf:RDF>
</x:xmpmeta>
<?xpacket end='w'?>

Load meta data to the image file:
exiftool -Tagsfromfile panorama.xmp panorama.jpg

Where panorama.jpg - is the source image file to create panorama.

Have Fun!

Friday, July 8, 2016

How To Use Percona Tools to Backup and Restore Your MySql Database

Percona tools have a fast and reliable utility to backup your database named innobackupex. And the most important is you have not to stop the database to make your backup consistent (it means if you simply use mysqlbackup without additional tricks on a running in production database, you may got a backup file where some tables have some changes and related tables don't have corresponding changes). So, let me show you some commands how to use the innobackupex.

1. How to install innobackupex

For Debian and Ubuntu:

Add the Percona repository:
wget https://repo.percona.com/apt/percona-release_0.1-3.$(lsb_release -sc)_all.deb
sudo dpkg -i percona-release_0.1-3.$(lsb_release -sc)_all.deb
sudo apt-get update

And install:
sudo apt-get install percona-xtrabackup

For CentOS and RedHat:

Add Percona YUM repository:
wget http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
rpm -ivH percona-release-0.1-3.noarch.rpm

And install the tool:
yum install percona-xtrabackup-22

2. How to backup

innobackupex --stream=xbstream --parallel=4 --compress --compress-threads=2 /var/lib/mysql > /backup/backup.xbstream

So, as you can see, the backup contains all the databases on the server. The params are self-explaining, so adjust as you wish. The "stream" param specify the output file to be something similar (and not compatible) to .tar.gz.

3. How to restore

It is much more trickier...

yum install qpress
xbstream -x < /backup/backup.xbstream
for i in $(find -name "*.qp"); do qpress -vd $i $(dirname ${i}) && rm -f $i; done
innobackupex --apply-log ./
service mysql stop
rm -Rf /var/lib/mysql/*
innobackupex --copy-back ./
chown -Rf mysql.mysql /var/lib/mysql
service mysql start

As you can see, you need the qpress tool from the percona repository. At first, we decompress the backup to database files, apply the binary log to these files to make the backup consistent, and then we restore the database files in a hard way (removing and replacing everything there!).

Hope you will never need this. Good luck, anyway!