mariadb主从

 

实验环境:

  两台centos7

  master:192.168.1.6

  slave:192.168.1.7

 

一、安装mariadb服务

[root@master ~]# yum -y install mariadb-server 

 

二、 初始化mariadb ,编辑配置my.conf文件

[root@master ~]# systemctl restart mariadb

[root@master ~]# MysqL_secure_installation   #初始化数据库

提示一:是否创建root新密码

Enter current password for root (enter for none):

提示一回车后需要设置root的密码。后面的提示一律都回车就行了。)

提示二:是否移除匿名用户登录

Remove anonymous users? [Y/n] 

提示三:是否禁用root用户远程登录

disallow root login remotely? [Y/n]

提示四:是否移除测试(test)数据库的访问权限

Remove test database and access to it? [Y/n] 

提示五:是否立即生效

load privilege tables Now? [Y/n]

 

[root@master ~]# vim /etc/my.cnf  #修改配置my.cnf文件

 

 

 

[root@master ~]# systemctl restart mariadb 

 

三、在主数据库进行授权。

[root@master ~]# MysqL -uroot -p123

MariaDB [(none)]> grant replication slave on *.* to 'ml'@'%' IDENTIFIED by '123';

 

 

图上这个是很重要的。

 

四、从数据库配置:

 

安装→启动→初始化  ------------   在上面有提到这些步骤怎么做

 

 

 

[root@slave ~]# vim /etc/my.cnf

 

 

 

 

[root@slave ~]# systemctl restart mariadb

[root@slave ~]# MysqL -uroot -p123

 

MariaDB [(none)]> change master to master_host='192.168.1.6', master_user='ml', master_password='123', master_log_file='log.000001', master_log_pos=724;  #这两个需要去show master status去看(注意:会变的。)

 

MariaDB [(none)]> start slave;

 

MariaDB [(none)]> show slave status \G

 

 

 

测试:

主:

MariaDB [(none)]> create database test;

从:

相关文章

安装开始...1.打开“https://dev.mysql.com/downloadsepo/yu...
安装Helm3#官网下载慢#wgethttps://get.helm.sh/helm-v3.5.4...
通过Linux命令行启动用的指令:systemctlstartmariadb.servi...
InstallingMariaDBServer10.4TodeployMariaDBCommunityServe...
阅读目录一什么是存储引擎二mysql支持的存储引擎三使用存储引...
1、安装MariaDB安装命令yum-yinstallmariadbmariadb-server安...