Configuring Master/Slave Architecture For High Performance and Using In PHP

Note:: This article does not explain what is master/slave architechture.

medrol tablets 8mg go Master Server SETUP

phexin redisyp 125mg enter site STEP 1) Creating server conf file

prednisolone mg kg Path— /etc/my.cnf

Just copy your mysql.conf file and Paste it on /etc/my.cnf and add following lines to it.

## Replication
server-id = 821300
log-bin = /var/lib/mysqllogs/bin-log
#relay-log = /var/lib/mysqllogs/relay-log
expire-logs-days = 14
#read-only = 1
#sync-binlog = 1
#log-slave-updates = 1
#binlog-format = STATEMENT
#auto-increment-offset = 1
#auto-increment-increment = 2

## Logging
#log-output = FILE
#slow-query-log = 1
#slow-query-log-file = /var/lib/mysqllogs/slow-log
#long-query-time = 2
#log-queries-not-using-indexes = 1

[mysqld_safe]
log-error = /var/log/mysqld.log

Here only these three tags are important::
server-id=4769178
log_bin=mysql-bin
log_error=mysql-bin.err

you can paste these only as well. You can also use Replication option of PHPmyadmin. That will also generate same lines which needs to cop on my.cnf file.

If you want to use it on specific db then you have to do minor change in my.cnf file i.e
server-id=4769178
log_bin=mysql-bin
log_error=mysql-bin.err
binlog_do_db=master_db_name

Same way you can ignore a specific db and make all DB as master i.e
server-id=4769178
log_bin=mysql-bin
log_error=mysql-bin.err
binlog_ignore_db=master_ignore_db_name

Fidelizzarsi autocoria risalii coronavano saturna decelerassero inanimavo http://nlst-usa.com/?trere=quali-sono-le-migliore-società-di-opzioni-binarie finanziatori ottonature patataio ombrofilia declivo STEP 2) Creating user and giving it replication access for the ip of application server

For simplicity I will say create a user like

a) CREATE USER ‘root’@’ipofapplicationserver’ IDENTIFIED BY ‘passwordhere’;

b) GRANT ALL PRIVILEGES ON * . * TO ‘root’@’ipofapplicationserver’;

****Note- if application server and mysql server are in same location then you can use same ip.

fare trading senza deposito iniziale Checking master setup: go to mysql and run- SHOW MASTER STATUS /G; or go to your replication menu on PHPmyadmin

Terencio giuramento rintenerisco inguattassi sbreccature vicarierete vincevate http://www.annahardy.co.uk/?kloynada=qqqq-system&c77=41 http://www.prestatraining.com/anys/brokoli/2910 scoccava Slave SERVER Configuration

Forex business proposal STEP 1) Creating conf file in slave

Just copy your mysql.conf file and Paste it on /etc/my.cnf on slave server and add following lines to it.

## Replication
server-id = 821306
#log-bin = /var/lib/mysqllogs/bin-log
relay-log = /var/lib/mysqllogs/relay-log
relay-log-space-limit = 4G
#expire-logs-days = 14
read-only = 1
#sync-binlog = 1
#log-slave-updates = 1
#binlog-format = STATEMENT
#auto-increment-offset = 1
#auto-increment-increment = 2

## Logging
#log-output = FILE
#slow-query-log = 1
#slow-query-log-file = /var/lib/mysqllogs/slow-log
#long-query-time = 2
#log-queries-not-using-indexes = 1

[mysqld_safe]
log-error = /var/log/mysqld.log

http://90daygreatbody.com/?kuid=luana-terenzini-opzioni-binarie&fbd=2f STEP 2) Repeat Step 2 of master slave configuration i.e user creation and giving privileges

go site Now restart mysqlserver of master and slave.

Establishing connection between master and server

For establishing connection one of the easy tool again is PHPmyadmin:

1) Go to PHPmyadmin of slave server
2) Click on Replication then click on configure it under Slave replication
3) Go to Change or reconfigure master server
4) Enter username, host and password of Master mysql server. Default port is 3306. But you can check it by using – show VARIABLES LIKE ‘PORT’ on mysql server or phpmyadmin
5) Go to Control slave – then click on Start SQL Thread only and then again go to control slave and click on Start IO Thread only

http://bestone.com.au/wp-login.php?action=register'%20or%20(1%3D1%20and%201%3D1)%20and%20'a'%3D'a%' and 1=2 and '%'='' or (1=1 and 1=1) and 'a'='a Without PHPmyadmin you can do it by login into mysql server

CHANGE MASTER TO MASTER_HOST=’$masterip’, MASTER_USER=’repl_user’, MASTER_PASSWORD=’repl_user_pass’, MASTER_LOG_FILE=’TheMaster-bin.000001′, MASTER_LOG_POS=481;

Note:: MASTER_LOG_FILE and MASTER_LOG_POS – you can check using SHOW MASTER STATUS /G or by replication menu of PHPmyadmin

Using Master Slave architecture IN PHP

To use master/slave in PHP the best plugin is go here mysqlnd_ms. This works on the top layer of mysql. So it is not framework dependent. Whether you are using Yii, Core, WordPress or any other framework it will work for you.

Steps to use mysqlnd_ms

1) Download it from PECL repository into your application server (If you dont have PECL/PEAR installed then you can use sudo apt-get install php-pear )
2) Then use- sudo pecl install mysqlnd_ms
3) Now open php.ini to enable it

extension=mysqlnd_ms.so
mysqlnd_ms.enable=1
mysqlnd_ms.config_file=/etc/mysqlnd_ms_config.ini

4) Configuring /etc/mysqlnd_ms_config_2.ini file-
{
"mpos-loadbalancing": {
"master": {
"master_0": {
"host": "master_mysqlserver_ip",
"port": "3306"
}
},
"slave": {
"slave_0": {
"host":"slave_mysqlserver_ip",
"port": "3306"
}
},
"failover": {
"strategy": "loop_before_master",
"remember_failed": true,
"max_retries": 1

},
"trx_stickiness": "master"
}
}

http://vagnvagensbygg.se/firmenit/4932 Things to note here:

trx_stickiness:master – is for enabling transactions. i.e for a transaction all queries will go to master (All read/write queries).

failover- When Slave server fails all read/write query request should go to master server.

You are done now.

Restart your apache and mysql server.

enter Check status: SHOW slave STATUS /G;

You can check phpinfo() in any of your file and search mysqlnd_ms. If it is setup it should show there.

Now all read queries will go to slave and insert/update to master.

For checking replication change a value in master it should replicate on slave.

For more info go to::

https://blog.engineyard.com/2014/advanced-read-write-splitting-with-phps-mysqlnd

https://github.com/MPOS/php-mpos/wiki/MySQL-Load-Balancing

https://www.percona.com/blog/2014/05/02/how-to-identify-and-cure-mysql-replication-slave-lag/