Deploy MySQL master-slave server, create database and table according to PHP Programmer's requirement.
- Experimental requirements
Master: 192.168.43.229
From: 192.168.43.198
Master Master
- Turn on time synchronization
# systemctl stop firewalld.service //关闭防火墙# setenforce 0# vim /etc/ntp.conf末尾添加:server 127.127.43.0 //本地是时钟源// fudge 127.127.43.0 stratum 8 //设置时间层级为8(限制在15内# systemctl start ntpd.service //开启时间同步
from slave
- Turn on time synchronization
# systemctl stop firewalld.service //关闭防火墙# setenforce 0# systemctl start ntpd.service //开启时间同步# /usr/sbin/ntpdate 192.168.43.229
Install MySQL (master and slave)
# tar zxvf mysql-5.5.24.tar.gz-c/opt/# yum install gcc gcc-c++ make cmake ncurses-devel bison libaio-devel# useradd-s /sbin/nologin MySQL//add MySQL user and join to MySQL Group # mkdir/usr/local/mysql# Cd/opt/mysql-5.5.24.tar.gzcmake-dcmake_install_ Prefix=/usr/local/mysql-dmysql_unix_addr=/home/mysql/mysql.sock-ddefault_charset=utf8-ddefault_co Llation=utf8_general_ci-dwith_extra_charsets=all-dwith_myisam_storage_engine=1-dwith_innobase_ Storage_engine=1-dwith_memory_storage_engine=1-dwith_readline=1-denabled_local_infile=1 -dmysql_datadir=/home/mysql-dmysql_user=mysql-dmysql_tcp_port=3306 # make && make install # chown-r Mysql.mysql/usr/local/mysql # export path= $PATH:/usr/local/mysql/bin/\* Open *\ or optionally vi/etc/profile to run Source/etc/profile # CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF after the last line joins # CP Support-files/mySql.server/etc/init.d/mysqld # chmod 755/etc/init.d/mysqld # chkconfig--add/etc/init.d/mysqld # Chkconfig mysqld--level on initializing database #/usr/local/mysql/scripts/mysql_install_db--user=mysql--ldata=/var/lib/mysql-- Basedir=/usr/local/mysql--datadir=/home/mysql# ln-s/var/lib/mysql/mysql.sock/home/mysql/mysql.sock/* Directly establish a soft connection */# vi/etc/init.d/mysqldbasedir=/usr/local/mysqldatadir=/home/mysql# service mysqld start# mysqladmin-u root password ' 123123 '//Create a password for the root user
Main Mater
# vim /etc/my.cnfserver-id = 11log-bin=master-bin //主服务器日志文件//log-slave-updates=true //从服务器更新二进制日志//# systemctl restart mysqld.service# mysql -u root -pGRANT REPLICATION SLAVE ON *.* TO ‘myslave‘@‘192.168.43.%‘ IDENTIFIED BY ‘123456‘;# FLUSH PRIVILEGES;# show master status;
from slave
# vim /etc/my.cnfserver-id = 22relay-log=relay-log-bin //从主服务器上同步日志文件记录到本地//relay-log-index=slave-relay-bin.index //定义relay-log的位置和名称//# systemctl restart mysqld.service# mysql -u root -pchange master to master_host=‘192.168.43.229‘,master_user=‘myslave‘,master_password=‘123456‘,master_log_file=‘master-bin.000001‘,master_log_pos=338;# start slave;# show slave status\G; //查看状态//
Master Master
MySQL master-slave service for social networking sites deployed on CENTOS7