主从数据据库配置

1.关闭防护墙
setence 0
systemctl stop firewalls
2.配制主从ip
vi /etc/hosts
192.168.100.213 mysql1
192.168.100.122mysql2

配置yum 源
mv /etc/yum.repos.d/CentOS-* /media/
vi /etc/yum.repos.d/local.repo
mkdir /opt/centos
mount CentOS~~~ /opt/centos

3.安装数据库
yum -y install mariadb-server
启动数据库
systemctl start mariadb
systemctl enabled mariadb
4.初始化数据库
mysql_secure_installation
默认 Y Y N Y Y
配置mysql1
vi /etc/my.conf
[mysqld]
添加
log_bin=mysql-bin
binlog_ignore_db=mysql
server_id=30
systemctl restart mariadb
mysql -uroot -p000000
1节点
grant all privileges on *.* to root@'%' identified by "000000";

grant replication slave on *.* to 'user'@'mysql2' identified by '000000';
2节点
log_bin = mysql-bin
binlog_ignore_db=mysql
server_id =40
5
在2节点重启
systemctl restart mariadb
mysql - uroot -p000000
change master to master_host='mysql1',master_user='user',master_password='000000';
start slave;
show slave status\G
(stop slave)
(create database test;)
start slave;
show slave status\G

 

mysql数据库中的user表的hostuserpassword字段; (3)赋予这个用户对所有数据库拥有查询”“删除”“更新”“创建的本地权限。依次将操作命令和返回结果以文本形式提交到答题框。

参考答案:

[MariaDB [(none)]> insert into mysql.user(host,user,Password) values("localhost","examuser",Password("000000"));

Query OK, 1 row affected, 4 warnings (0.00 sec)

MariaDB [(none)]> use mysql

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

MariaDB [mysql]> select host,user,password from user;

+-----------+----------+-------------------------------------------+

| host | user | password |

+-----------+----------+-------------------------------------------+

| localhost | root | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

| xiandian | root | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

| 127.0.0.1 | root | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

| ::1 | root | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

| localhost | keystone | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

| % | keystone | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

| localhost | glance | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

| % | glance | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

| localhost | nova | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

| % | nova | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

| localhost | neutron | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

| % | neutron | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

| localhost | cinder | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

| % | cinder | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

| localhost | heat | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

| % | heat | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

| localhost | aodh | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

| % | aodh | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

| localhost | examuser | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |

+-----------+----------+-------------------------------------------+

19 rows in set (0.00 sec)

MariaDB [mysql]> grant select,delete,update,create on *.* to examuser@"localhost" identified by "000000";

Query OK, 0 rows affected (0.01 sec)

 

posted @ 2020-09-09 16:50  东北最后深情  阅读(207)  评论(0编辑  收藏  举报