使用资源编排 ROS 轻松部署单点网站——以 WordPress 为例

介绍

WordPress是一款免费开源的网站内容管理系统(CMS),它可以帮助用户简单快捷地创建和管理自己的网站,包括博客、新闻网站、电子商务网站、社交网络等等。WordPress 有丰富的主题和插件库,使得用户可以轻松地为网站定制外观和功能。WordPress 的易用性和可扩展性使其成为世界上最受欢迎的网站建设工具之一。

资源编排服务(Resource Orchestration Service, ROS)是阿里云提供基于基础设施即代码(Infrastructure as Code, IaC) 理念的自动化部署服务,我们可以通过定义一个 JSON/YAML/Terraform 模板,轻松部署一套云上单点网站环境。比如部署一套 WordPress 环境,包括创建 VPC、ECS 等云资源,在 ECS 实例中安装 PHP、MySQL 和 WordPress 等。

部署步骤

  1. 登录ROS 控制台-WordPress 部署页面

  2. 配置模板参数:选择 ECS 实例的可用区、实例类型、系统盘类型、实例密码、数据库用户密码

  3. 点击【下一步】,然后【创建】。部署完成后,点击资源栈的输出,即可看到 WordPress 服务的地址。点击链接即可体验 WordPress 的功能。

    在这里插入图片描述

部署原理

我们可以看到通过 ROS 可以非常快捷地部署阿里云上的各种云资源(比如 VPC、VSwitch、ECS 实例等)和应用程序(比如 WordPress)。如果想了解是如何做到的,那么可以阅读此章节。

  1. 编写 ROS 模板。在如下模板中定义了:
  • Resources:定义了 VPC、VSwitch、ECS 实例、安全组、安全组规则以及安装 WordPress 的命令执行。
  • Parameters:定义了常用的参数,比如可用区、ECS 实例类型类型。
  • Outputs:定义了自定义输出,比如 WordPress 服务的地址。
ROSTemplateFormatVersion: "2015-09-01"
Description:
  en: Manually build a WordPress website on a CentOS 7 ECS instance.
  zh-cn: 在ECS实例(CentOS 7)上搭建WordPress。
Conditions:
  CreateInstance:
    Fn::Equals:
      - Ref: InstanceSource
      - CreateNew
Parameters:
  InstanceSource:
    Type: String
    Default: CreateNew
    Label:
      zh-cn: 实例来源
      en: Instance Source
    AllowedValues:
      - CreateNew
      - UseExisted
    AssociationPropertyMetadata:
      ValueLabelMapping:
        CreateNew:
          zh-cn: 创建新实例
          en: Create New Instance
        UseExisted:
          zh-cn: 选择已有实例
          en: Select Existed Instance
  InstanceId:
    Type: String
    Label:
      en: Existing ECS Instance
      zh-cn: 已创建ECS实例
    Description:
      en: Select an ECS instance with the CentOS 7.9 64-bit operating system.
      zh-cn: 选择已存在操作系统为CentOS 7.9 64位的ECS实例。
    AssociationProperty: ALIYUN::ECS::Instance::InstanceId
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Equals:
            - ${InstanceSource}
            - UseExisted
    Default: Null
  ZoneId:
    Type: String
    Label:
      en: VSwitch Availability Zone
      zh-cn: 可用区ID
    Description:
      en: Availability Zone ID,<br><b>note: <font color='blue'>Before selecting, please confirm that the Availability Zone supports the specification of creating ECS resources.</font></b>
      zh-cn: 可用区ID。<br><b>注: <font color='blue'>选择可用区前请确认该可用区是否支持创建ECS资源的规格。</font></b>
    Required: true
    AssociationProperty: ALIYUN::ECS::Instance:ZoneId
    AssociationPropertyMetadata:
      ZoneId: ZoneId
      Visible:
        Condition:
          Fn::Equals:
            - ${InstanceSource}
            - CreateNew
    Default: Null
  InstanceType:
    Type: String
    Label:
      en: Instance Type
      zh-cn: 实例类型
    Description:
      en: "See detail: <a href='https://www.alibabacloud.com/help/en/doc-detail/25378.html' target='_blank'><b><font color='blue'>Instance Specification Family</font></a></b>"
      zh-cn: 规格详见:<a href='https://help.aliyun.com/document_detail/25378.html' target='_blank'><b><font color='blue'>实例规格族</font></a></b>
    Required: true
    AssociationProperty: ALIYUN::ECS::Instance::InstanceType
    AssociationPropertyMetadata:
      DefaultValueStrategy: recent
      ZoneId: ZoneId
      Visible:
        Condition:
          Fn::Equals:
            - ${InstanceSource}
            - CreateNew
    Default: ecs.c5.large
  SystemDiskCategory:
    Type: String
    Label:
      en: System Disk Type
      zh-cn: 系统盘类型
    Required: true
    AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
    AssociationPropertyMetadata:
      AutoSelectFirst: true
      AutoChangeType: false
      LocaleKey: DiskCategory
      InstanceType: ${InstanceType}
      ZoneId: ZoneId
      Visible:
        Condition:
          Fn::Equals:
            - ${InstanceSource}
            - CreateNew
    Default: cloud_essd
  InstancePassword:
    Type: String
    Label:
      en: Instance Password
      zh-cn: 实例密码
    Description:
      en: Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in).
      zh-cn: 服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)。
    ConstraintDescription:
      en: Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in).
      zh-cn: 长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)。
    AllowedPattern: '[0-9A-Za-z\_\-\&:;''<>,=%`~!@#\(\)\$\^\*\+\|\{\}\[\]\.\?\/]+$'
    AssociationPropertyMetadata:
      Required: true
      Visible:
        Condition:
          Fn::Equals:
            - ${InstanceSource}
            - CreateNew
    MinLength: 8
    MaxLength: 30
    NoEcho: true
    Default: Null
  DbPassword:
    Type: String
    Label:
      en: DB User Password
      zh-cn: 数据库用户密码
    Description:
      en: |-
        The password must be 8 to 32 characters in length. <br>
        It must contain the following character types: uppercase letters, lowercase letters, digits, and special characters. <br> 
        Special characters include <span style="background:#E7E9EB;"><b>!@#$%^&*()_+-=</b></span>.<br>
        <b>If you repeatedly provision in this tutorial on the same ECS instance, make sure that the MySQL database password is exactly the same as the password set when the template was executed for the first time. Otherwise, the result of provisioning is unavailable.</b>
      zh-cn: |-
        长度为8~32位,需包含大写字母、小写字母、特殊字符和数字,允许的特殊字符包括<span style="background:#E7E9EB;"><b>!@#$%^&*()_+-=</b></span>。<br> 
        <b>如果您在同一台ECS实例上重复执行本教程的一键配置模板,请确保MySQL数据库密码和第一次执行模板时设置的密码完全一致。否则一键配置结果不可用。</b>
    ConstraintDescription:
      en: |-
        The password must be 8 to 32 characters in length. <br>
        It must contain the following character types: uppercase letters, lowercase letters, digits, and special characters. <br> 
        Special characters include <span style="background:#E7E9EB;"><b>!@#$%^&*()_+-=</b></span>.<br>
        <b>If you repeatedly provision in this tutorial on the same ECS instance, make sure that the MySQL database password is exactly the same as the password set when the template was executed for the first time. Otherwise, the result of provisioning is unavailable.</b>
      zh-cn: 长度为8~32位,需包含四项大写字母、小写字母、特殊字符和数字,允许的特殊字符包括<span style="background:#E7E9EB;"><b>!@#$%^&*()_+-=</b></span>。
    AllowedPattern: ^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])((?=.*[!@#\$%\^&\*\(\)\-\+])|(?=.*[_\.,:;\-\?]))[a-zA-Z0-9!@#\$%\^&\*\(\)\-\+_\.,:;\-\?]{8,32}$
    Required: true
    NoEcho: true
Resources:
  Vpc:
    Type: ALIYUN::ECS::VPC
    Condition: CreateInstance
    Properties:
      CidrBlock: 192.168.0.0/16
  VSwitch:
    Type: ALIYUN::ECS::VSwitch
    Condition: CreateInstance
    Properties:
      ZoneId:
        Ref: ZoneId
      VpcId:
        Ref: Vpc
      CidrBlock: 192.168.0.0/24
  SecurityGroup:
    Type: ALIYUN::ECS::SecurityGroup
    Condition: CreateInstance
    Properties:
      VpcId:
        Ref: Vpc
  SecurityGroupIngress_22:
    Type: ALIYUN::ECS::SecurityGroupIngress
    Properties:
      SecurityGroupId:
        Fn::Jq:
          - First
          - .[0].SecurityGroupIds[0]
          - Fn::GetAtt:
              - DS_Instances
              - Instances
      SourceCidrIp: 0.0.0.0/0
      IpProtocol: tcp
      NicType: intranet
      PortRange: 22/22
  SecurityGroupIngress_80:
    Type: ALIYUN::ECS::SecurityGroupIngress
    Properties:
      SecurityGroupId:
        Fn::Jq:
          - First
          - .[0].SecurityGroupIds[0]
          - Fn::GetAtt:
              - DS_Instances
              - Instances
      SourceCidrIp: 0.0.0.0/0
      IpProtocol: tcp
      NicType: intranet
      PortRange: 80/80
  SecurityGroupIngress_443:
    Type: ALIYUN::ECS::SecurityGroupIngress
    Properties:
      SecurityGroupId:
        Fn::Jq:
          - First
          - .[0].SecurityGroupIds[0]
          - Fn::GetAtt:
              - DS_Instances
              - Instances
      SourceCidrIp: 0.0.0.0/0
      IpProtocol: tcp
      NicType: intranet
      PortRange: 443/443
  WaitConditionHandle:
    Type: ALIYUN::ROS::WaitConditionHandle
    Properties: {}
  RosWaitCondition:
    Type: ALIYUN::ROS::WaitCondition
    Properties:
      Count: 1
      Handle:
        Ref: WaitConditionHandle
      Timeout: 7200
  DS_Instances:
    Type: DATASOURCE::ECS::Instances
    Properties:
      InstanceIds:
        Fn::If:
          - CreateInstance
          - Fn::GetAtt:
              - InstanceGroup
              - InstanceIds
          - - Ref: InstanceId
  InstanceGroup:
    Type: ALIYUN::ECS::InstanceGroup
    Condition: CreateInstance
    Properties:
      VpcId:
        Ref: Vpc
      VSwitchId:
        Ref: VSwitch
      SecurityGroupId:
        Ref: SecurityGroup
      ImageId: centos_7_8
      InstanceType:
        Ref: InstanceType
      SystemDiskCategory:
        Ref: SystemDiskCategory
      Password:
        Ref: InstancePassword
      IoOptimized: optimized
      MaxAmount: 1
  InstallWordpress:
    Type: ALIYUN::ECS::RunCommand
    Properties:
      InstanceIds:
        Fn::If:
          - CreateInstance
          - Fn::GetAtt:
              - InstanceGroup
              - InstanceIds
          - - Ref: InstanceId
      Type: RunShellScript
      Sync: true
      Timeout: 7200
      CommandContent:
        Fn::Sub:
          - |-
            #!/bin/bash
            if [ ! -f .ros.provision ]; then
              echo "Name: 手动搭建WordPress(CentOS 7)" > .ros.provision
            fi

            name=$(grep "^Name:" .ros.provision | awk -F':' '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
            if [[ "$name" != "手动搭建WordPress(CentOS 7)" ]]; then
              echo "当前实例已使用过\"$name\"教程的一键配置,不能再使用本教程的一键配置"
              ${WaitConditionHandle.CurlCli} --data-binary "{\"status\": \"FAILURE\", \"reason\": \"The current instance has already applied the configuration of the \\\"$name\\\" tutorial, and the configuration of this tutorial can no longer be applied.\"}"
              exit 0
            fi

            echo "#########################"
            echo "# Check Network"
            echo "#########################"
            ping -c 2 -W 2 aliyun.com > /dev/null
            if [[ $? -ne 0 ]]; then
              echo "当前实例无法访问公网"
              ${WaitConditionHandle.CurlCli} --data-binary "{\"status\": \"FAILURE\", \"reason\": \"The current instance cannot access the public network.\"}"
              exit 0
            fi

            if ! grep -q "^Step1: Prepare Environment$" .ros.provision; then
              echo "#########################"
              echo "# Prepare Environment"
              echo "#########################"
              systemctl status firewalld
              systemctl stop firewalld
              echo "Step1: Prepare Environment" >> .ros.provision
            else
              echo "#########################"
              echo "# Environment has been ready"
              echo "#########################"
            fi

            if ! grep -q "^Step2: Install Nginx$" .ros.provision; then
              echo "#########################"
              echo "# Install Nginx"
              echo "#########################"
              yum -y install nginx
              nginx -v
              echo "Step2: Install Nginx" >> .ros.provision
            else
              echo "#########################"
              echo "# Nginx has been installed"
              echo "#########################"
            fi

            if ! grep -q "^Step3: Install MySQL$" .ros.provision; then
              echo "#########################"
              echo "# Install MySQL"
              echo "#########################"
              rpm -Uvh  https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
              yum -y install mysql-community-server --nogpgcheck
              mysql -V
              systemctl start mysqld
              systemctl enable mysqld
              systemctl daemon-reload
              echo "Step3: Install MySQL" >> .ros.provision
            else
              echo "#########################"
              echo "# MySQL has been installed"
              echo "#########################"
            fi

            if ! grep -q "^Step4: Install PHP$" .ros.provision; then
              echo "#########################"
              echo "# Install PHP"
              echo "#########################"
              yum install -y \
                https://mirrors.aliyun.com/ius/ius-release-el7.rpm \
                https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
              yum -y install php-devel php php-cli php-common php-gd php-ldap php-mbstring php-mcrypt php-pdo php-fpm php-opcache php-pecl-redis php-pecl-mongodb php-mysqlnd
              php -v
              echo "Step4: Install PHP" >> .ros.provision
            else
              echo "#########################"
              echo "# PHP has been installed"
              echo "#########################"
            fi

            if ! grep -q "^Step4: Config Nginx$" .ros.provision; then
              echo "#########################"
              echo "# Config Nginx"
              echo "#########################"
              cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
              cat > /etc/nginx/nginx.conf << \EOF
            # For more information on configuration, see:
            #   * Official English Documentation: http://nginx.org/en/docs/
            #   * Official Russian Documentation: http://nginx.org/ru/docs/

            user nginx;
            worker_processes auto;
            error_log /var/log/nginx/error.log;
            pid /run/nginx.pid;

            # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
            include /usr/share/nginx/modules/*.conf;

            events {
                worker_connections 1024;
            }

            http {
                log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                                  '$status $body_bytes_sent "$http_referer" '
                                  '"$http_user_agent" "$http_x_forwarded_for"';

                access_log  /var/log/nginx/access.log  main;

                sendfile            on;
                tcp_nopush          on;
                tcp_nodelay         on;
                keepalive_timeout   65;
                types_hash_max_size 4096;

                include             /etc/nginx/mime.types;
                default_type        application/octet-stream;

                # Load modular configuration files from the /etc/nginx/conf.d directory.
                # See http://nginx.org/en/docs/ngx_core_module.html#include
                # for more information.
                include /etc/nginx/conf.d/*.conf;

                server {
                    listen       80;
                    listen       [::]:80;
                    server_name  _;
                    root         /usr/share/nginx/html/wordpress;

                    # Load configuration files for the default server block.
                    include /etc/nginx/default.d/*.conf;

                    location / {
                        index index.php index.html index.htm;
                    }

                    location ~ .php$ {
                        root /usr/share/nginx/html/wordpress;    # 将/usr/share/nginx/html替换为您的网站根目录,本文使用/usr/share/nginx/html作为网站根目录。
                        fastcgi_pass 127.0.0.1:9000;   # Nginx通过本机的9000端口将PHP请求转发给PHP-FPM进行处理。
                        fastcgi_index index.php;
                        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                        include fastcgi_params;   # Nginx调用fastcgi接口处理PHP请求。
                    }

                    error_page 404 /404.html;
                    location = /404.html {
                    }

                    error_page 500 502 503 504 /50x.html;
                    location = /50x.html {
                    }
                }

            # Settings for a TLS enabled server.
            #
            #    server {
            #        listen       443 ssl http2;
            #        listen       [::]:443 ssl http2;
            #        server_name  _;
            #        root         /usr/share/nginx/html;
            #
            #        ssl_certificate "/etc/pki/nginx/server.crt";
            #        ssl_certificate_key "/etc/pki/nginx/private/server.key";
            #        ssl_session_cache shared:SSL:1m;
            #        ssl_session_timeout  10m;
            #        ssl_ciphers HIGH:!aNULL:!MD5;
            #        ssl_prefer_server_ciphers on;
            #
            #        # Load configuration files for the default server block.
            #        include /etc/nginx/default.d/*.conf;
            #
            #        error_page 404 /404.html;
            #            location = /40x.html {
            #        }
            #
            #        error_page 500 502 503 504 /50x.html;
            #            location = /50x.html {
            #        }
            #    }

            }
            EOF
              systemctl start nginx
              systemctl enable nginx
              echo "Step4: Config Nginx" >> .ros.provision
            else
              echo "#########################"
              echo "# Nginx has been configured"
              echo "#########################"
            fi

            if ! grep -q "^Step6: Config MySQL$" .ros.provision; then
              echo "#########################"
              echo "# Config MySQL"
              echo "#########################"
              export MYSQL_PWD=`grep "temporary password" /var/log/mysqld.log | awk '{print $NF}'`
              mysqladmin -uroot password '${DbPassword}'
              export MYSQL_PWD='${DbPassword}'
              mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '${DbPassword}'"
              echo CREATE DATABASE wordpress\; >> /tmp/setup.mysql
              echo CREATE user "user"@"localhost" identified by '"${DbPassword}"'\; >> /tmp/setup.mysql
              echo GRANT ALL privileges ON wordpress.* TO "user"@"localhost" IDENTIFIED BY '"${DbPassword}"'\; >> /tmp/setup.mysql
              echo FLUSH privileges\;>> /tmp/setup.mysql
              chmod 400 /tmp/setup.mysql
              mysql -u root --password='${DbPassword}' < /tmp/setup.mysql          
              echo "Step6: Config MySQL" >> .ros.provision
            else
              echo "#########################"
              echo "# MySQL has been configured"
              echo "#########################"
            fi

            if ! grep -q "^Step7: Config PHP$" .ros.provision; then
              echo "#########################"
              echo "# Config PHP"
              echo "#########################"
              echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/phpinfo.php
              systemctl start php-fpm
              systemctl enable php-fpm
              echo "Step7: Config PHP" >> .ros.provision
            else
              echo "#########################"
              echo "# PHP has been configured"
              echo "#########################"
            fi

            if ! grep -q "^Step8: Install wordpress$" .ros.provision; then
              echo "#########################"
              echo "# Install wordpress"
              echo "#########################"
              yum -y install wordpress
              echo "Step8: Install wordpress" >> .ros.provision
            else
              echo "#########################"
              echo "# wordpress has been installed"
              echo "#########################"
            fi

            if ! grep -q "^Step9: Config wordpress$" .ros.provision; then
              echo "#########################"
              echo "# Config wordpress"
              echo "#########################"
              mv /usr/share/wordpress /usr/share/nginx/html/wordpress
              cd /usr/share/nginx/html/wordpress
              ln -snf /etc/wordpress/wp-config.php wp-config.php
              sed -i "s/database_name_here/wordpress/" wp-config.php
              sed -i "s/username_here/user/" wp-config.php
              sed -i "s/password_here/${DbPassword}/" wp-config.php
              echo "Step9: Config wordpress" >> .ros.provision
            else
              echo "#########################"
              echo "# wordpress has been configured"
              echo "#########################"
            fi

            systemctl restart nginx
            ${WaitConditionHandle.CurlCli} --data-binary '{"status": "SUCCESS"}'
          - IP:
              Fn::Jq:
                - First
                - if .[0].PublicIpAddress != [] then .[0].PublicIpAddress[0] else .[0].EipAddress.IpAddress end
                - Fn::GetAtt:
                    - DS_Instances
                    - Instances
    DependsOn:
      - SecurityGroupIngress_22
      - SecurityGroupIngress_443
      - SecurityGroupIngress_80
Outputs:
  WordPressUrl:
    Description:
      zh-cn: WordPress 地址
      en: WordPress Address
    Value:
      Fn::Sub:
        - http://${IP}
        - IP:
            Fn::Jq:
              - First
              - if .[0].PublicIpAddress != [] then .[0].PublicIpAddress[0] else .[0].EipAddress.IpAddress end
              - Fn::GetAtt:
                  - DS_Instances
                  - Instances
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - InstanceSource
          - InstanceId
          - ZoneId
          - InstanceType
          - SystemDiskCategory
          - InstancePassword
          - DbPassword
        Label:
          default: ECS
    TemplateTags:
      - acs:example:web:搭建WordPress(CentOS 7)
  1. 在 ROS 控制台中使用此模板创建资源栈。ROS 会自动解析出模板中资源的依赖关系,按照资源依赖顺序创建云资源。如果资源间没有依赖,则会并发创建,从而提升部署效率。ROS 会把这次创建的所有资源存放到一个“资源栈”中,后续可以方便地管理这组资源集合。比如:
  • 将新模板应用到这个“资源栈”中,从而更新里面的资源。
  • 删除这个“资源栈”,从而把所有的资源删掉。

总结

基于 IaC 的理念,通过定义一个模板,使用 ROS 进行自动化部署,可以非常高效快捷地部署任意云资源和应用(比如 WordPress 服务)。相比于手动部署或者通过 API、SDK 的部署方式,有着高效、稳定等诸多优势,也是服务上云的最佳实践。

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

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

相关文章

点线面推进未来智造

如今&#xff0c;宁波拥有门类齐全的制造业体系&#xff0c;形成了以石油化工、汽车及零部件、电工电器、纺织服装等为支柱的产业集群。 宁波工业的发展并非一蹴而就&#xff0c;蓝卓总经理谭彰详细解读了宁波制造业的发展历程与当下目标&#xff0c;从工业小市到工业大市、工业…

【深度学习】第5章——卷积神经网络(CNN)

一、卷积神经网络 1.定义 卷积神经网络&#xff08;Convolutional Neural Network, CNN&#xff09;是一种专门用于处理具有网格状拓扑结构数据的深度学习模型&#xff0c;特别适用于图像和视频处理。CNN 通过局部连接和权重共享机制&#xff0c;有效地减少了参数数量&#x…

阿一课代表今日分享之使用dnscat2 进行dns隧道反弹shell(直连模式linux对linux)

DNS介绍 DNS是域名系统(Domain Name System)的缩写&#xff0c;是因特网的一项核心服务&#xff0c;它作为可以将域名和IP地址相互映射的一个分布式数据库&#xff0c;能够使人更方便的访问互联网&#xff0c;而不用去记住能够被机器直接读取的IP数串。 DNS的记录类型有很多&a…

数据结构--二叉树收尾

1.二叉树销毁 运用递归方法 分类&#xff1a; 根节点左子树右子树&#xff08;一般都是这个思路&#xff0c;不断进行递归即可&#xff09; 选择方法&#xff08;分析)&#xff1a; 前序&#xff1a;如果直接销毁根就无法找到左子树右子树 中序&#xff1a;也会导致丢失其…

非关系型数据库(NoSQL)与 关系型数据库(RDBMS)的比较

非关系型数据库&#xff08;NoSQL&#xff09;与 关系型数据库&#xff08;RDBMS&#xff09;的比较 一、引言二、非关系型数据库&#xff08;NoSQL&#xff09;2.1 优势 三、关系型数据库&#xff08;RDBMS&#xff09;3.1 优势 四、结论 &#x1f496;The Begin&#x1f496;…

【ai_agent】从零写一个agent框架(四)用rust制作一个python的虚拟运行环境。

前言 为了增加框架的扩展性和适用性&#xff0c;我们要能够在流程节点中运行python脚本。 这个时候需要考虑几个问题&#xff1a; 1 为什么是python&#xff1f; 思考&#xff1a;老实说我并不喜欢python&#xff0c;我更倾向于lua这种短小轻快的脚本。在我之前写的规则引擎…

fm足球经理Football Manager 2022 for mac 下载安装包

《Football Manager 2022》&#xff08;足球经理2022&#xff09;是一款由Sports Interactive开发并由SEGA发行的足球管理模拟游戏。这款游戏让玩家扮演足球俱乐部的 manager&#xff08;经理&#xff09;&#xff0c;负责球队的所有管理工作&#xff0c;包括战术制定、球员转会…

优画质低功耗,空域GPU超分技术引领图像渲染新体验

随着大数据时代的发展&#xff0c;虚拟现实、增强现实等需要实时图像处理和计算的应用&#xff0c;对GPU加速引擎服务提出了新的挑战和机遇。 HarmonyOS SDK GPU加速引擎服务&#xff08;XEngine Kit&#xff09;提供的空域GPU超分能力&#xff0c;基于单帧输入图像&#xff0…

NLP入门——卷积语言模型的搭建、训练与预测

语言模型建模是针对句子建模&#xff0c;主要分为掩码语言模型和自回归语言模型。 我们从corpus中截取一句话作为例子&#xff0c;这句话是bpe分词后的句子&#xff1a; 1994 年 5 月 17 日 安全 理事会 第 33 77 次 会议 通过 掩码语言模型的主要机制是&#xff1a;例如将33 7…

力扣爆刷第162天之TOP100五连刷76-80(最小路径和、最长公共前缀、最长连续序列)

力扣爆刷第162天之TOP100五连刷76-80&#xff08;最小路径和、最长公共前缀、最长连续序列&#xff09; 文章目录 力扣爆刷第162天之TOP100五连刷76-80&#xff08;最小路径和、最长公共前缀、最长连续序列&#xff09;一、64. 最小路径和二、221. 最大正方形三、162. 寻找峰值…

OpenCV距离变换函数distanceTransform的使用

操作系统&#xff1a;ubuntu22.04OpenCV版本&#xff1a;OpenCV4.9IDE:Visual Studio Code编程语言&#xff1a;C11 功能描述 distanceTransform是OpenCV库中的一个非常有用的函数&#xff0c;主要用于计算图像中每个像素到最近的背景&#xff08;通常是非零像素到零像素&…

「C++系列」C++ 修饰符类型

文章目录 一、C 修饰符类型1. 访问修饰符&#xff08;Access Modifiers&#xff09;2. 存储类修饰符&#xff08;Storage Class Specifiers&#xff09;3. 类型修饰符&#xff08;Type Modifiers&#xff09;4. 函数修饰符 二、C 修饰符类型-案例1. 访问修饰符案例2. 存储类修饰…

JavaSE 面向对象程序设计进阶 IO流 字符输入输出流及底层原理

目录 字符输入流FileReader 空参的read方法 带参的read方法 字符输出流FileWriter 字符输入流底层原理 字符输出流底层原理 字符输入流FileReader 输入流 一次读一个字节 遇到中文时 一次读多个字节 输出流 底层会把数据按照指定的编码方式进行编码 在变成直接写到文件当…

Defensor 4.5:构建数据资产为中心的安全运营体系

5月31日“向星力”未来数据技术峰会上&#xff0c;星环科技重磅发布数据安全管理平台 Defensor 4.5版本。新版本引入了以数据资产为中心的数据安全运营体系&#xff0c;通过智能化大模型技术&#xff0c;帮助企业快速、精准地识别核心重要资产&#xff1b;建设全局的数据安全策…

昇思MindSpore学习笔记6-04计算机视觉--Shufflenet图像分类

摘要&#xff1a; 记录MindSpore AI框架使用ShuffleNet网络对CIFAR-10数据集进行分类的过程、步骤和方法。包括环境准备、下载数据集、数据集加载和预处理、构建模型、模型训练、模型评估、模型测试等。 一、概念 1.ShuffleNet网络 旷视科技提出的CNN模型 应用在移动端 通…

【JavaSE】图书管理系统

目录 最终效果book包Book类BookList类 user包User类AdmiUser类&#xff08;管理员类&#xff09;NormalUser类&#xff08;普通用户类&#xff09; opeeration包IOperation接口FindOpertion类&#xff08;查找操作&#xff09;AddOpertion类&#xff08;增加操作&#xff09;De…

关于解决双屏幕鼠标移动方向问题

1.点开设置》系统》屏幕 2.分清屏幕标识&#xff0c;一般笔记本为1 3.点击要移动的屏幕&#xff0c;然后按住鼠标左键不方进行移动 感谢您的浏览&#xff0c;希望可以帮到您&#xff01;

探索多模态预训练:MAnTiS、ActionCLIP、CPT与CoOp的Prompt技巧

上一篇博文整理了 预训练新范式&#xff08;Prompt-tuning&#xff0c;Prefix-tuning&#xff0c;P-tuning&#xff09; &#xff0c;主要是围绕NLP上的成果&#xff0c;具体的概念本文也不做过多赘述。本篇文章将主要整理几篇有代表性的Prompt方法在多模态领域中的应用。 Mult…

unity使用 MQTT复现plant simulate仿真

unity使用 MQTT复现plant simulate仿真 一、plant simulate端配置 1、plant simulate MQTT组件配置,该组件在类库的信息流类目下,端口不变,填写ip即可; 2、设备配置界面,在控件入口和出口处各挂一个脚本,当物料出入该设备时会分别触发执行这两个脚本,粘贴如下代码; E…

视频怎么压缩变小?最佳视频压缩器

即使在云存储和廉价硬盘空间时代&#xff0c;大视频文件使用起来仍然不方便。无论是存储、发送到电子邮件帐户还是刻录到 DVD&#xff0c;拥有最好的免费压缩软件可以确保您快速缩小文件大小&#xff0c;而不必担心视频质量下降。继续阅读以探索一些顶级最佳 免费视频压缩器选项…