续:当有数据时添加slave2

news/2024/9/19 0:36:46/ 标签: adb

【示例】

另启一台虚拟机,作为mysql3.

新的虚拟机没有mysql软件包,如何才能快速部署?通过mysql1.

mysql1:

[root@mysql1 ~]# rsync -al /usr/local/mysql/ root@172.25.254.166:/usr/local/mysql
The authenticity of host '172.25.254.166 (172.25.254.166)' can't be established.
ECDSA key fingerprint is SHA256:1m5IRRo+zVA9sKXK9QYE0jYLtAv1N3k516SZFFwGJu0.
ECDSA key fingerprint is MD5:45:ca:cf:c6:02:53:c2:b1:1e:ff:92:da:25:00:ea:19.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.25.254.166' (ECDSA) to the list of known hosts.
root@172.25.254.166's password: 

mysql3:

[root@mysql3 ~]# useradd -s /sbin/nologin -M mysql
[root@mysql3 ~]# mkdir -p /data/mysql
[root@mysql3 ~]# 
[root@mysql3 ~]# chown mysql.mysql /data/mysql/
 

[root@mysql3 local]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@mysql3 local]# 

##环境变量
[root@mysql3 local]# vim ~/.bash_profile 
[root@mysql3 ~]# 
[root@mysql3 ~]# cat ~/.bash_profile 
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin

export PATH


[root@mysql3 ~]# vim /etc/my.cnf
[root@mysql3 ~]# 
[root@mysql3 ~]# cat /etc/my.cnf
[mysqld]
datadir=/data/mysql
socket=/data/mysql/mysql.sock
symbolic-links=0
server_id=3
#super_read_only=on
 

#初始化mysql

[root@mysql3 ~]# mysqld --user=mysql --initialize
2024-08-26T18:06:34.996447Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2024-08-26T18:06:35.725476Z 0 [Warning] InnoDB: New log files created, LSN=45790
2024-08-26T18:06:35.866173Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2024-08-26T18:06:35.933982Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: eeeb0852-63d5-11ef-8e1b-000c29a7a897.
2024-08-26T18:06:35.937678Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2024-08-26T18:06:36.672776Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2024-08-26T18:06:36.672820Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2024-08-26T18:06:36.673904Z 0 [Warning] CA certificate ca.pem is self signed.
2024-08-26T18:06:36.815738Z 1 [Note] A temporary password is generated for root@localhost: Z%E(/tYtI7GH
[root@mysql3 ~]# 
[root@mysql3 ~]# vim passwd.txt 
[root@mysql3 ~]# 
[root@mysql3 ~]# cat passwd.txt 
Z%E(/tYtI7GH

##能查看到则成功
[root@mysql3 ~]# ls /data/mysql/
auto.cnf    client-cert.pem  ibdata1      mysql               public_key.pem   sys
ca-key.pem  client-key.pem   ib_logfile0  performance_schema  server-cert.pem
ca.pem      ib_buffer_pool   ib_logfile1  private_key.pem     server-key.pem
 

#启动

[root@mysql3 ~]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/data/mysql/mysql3.err'.
. SUCCESS! 
[root@mysql3 ~]# 
 

##

[root@mysql3 ~]# mysql_secure_installation 

Securing the MySQL server deployment.

Enter password for user root: 

The existing password for the user account root has expired. Please set a new password.

New password: 

Re-enter new password: 

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: n
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 

至此,部署好了mysql!!

拉平数据:

在已有主从的情况下,再加一个从,如果直接设定mysql3(slave2)为mysql1(master)的从,mysql1(master)现有的数据不能同步到slave2(mysql3)。要使得slave2(mysql3),能同步到master(mysql1)已有的数据!!必须做拉平数据。

1、对master(mysql1)必须进行锁库、锁表:保证数据库不能写,保证备份前后的数据一致(就是不能一边在备份,一边还在往数据库里写……)

##主节点master数据备份:

[root@mysql1 ~]# mysqldump -uroot -p folian > folian.sql
Enter password: 
[root@mysql1 ~]# cat folian.sql 
-- MySQL dump 10.13  Distrib 5.7.44, for Linux (x86_64)
--
-- Host: localhost    Database: folian
-- ------------------------------------------------------
-- Server version    5.7.44-log

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `userlist`
--

DROP TABLE IF EXISTS `userlist`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `userlist` (
  `username` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `password` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `userlist`
--

LOCK TABLES `userlist` WRITE; #锁了一个叫userlist的库,还得指定表
/*!40000 ALTER TABLE `userlist` DISABLE KEYS */;
INSERT INTO `userlist` VALUES ('folian','123');
/*!40000 ALTER TABLE `userlist` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2024-08-27  2:42:23
[root@mysql1 ~]# scp folian.sql root@172.25.254.166:/mnt/
root@172.25.254.166's password: 
folian.sql 

[root@mysql3 ~]# cd /mnt/
[root@mysql3 mnt]# ls
folian.sql
mysql3上有了folian.sql文件,如何恢复回去??

##注意恢复的时候没有库,所以需要建库

[root@mysql3 ~]# mysql -uroot -predhat -e "CREATE DATABASE folian;"
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@mysql3 ~]# mysql -uroot -predhat folian < folian.sql
-bash: folian.sql: No such file or directory
[root@mysql3 ~]# 
[root@mysql3 ~]# cd /mnt/
[root@mysql3 mnt]# mysql -uroot -predhat folian < folian.sql ##指定库,把folian.sql导进去
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@mysql3 mnt]# 
以上即=拉平数据》》

@

@

[root@mysql3 ~]# mysql -uroot -predhat
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 11
Server version: 5.7.44 Source distribution

Copyright (c) 2000, 2023, 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> CHANGE MASTER TO MASTER_HOST='172.25.254.6',MASTER_USER='repl',MASTER_PASSWORD='redhat',MASTER_LOG_FILE="mysql-bin.000001",MASTER_LOG_POS='2086';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''2086'' at line 1
mysql> CHANGE MASTER TO MASTER_HOST='172.25.254.6',MASTER_USER='repl',MASTER_PASSWORD='redhat',MASTER_LOG_FILE="mysql-bin.000001",MASTER_LOG_POS=2086;
Query OK, 0 rows affected, 2 warnings (0.02 sec)

mysql> slave start;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'slave start' at line 1
mysql> 
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW SLAVE STATUS\G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 172.25.254.6
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000001
          Read_Master_Log_Pos: 2086
               Relay_Log_File: mysql3-relay-bin.000002
                Relay_Log_Pos: 320
        Relay_Master_Log_File: mysql-bin.000001
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes

              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 2086
              Relay_Log_Space: 528
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 

  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 1
                  Master_UUID: 830992bc-605c-11ef-b0f2-000c29c6c80f
             Master_Info_File: /data/mysql/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: 
                Auto_Position: 0
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
1 row in set (0.00 sec)

ERROR: 
No query specified

**************/无关/******************

[root@mysql2 ~]# mysql -urpel -predhat  
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'rpel'@'localhost' (using password: YES)
[root@mysql2 ~]# 
[root@mysql2 ~]# mysql -urepl -predhat
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'repl'@'localhost' (using password: YES)
[root@mysql2 ~]# 
[root@mysql2 ~]# mysql -urepl -predhat -h 172.25.254.6  ##rpel 授权用户
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 23
Server version: 5.7.44-log Source distribution

Copyright (c) 2000, 2023, 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> 
[root@mysql2 ~]# mysql -uhaha -predhat -h 172.25.254.6  ##非授权用户不行。
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'haha'@'172.25.254.66' (using password: YES)

##测试slave2是否成功设为了从节点

mater上:

mysql> INSERT INTO folian.userlist values ('user2','123');
Query OK, 1 row affected (0.02 sec)
slave2上:

mysql> SELECT * FROM folian.userlist;
+----------+----------+
| username | password |
+----------+----------+
| folian   | 123      |    ##原来的也有
| user2    | 123      |   ##现在的也有 yes
+----------+----------+
2 rows in set (0.00 sec)
 

当然slave1上也会有:

mysql> SELECT * FROM folian.userlist;
+----------+----------+
| username | password |
+----------+----------+
| folian   | 123      |
| user2    | 123      |
+----------+----------+
2 rows in set (0.02 sec)
这就是一主两从》》》

思考:什么时候主多,什么时候从多?

主多:写入大于读取

从多:读取大于写入

 

关于SQL_Delay:延迟

延迟复制:作用?

做了一个操作,又返回的机会;

用一个slave作为示例:slave2

mysql> STOP SLAVE SQL_THREAD;
Query OK, 0 rows affected (0.01 sec)

mysql> CHANGE MASTER TO MASTER_DELAY=60;
Query OK, 0 rows affected (0.00 sec)

mysql> START SLAVE SQL_THREAD;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW SLAVE STATUS\G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 172.25.254.6
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000001
          Read_Master_Log_Pos: 2354
               Relay_Log_File: mysql3-relay-bin.000002
                Relay_Log_Pos: 588
        Relay_Master_Log_File: mysql-bin.000001
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 2354
              Relay_Log_Space: 796
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 1
                  Master_UUID: 830992bc-605c-11ef-b0f2-000c29c6c80f
             Master_Info_File: /data/mysql/master.info
                    SQL_Delay: 60
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: 
                Auto_Position: 0
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
1 row in set (0.00 sec)

ERROR: 
No query specified
 

延迟已经设置好了为60s;

比如这时,在master上把folian.userlist表中的user2给删了;

mysql> delete from folian.userlist where username='user2';
Query OK, 1 row affected (0.01 sec)
mysql> select * from folian.userlist;
+----------+----------+
| username | password |
+----------+----------+
| folian   | 123      |
+----------+----------+
1 row in set (0.00 sec)
 

然后去slave2上查看:在60秒内发现被删除的数据还在,假如删除是误操作的,可以紧急把库导出来备份恢复。

mysql> select * from folian.userlist;
+----------+----------+
| username | password |
+----------+----------+
| folian   | 123      |
+----------+----------+
1 row in set (0.00 sec)
 

慢查询日志

##查看慢查询日志是否开启

mysql> SHOW variables like "slow%";
+---------------------+-----------------------------+
| Variable_name       | Value                       |
+---------------------+-----------------------------+
| slow_launch_time    | 2                           |
| slow_query_log      | OFF                         |
| slow_query_log_file | /data/mysql/mysql1-slow.log |
+---------------------+-----------------------------+
3 rows in set (0.04 sec)

 

#开启或关闭慢查询日志,是在master上

mysql> SET GLOBAL slow_query_log=ON;
#所有的SET都可以写在/etc/my.cnf里

[root@mysql1 ~]# vim /etc/my.cnf
[root@mysql1 ~]# cat /etc/my.cnf
[mysqld]
datadir=/data/mysql
socket=/data/mysql/mysql.sock
symbolic-links=0
log-bin=mysql-bin
server-id=1
slow_query_log=on;

##但是写在my.cnf里要重启后才能生效,还是直接进入mysql里写。

mysql> SET GLOBAL slow_query_log=ON;
Query OK, 0 rows affected (0.02 sec)

mysql> SET GLOBAL slow_query_log=ON;
Query OK, 0 rows affected (0.02 sec)

mysql> SHOW variables like "slow%";
+---------------------+-----------------------------+
| Variable_name       | Value                       |
+---------------------+-----------------------------+
| slow_launch_time    | 2                           |
| slow_query_log      | ON                          |
| slow_query_log_file | /data/mysql/mysql1-slow.log |
+---------------------+-----------------------------+
3 rows in set (0.01 sec)
 

#开启了慢查询,还要设置慢查询的时间

mysql> SHOW variables like "long";
Empty set (0.00 sec)

mysql> SHOW variables like "long%";
+-----------------+-----------+
| Variable_name   | Value     |
+-----------------+-----------+
| long_query_time | 10.000000 |  ##这里默认为10s,意思是时间超过10s则视为慢查询
+-----------------+-----------+
1 row in set (0.00 sec)
 

#测试慢查询

mysql> select sleep (10);   #当执行这个操作,要等待十秒才会出现。。。
+------------+
| sleep (10) |
+------------+
|          0 |
+------------+
1 row in set (10.00 sec)
##查看慢查询日志

[root@mysql1 mysql]# cat /data/mysql/mysql1-slow.log
/usr/local/mysql/bin/mysqld, Version: 5.7.44-log (Source distribution). started with:
Tcp port: 3306  Unix socket: /data/mysql/mysql.sock
Time                 Id Command    Argument
# Time: 2024-08-27T01:47:19.777138Z
# User@Host: root[root] @ localhost []  Id:    27
# Query_time: 10.003945  Lock_time: 0.000000 Rows_sent: 1  Rows_examined: 0
SET timestamp=1724723239;
select sleep (10);


http://www.ppmy.cn/news/1519792.html

相关文章

Java算法之快速排序(Quick Sort)

快速排序&#xff1a;分而治之的高效排序算法 简介 快速排序是一种分而治之的排序算法&#xff0c;由C. A. R. Hoare在1960年提出。它通过选取一个元素作为"基准"&#xff08;pivot&#xff09;&#xff0c;然后重新排列数组&#xff0c;使得所有比基准值小的元素都…

【软考】【多媒体应用设计师】媒体与技术

1. 多媒体技术改变了传统循序式模式&#xff0c;用户可以借助超文本链接等方式&#xff0c;更自由灵活地访问所需的信息&#xff0c;体现了其&#xff08; &#xff09;的特点。 A.控制性 B.非线性 C.集成性 D.实时性 答案解析&#xff1a;本题考查信息多媒体非线性特点。多媒体…

安防监控/软硬一体/视频汇聚网关EasyCVR硬件启动崩溃是什么原因?

安防视频监控EasyCVR安防监控视频系统采用先进的网络传输技术&#xff0c;支持高清视频的接入和传输&#xff0c;能够满足大规模、高并发的远程监控需求。EasyCVR平台支持多种视频流的外部分发&#xff0c;如RTMP、RTSP、HTTP-FLV、WebSocket-FLV、HLS、WebRTC、WS-FMP4、HTTP-…

vue part 5

生命周期 <!DOCTYPE html> <html><head><meta charset"UTF-8" /><title>引出生命周期</title><!-- 引入Vue --><script type"text/javascript" src"https://cdn.jsdelivr.net/npm/vue/dist/vue.js&quo…

进程、线程的区别

进程&#xff08;Process&#xff09;和线程&#xff08;Thread&#xff09;是操作系统中的基本概念&#xff0c;它们在资源管理和任务执行方面有着本质的区别&#xff1a; 定义&#xff1a; 进程&#xff1a;进程是操作系统进行资源分配和调度的一个独立单位。每个进程都有自己…

ArcGIS Pro 3.1下载分享

在使用了很长一段时间ArcGIS Pro 3.0之后&#xff0c;终于迎来了ArcGIS Pro 3.1的更新&#xff0c;这里为你分享一下ArcGIS Pro 3.1的安装步骤。 软件介绍 ArcGIS Pro 3.1 是由Esri发布的地理信息系统 (GIS) 软件的较新版本&#xff0c;作为 ArcGIS 桌面应用程序家族中的核心…

【递归深搜之记忆化搜索算法】

1. 斐波那契数 解法一&#xff1a;递归 class Solution { public:int fib(int n) {return dfs(n);}int dfs(int n){if(n 0 || n 1)return n;return dfs(n - 1) dfs(n - 2);} }; 解法二&#xff1a;记忆化搜索 class Solution {int nums[31]; // 备忘录 public:int fib(int …

使用C++,仿照string类,实现myString

类由结构体演化而来&#xff0c;只需要将struct改成关键字class&#xff0c;就定义了一个类 C中类和结构体的区别&#xff1a;默认的权限不同&#xff0c;结构体中默认权限为public&#xff0c;类中默认权限为private 默认的继承方式不同&#xff0c;结构体的默认继承方式为p…

微型直线导轨高精度运行的工作原理

微型导轨是一种用于高精度定位和运动控制的传动装置&#xff0c;常用于微小化、高精密度化的机械设备中&#xff0c;如IC制造设备、半导体设备、高速移载的设备、精密测量、检测仪器、医疗设备、X-Y table&#xff0c;以及高速皮带驱动的设备等小型化设备。 微型导轨的构成相对…

单窗口IP代理设置指南:轻松搞定

在现代互联网生活中&#xff0c;IP代理已经成为了许多人日常上网的必备工具。单窗口IP代理是一种非常实用的代理方式&#xff0c;它允许你在同一个浏览器中为不同的窗口设置不同的IP地址&#xff0c;从而更好地保护隐私和实现多任务处理。今天&#xff0c;我们就来详细讲解一下…

在 macOS 上升级 Ruby 版本的几种方法

在 macOS 上升级 Ruby 版本通常有几种方法&#xff0c;以下是一些常用的方法&#xff1a; 使用系统自带的 Ruby: macOS 系统自带 Ruby&#xff0c;但通常不是最新版本。可以通过终端使用 softwareupdate 命令来更新系统自带的 Ruby。 使用 Homebrew: Homebrew 是 macOS 的包管…

字符串地指针表示方式

每日诗词&#xff1a; 人生自是有情痴&#xff0c;此恨不关风与月。 ——玉楼春尊前拟把归期说 【宋】欧阳修 目录 数组本身的值和数组储存的值一样吗 char[]和cahr*的区别 1. 类型 2. 内存分配 3. 使用方式 4. 字符串字面量 实例 变式 总结&#xff1a; 下期预告&a…

vue2+countup.js实现大屏数字滚动效果封装

很多大屏、官网或者展示类页面会用到数字跳动更新效果的需求&#xff0c;countup用起来就非常方便 一、官网 CountUp.js 二、效果图 三、安装countup与引入 npm install countup 进行安装依赖 import { CountUp } from countUp.js;//需要用到的页面引入&#xff0c;也可以…

生成式AI:创造性智能的新纪元

引言 随着人工智能技术的飞速发展&#xff0c;生成式AI&#xff08;Generative AI&#xff09;已经成为一个引人注目的领域。它不仅仅是模仿人类行为&#xff0c;而是通过学习大量的数据&#xff0c;创造出全新的内容&#xff0c;如文本、图像、音乐等。本文将探讨生成式AI的基…

同样128个内核,AMD霄龙9755性能翻倍:Zen 5架构下的性能飞跃

近日&#xff0c;AMD在服务器处理器领域再次展示了其强大的技术实力&#xff0c;随着AMD EPYC“Turin”处理器发布日期的临近&#xff0c;其基准测试结果也开始浮出水面。硬件爱好者博主9550pro近期分享了AMD 128核EPYC 9755“Turin”处理器在7zip压缩/解压缩基准测试中的跑分数…

力扣(可被三整除的最大和)

1262. 可被三整除的最大和 提示 给你一个整数数组 nums&#xff0c;请你找出并返回能被三整除的元素 最大和。 思路&#xff1a; 方法一&#xff1a;利用一个长度为3的数组&#xff0c;分别保存0到i内余数为0&#xff0c;1&#xff0c;2的最大和&#xff0c;这样对于一个进入…

通过 NestJS 实现与第三方接口的文件流无缝对接

引言 在当今的Web应用中&#xff0c;高效的文件上传至关重要。本文将介绍如何从前端页面调用NestJS提供的文件上传接口&#xff0c;并通过该接口将文件流直接上传至第三方服务&#xff0c;以此提升上传效率和用户体验。通过这一流程&#xff0c;我们将展示如何利用NestJS与外部…

Java泛型基础概念

Java 泛型是 Java SE 5 引入的一种特性&#xff0c;允许在编写代码时指定类、接口或方法的类型参数。通过泛型&#xff0c;你可以编写更具通用性、类型安全的代码&#xff0c;避免在运行时遇到不必要的类型转换错误。 1. 泛型的基本语法 泛型的基本形式如下&#xff1a; cla…

PHP房屋出售出租多端多平台预约系统小程序源码

&#x1f3e0;&#x1f511;「房屋出售出租多端运营系统」——房产管理新纪元&#xff0c;一键掌控所有&#xff01;&#x1f680; &#x1f3e1; 开篇直击&#xff1a;房产市场新利器&#xff0c;轻松管理不再是梦&#xff01; 亲们&#xff0c;还在为房屋出售或出租的繁琐流…

qt父类和子类转换的安全性问题

在 Qt 中&#xff0c;父类和子类之间的转换遵循 C 的类型转换规则。以下是关于父类和子类转换安全性的详细说明&#xff1a; 1. 向上转型&#xff08;Upcasting&#xff09; 定义&#xff1a;将子类对象转换为父类对象。安全性&#xff1a;这是安全的&#xff0c;因为子类对象…