nginx学习(3)Nginx 负载均衡

news2024/9/22 1:25:38

Nginx 负载均衡 实战案例

实现效果
浏览器地址栏输入地址 http://172.31.0.99/oa/a.html,负载均衡效果,平均在 8083 和 8084 端口中,刷新浏览器,显示不同

一、配置

1、先创建2个文件夹tomcat8083和tomcat8084,并将apache-tomcat-8.5.87解压到tomcat8083和tomcat8084中

(或者复制一份tomcat8081中的/apache-tomcat-8.5.87到这两个文件中)

[root@oa tools]# mkdir tomcat8083
[root@oa tools]# mkdir tomcat8084

在这里插入图片描述

[root@oa tools]# cp -r /tools/tomcat8081/apache-tomcat-8.5.87 tomcat8083
[root@oa tools]# cp -r /tools/tomcat8081/apache-tomcat-8.5.87 tomcat8084

2、修改Tomcat配置文件

tomcat8083

2、将tomcat8083中的server.xml内容修改后如下:
在这里插入图片描述

2.1、修改server 的默认端口,由默认8005->8093
在这里插入图片描述

2.2、修改http协议的默认端口,由默认的8080->8083
在这里插入图片描述

2.3修改默认ajp协议的默认端口,由默认的8009->9003
在这里插入图片描述

最终修改文件:

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 -->
<Server port="8093" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />
  -->
  <!-- APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->


    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL/TLS HTTP/1.1 Connector on port 8083
    -->
    <Connector port="8083" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8445" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8083" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8445" />
    -->
    <!-- Define an SSL/TLS HTTP/1.1 Connector on port 8445
         This connector uses the NIO implementation. The default
         SSLImplementation will depend on the presence of the APR/native
         library and the useOpenSSL attribute of the AprLifecycleListener.
         Either JSSE or OpenSSL style configuration may be used regardless of
         the SSLImplementation selected. JSSE style configuration is used below.
    -->
    <!--
    <Connector port="8445" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true">
        <SSLHostConfig>
            <Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
                         type="RSA" />
        </SSLHostConfig>
    </Connector>
    -->
    <!-- Define an SSL/TLS HTTP/1.1 Connector on port 8445 with HTTP/2
         This connector uses the APR/native implementation which always uses
         OpenSSL for TLS.
         Either JSSE or OpenSSL style configuration may be used. OpenSSL style
         configuration is used below.
    -->
    <!--
    <Connector port="8445" protocol="org.apache.coyote.http11.Http11AprProtocol"
               maxThreads="150" SSLEnabled="true" >
        <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
        <SSLHostConfig>
            <Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
                         certificateFile="conf/localhost-rsa-cert.pem"
                         certificateChainFile="conf/localhost-rsa-chain.pem"
                         type="RSA" />
        </SSLHostConfig>
    </Connector>
    -->

    <!-- Define an AJP 1.3 Connector on port 9003 -->
    <!--
    <Connector protocol="AJP/1.3"
               address="::1"
               port="9003"
               redirectPort="8445" />
    -->

    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
    -->
    <Engine name="Catalina" defaultHost="localhost">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->

      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
           via a brute-force attack -->
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- This Realm uses the UserDatabase configured in the global JNDI
             resources under the key "UserDatabase".  Any edits
             that are performed against this UserDatabase are immediately
             available for use by the Realm.  -->
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
    </Engine>
  </Service>
</Server>

tomcat8084

tomcat4也是和tomcat3,修改相同的文职,变成不同的端口就行,可以看我最终修改的一下文件,就是修改成别的端口就行。

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 -->
<Server port="8094" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />
  -->
  <!-- APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->


    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL/TLS HTTP/1.1 Connector on port 8084
    -->
    <Connector port="8084" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8445" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8084" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8445" />
    -->
    <!-- Define an SSL/TLS HTTP/1.1 Connector on port 8445
         This connector uses the NIO implementation. The default
         SSLImplementation will depend on the presence of the APR/native
         library and the useOpenSSL attribute of the AprLifecycleListener.
         Either JSSE or OpenSSL style configuration may be used regardless of
         the SSLImplementation selected. JSSE style configuration is used below.
    -->
    <!--
    <Connector port="8445" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true">
        <SSLHostConfig>
            <Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
                         type="RSA" />
        </SSLHostConfig>
    </Connector>
    -->
    <!-- Define an SSL/TLS HTTP/1.1 Connector on port 8445 with HTTP/2
         This connector uses the APR/native implementation which always uses
         OpenSSL for TLS.
         Either JSSE or OpenSSL style configuration may be used. OpenSSL style
         configuration is used below.
    -->
    <!--
    <Connector port="8445" protocol="org.apache.coyote.http11.Http11AprProtocol"
               maxThreads="150" SSLEnabled="true" >
        <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
        <SSLHostConfig>
            <Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
                         certificateFile="conf/localhost-rsa-cert.pem"
                         certificateChainFile="conf/localhost-rsa-chain.pem"
                         type="RSA" />
        </SSLHostConfig>
    </Connector>
    -->

    <!-- Define an AJP 1.3 Connector on port 9004 -->
    <!--
    <Connector protocol="AJP/1.3"
               address="::1"
               port="9004"
               redirectPort="8445" />
    -->

    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
    -->
    <Engine name="Catalina" defaultHost="localhost">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->

      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
           via a brute-force attack -->
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- This Realm uses the UserDatabase configured in the global JNDI
             resources under the key "UserDatabase".  Any edits
             that are performed against this UserDatabase are immediately
             available for use by the Realm.  -->
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
    </Engine>
  </Service>
</Server>

二、创建项目文件夹

tomcat8083

1、在/tools/tomcat8083/apache-tomcat-8.5.87/webapps,创建一个oa的文件夹
在这里插入图片描述
2、并在oa 的文件夹中,建立一个a.html文件,内容如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>NGINX 负载均衡Tomcat3</h1>
</body>
</html>

tomcat8084

1、在/tools/tomcat8084/apache-tomcat-8.5.87/webapps,创建一个oa的文件夹
在这里插入图片描述
2、并在oa 的文件夹中,建立一个a.html文件,内容如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>NGINX 负载均衡Tomcat4</h1>
</body>
</html>

三、启动Tomcatcat

1、启动tomcat8083

[root@oa tomcat8083]# cd /tools/tomcat8083/apache-tomcat-8.5.87/bin
[root@oa bin]# ./startup.sh 

在这里插入图片描述

2、启动tomcat8084

[root@oa tomcat8083]# cd /tools/tomcat8084/apache-tomcat-8.5.87/bin
[root@oa bin]# ./startup.sh

在这里插入图片描述

三、配置NGINX

1、找到NGINX的配置文件/usr/local/nginx/conf 路劲 下,修改nginx.conf文件
在这里插入图片描述
2、进行负载均衡的配置
在这里插入图片描述


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

   upstream myserver {
        server 172.31.0.99:8083;
        server 172.31.0.99:8084;
    }

    server {
        listen       80;        
        #server_name  localhost;
       server_name  172.31.0.99; 
        
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
           proxy_pass http://myserver;
            index  index.html index.htm;
        }

     

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
 server {
        listen       8001;        
        #server_name  localhost;
        server_name  172.31.0.99; 
        
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location ~  /vod/ {
            
            proxy_pass http://127.0.0.1:8081;
            
        }
         location ~  /edu/ {
            
            proxy_pass http://127.0.0.1:8082;
            
        }
     }

    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

3、启动nginx
[root@oa bin]# cd /usr/local/nginx/sbin
[root@oa sbin]# ./nginx

在这里插入图片描述

三、最终测试

访问:http://172.31.0.99/oa/a.html

1、第一次访问,
在这里插入图片描述
2、直接在浏览器中右击,“”“重新加载”,就看到如下的界面
在这里插入图片描述

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

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

相关文章

JSP 四大域对象

我们来说说JSP的四大域对象 首先 我们要了解他们是四种保存范围 第一种 是 Page范围 只作用于当前界面 只要页面跳转了 其他页面就拿不到了 第二种 request范围 在一次请求中有效 就是 我们服务端指向某个界面 并传递数据给他 那么 如果你是客户端跳转就不生效了 第三种 sessi…

internet download manager2024中文绿色版(IDM下载器)

在现代互联网时代&#xff0c;文件下载已经成为我们日常生活中必不可少的一项技能。无论是下载软件、音乐、视频还是其他文件&#xff0c;一个高效的下载方法能够为我们节省时间和精力。本文将为您提供一份简明扼要的下载教程&#xff0c;让您轻松掌握文件下载的技巧。 intern…

2021年3月青少年软件编程(Python)等级考试试卷(一级)

2021年3月青少年软件编程&#xff08;Python&#xff09;等级考试试卷&#xff08;一级&#xff09; 分数&#xff1a;100.00 题数&#xff1a;37一、单选题&#xff08;共25题&#xff0c;每题2分&#xff0c;共50分&#xff09;二、判断题&#xff08;共10题&#xff0c;每题…

vue2通信方法(最全)

前言 数据传递是框架的核心要素之一,也是在业务开发中极其重要的技术.熟练掌握所有的通信方法,是开发者必须具备的技能。 这篇文章我将会把vue2所有的通信的方法都形成简单易懂的demo。 在我的分类中,通信方法有两种大类型: 1.vue框架提供的通信方法 2.插件及其他通信方法…

指针学习(五)

一.函数指针数组 定义&#xff1a;函数指针放进数组中&#xff0c;就叫函数指针数组&#xff0c;准确的说&#xff0c;将一个函数的地址存到⼀个数组中 那这个数组就叫函数指针数组。 int (*pi[5])(int); 解读&#xff1a;pi先和[]结合&#xff0c;因此是数组&#xff0c;加i…

Leetcode—5.最长回文子串【中等】

2023每日刷题&#xff08;三十五&#xff09; Leetcode—5.最长回文子串 中心扩展法算法思想 可以使用一种叫作“中心扩展法”的算法。由回文的性质可以知道&#xff0c;回文一定有一个中心点&#xff0c;从中心点向左和向右所形成的字符序列是一样的&#xff0c;并且如果字符…

Threejs_04 gui调试开发

threejs的快捷调试工具就是这玩意&#xff0c;那么如何使用呢&#xff1f;&#xff1f; 使用gui调试开发 引入gui实例 //导入lil.gui // import * as dat from "dat.gui"; // 旧 import { GUI } from "three/examples/jsm/libs/lil-gui.module.min.js";…

Vatee万腾科技创新之舟:Vatee数字化力量引领未来的独特路径

在数字化的大潮中&#xff0c;Vatee万腾如一艘科技创新之舟&#xff0c;在未来的海洋中翱翔。vatee万腾以强大的数字化力量为桨&#xff0c;引领着行业向着新的、独特的路径前行&#xff0c;塑造着数字时代的未来。 Vatee万腾不仅仅是一家科技公司&#xff0c;更是一艘创新之舟…

数据结构与算法编程题2

逆置线性表&#xff0c;使空间复杂度为 O(1) #include <iostream> using namespace std;typedef int ElemType; #define Maxsize 100 #define OK 1 #define ERROR 0 typedef struct SqList {ElemType data[Maxsize];int length; }SqList;void Init_SqList(SqList& …

外贸人如何向国外客户展现我们的合作诚意

最近听直播&#xff0c; 一个小伙伴说自己在国外找了一个合作伙伴&#xff0c; 让他代表自己的公司和当地的客户沟通&#xff0c;然后给对方结算佣金&#xff0c;虽然对方口头答应好好的&#xff0c;但是好像做事情并不用心的样子。 比如自己之前去他们当地设展的时候邀请对方…

MAX/MSP SDK学习01:Object的基本构成、创建销毁行为函数的定义、属性的赋值、以及相关注意事项

Object的基本构成、创建&销毁&行为函数的定义、属性的赋值、以及相关注意事项。 #include "ext.h" // standard Max include, always required #include "ext_obex.h" // required for new style Max object// object struct&#xff0c;定义属…

ruoyi-vue前后端分离版本验证码实现思路

序 时隔三个月&#xff0c;再次拿起我的键盘。 前言 ruoyi-vue是若依前后端分离版本的快速开发框架&#xff0c;适合用于项目开始搭建后台管理系统。本篇文章主要介绍其验证码实现的思路。 一、实现思路简介 1、后端会生成一个表达式&#xff0c;比如1 2 ? 3&#xff0…

Django 入门学习总结2

通过学习&#xff0c;我们可以实现一个简单的投票系统。这个投票系统有两部分组成。 公共部分&#xff0c;公众可以查看和进行投票。管理员可以进行增加、删除、修改投票信息。 这里投票系统Python语言版本为3.10.13&#xff0c;Django Web框架版本为4.2.7。 投票系统的实现…

湖科大计网:传输层

一、传输层概述 一、基本概念 传输层是端到端的协议。 因特网的两种不同的传输层协议&#xff1a; TCP&#xff1a;面向连接 UDP&#xff1a;无连接 我们在学习的过程中&#xff0c;只需要关注传输层之间的通信&#xff0c;不需要关注传输层协议数据是经过路由器转发至目的网络…

利用python下的matplotlib库绘制能突出显示的饼状图

需求描述 根据已有的数据绘制一个占比图&#xff0c;期望能对其中的部分占比成分进行突出显示。 原始数据如下&#xff1a; 国外投资&#xff08;5%&#xff09;、公司投资&#xff08;8%&#xff09;、地方投资&#xff08;7%&#xff09;、中央财政&#xff08;80%&#xff…

小红书软文种草怎么做,新产品上市软文创作技巧!

很多品牌有新品上市时都会借助软文传播来打开销路。因此&#xff0c;软文的质量几乎决定了新产品的营销结果。今天为大家分享下小红书软文种草怎么做&#xff0c;新产品上市软文创作技巧&#xff01; 一、新品上市软文撰写的三大重点 1、确定软文撰写角度 新品上市软文&#xf…

使用契约的链上限价订单

我们开发了链上限价订单。 它基于一种称为契约的智能合约&#xff0c;只有在花费输出的交易满足特定条件时才可以花费输出。 为了演示其工作原理&#xff0c;我们实施了以比特币支付的 Ordinals 代币买卖限价订单&#xff0c;无需托管人。 它可以运行在任何比特币协议链上&…

七,vi和vim

Linux系统会内置vi文本编辑器 Vim具有程序编辑的能力&#xff0c;可以看做是Vi的增强版本&#xff0c;可以主动的以字体颜色辨别语法的正确性&#xff0c;方便程序设计。代码补完、编译及错误跳转等方便编程的功能特别丰富&#xff0c;在程序员中被广泛使用。 vi和vim常用的三…

基因组坐标系统的 0-based 和 1-based(图文详解)

基因组坐标中的 “0-based” 和 “1-based” 是两种不同的规范&#xff0c;用于表示基因组上的位置。 它们在不同的上下文和文件格式中可能会有不同的使用方式。 下面我们聊聊它们间的区别和应用&#xff1a; 一、0-based 也叫做 zero-based half-open 示例 start0&#xf…

Wireshark网络工具

Wireshark是网络包分析工具。网络包分析工具的主要作用是尝试捕获网络包&#xff0c;并尝试显示包的尽可能详细的情况。 Wireshark是一个免费开源软件&#xff0c;不需要付费&#xff0c;免费使用&#xff0c;可以直接登陆到Wireshark的官网下载安装。 在windows环境中&#x…