商场项目-Mysql读写分离

1.需求:提高数据库读写效率及安全性:

2.环境:两台主机部署mysql数据库,使用Centos,配置/etc/my.cnf:





3.Mater创建账号:

mysql> GRANT REPLICATION SLAVE ON *.* TO 'slave'@'%' identified by 'Slave@000';

mysql> FLUSH PRIVILEGES; #刷新权限



4.从mysql:

mysql> change master to master_host='192.168.1.240', master_user='slave', master_password='Slave@000',master_log_file='binlog.000013', master_log_pos=1;

mysql> start slave;

mysql> show slave status \G; #查看链接状态:



5.Django配置选择读写数据库的选择: