标签:host ati file ror slave emc ide query ast
环境设置systemctl enable mysqld
systemctl start mysqld
systemctl status mysqld
grep ‘password‘ /var/log/mysqld.log |head -n 1
mysql 主从构建
MASTER配置文件设置
Master 配置文件中开启bin-log文件,设置server-id,设置完毕重新启动mysql
[root@mysqlcluster1 ~]# vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-bin=mysql-bin
server-id= 1
[mysql_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
server-id:为主服务器A的ID值
log-bin:二进制变更日值
master上添加复制用户
授权同步用户和密码
登录mysql 数据库,新建数据库账号,赋予同步权限
mysql -uroot -p
在主服务器新建一个用户赋予“REPLICATION SLAVE”的权限。你不需要再赋予其它的权限。在下面的命令,把X.X.X.X替换为从服务器的IP。
mysql> GRANT REPLICATION SLAVE ON . TO ‘tongbu‘@‘%‘ IDENTIFIED BY ‘P@ssw0rd‘;
设置从库slave
Slave执行change master绑定主库
slave配置文件设置
vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-bin=mysql-bin
server-id= 2
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
执行change master
mysql> change master to master_host=‘192.168.1.51‘,
-> master_user=‘tongbu‘,
-> master_password=‘P@ssw0rd‘,
-> master_log_file=‘mysql-bin.000001‘,
-> master_log_pos=444;
Query OK, 0 rows affected, 2 warnings (0.01 sec)
change master to master_host=‘192.168.1.51‘,master_user=‘tongbu‘,master_password=‘P@ssw0rd‘,master_log_file=‘mysql-bin.000002‘,MASTER_LOG_POS=1084;
启动slave服务
mysql> start slave;
测试
在master数据库服务器创建一个数据库文件
mysql> show slave status\G
mysql> create database mysqltesting charset=utf8;
去从数据库查看
mysql> show databases;
查看文件内容
查看bin-log文件
mysql> show master status;
从库是从bin-log 444之后同步
mysql-bin.000001 文件位置在/var/lib/mysql/
ll /var/lib/mysql
bin-log文件内容
[root@mysqlcluster1 mysql]# mysqlbinlog mysql-bin.000002 |more
Bin-log文件中都是一些执行的步骤
记录了时间段及编号段内的执行的内容
relay-log日志
mysqlbinlog mysqlcluster2-relay-bin.000002 |more
master.info文件
Master.info文件在slave机器上,主要记录了同步账号和密码
cat master.info
标签:host ati file ror slave emc ide query ast
原文地址:https://blog.51cto.com/huxiaoqiu/2539788