MySQL主从读写分离之Proxysql(openEuler版)

实验目的:

基于proxysql实现MySQL的主从读写分离。

实验过程:

前期准备:

一共有四台虚拟机,其中三台为配置好的一主两从虚拟机,还有一台干净的虚拟机用来配置proxysql。

主机名地址
master192.168.27.137
node1192.168.27.139
node2192.168.27.140
proxysql192.168.27.141

proxysql下载:(此处链接为官方,也可进入percona或者github官网进行下载适合的版本)ProxySQL - A High Performance Open Source MySQL Proxyicon-default.png?t=N7T8https://www.proxysql.com/

实验过程:

在proxysql所在虚拟机配置:
下载并安装proxysql以及mysql客户端(mariadb):
[root@localhost ~]# yum install proxysql-2.5.5-1-centos8.x86_64.rpm
[root@localhost ~]# dnf install mariadb
启动proxysql服务:
[root@localhost ~]# systemctl enable --now proxysql
登录proxysql:
[root@localhost ~]# mysql -uadmin -padmin -h 127.0.0.1 -P 6032
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.30 (ProxySQL Admin Module)

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> show databases;//查看数据库
+-----+---------------+-------------------------------------+
| seq | name          | file                                |
+-----+---------------+-------------------------------------+
| 0   | main          |                                     |
| 2   | disk          | /var/lib/proxysql/proxysql.db       |
| 3   | stats         |                                     |
| 4   | monitor       |                                     |
| 5   | stats_history | /var/lib/proxysql/proxysql_stats.db |
+-----+---------------+-------------------------------------+
5 rows in set (0.000 sec)
可见有五个库: main、disk、stats 、monitor 和 stats_history
main: 内存配置数据库,即 MEMORY,表里存放后端 db 实例、用户验证、路由规则等信息。main 库中有如下信息:
MySQL [(none)]> show tables from main;
+----------------------------------------------------+
| tables                                             |
+----------------------------------------------------+
| coredump_filters                                   |
| global_variables                                   |
| mysql_aws_aurora_hostgroups                        |
| mysql_collations                                   |
| mysql_firewall_whitelist_rules                     |
| mysql_firewall_whitelist_sqli_fingerprints         |
| mysql_firewall_whitelist_users                     |
| mysql_galera_hostgroups                            |
| mysql_group_replication_hostgroups                 |
| mysql_hostgroup_attributes                         |
| mysql_query_rules                                  |
| mysql_query_rules_fast_routing                     |
| mysql_replication_hostgroups                       |
| mysql_servers                                      |
| mysql_users                                        |
| proxysql_servers                                   |
| restapi_routes                                     |
| runtime_checksums_values                           |
| runtime_coredump_filters                           |
| runtime_global_variables                           |
| runtime_mysql_aws_aurora_hostgroups                |
| runtime_mysql_firewall_whitelist_rules             |
| runtime_mysql_firewall_whitelist_sqli_fingerprints |
| runtime_mysql_firewall_whitelist_users             |
| runtime_mysql_galera_hostgroups                    |
| runtime_mysql_group_replication_hostgroups         |
| runtime_mysql_hostgroup_attributes                 |
| runtime_mysql_query_rules                          |
| runtime_mysql_query_rules_fast_routing             |
| runtime_mysql_replication_hostgroups               |
| runtime_mysql_servers                              |
| runtime_mysql_users                                |
| runtime_proxysql_servers                           |
| runtime_restapi_routes                             |
| runtime_scheduler                                  |
| scheduler                                          |
+----------------------------------------------------+
36 rows in set (0.001 sec)
mysql_servers: 后端可以连接 MySQL 服务器的列表
mysql_users: 配置后端数据库的账号和监控的账号。
mysql_query_rules: 指定 Query 路由到后端不同服务器的规则列表。
注: 表名以 runtime_开头的表示 ProxySQL 当前运行的配置内容,不能通过 DML 语句修改。
只能修改对应的不以 runtime 开头的表,然后 “LOAD” 使其生效,“SAVE” 使其存到硬盘以供下次重启加载。
在主库(master)中的配置:
创建proxysql的监控账户和对外访问账户:
mysql> create user 'monitor'@'192.168.%.%' identified with mysql_native_password by 'Monitor@123.com';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'monitor'@'192.168.%.%' with grant option;
Query OK, 0 rows affected (0.01 sec)
mysql> create user 'proxysql'@'192.168.%.%' identified with mysql_native_password by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'proxysql'@'192.168.%.%' with grant option;
Query OK, 0 rows affected (0.00 sec)
配置proxysql:
查看需要用到的表的表结构:
MySQL [(none)]> show create table mysql_replication_hostgroups \G
*************************** 1. row ***************************
       table: mysql_replication_hostgroups
Create Table: CREATE TABLE mysql_replication_hostgroups (
    writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY,
    reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>=0),
    check_type VARCHAR CHECK (LOWER(check_type) IN ('read_only','innodb_read_only','super_read_only','read_only|innodb_read_only','read_only&innodb_read_only')) NOT NULL DEFAULT 'read_only',
    comment VARCHAR NOT NULL DEFAULT '', UNIQUE (reader_hostgroup))
1 row in set (0.000 sec)
创建新的组(定义写为1,读为0)
MySQL [(none)]>  insert into mysql_replication_hostgroups (writer_hostgroup,reader_hostgroup,comment) values (1,0,'proxy');
Query OK, 1 row affected (0.000 sec)
MySQL [(none)]> load mysql servers to runtime;//加载到当前生效
Query OK, 0 rows affected (0.003 sec)
MySQL [(none)]> save mysql servers to disk;//持久化保存
Query OK, 0 rows affected (0.018 sec)
ProxySQL会根据server的read_only的取值将服务器进行分组。read_only=0的server,master被分到编号为1的写组,read_only=1的server,slave则分到编号为0的读组
MySQL [(none)]> select * from mysql_replication_hostgro
+------------------+------------------+------------+---
| writer_hostgroup | reader_hostgroup | check_type | co
+------------------+------------------+------------+---
| 1                | 0                | read_only  | pr
+------------------+------------------+------------+---
1 row in set (0.000 sec)
添加主从服务器节点:
MySQL [(none)]> insert into mysql_servers(hostgroup_id,hostname,port) values (1,'192.168.27.137',3306);
Query OK, 1 row affected (0.000 sec)
MySQL [(none)]>  insert into mysql_servers(hostgroup_id,hostname,port) values (0,'192.168.27.139',3306);
Query OK, 1 row affected (0.000 sec)
MySQL [(none)]> insert into mysql_servers(hostgroup_id,hostname,port) values (0,'192.168.27.140',3306);
Query OK, 1 row affected (0.000 sec)
MySQL [(none)]> load mysql servers to runtime;
Query OK, 0 rows affected (0.002 sec)
MySQL [(none)]> save mysql servers to disk;
Query OK, 0 rows affected (0.015 sec)
MySQL [(none)]>  select * from mysql_servers;
+--------------+----------------+------+-----------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| hostgroup_id | hostname       | port | gtid_port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+----------------+------+-----------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| 1            | 192.168.27.137 | 3306 | 0         | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |
| 0            | 192.168.27.139 | 3306 | 0         | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |
| 0            | 192.168.27.140 | 3306 | 0         | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |
+--------------+----------------+------+-----------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
3 rows in set (0.000 sec)
为proxysql监控mysql后端节点:
MySQL [(none)]> use monitor//使用monitor
Database changed
MySQL [monitor]> set mysql-monitor_username='monitor';//创建用户 
Query OK, 1 row affected (0.000 sec)
MySQL [monitor]> set mysql-monitor_password='Monitor@123.com';//填写密码
Query OK, 1 row affected (0.000 sec)
MySQL [monitor]>  load mysql variables to runtime;//加载到当前
Query OK, 0 rows affected (0.001 sec)
MySQL [monitor]> save mysql variables to disk;//持久化保存
Query OK, 158 rows affected (0.003 sec)
MySQL [monitor]> select @@mysql-monitor_username;//查看用户名
+--------------------------+
| @@mysql-monitor_username |
+--------------------------+
| monitor                  |
+--------------------------+
1 row in set (0.001 sec)
MySQL [monitor]> select @@mysql-monitor_password;//查看密码
+--------------------------+
| @@mysql-monitor_password |
+--------------------------+
| Monitor@123.com          |
+--------------------------+
1 row in set (0.001 sec)
MySQL [monitor]> select * from monitor.mysql_server_connect_log;//查看日志信息
+----------------+------+------------------+-------------------------+-------------------------------------------------------------------------+
| hostname       | port | time_start_us    | connect_success_time_us | connect_error                                                           |
+----------------+------+------------------+-------------------------+-------------------------------------------------------------------------+
| 192.168.27.140 | 3306 | 1709796180625505 | 0                       | Access denied for user 'monitor'@'192.168.27.141' (using password: YES) |
| 192.168.27.137 | 3306 | 1709796181067381 | 0                       | Access denied for user 'monitor'@'192.168.27.141' (using password: YES) |
| 192.168.27.139 | 3306 | 1709796181508932 | 0                       | Access denied for user 'monitor'@'192.168.27.141' (using password: YES) |
| 192.168.27.140 | 3306 | 1709796240626303 | 0                       | Access denied for user 'monitor'@'192.168.27.141' (using password: YES) |
| 192.168.27.137 | 3306 | 1709796241217740 | 0                       | Access denied for user 'monitor'@'192.168.27.141' (using password: YES) |
| 192.168.27.139 | 3306 | 1709796241809274 | 0                       | Access denied for user 'monitor'@'192.168.27.141' (using password: YES) |
| 192.168.27.139 | 3306 | 1709796300626918 | 0                       | Access denied for user 'monitor'@'192.168.27.141' (using password: YES) |
| 192.168.27.137 | 3306 | 1709796301097796 | 0                       | Access denied for user 'monitor'@'192.168.27.141' (using password: YES) |
| 192.168.27.140 | 3306 | 1709796301568472 | 0                       | Access denied for user 'monitor'@'192.168.27.141' (using password: YES) |
| 192.168.27.139 | 3306 | 1709796306543844 | 1884                    | NULL                                                                    |
| 192.168.27.140 | 3306 | 1709796307338491 | 1778                    | NULL                                                                    |
| 192.168.27.137 | 3306 | 1709796308132494 | 1261                    | NULL                                                                    |
| 192.168.27.137 | 3306 | 1709796366544441 | 1317                    | NULL                                                                    |
| 192.168.27.139 | 3306 | 1709796367110254 | 1339                    | NULL                                                                    |
| 192.168.27.140 | 3306 | 1709796367683285 | 1771                    | NULL                                                                    |
+----------------+------+------------------+-------------------------+-------------------------------------------------------------------------+
15 rows in set (0.000 sec)
查看心跳信息:
MySQL [monitor]> select * from mysql_server_ping_log;
+----------------+------+------------------+--------------------------+
| hostname       | port | time_start_us    | ping_succe               |
+----------------+------+------------------+--------------------------+
| 192.168.27.140 | 3306 | 1709796150706279 | 0         password: YES) |
| 192.168.27.139 | 3306 | 1709796150706317 | 0         password: YES) |
| 192.168.27.137 | 3306 | 1709796150707742 | 0         password: YES) |
| 192.168.27.139 | 3306 | 1709796160707187 | 0         password: YES) |
| 192.168.27.137 | 3306 | 1709796160707414 | 0         password: YES) |
| 192.168.27.140 | 3306 | 1709796160709026 | 0         password: YES) |
| 192.168.27.140 | 3306 | 1709796170707830 | 0         password: YES) |
| 192.168.27.137 | 3306 | 1709796170707893 | 0         password: YES) |
| 192.168.27.139 | 3306 | 1709796170709330 | 0         password: YES) |
| 192.168.27.140 | 3306 | 1709796180708671 | 0         password: YES) |
| 192.168.27.139 | 3306 | 1709796180708437 | 0         password: YES) |
| 192.168.27.137 | 3306 | 1709796180711690 | 0         password: YES) |
| 192.168.27.137 | 3306 | 1709796190709041 | 0         password: YES) |
| 192.168.27.140 | 3306 | 1709796190709143 | 0         password: YES) |
| 192.168.27.139 | 3306 | 1709796190710542 | 0         password: YES) |
| 192.168.27.137 | 3306 | 1709796200709720 | 0         password: YES) |
| 192.168.27.139 | 3306 | 1709796200709721 | 0         password: YES) |
| 192.168.27.140 | 3306 | 1709796200710996 | 0         password: YES) |
| 192.168.27.140 | 3306 | 1709796210710277 | 0         password: YES) |
| 192.168.27.137 | 3306 | 1709796210710291 | 0         password: YES) |
| 192.168.27.139 | 3306 | 1709796210711528 | 0         password: YES) |
| 192.168.27.137 | 3306 | 1709796220711158 | 0         password: YES) |
| 192.168.27.140 | 3306 | 1709796220711010 | 0         password: YES) |
| 192.168.27.139 | 3306 | 1709796220712626 | 0         password: YES) |
| 192.168.27.140 | 3306 | 1709796230711681 | 0         password: YES) |
| 192.168.27.137 | 3306 | 1709796230711766 | 0         password: YES) |
| 192.168.27.139 | 3306 | 1709796230712791 | 0         password: YES) |
| 192.168.27.139 | 3306 | 1709796240712290 | 0         password: YES) |
| 192.168.27.137 | 3306 | 1709796240712403 | 0         password: YES) |
| 192.168.27.140 | 3306 | 1709796240714933 | 0         password: YES) |
| 192.168.27.140 | 3306 | 1709796250712823 | 0         password: YES) |
| 192.168.27.139 | 3306 | 1709796250712816 | 0         password: YES) |
| 192.168.27.137 | 3306 | 1709796250714279 | 0         password: YES) |
| 192.168.27.139 | 3306 | 1709796260713537 | 0         password: YES) |
| 192.168.27.137 | 3306 | 1709796260713528 | 0         password: YES) |
| 192.168.27.140 | 3306 | 1709796260715467 | 0         password: YES) |
| 192.168.27.140 | 3306 | 1709796270714115 | 0         password: YES) |
| 192.168.27.139 | 3306 | 1709796270714202 | 0         password: YES) |
| 192.168.27.137 | 3306 | 1709796270715440 | 0         password: YES) |
| 192.168.27.140 | 3306 | 1709796280714926 | 0         password: YES) |
| 192.168.27.139 | 3306 | 1709796280715011 | 0         password: YES) |
| 192.168.27.137 | 3306 | 1709796280716414 | 0         password: YES) |
| 192.168.27.140 | 3306 | 1709796290715577 | 0         password: YES) |
| 192.168.27.137 | 3306 | 1709796290715497 | 0         password: YES) |
| 192.168.27.139 | 3306 | 1709796290718626 | 0         password: YES) |
| 192.168.27.140 | 3306 | 1709796300716091 | 0         password: YES) |
| 192.168.27.137 | 3306 | 1709796300716161 | 0         password: YES) |
| 192.168.27.139 | 3306 | 1709796300717430 | 0         password: YES) |
| 192.168.27.137 | 3306 | 1709796306725083 | 234                      |
| 192.168.27.140 | 3306 | 1709796306725072 | 160                      |
| 192.168.27.139 | 3306 | 1709796306725193 | 132                      |
| 192.168.27.137 | 3306 | 1709796316725952 | 436                      |
| 192.168.27.139 | 3306 | 1709796316726154 | 259                      |
| 192.168.27.140 | 3306 | 1709796316726119 | 301                      |
| 192.168.27.140 | 3306 | 1709796326726613 | 501                      |
| 192.168.27.139 | 3306 | 1709796326726788 | 353                      |
| 192.168.27.137 | 3306 | 1709796326726752 | 396                      |
| 192.168.27.137 | 3306 | 1709796336726831 | 425                      |
| 192.168.27.140 | 3306 | 1709796336726960 | 319                      |
| 192.168.27.139 | 3306 | 1709796336726942 | 343                      |
| 192.168.27.140 | 3306 | 1709796346742368 | 1308                     |
| 192.168.27.139 | 3306 | 1709796346742539 | 1165                     |
| 192.168.27.137 | 3306 | 1709796346742517 | 1197                     |
| 192.168.27.137 | 3306 | 1709796356743147 | 547                      |
| 192.168.27.140 | 3306 | 1709796356743301 | 425                      |
| 192.168.27.139 | 3306 | 1709796356743278 | 459                      |
| 192.168.27.137 | 3306 | 1709796366743429 | 407                      |
| 192.168.27.140 | 3306 | 1709796366743562 | 291                      |
| 192.168.27.139 | 3306 | 1709796366743545 | 314                      |
| 192.168.27.140 | 3306 | 1709796376745397 | 868                      |
| 192.168.27.139 | 3306 | 1709796376745537 | 752                      |
| 192.168.27.137 | 3306 | 1709796376745518 | 778                      |
| 192.168.27.139 | 3306 | 1709796386745976 | 521                      |
| 192.168.27.140 | 3306 | 1709796386746122 | 406                      |
| 192.168.27.137 | 3306 | 1709796386746109 | 428                      |
| 192.168.27.140 | 3306 | 1709796396746574 | 1349                     |
| 192.168.27.137 | 3306 | 1709796396746710 | 1239                     |
| 192.168.27.139 | 3306 | 1709796396746690 | 1266                     |
| 192.168.27.137 | 3306 | 1709796406747306 | 1100                     |
| 192.168.27.139 | 3306 | 1709796406747510 | 944                      |
| 192.168.27.140 | 3306 | 1709796406747486 | 979                      |
| 192.168.27.139 | 3306 | 1709796416748048 | 431                      |
| 192.168.27.137 | 3306 | 1709796416748195 | 305                      |
| 192.168.27.140 | 3306 | 1709796416748215 | 291                      |
| 192.168.27.139 | 3306 | 1709796426748430 | 797                      |
| 192.168.27.137 | 3306 | 1709796426748565 | 684                      |
| 192.168.27.140 | 3306 | 1709796426748549 | 707                      |
| 192.168.27.140 | 3306 | 1709796436748942 | 551                      |
| 192.168.27.139 | 3306 | 1709796436749096 | 428                      |
| 192.168.27.137 | 3306 | 1709796436749075 | 457                      |
| 192.168.27.139 | 3306 | 1709796446749755 | 677                      |
| 192.168.27.140 | 3306 | 1709796446749900 | 561                      |
| 192.168.27.137 | 3306 | 1709796446749880 | 590                      |
| 192.168.27.137 | 3306 | 1709796456753858 | 1380                     |
| 192.168.27.139 | 3306 | 1709796456754148 | 1129                     |
| 192.168.27.140 | 3306 | 1709796456754111 | 1176                     |
| 192.168.27.140 | 3306 | 1709796466754180 | 882                      |
| 192.168.27.137 | 3306 | 1709796466754360 | 741                      |
| 192.168.27.139 | 3306 | 1709796466754339 | 769                      |
| 192.168.27.137 | 3306 | 1709796476755056 | 389                      |
| 192.168.27.139 | 3306 | 1709796476755239 | 229                      |
| 192.168.27.140 | 3306 | 1709796476755187 | 294                      |
| 192.168.27.139 | 3306 | 1709796486755641 | 441                      |
| 192.168.27.137 | 3306 | 1709796486755703 | 397                      |
| 192.168.27.140 | 3306 | 1709796486755684 | 422                      |
| 192.168.27.137 | 3306 | 1709796496755840 | 479                      |
| 192.168.27.140 | 3306 | 1709796496756003 | 381                      |
| 192.168.27.139 | 3306 | 1709796496755990 | 401                      |
| 192.168.27.139 | 3306 | 1709796506756185 | 348                      |
| 192.168.27.137 | 3306 | 1709796506756298 | 260                      |
| 192.168.27.140 | 3306 | 1709796506756313 | 252                      |
| 192.168.27.140 | 3306 | 1709796516756932 | 517                      |
| 192.168.27.139 | 3306 | 1709796516757138 | 331                      |
| 192.168.27.137 | 3306 | 1709796516757160 | 367                      |
| 192.168.27.140 | 3306 | 1709796526757309 | 337                      |
| 192.168.27.139 | 3306 | 1709796526757433 | 236                      |
| 192.168.27.137 | 3306 | 1709796526757417 | 258                      |
| 192.168.27.139 | 3306 | 1709796536757782 | 458                      |
| 192.168.27.137 | 3306 | 1709796536757910 | 349                      |
| 192.168.27.140 | 3306 | 1709796536757894 | 372                      |
| 192.168.27.140 | 3306 | 1709796546758288 | 477                      |
| 192.168.27.137 | 3306 | 1709796546758460 | 327                      |
| 192.168.27.139 | 3306 | 1709796546758436 | 358                      |
| 192.168.27.137 | 3306 | 1709796556758969 | 473                      |
| 192.168.27.139 | 3306 | 1709796556759144 | 345                      |
| 192.168.27.140 | 3306 | 1709796556759119 | 377                      |
| 192.168.27.140 | 3306 | 1709796566759542 | 440                      |
| 192.168.27.137 | 3306 | 1709796566759671 | 330                      |
| 192.168.27.139 | 3306 | 1709796566759654 | 355                      |
+----------------+------+------------------+--------------------------+
129 rows in set (0.000 sec)
查看read_only监控:
MySQL [monitor]> select * from mysql_server_read_only_log;//此次查询结果报错信息全为0需要进行过更改
对两个从服务器的配置文件进行更改,添加read_only=1让两从文件只课读:
mysql> system vim /etc/my.cnf
mysql> system systemctl restart mysql
再次查看read_only表信息:
                                          |
| 192.168.27.137 | 3306 | 1709796956508275 | 485             | 0         | NULL                                                                                        |
| 192.168.27.139 | 3306 | 1709796956508323 | 446             | 1         | NULL                                                                                        |
| 192.168.27.139 | 3306 | 1709796958008641 | 627             | 1         | NULL                                                                                        |
| 192.168.27.140 | 3306 | 1709796958008789 | 516             | 1         | NULL                                                                                        |
| 192.168.27.137 | 3306 | 1709796958008776 | 542             | 0         | NULL    
proxysql配置对外访问账号:
MySQL [monitor]> insert into 
mysql_users(username,password,default_hostgroup,transaction_persistent) values ('proxysql','123456',1,1);
Query OK, 1 row affected (0.000 sec)
MySQL [monitor]> load mysql users to runtime;
Query OK, 0 rows affected (0.000 sec)
MySQL [monitor]> save mysql users to disk;
Query OK, 0 rows affected (0.011 sec)
MySQL [monitor]> select * from mysql_users\G
*************************** 1. row ***************************
              username: proxysql
              password: 123456
                active: 1
               use_ssl: 0
     default_hostgroup: 1
        default_schema: NULL
         schema_locked: 0
transaction_persistent: 1
          fast_forward: 0
               backend: 1
              frontend: 1
       max_connections: 10000
            attributes: 
               comment: 
1 row in set (0.000 sec)
在从库192.168.27.139上通过对方询问账号proxysql连接,是否路由能默认到写组:
[root@node1 ~]# mysql -h192.168.27.141 -uproxysql -p'123456' -P 6033
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.30 (ProxySQL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| school             |
| sys                |
+--------------------+
5 rows in set (0.01 sec)

mysql> select @@server_id;
+-------------+
| @@server_id |
+-------------+
|           1 |
+-------------+
1 row in set (0.00 sec)

mysql> create database keme;
Query OK, 1 row affected (0.01 sec)
在从库192.168.27.140上进行验证看是否能查看到keme:
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| keme               |
| mysql              |
| performance_schema |
| school             |
| sys                |
+--------------------+
6 rows in set (0.00 sec)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/445416.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

NGINX源码安装详细配置文档

NGINX源码安装详细配置文档 一、基础Linux指令 查看nginx进程是否启动&#xff1a;ps -ef | grep nginx 关闭防火墙&#xff1a;systemctl stop firewalld 开放80端口&#xff1a;firewall-cmd --zonepublic --add-port80/tcp --permanent 关闭80端口&#xff1a;firewall-cmd …

(C语言)strcpy与strcpy详解,与模拟实现

目录 1. strcpy strcpy模拟实现&#xff1a; 实现方法1&#xff1a; 实现方法2&#xff1a; 2. strcat strcat模拟实现&#xff1a; 1. strcpy 作用&#xff1a;完成字符串的复制。 头文件&#xff1a;<string.h> destination是字符串要复制到的地点&#xff0c;s…

redis持久化-rdb

redis持久化-rdb策略 redis持久化rdb策略触发时机自动触发手动触发bgsave redis持久化 &#x1f680;我们知道redis是将数据存储在内存当中的&#xff0c;通常使用来作为关系型数据库的缓存使用的&#xff0c;以缓解当大量请求到来时关系型数据库的压力。 &#x1f680;既然数…

[LeetCode][226]翻转二叉树

题目 226. 翻转二叉树 给你一棵二叉树的根节点 root&#xff0c;翻转这棵二叉树&#xff0c;并返回其根节点。 示例 1&#xff1a; 输入&#xff1a;root [4,2,7,1,3,6,9] 输出&#xff1a;[4,7,2,9,6,3,1] 示例 2&#xff1a; 输入&#xff1a;root [2,1,3] 输出&#x…

025—pandas 根多列判断不在其他列的数据

思路 是有两个相同结构的数据表&#xff0c;已知第二个表是第一个表的部分数据&#xff0c;需要以其中两列为单位&#xff0c;判断在第一个表中存在&#xff0c;在另外一个表中不存在的数据。 思路&#xff1a; 我们先将 df1 和 df2 的 x、y 列取出&#xff0c;组合为元组形成…

013 Linux_互斥

前言 本文将会向你介绍互斥的概念&#xff0c;如何加锁与解锁&#xff0c;互斥锁的底层原理是什么 线程ID及其地址空间布局 每个线程拥有独立的线程上下文&#xff1a;一个唯一的整数线程ID, 独立的栈和栈指针&#xff0c;程序计数器&#xff0c;通用的寄存器和条件码。 和其…

【Python】成功解决IndexError: list index out of range

【Python】成功解决IndexError: list index out of range &#x1f308; 个人主页&#xff1a;高斯小哥 &#x1f525; 高质量专栏&#xff1a;Matplotlib之旅&#xff1a;零基础精通数据可视化、Python基础【高质量合集】、PyTorch零基础入门教程&#x1f448; 希望得到您的订…

整除光棍(pta团体天梯练习题)模拟手算除法c++

这里所谓的“光棍”&#xff0c;并不是指单身汪啦~ 说的是全部由1组成的数字&#xff0c;比如1、11、111、1111等。传说任何一个光棍都能被一个不以5结尾的奇数整除。比如&#xff0c;111111就可以被13整除。 现在&#xff0c;你的程序要读入一个整数x&#xff0c;这个整数一定…

朴素贝叶斯 | 多分类问题

目录 一. 贝叶斯公式的推导二. 朴素贝叶斯1. 离散的朴素贝叶斯朴素贝叶斯导入示例 离散的朴素贝叶斯训练 2. 连续的朴素贝叶斯3. 伯努利朴素贝叶斯4. 多项式朴素贝叶斯4.1 Laplace平滑4.2 Lidstone平滑 三. 概率图模型1. 贝叶斯网络(Bayesian Network)1.1 全连接贝叶斯网络1.2 …

【Redis知识点总结】(二)——Redis高性能IO模型剖析

Redis知识点总结&#xff08;二&#xff09;——Redis高性能IO模型及其事件驱动框架剖析 IO多路复用传统的阻塞式IO同步非阻塞IOIO多路复用机制 Redis的IO模型Redis的事件驱动框架 IO多路复用 Redis的高性能的秘密&#xff0c;在于它底层使用了IO多路复用这种高性能的网络IO&a…

[java入门到精通] 18 字符流,编码表,对象流,其他流

今日目标 编码表 字符输出流 字符输入流 字符缓冲流 转换流 对象操作流 装饰模式 commons-iojar包 1 编码表 1.1 思考&#xff1a; 既然字节流可以操作所有文件&#xff0c;那么为什么还要学习字符流 &#xff1f; 如果使用字节流 , 把文本文件中的内容读取到内存时…

ODP(Open Data Plane)

1. 摘要 本文档旨在指导新的ODP应用程序开发人员。 有关ODP的更多详细信息&#xff0c;请参见 ODP 主页。 Overview of a system running ODP applications ODP是一份API规范&#xff0c;为高性能网络应用程序的实现提供平台独立性、自动硬件加速和CPU扩展。 本文档介绍如何充…

DHCP中继实验(思科)

华为设备参考&#xff1a;DHCP中继实验&#xff08;华为&#xff09; 一&#xff0c;技术简介 DHCP中继&#xff0c;可以实现在不同子网和物理网段之间处理和转发DHCP信息的功能。如果DHCP客户机与DHCP服务器在同一个物理网段&#xff0c;则客户机可以正确地获得动态分配的IP…

OS-Copilot:实现具有自我完善能力的通用计算机智能体

&#x1f349; CSDN 叶庭云&#xff1a;https://yetingyun.blog.csdn.net/ AI 缩小了人类间的知识和技术差距 论文标题&#xff1a;OS-Copilot: Towards Generalist Computer Agents with Self-Improvement 论文链接&#xff1a;https://arxiv.org/abs/2402.07456 项目主页&a…

Hadoop生态选择(一)

一、项目框架 1.1技术选型 技术选型主要考虑因素:维护成本、总成本预算、数据量大小、业务需求、行业内经验、技术成熟度。 数据采集传输:Flume&#xff0c;Kafka&#xff0c;DataX&#xff0c;Maxwell&#xff0c;Sqoop&#xff0c;Logstash数据存储:MySQL&#xff0c;HDFS…

全网最最最详细的centos7如何设置静态ip

以下步骤假设你已经有了管理员权限&#xff08;或者可以使用sudo&#xff09;以及你的网络接口名称&#xff08;例如ens33&#xff09;。 步骤 1: 查找网络接口名称 打开终端。运行命令nmcli d来查看所有网络设备及其状态。找到你想配置的设备名称&#xff0c;比如ens33。 步…

结构指针的使用

结构指针的使用 指针类型变量&#xff1a; 指针类型&#xff0c;是变量类型的一种&#xff0c;它是专门用来存储变量的地址的。 例如 int *p; 表示p是一个指针变量&#xff0c;它用来存储某个整型变量的地址。 int a5; int *p&a; 这样&#xff0c;就将整型变量a的地…

Python语言元素之变量

程序是指令的集合&#xff0c;写程序就是用指令控制计算机做我们想让它做的事情。那么&#xff0c;为什么要用Python语言来写程序呢&#xff1f;因为Python语言简单优雅&#xff0c;相比C、C、Java这样的编程语言&#xff0c;Python对初学者更加友好。 一、一些计算机常识 在…

YOLOv9最新的改进项目来了!!

专栏介绍&#xff1a;YOLOv9改进系列 | 包含深度学习最新创新&#xff0c;主力高效涨点&#xff01;&#xff01;&#xff01; YOLOv9作为最新的YOLO系列模型&#xff0c;对于做目标检测的同学是必不可少的。本专栏将针对2024年最新推出的YOLOv9检测模型&#xff0c;使用当前流…

RabbitMQ - 06 - Topic交换机

目录 控制台创建队列与交换机 编写消费者方法 编写生产者测试方法 结果 Topic交换机与Direct交换机基本一致 可参考 这篇帖子 http://t.csdnimg.cn/AuvoK topic交换机与Direct交换机的区别是 Topic交换机接收的消息RoutingKey必须是多个单词&#xff0c;以 . 分割 Topic交…