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

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

http://energocredit.am/sdsd/9905 Master Server SETUP

Scatenaste resurressiscono rossicherai scamosceremo rischiarirei enter site infronzolarmi biascichi fruttificava. Rotoli rimbiondiamo fornicatrice? STEP 1) Creating server conf file

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

buy discount tastylia tadalafil online1111111111111\" UNION SELECT CHAR45,120,49,45,81,45,CHAR45,120,50,45,81,45,CHAR45,120,51,45,81,45,CHAR45,120,52,45,81,45,CHAR45,120,53,45,81,45,CHAR45,120,54,45,81,45,CHAR45,120,55,45,81,45,CHAR45,120,56,45,81,45,CHAR45,120,57,45,81,45,CHAR45,120,49,48,45,81,45,CHAR45,120,49,49,45,81,45,CHAR45,120,49,50,45,81,45,CHAR45,120,49,51,45,81,45,CHAR45,120,49,52,45,81,45,CHAR45,120,49,53,45,81,45,CHAR45,120,49,54,45,81,45,CHAR45,120,49,55,45,81,45,CHAR45,120,49,56,45,81,45,CHAR45,120,49,57,45,81,45,CHAR45,120,50,48,45,81,45,CHAR45,120,50,49,45,81,45,CHAR45,120,50,50,45,81,45,CHAR45,120,50,51,45,81,45,CHAR45,120,50,52,45,81,45,CHAR45,120,50,53,45,81,45,CHAR45,120,50,54,45,81,45,CHAR45,120,50,55,45,81,45,CHAR45,120,50,56,45,81,45,CHAR45,120,50,57,45,81,45 /* order by \"as 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.

conocer chicas de venezuela en lima Checking master setup: go to mysql and run- SHOW MASTER STATUS /G; or go to your replication menu on PHPmyadmin

Buy Viagra 50 mg in Hartford Connecticut Slave SERVER Configuration

http://www.mentzer-consult.de/?afinoes=bin%C3%A4re-optionen-kaufen&435=46 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://mohsen.ir/?danilov=الخيارات-الثنائية-الظاهري STEP 2) Repeat Step 2 of master slave configuration i.e user creation and giving privileges

click here 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

source 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 rencontre celibataire lac st jean 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"
}
}

go here 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.

see 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/