mysql-搭建主从复制

news2024/11/17 17:41:48

文章目录

  • 1、准备主服务器
  • 2、准备从服务器
  • 3、主库配置
    • 3.1、创建MySQL主服务器配置文件:
  • 4、从库配置
  • 5、搭建主从&测试
    • 5.1、使用命令行登录MySQL主服务器
    • 5.2、主机中查询master状态:
    • 5.3、从机中查询slave状态:
    • 5.4、主机中创建slave用户:
    • 5.5、在从机上配置主从关系:
    • 5.6、启动从库的io和sql线程:都启动成功主从才搭建成功
  • 6、在3306主机上创建mydb1
  • 7、在3306主机上创建mydb2
  • 8、在3306主机上创建mydb3
  • 9、在3306主机上创建mydb4

mysql集群:
单台设备的负载压力:主从复制
集群:分摊访问压力和存储压力
需求:使用 3306 mysql当作主, 3316 mysql 当作从,在3306中对 mydb2/mydb3 数据库所有的操作,希望能够主从复制同步到3316,其他的数据库操作不同步。

1、准备主服务器

[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                       COMMAND                   CREATED        STATUS      PORTS                                                                                  
ab66508d9441   mysql:8                     "docker-entrypoint.s…"   8 months ago   Up 9 days   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp                                   spzx-mysql

此时我已经有一个主服务器 spzx-mysql

2、准备从服务器

docker run -d \
-p 3316:3306 \
-v mysql-slave1-conf:/etc/mysql/conf.d \
-v mysql-slave1-data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=123456 \
--name atguigu-mysql-slave1 \
mysql:8
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                       COMMAND                   CREATED          STATUS         PORTS                                                                                  NAMES
c236f876ae40   mysql:8                     "docker-entrypoint.s…"   10 seconds ago   Up 3 seconds   33060/tcp, 0.0.0.0:3316->3306/tcp, :::3316->3306/tcp                                   atguigu-mysql-slave1
ab66508d9441   mysql:8                     "docker-entrypoint.s…"   8 months ago     Up 9 days      0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp                                   spzx-mysql

3、主库配置

  1. 先在主mysql中配置 记录mydb2/mydb3库的操作日志到binlog日志文件中
    – 主库写操作会按照配置记录到二进制文件中(binlog)
    – 主库需要创建一个从账户并分配可以读取binlog日志的权限
  2. 在从mysql中配置中继日志文件,用来保存读取到的mysql主的 binlog 日志
    – 从库可以开启主从复制,从指定的主库的binlog文件中加载日志缓存到自己的relaylog文件中,最后通过一个sql线程将relaylog文件中的日志replay到自己的库表中
    – 从库需要使用主库提供的账号和主库的binlog文件建立连接

3.1、创建MySQL主服务器配置文件:

[root@localhost ~]# docker inspect spzx-mysql 
        "Mounts": [
            {
                "Type": "volume",
                "Name": "mysql_conf",
                "Source": "/var/lib/docker/volumes/mysql_conf/_data",
                "Destination": "/etc/mysql",
                "Driver": "local",
                "Mode": "z",
                "RW": true,
                "Propagation": ""
            },
            {
                "Type": "volume",
                "Name": "mysql_data",
                "Source": "/var/lib/docker/volumes/mysql_data/_data",
                "Destination": "/var/lib/mysql",
                "Driver": "local",
                "Mode": "z",
                "RW": true,
                "Propagation": ""
            }
        ],
[root@localhost _data]# cd /var/lib/docker/volumes/mysql_conf/_data
[root@localhost _data]# ll
总用量 8
drwxrwxr-x. 2 root root   41 1226 2023 conf.d
-rw-rw-r--. 1 root root 1080 1221 2021 my.cnf
-rw-r--r--. 1 root root 1448 928 2021 my.cnf.fallback
[root@localhost _data]# vim my.cnf

配置如下内容:

[mysqld]
# 服务器唯一id,默认值1
server-id=1
# 设置日志格式,默认值ROW。row(记录行数据)  statement(记录sql)  mixed(混合模式)
binlog_format=STATEMENT
# 二进制日志名,默认binlog
# log-bin=binlog
log-bin=spzxbinlog
# 设置需要复制的数据库,默认复制全部数据库
binlog-do-db=mydb2
binlog-do-db=mydb3
# 设置不需要复制的数据库
binlog-ignore-db=mydb4
#binlog-ignore-db=infomation_schema

在这里插入图片描述

[root@localhost _data]# docker restart spzx-mysql
spzx-mysql
[root@localhost _data]# ll ../../mysql_data/_data/

在这里插入图片描述

4、从库配置

[root@localhost _data]# docker inspect atguigu-mysql-slave1 

在这里插入图片描述

vim /var/lib/docker/volumes/mysql-slave1-conf/_data/my.cnf

配置如下内容:

[mysqld]
# 服务器唯一id,每台服务器的id必须不同,如果配置其他从机,注意修改id
server-id=2
# 中继日志名,默认xxxxxxxxxxxx-relay-bin
#relay-log=relay-bin

在这里插入图片描述

[root@localhost _data]# docker restart atguigu-mysql-slave1 
atguigu-mysql-slave1

5、搭建主从&测试

5.1、使用命令行登录MySQL主服务器

[root@localhost _data]# docker exec -it spzx-mysql /bin/bash
root@ab66508d9441:/# mysql -uroot -p123456
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 8
Server version: 8.0.27 MySQL Community Server - GPL

Copyright (c) 2000, 2021, 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.

5.2、主机中查询master状态:

mysql> show master status;
+-------------------+----------+--------------+------------------+-------------------+
| File              | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-------------------+----------+--------------+------------------+-------------------+
| spzxbinlog.000001 |      156 | mydb2,mydb3  | mydb4            |                   |
+-------------------+----------+--------------+------------------+-------------------+
1 row in set (0.01 sec)

5.3、从机中查询slave状态:

[root@localhost ~]# docker exec -it atguigu-mysql-slave1 /bin/bash
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
root@c236f876ae40:/# mysql -uroot -p123456
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 9
Server version: 8.0.27 MySQL Community Server - GPL

Copyright (c) 2000, 2021, 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> 
mysql> show slave status;
Empty set, 1 warning (0.02 sec)

从库必须和主库主动建立连接 开启自己的sql和io线程

5.4、主机中创建slave用户:

-- 创建slave用户
CREATE USER 'atguigu_slave'@'%';
-- 设置密码
ALTER USER 'atguigu_slave'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
-- 授予复制权限
GRANT REPLICATION SLAVE ON *.* TO 'atguigu_slave'@'%';
-- 刷新权限
FLUSH PRIVILEGES;
mysql> show master status;
+-------------------+----------+--------------+------------------+-------------------+
| File              | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-------------------+----------+--------------+------------------+-------------------+
| spzxbinlog.000001 |     1074 | mydb2,mydb3  | mydb4            |                   |
+-------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

5.5、在从机上配置主从关系:

CHANGE MASTER TO MASTER_HOST='192.168.74.148', 
MASTER_USER='atguigu_slave',MASTER_PASSWORD='123456', MASTER_PORT=3306,
MASTER_LOG_FILE='spzxbinlog.000001',MASTER_LOG_POS=1074; 
mysql> CHANGE MASTER TO MASTER_HOST='192.168.74.148', 
    -> MASTER_USER='atguigu_slave',MASTER_PASSWORD='123456', MASTER_PORT=3306,
    -> MASTER_LOG_FILE='spzxbinlog.000001',MASTER_LOG_POS=1074; 
Query OK, 0 rows affected, 9 warnings (0.05 sec)
mysql> show slave status;
+----------------+----------------+---------------+-------------+---------------+-------------------+---------------------+-------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+-----------------------------+------------------+-------------+-------------------------+-----------+---------------------+-------------------------+--------------------+-------------+-------------------------+--------------------------+----------------+--------------------+--------------------+-------------------+---------------+----------------------+--------------+--------------------+------------------------+-----------------------+-------------------+
| Slave_IO_State | Master_Host    | Master_User   | Master_Port | Connect_Retry | Master_Log_File   | Read_Master_Log_Pos | Relay_Log_File                | Relay_Log_Pos | Relay_Master_Log_File | Slave_IO_Running | Slave_SQL_Running | Replicate_Do_DB | Replicate_Ignore_DB | Replicate_Do_Table | Replicate_Ignore_Table | Replicate_Wild_Do_Table | Replicate_Wild_Ignore_Table | Last_Errno | Last_Error | Skip_Counter | Exec_Master_Log_Pos | Relay_Log_Space | Until_Condition | Until_Log_File | Until_Log_Pos | Master_SSL_Allowed | Master_SSL_CA_File | Master_SSL_CA_Path | Master_SSL_Cert | Master_SSL_Cipher | Master_SSL_Key | Seconds_Behind_Master | Master_SSL_Verify_Server_Cert | Last_IO_Errno | Last_IO_Error | Last_SQL_Errno | Last_SQL_Error | Replicate_Ignore_Server_Ids | Master_Server_Id | Master_UUID | Master_Info_File        | SQL_Delay | SQL_Remaining_Delay | Slave_SQL_Running_State | Master_Retry_Count | Master_Bind | Last_IO_Error_Timestamp | Last_SQL_Error_Timestamp | Master_SSL_Crl | Master_SSL_Crlpath | Retrieved_Gtid_Set | Executed_Gtid_Set | Auto_Position | Replicate_Rewrite_DB | Channel_Name | Master_TLS_Version | Master_public_key_path | Get_master_public_key | Network_Namespace |
+----------------+----------------+---------------+-------------+---------------+-------------------+---------------------+-------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+-----------------------------+------------------+-------------+-------------------------+-----------+---------------------+-------------------------+--------------------+-------------+-------------------------+--------------------------+----------------+--------------------+--------------------+-------------------+---------------+----------------------+--------------+--------------------+------------------------+-----------------------+-------------------+
|                | 192.168.74.148 | atguigu_slave |        3306 |            60 | spzxbinlog.000001 |                1074 | c236f876ae40-relay-bin.000001 |             4 | spzxbinlog.000001     | No               | No                |                 |                     |                    |                        |                         |                             |          0 |            |            0 |                1074 |             156 | None            |                |             0 | No                 |                    |                    |                 |                   |                |                  NULL | No                            |             0 |               |              0 |                |                             |                0 |             | mysql.slave_master_info |         0 |                NULL |                         |              86400 |             |                         |                          |                |                    |                    |                   |             0 |                      |              |                    |                        |                     0 |                   |
+----------------+----------------+---------------+-------------+---------------+-------------------+---------------------+-------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+-----------------------------+------------------+-------------+-------------------------+-----------+---------------------+-------------------------+--------------------+-------------+-------------------------+--------------------------+----------------+--------------------+--------------------+-------------------+---------------+----------------------+--------------+--------------------+------------------------+-----------------------+-------------------+
1 row in set, 1 warning (0.00 sec)

在这里插入图片描述

5.6、启动从库的io和sql线程:都启动成功主从才搭建成功

mysql> start slave;
Query OK, 0 rows affected, 1 warning (0.03 sec)
mysql> show slave status;
+----------------------------------+----------------+---------------+-------------+---------------+-------------------+---------------------+-------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+-----------------------------+------------------+--------------------------------------+-------------------------+-----------+---------------------+----------------------------------------------------------+--------------------+-------------+-------------------------+--------------------------+----------------+--------------------+--------------------+-------------------+---------------+----------------------+--------------+--------------------+------------------------+-----------------------+-------------------+
| Slave_IO_State                   | Master_Host    | Master_User   | Master_Port | Connect_Retry | Master_Log_File   | Read_Master_Log_Pos | Relay_Log_File                | Relay_Log_Pos | Relay_Master_Log_File | Slave_IO_Running | Slave_SQL_Running | Replicate_Do_DB | Replicate_Ignore_DB | Replicate_Do_Table | Replicate_Ignore_Table | Replicate_Wild_Do_Table | Replicate_Wild_Ignore_Table | Last_Errno | Last_Error | Skip_Counter | Exec_Master_Log_Pos | Relay_Log_Space | Until_Condition | Until_Log_File | Until_Log_Pos | Master_SSL_Allowed | Master_SSL_CA_File | Master_SSL_CA_Path | Master_SSL_Cert | Master_SSL_Cipher | Master_SSL_Key | Seconds_Behind_Master | Master_SSL_Verify_Server_Cert | Last_IO_Errno | Last_IO_Error | Last_SQL_Errno | Last_SQL_Error | Replicate_Ignore_Server_Ids | Master_Server_Id | Master_UUID                          | Master_Info_File        | SQL_Delay | SQL_Remaining_Delay | Slave_SQL_Running_State                                  | Master_Retry_Count | Master_Bind | Last_IO_Error_Timestamp | Last_SQL_Error_Timestamp | Master_SSL_Crl | Master_SSL_Crlpath | Retrieved_Gtid_Set | Executed_Gtid_Set | Auto_Position | Replicate_Rewrite_DB | Channel_Name | Master_TLS_Version | Master_public_key_path | Get_master_public_key | Network_Namespace |
+----------------------------------+----------------+---------------+-------------+---------------+-------------------+---------------------+-------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+-----------------------------+------------------+--------------------------------------+-------------------------+-----------+---------------------+----------------------------------------------------------+--------------------+-------------+-------------------------+--------------------------+----------------+--------------------+--------------------+-------------------+---------------+----------------------+--------------+--------------------+------------------------+-----------------------+-------------------+
| Waiting for source to send event | 192.168.74.148 | atguigu_slave |        3306 |            60 | spzxbinlog.000001 |                1074 | c236f876ae40-relay-bin.000002 |           325 | spzxbinlog.000001     | Yes              | Yes               |                 |                     |                    |                        |                         |                             |          0 |            |            0 |                1074 |             541 | None            |                |             0 | No                 |                    |                    |                 |                   |                |                     0 | No                            |             0 |               |              0 |                |                             |                1 | af98f4d4-a3ca-11ee-b194-0242ac110002 | mysql.slave_master_info |         0 |                NULL | Replica has read all relay log; waiting for more updates |              86400 |             |                         |                          |                |                    |                    |                   |             0 |                      |              |                    |                        |                     0 |                   |
+----------------------------------+----------------+---------------+-------------+---------------+-------------------+---------------------+-------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+-----------------------------+------------------+--------------------------------------+-------------------------+-----------+---------------------+----------------------------------------------------------+--------------------+-------------+-------------------------+--------------------------+----------------+--------------------+--------------------+-------------------+---------------+----------------------+--------------+--------------------+------------------------+-----------------------+-------------------+
1 row in set, 1 warning (0.01 sec)

在这里插入图片描述

6、在3306主机上创建mydb1

在这里插入图片描述
在这里插入图片描述
此时刷新3316从数据库,发现没有mydb1

7、在3306主机上创建mydb2

在这里插入图片描述
此时刷新3316从数据库,发现从机复制了主机中的mydb2数据库到从机中

8、在3306主机上创建mydb3

在这里插入图片描述

9、在3306主机上创建mydb4

在这里插入图片描述

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

CSP-J算法基础 树状结构与二叉树

文章目录 前言树状结构树状结构的基本概念:为什么需要树状结构?优点树状结构的示例 二叉树什么是二叉树?二叉树的类型什么样的树不是二叉树?二叉树的五种形态 完全二叉树相关概念完全二叉树的定义: 相关概念1. **高度&…

SAAS智慧工地源码,建筑行业数字化管理云平台系统

智慧工地是建筑行业数字化转型的重要组成部分,它通过集成物联网、大数据、云计算、人工智能等现代信息技术,对建筑工地进行智能化管理,以提高施工效率、保障施工安全、控制施工成本、提升施工质量。 以下是智慧工地的主要特点和应用&#xff…

【油猴脚本】00003案例 Tampermonkey油猴脚本引入css 库,油猴脚本css库的使用

前言:哈喽,大家好,今天给大家分享htmlcss 绚丽Loading!并提供具体代码帮助大家深入理解,彻底掌握!创作不易,如果能帮助到大家或者给大家一些灵感和启发,欢迎收藏关注哦 &#x1f495…

通过python提取PDF文件指定页的图片

整体思路 要从 PDF 文件中提取指定页和指定位置的图片,可以分几个步骤来实现: 1.1 准备所需工具与库 在 Python 中处理 PDF 和图像时,需要使用几个库: PyMuPDF (fitz):用于读取和处理 PDF 文件,可以精确…

【STM32】esp8266连接wifi

1.配置stm32cubemx 使用串口二接收esp8266的数据,单片机接收,使用串口1将数据发送给串口助手 串口2波特率设置74880,串口1设置115200 在初始化的时候需要将复位引脚拉低20ms,然后再拉高20ms, 设置GPIOB的输出模式 对PB12做输出处理 2.…

多旋翼无人机挂载电激发弹发射器技术详解

多旋翼无人机挂载电激发弹发射器技术是一种结合了无人机的高机动性和电激发弹发射器的精确打击能力的先进技术。以下是对该技术的详细解析: 一、多旋翼无人机概述 多旋翼无人机,也称为多轴飞行器或多旋翼飞行器,是一种具有三个及以上旋翼轴…

【pycharm】安装以及简单使用教程

以windows版本举例: 1、首先去Pycharm官网,或者直接输入网址:http://www.jetbrains.com/pycharm/download/#sectionwindows,下载PyCharm安装包,根据自己电脑的操作系统进行选择,对于windows系统选择下图的…

大数据处理技术:Hadoop开发环境搭建

目录 1 实验名称 2 实验目的 3 实验内容 4 实验原理 5 实验过程或源代码 5.1 JavaJDK的配置 5.2 Hadoop安装与伪分布式集群搭建 5.3 HDFS系统初体验 6 实验结果 6.1 JavaJDK的配置结果 6.2 Hadoop安装与伪分布式集群搭建结果 6.3 HDFS系统初体验结果 1 实验名称 Ha…

用Cursor生成一个代办事项列表的功能

一、本地新建html文件 二、输入代码 2.1 Cursor描述 其实这一段代码使用Cursor生成,可以输入如下内容,即可自动生成代码: 创建一个代办事项列表应用的基本结构,呈现在可交互界面上,1,提供可交互界面&…

乐器检测系统源码分享

乐器检测检测系统源码分享 [一条龙教学YOLOV8标注好的数据集一键训练_70全套改进创新点发刊_Web前端展示] 1.研究背景与意义 项目参考AAAI Association for the Advancement of Artificial Intelligence 项目来源AACV Association for the Advancement of Computer Vision …

【Vue】- Vue表达式

文章目录 知识回顾前言Vue项目介绍 源码分析1. 项目结构介绍(单页面应用程序)2. 项目运行流程图(单页面应用程序)3. 选项式和组合式api4. 插值表达式 {{}} 胡子语法5. reactive函数6. ref表达式 拓展知识reactive和ref的选择 总结 知识回顾 前言 Vue项…

利用python处理线性规划问题

利用python处理线性规划问题 linprog函数基本例题例题1例题2 典型例题例一:生产决策问题例一:生产决策问题 (例题和部分解答思路来自清风老师) linprog函数 导入模块 from scipy.optimize import linprog函数功能 Linear progra…

计算机毕业设计 毕业季一站式旅游服务定制平台的设计与实现 Java实战项目 附源码+文档+视频讲解

博主介绍:✌从事软件开发10年之余,专注于Java技术领域、Python人工智能及数据挖掘、小程序项目开发和Android项目开发等。CSDN、掘金、华为云、InfoQ、阿里云等平台优质作者✌ 🍅文末获取源码联系🍅 👇🏻 精…

视频笔记1

玩转apollo课程内讲解靠边启动场景_哔哩哔哩_bilibili 用open_space_roi_decider 改后 善用坐标点 如何不影响其它场景:if判断

Gradio快速部署构建AIGC的web应用 ,python

Gradio快速部署构建AIGC的web应用 ,python Gradio开源项目链接: https://github.com/gradio-app/gradiohttps://github.com/gradio-app/gradio (1)python的pip安装: pip install gradio (2)写…

webpack打包原理

目录 1、搭建结构,读取配置参数2、配置参数对象初始化 Compiler(new Compiler(webpackOptions))3、挂载配置文件中的插件,4、执行Compiler 中的 run 方法进行编译5、根据配置文件中的entry 配置项找到所有的入口6、从入口文件出发…

HAL库学习梳理——UART

笔者跟着B站铁头山羊视频学习 STM32-HAL库 开发教程。下面对HAL库有关UART课程知识和应用做一个梳理。 省流: uint8_t byteNumber 0x5a;uint8_t byteArray[] {0,1,2,3,4,5};char ch a;char *str "Hello word";HAL_UART_Transmit(&huart1,&by…

Windows环境下 VS2022 编译 Xvid 源码

Xvid Xvid 是一个开源的视频编解码器,遵循 MPEG-4 视频编码标准,特别是 MPEG-4 Part 2 Advanced Simple Profile。它被广泛用于视频的压缩和解压,尤其是在互联网上分享视频文件时,因为它能够有效地减小文件大小而不会过多损失视频…

切线空间:unity中shader切线空间,切线矩阵,TBN矩阵 ,法线贴图深度剖析

unity中shader切线空间 看了网上各种解释,各种推理。直接脑袋大。感觉复杂的高大上。当深入了解后,才发是各种扯淡。 一切从模型法向量开始 在shader中,大部分的光照计算都是与法向量有关。通过法向量和其他向量能计算出模型在光线照射下的…

How to see if openAI (node js) createModeration response “flagged“ is true

题意:如何查看 OpenAI (Node.js) createModeration 响应中的 "flagged" 是否为 true 问题背景: Using the OpenAI createModeration feature, I am trying to see if the string gets flagged or not. 使用 OpenAI 的 createModeration 功能…