Friday, September 25, 2015

How to use percona toolkit to fix broken mysql replication

How to use percona toolkit to fix broken mysql replication
host1=my slave server (name or ip)
host2=my master server (name or ip)
Following will syncronizing missed data from master to slave
Thefore we need to take the last binlog file and key position on the master:
# mysql
mysql> show master status\G;
*************************** 1. row ***************************
File: mysql-bin.000022
Position: 474336476
Binlog_Do_DB:
Binlog_Ignore_DB:
1 row in set (0.00 sec)
On the slave:
mysql> slave stop;
mysql>CHANGE MASTER TO master_log_file='mysql-bin.000022',master_log_pos=474336476;
mysql> slave start;

Next , we going to synchronize all missed data from master
# pt-table-sync --verbose --print --execute h=host2 --database test h=host1
Sample out is:
DELETE REPLACE INSERT UPDATE ALGORITHM START END EXIT DATABASE.TABLE
UPDATE `test`.`demo_test` SET `c2`=’core|a:3:{s:23:”_session_validator_data”;a:4:{s:11:”remote_addr”;s:13:”5.255.253.127″;s:8:”http_via”;s:0:””;s:20:”http_x_forwarded_for”;s:0:””;s:15:”http_user_agent”;s:64:”Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)”;}s:12:”visitor_data”;a:16:{s:0:””;N;s:11:”server_addr”;i:1054544702;s:11:”remote_addr”;i:100662655;s:11:”http_secure”;b:0;s:9:”http_host”;s:15:”musicgate.co.il”;s:15:”http_user_agent”;s:64:”Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)”;s:20:”http_accept_language”;s:42:”ru, uk;q=0.8, be;q=0.8, en;q=0.7, *;q=0.01″;s:19:”http_accept_charset”;s:0:””;s:11:”request_uri”;s:58:”/wishlist/index/add/product/942/form_key/jgjZFa9Idi12wjim/”;s:10:”session_id”;s:26:”00013fgiur7cecou15b8iu7j62″;s:12:”http_referer”;s:0:””;s:14:”first_visit_at”;s:19:”2015-05-12 18:36:27″;s:14:”is_new_visitor”;b:0;s:13:”last_visit_at”;s:19:”2015-05-12 18:36:27″;s:10:”visitor_id”;s:7:”2835829″;s:11:”last_url_id”;s:7:”2881777″;}s:8:”last_url”;s:82:”http://musicgate.co.il/core/index/noCookies/’, `c3`=’0′, `c4`=’8288′, `c5`=’101′ WHERE `c1`=’00013fgiur7cecou15b8iu7j62′ LIMIT 1 /*percona-toolkit src_db:test src_tbl:demo_test src_dsn:h=xx.xxx.xx.xx dst_db:test dst_tbl:demo_test dst_dsn:h=xx.xxx.xx.xx lock:0 transaction:1 changing_src:0 replicate:0 bidirectional:0 pid:19564 user:user host:myhost*/;
# 0 0 0 1 Chunk 17:04:11 17:04:26 2 test.demo_test
We need to stop/strt the slave
mysql> slave stop;
mysql> slave start;

To be sure all going well:
mysql> show slave status\G;
If:
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
All work as expected.
The advantage of this method is not complex mysqldump and restore needed. No downtime.No table locks.

Wednesday, July 15, 2015

MYSQLDUMP MYSQL MASTER SERVER

Dump with binary and log position
# mysqldump –single-transaction –master-data=2 DATABASE NAME| gzip > /root/DATABASE.sql.gz
restore
# gunzip < /root/DATABASE.sql.gz | mysql DATABASE

PHP FPM – HOW TO SEPARATE VHOST(WEB SITE) AND EXTEND LIMITS PER VHOST ON NGINX.

php fpm – How to separate vhost(web site) and extend limits per vhost on nginx.
I’m done it for phpmyadmin to allow import large files (this can be used to separate vhosts with limitations or extend as well)
# cp /etc/php5/fpm/pool.d/www.conf /etc/php5/fpm/pool.d/phpmyadmin.conf
# nano /etc/php5/fpm/pool.d/phpmyadmin.conf
change
; pool name (‘www’ here)
[www]
to
[phpmyadmin]
change
; Note: This value is mandatory.
listen = /var/run/php5-fpm.sock
to
; Note: This value is mandatory.
listen = /var/run/php5-fpm-phpmyadmin.sock
# nano /etc/nginx/sites-enabled/phpmyadmin
chnge
fastcgi_pass unix:/var/run/php5-fpm.sock;
to
fastcgi_pass unix:/var/run/php5-fpm-phpmyadmin.sock;
# nano /home/phpmyadmin/.user.ini
add
upload_max_filesize = 20M
memory_limit = 256M
max_execution_time = 300
max_input_time = 240
# sudo service php5-fpm restart
# sudo service nginx reload

LINUX SENDMAIL WORK SLOW (FQDN)

Sendmail work slow , up to 60 sec when send mail.
This is because sendmail can’t resolve the right FQDN.
How to resolve:
1) We check what is our hostname
# hostname -f
# newdev

2) The fix is:
# nano /etc/hosts
and make the first line loock like”
# 127.0.0.1 localhost localhost.newdev newdev
Now , the sendmail send mails without delay.

CLAMD HAS FAILED. CONTACT YOUR SYSTEM ADMINISTRATOR IF THE SERVICE DOES NOT AUTOMAGICALLY RECOVER

clamd has failed. Contact your system administrator if the service does not automagically recover.
Home »cPanel »Manage Plugins
Uninstall clamavconnector
Install and keep updated
cpanel_clam

Thursday, December 25, 2014

How to add launchpad ubuntu repository and install php5-memcached 2.2.0

Add repository
# add-apt-repository ppa:ondrej/php5
Check available versions
# apt-get update
# apt-cache policy php5-memcached
Install memcashed
# apt-get install php5-memcached

Monday, December 1, 2014

VARNISH WEB INTERFACE FOR ADMIN AND CACHE INVALIDATION

1) Download and extract
wget https://github.com/varnish/vagent2/archive/master.zip
unzip master.zip

2)Install
cd vagent2-master/
./configure
make
make install

3)Protect the interface
nano /etc/varnish/agent_secret
Insert formatted
user:password
4)Start the agent

/usr/local/bin/varnish-agent

5)Varnish Web Interfase access (when promted for login , enter the user:password from /etc/varnish/agent_secret)
http://THE-SERVER-IP:6085/html/
6) The Varnish Web Interfase allow:
stop/start varnish
Cache invalidation
Set Parameters
View varnish performance
2014-12-01 23_16_57-Varnish Agent