第一篇:SpringCloud 構建微服務系統之服務注冊和發現(consul)

版權聲明:本文為博主原創文章,未經博主允許不得轉載。 https://blog.csdn.net/u010046908/article/details/85260629

今天我們要學習的是consul在soringcloud中的使用。首先學習consul之前,我們應該看看consul的官網,對它有一個初步的認識。

1. consul 官網 (https://www.consul.io)

在這里插入圖片描述

2. consul 簡介

consul是google開源的一個使用go語言開發的服務發現、配置管理中心服務。內置了服務注冊與發現框 架、分布一致性協議實現、健康檢查、Key/Value存儲、多數據中心方案,不再需要依賴其他工具(比如ZooKeeper等)。服務部署簡單,只有一個可運行的二進制的包。每個節點都需要運行agent,他有兩種運行模式server和client。每個數據中心官方建議需要3或5個server節點以保證數據安全,同時保證server-leader的選舉能夠正確的進行。

3.consul基本概念

  • client

CLIENT表示consul的client模式,就是客戶端模式。是consul節點的一種模式,這種模式下,所有注冊到當前節點的服務會被轉發到SERVER,本身是不持久化這些信息。

  • server

SERVER表示consul的server模式,表明這個consul是個server,這種模式下,功能和CLIENT都一樣,唯一不同的是,它會把所有的信息持久化的本地,這樣遇到故障,信息是可以被保留的。

  • server-leader

中間那個SERVER下面有LEADER的字眼,表明這個SERVER是它們的老大,它和其它SERVER不一樣的一點是,它需要負責同步注冊的信息給其它的SERVER,同時也要負責各個節點的健康監測。

  • raft

server節點之間的數據一致性保證,一致性協議使用的是raft,而zookeeper用的paxos,etcd采用的也是taft。

  • 服務發現協議

consul采用http和dns協議,etcd只支持http

  • 服務注冊

consul支持兩種方式實現服務注冊,一種是通過consul的服務注冊http API,由服務自己調用API實現注冊,另一種方式是通過json個是的配置文件實現注冊,將需要注冊的服務以json格式的配置文件給出。consul官方建議使用第二種方式。

  • 服務發現

consul支持兩種方式實現服務發現,一種是通過http API來查詢有哪些服務,另外一種是通過consul agent 自帶的DNS(8600端口),域名是以NAME.service.consul的形式給出,NAME即在定義的服務配置文件中,服務的名稱。DNS方式可以通過check的方式檢查服務。

  • 服務間的通信協議

Consul使用gossip協議管理成員關系、廣播消息到整個集群,他有兩個gossip pool(LAN pool和WAN pool),LAN pool是同一個數據中心內部通信的,WAN pool是多個數據中心通信的,LAN pool有多個,WAN pool只有一個。

4.consul架構圖

在這里插入圖片描述

5.Consul常用命令

5.1 agent 運行一個consul agent

consul agent -dev

5.2 join 將agent加入到consul集群

consul join IP

5.3 members 列出consul cluster的members

consul members

5.4 leave 將節點移除所在集群

consul leave

6.consul安裝和啟動

在這里插入圖片描述

點擊“download”下載:使用命令啟動

 consul agent -dev

啟動成功之后在地址:http://localhost:8500在這里插入圖片描述

7.consul服務的發現與注冊

7.1 注冊服務

使用HTTP API 注冊個服務,使用[接口API](https://www.consul.io/api/agent/service.html API)調用

調用 http://localhost:8500/v1/agent/service/register PUT 注冊一個服務。request body:

{"ID": "userServiceId", //服務id"Name": "userService", //服務名"Tags": [              //服務的tag,自定義,可以根據這個tag來區分同一個服務名的服務"primary","v1"],"Address": "127.0.0.1",//服務注冊到consul的IP,服務發現,發現的就是這個IP"Port": 9000,          //服務注冊consul的PORT,發現的就是這個PORT"EnableTagOverride": false,"Check": {             //健康檢查部分"DeregisterCriticalServiceAfter": "90m","HTTP": "http://www.baidu.com", //指定健康檢查的URL,調用后只要返回20X,consul都認為是健康的"Interval": "10s"   //健康檢查間隔時間,每隔10s,調用一次上面的URL}
}

使用curl調用

curl http://127.0.0.1:8500/v1/agent/service/register -X PUT -i -H "Content-Type:application/json" -d '{"ID": "userServiceId",  "Name": "userService","Tags": ["primary","v1"],"Address": "127.0.0.1","Port": 8000,"EnableTagOverride": false,"Check": {"DeregisterCriticalServiceAfter": "90m","HTTP": "http://www.baidu.com","Interval": "10s"}
}'

結果

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed
100   288    0     0  100   288      0  18000 --:--:-- --:--:-- --:--:-- 18000HTTP/1.1 200 OK
Vary: Accept-Encoding
Date: Wed, 26 Dec 2018 05:11:32 GMT
Content-Length: 0

在這里插入圖片描述

7.2 發現個服務

剛剛注冊了名為userService的服務,我們現在發現(查詢)下這個服務

curl http://127.0.0.1:8500/v1/catalog/service/userService

返回的響應:

 curl http://127.0.0.1:8500/v1/catalog/service/userService% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed
100   891  100   891    0     0  28741      0 --:--:-- --:--:-- --:--:-- 28741[{"ID": "9b831a00-ae68-d575-5e51-df193897b834","Node": "vip-PC","Address": "127.0.0.1","Datacenter": "dc1","TaggedAddresses": {"lan": "127.0.0.1","wan": "127.0.0.1"},"NodeMeta": {"consul-network-segment": ""},"ServiceKind": "","ServiceID": "userServiceId","ServiceName": "userService","ServiceTags": ["primary","v1"],"ServiceAddress": "127.0.0.1","ServiceWeights": {"Passing": 1,"Warning": 1},"ServiceMeta": {},"ServicePort": 8000,"ServiceEnableTagOverride": false,"ServiceProxyDestination": "","ServiceProxy": {},"ServiceConnect": {},"CreateIndex": 88,"ModifyIndex": 88}
]

基本的服務發現和注冊我們已經弄清楚了。接下來我來看看Spring Cloud 整合consul的使用。

8. consul服務提供者

8.1創建一個項目:spring-cloud-consul-provider

引入依賴

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.1.1.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.lidong</groupId><artifactId>spring-cloud-consul-producer</artifactId><version>1.0.0</version><name>spring-cloud-consul-producer</name><description>Demo project for Spring Boot</description><properties><java.version>1.8</java.version><spring-cloud.version>Greenwich.RC2</spring-cloud.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-consul-discovery</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>${spring-cloud.version}</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build><repositories><repository><id>spring-milestones</id><name>Spring Milestones</name><url>https://repo.spring.io/milestone</url></repository></repositories></project>

對配置文件做一個簡單的介紹,我們使用的是最新版的springboot2.1.1,springcloud.Greenwich.RC2版本。
其中:

spring-boot-starter-actuator   健康檢查依賴于此包。
spring-cloud-starter-consul-discovery   Spring Cloud consul的服務發現支持。

8.2 提供者添加配置(application.yml)

server:port: 9001 #提供者的端口
spring:application:name: spring-cloud-consul-producercloud:consul:host: localhostport: 8500discovery:tags: devserviceName: spring-cloud-consul-producer   # 注冊到consul的服務名稱healthCheckPath: /actuator/healthhealthCheckInterval: 15shealthCheckUrl: http://127.0.0.1:9001/actuator/healthregister: trueprefer-ip-address: false

consul的地址和端口號默認是127.0.0.1:8500,如果沒有配置hosts,默認的地址localhost,consul服務會占用8500端口
server.port :9001 服務的提供者的端口
spring.application.name 是指注冊到 consul的服務名稱,后期客戶端會根據這個名稱來進行服務調用。
spring.application.cloud.discovery.discovery.host: localhost
spring.application.cloud.discovery.discovery. port:8500

8.3 修改啟動類

添加 @EnableDiscoveryClient 注解,開啟服務發現支持。

package com.lidong.provider;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;/*** 開啟服務發現*/
@EnableDiscoveryClient
@SpringBootApplication
public class SpringCloudLidongProviderApplication {public static void main(String[] args) {SpringApplication.run(SpringCloudLidongProviderApplication.class, args);}}

8.4新建服務

新建 ConsulProducerController,提供 sayHello 接口, 返回一個hello—>字符串。

package com.lidong.provider.service;import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;/*** 創建服務*/
@RestController
public class ConsulProducerController {@Value("${server.port}")private Integer port;/*** 服務接口* @param name* @return*/@RequestMapping("/hello")public String sayHello(@RequestParam("name")String name) {return "hello ---> "+name+" port -->"+port;}
}

啟動項目:

2018-12-26 13:21:42.984  INFO 20248 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 9001 (http) with context path ''
2018-12-26 13:21:42.994  INFO 20248 --- [           main] o.s.c.c.s.ConsulServiceRegistry          : Registering service with consul: NewService{id='spring-cloud-consul-producer-9001', name='spring-cloud-consul-producer', tags=[dev, secure=false], address='vip-PC', meta=null, port=9001, enableTagOverride=null, check=Check{script='null', interval='15s', ttl='null', http='http://127.0.0.1:9001/actuator/health', method='null', header={}, tcp='null', timeout='null', deregisterCriticalServiceAfter='null', tlsSkipVerify=null, status='null'}, checks=null}
2018-12-26 13:21:43.008  INFO 20248 --- [           main] l.p.SpringCloudLidongProviderApplication : Started SpringCloudLidongProviderApplication in 4.09 seconds (JVM running for 4.755)

服務提供者發布成功。
這時候,我們在控制臺會發現服務列表中有一個名字為spring-cloud-consul-producer的服務

在這里插入圖片描述
點擊詳情會發現服務的詳細信息
在這里插入圖片描述

9. Consul服務消費者

9.1創建一個項目:spring-cloud-consul-consumer

引入依賴

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.1.1.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.lidong</groupId><artifactId>spring-cloud-consul-consumer</artifactId><version>0.0.1-SNAPSHOT</version><name>spring-cloud-consul-consumer</name><description>Demo project for Spring Boot</description><properties><java.version>1.8</java.version><spring-cloud.version>Greenwich.RC2</spring-cloud.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-consul-discovery</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-ribbon</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId></dependency></dependencies><dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>${spring-cloud.version}</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build><repositories><repository><id>spring-milestones</id><name>Spring Milestones</name><url>https://repo.spring.io/milestone</url></repository></repositories></project>

9.2 消費者添加配置(application.yml)

server:port: 9002 #服務消費者的端口
spring:application:name: spring-cloud-consul-consumercloud:consul:host: localhostport: 8500discovery:tags: devregister: false    #設置不需要注冊到 consul 中healthCheckPath: /actuator/healthhealthCheckInterval: 15shealthCheckUrl: http://127.0.0.1:9002/actuator/health

consul的地址和端口號默認是 127.0.0.1:8500,如果沒有配置hosts,默認的地址localhost,consul服務會占用8500接口
server.port :9006 服務的消費者的端口
spring.application.cloud.consul.discovery.register: false

9.3配置啟動類

package com.lidong.consumer;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.client.RestTemplate;
@SpringBootApplication
@EnableDiscoveryClient
public class SpringCloudConsulConsumerApplication {@Autowiredprivate RestTemplateBuilder builder;@LoadBalanced@Bean// 添加負載均衡支持,很簡單,只需要在RestTemplate上添加@LoadBalanced注解,那么RestTemplate即具有負載均衡的功能,如果不加@LoadBalanced注解的話,會報java.net.UnknownHostException:springboot-h2異常,此時無法通過注冊到Eureka Server上的服務名來調用服務,因為RestTemplate是無法從服務名映射到ip:port的,映射的功能是由LoadBalancerClient來實現的。public RestTemplate restTemplate() {return builder.build();}public static void main(String[] args) {SpringApplication.run(SpringCloudConsulConsumerApplication.class, args);}}

9.4創建消費服務

package com.lidong.consumer.controller;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;/*** 創建服務的消費者*/
@RestController
public class ConsumerController {private static final String SERVICE_NAME = "spring-cloud-consul-producer";@Autowiredprivate DiscoveryClient discoveryClient;/*** 獲取所有服務*/@RequestMapping("/services")public Object services() {return discoveryClient.getInstances(SERVICE_NAME);}/*** 消費服務*/@RequestMapping("/callSayHello")public String services(@RequestParam("name") String name) {ServiceInstance serviceInstance = (ServiceInstance) discoveryClient.getInstances(SERVICE_NAME);String callServiceResult = new RestTemplate().getForObject(serviceInstance.getUri().toString() + "/hello", String.class);System.out.println(callServiceResult);return callServiceResult;}
}

http://localhost:9002/services

獲取服務列表的結果

[{"instanceId":"spring-cloud-consul-producer-9001","serviceId":"spring-cloud-consul-producer","host":"vip-PC","port":9001,"secure":false,"metadata":{"dev":"dev","secure":"false"},"uri":"http://vip-PC:9001","scheme":null}]

測試請求的url
http://localhost:9002/callSayHello?name=9002
消費的結果

hello ---> 9002 port -->9001

源碼地址
https://download.csdn.net/download/u010046908/10877868

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/252715.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/252715.shtml
英文地址,請注明出處:http://en.pswp.cn/news/252715.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

2018 年視頻監控企業競爭力分析 海康威視連續七年蟬聯全球第一

視頻監控是安防行業的核心 近年來&#xff0c;隨著我國政府對平安城市、" 雪亮工程 " 以及金融和交通運輸等領域的重視&#xff0c;對于安防產品的需求不斷提升&#xff0c;安防市場規模也在隨之不斷擴大。視頻監控是整個安防系統最重要的物理基礎&#xff0c;視頻監…

java 二維數組

二維數組 多維數組可以簡單地理解為在數組中嵌套數組 二維數組的定義格式 二維數組的定義有很多方式 第一種方式 1 int[][] arr new int[3][4]; 上面的代碼相當于定義了一個3*4的二維數組&#xff0c;即二維數組的長度為3&#xff0c;二維數組中的每個元素又是一個長度為4的數…

Ambient occlusion

https://en.wikipedia.org/wiki/Ambient_occlusion https://gamedev.stackexchange.com/questions/23/what-is-ambient-occlusion http://people.mpi-inf.mpg.de/~ritschel/Papers/SSDO.pdf 注解&#xff1a; 論文&#xff08;http://people.mpi-inf.mpg.de/~ritschel/Papers/S…

利用RTL2832u電視棒芯片追蹤民航飛機軌跡

我國民航飛機通訊的頻率為1090Mhz&#xff0c;而rtl2832u電視棒芯片可以接受的頻率范圍為24 – 1766 MHz&#xff08;通過改制Q通道可以接收0-30Mhz的短波&#xff09;下面開始介紹利用rtl2832u電視棒芯片獲取民航航線 第一步淘寶搜索rtl2832u820T(50塊錢就能買到) <ignore_…

預見2019:《2019年中國視頻監控產業全景圖譜》(附產業布局、政策環境、市場規模、發展趨勢)

2019-2024年中國視頻監控設備行業市場需求預測與投資戰略規劃分析報告2019-2024年中國安防行業市場前瞻與投資戰略規劃分析報告2019-2024年中國智能安防行業市場前瞻與投資戰略規劃分析報告2019-2024年中國智能家居設備行業市場前瞻與投資策略規劃報告2019-2024年中國城市軌道交…

nginx負載均衡 頁面緩存

nginx的upstream目前支持4種方式的分配 1、輪詢&#xff08;默認&#xff09; 每個請求按時間順序逐一分配到不同的后端服務器&#xff0c;如果后端服務器down掉&#xff0c;能自動剔除。 2、weight 指定輪詢幾率&#xff0c;weight和訪問比率成正比&#xff0c;用于后端服務器…

Date擴展 正則匹配

<script>Date.prototype.formatfunction(){var dthis;//嚴格匹配 yyyy-mm-dd hh-mm-ssvar reg1/yyyy-mm-dd hh-m-s/;//匹配 yyyy*mm*dd hh*mm*ss *為任意一個除\r\n之外的字符 中間為任意多個空格var reg2/y{4}.m{2}.dd\shh.mm.ss/;reg1.test(arguments[0]);reg2.test(a…

終于有人把EMC基礎知識總結如此清晰

傳導與輻射 電磁干擾(Electromagnetic Interference)&#xff0c;簡稱EMI&#xff0c;有傳導干擾和輻射干擾兩種。傳導干擾主要是電子設備產生的干擾信號通過導電介質或公共電源線互相產生干擾&#xff1b;輻射干擾是指電子設備產生的干擾信號通過空間耦合把干擾信號傳給另一個…

填坑-十萬個為什么?(13)

簡介:很多概念不清或忘記&#xff0c;重新構建自己的知識體系。每天問自己1~多個問題。我是菜鳥 成為大神之路! 1. 經典面試題 for(var i0;i<3;i){ setTimeout(function() { console.log(i) }, 10);}打印結果&#xff1f;分析&#xff1f; for(var i 0; i < 10; i) {con…

WordPress分類列表函數:wp_list_categories用法及參數詳解舉例

http://www.511yj.com/wordpress-wp-categories.html 注意&#xff1a; 1、 wp_list_categories() 和 list_cats() 以及 wp_list_cats() 的使用類似&#xff0c;但是后面 2 個已經棄用。 2、如果你希望不格式化輸出分類&#xff0c;請使用 get_categories() 3、因為 WordPress …

DVP,LVDS和MIPI

Mipi 接口 和 LVDS 接口區別 主要區別&#xff1a; 1. LVDS接口只用于傳輸視頻數據&#xff0c;MIPI DSI不僅能夠傳輸視頻數據&#xff0c;還能傳輸控制指令&#xff1b; 2. LVDS接口主要是將RGB TTL信號按照SPWG/JEIDA格式轉換成LVDS信號進行傳輸&#xff0c;MIPI DSI接口則…

安裝Cornerstone3.1注意點

mac在升級之后就不能社會做任何來源安裝,需要在終端運行 sudo spctl --master-disable//添加任何來源的,再次安裝就可以的轉載于:https://www.cnblogs.com/chengenyan/p/6835970.html

2019我的目標

1 能考上自己理想的高中 2 至少學會一直種語言&#xff08;英語&#xff09; 3 堅持記錄每一天&#xff0c;每個星期至少寫一遍文章 4 堅持到底 轉載于:https://www.cnblogs.com/ta20/p/10203974.html

nodejs開發——require與exports的使用

nodejs開發——require與exports的使用 另一片文章總結&#xff1a;http://www.cnblogs.com/hfultrastrong/p/8036682.html require require函數用于在當前模塊中加載和使用別的模塊&#xff0c;傳入一個模塊名&#xff0c;返回一個模塊導出對象。模塊名可使用相對路徑&#x…

jvm 內存溢出問題排查方法

如果你做TCP通訊或者map集合操作&#xff0c;并發處理等功能時&#xff0c;很容易出現 Java 內存溢出的問題。本篇文章&#xff0c;帶領大家深入jvm&#xff0c;分析并找出jvm內存溢出的代碼。 jvm中除了程序計數器&#xff0c;其他的區域都有可能會發生內存溢出 內存溢出是什么…

一個go1.9.x 編譯器內聯引起的棧信息錯亂的問題分析

2019獨角獸企業重金招聘Python工程師標準>>> 背景是在寫個日志庫&#xff0c;日志庫有個很重要的功能就是要打印出調用棧&#xff0c;知道具體是哪個文件&#xff0c;哪個函數調用的Info 等。 然后在測試中發現了一種寫法&#xff0c;我自己本機測試一直ok&#xff…

CMOS Sensor的調試經驗分享

轉自&#xff1a;http://bbs.52rd.com/forum.php?modviewthread&tid276351 CMOS Sensor的調試經驗分享      我這里要介紹的就是CMOS攝像頭的一些調試經驗。   首先&#xff0c;要認識CMOS攝像頭的結構。我們通常拿到的是集成封裝好的模組&#xff0c;一般由三個部…

Learn Python—表達式、數據類型、流程控制

表達式 在 Python 中&#xff0c;2 2 稱為“表達式”&#xff0c;它是語言中最基本的編程結構。表達式包含“值”&#xff08;例如2&#xff09;和“操作符”&#xff08;例如&#xff09;&#xff0c;并且總是可以求值&#xff08;也就是歸約&#xff09;為單個值。這意味著在…

監控工具之zabbix server3.4 部署配置

[rootlocalhost src]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) [rootlocalhost src]# pwd /usr/local/src 配置zabbix的yum源 [rootlocalhost src]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm …

CMOS Sensor基礎知識

CMOS Sensor基礎知識 曝光時間以行長為單位&#xff1b; PCLK以Hz為單位&#xff1b; 行長以周期數為單位&#xff0c;幀長以行長數為單位&#xff1b;其中周期數就是頻率 T 周期以ms為單位&#xff1b; f 頻率以Hz為單位&#xff1b; f 1 / T&#xff1b; Vsync Dummy Line…