15 Kasım 2021 Pazartesi

Vitess VtGate Nedir?

Giriş
vtgate komutu yazısına bakabilirsiniz.

VtGate'in Özellikleri
Açıklaması şöyle. Birden fazla vtgate olabilir. Bu durumda bunların önüne bir LoadBalancer konulur. Uygulamalar buna bağlanır
- User and application traffic is routed via vtgate
- A smart, stateless proxy
- Speaks the MySQL protocol
- Impersonates as a monolith MySQL server
- Relays queries to vttablets

VtGate Neden Lazım
Elimizde klasik bir MySQL sunucuları olsun

Sistem büyüdükçe daha fazla sunucu eklememiz gerekecektir. Bu da shard'ları yönetmeyi beraberinde getiriyor. 

Re-Sharding için Gerekir
Vitess kendi başına otomatik re-sharding yapabiliyor. VtGate uygulamamızı bu değişikliklerden yalıtıyor. Çünkü gelen sorguyu kendisi doğru shard'a yönlendiriyor.

Ekranlar
1. debug/status - Status Ekranı
VtGate sunucusunun debug/status ekranında şu başlıklar var
Status for vtgate
Executor
VSchema
Topology Cache
Gateway Status
Health Check Cache

2. debug/health
Sadece "ok" çıktısı veriyor

3. debug/vars
Bir sürü değişkenin değerini çıktı veriyor

VtGate Protokolü
Açıklaması şöyle
VTGate servers speak both gRPC and the MySQL server protocol. This allows you to connect to Vitess as if it were a MySQL Server without any changes to application code. 
VtGate Port'ları
Cluster içindeki portların açıklaması şöyle
application → vtgate
  TCP port 3306 or 15306 : Ben MySQL için hep 3306 kullanıldığını gördüm.
  TCP port 15999 (gRPC)
Ayrıca 15000 de Http için kullanılıyor. 

İstemciyi Failover veya Reparenting İşlerinden Yalıtmak için Gerekir
Açıklaması şöyle
Failover (a.k.a. Reparenting) is easy and transparent for clients. Clients only talk to a VTGate who takes care of failover and service discovery of the new primary transparently.
İsteklerin Yönlendirilmesi
Açıklaması şöyle
The VTGate node will inspect the query and will inspect cluster metadata that it has cached from the topology server. Based on this inspection VTGate will determine if the query spans multiple shards or a single shard. There are several cases here:

Query is Read Only and Applies to Single Shard: In this case the VTGate can forward the query to any serving replica in the shard. The database does all the work and VTGate simply returns the result back to the user.

Query is Read+Write and Applies to Single Shard: This case is identical to the previous case except that the query must be forwarded to the leader for the shard. In a cross cell deployment this could involve making a cross cell call.

Query is Read Only and Applies to Multiple Shards: VTGate forwards the read only query to a replica in all the shards that are involved in the query (this could be all the shards in the cluster or a subset — but we we talk about that more in a future post). The VTGate gets the results back from the various shards, combines the results and returns them back to the user.

Query is Read+Write and Applies to Multiple Shards: Same as previous except all queries need to be forwarded to shard leaders.
Cross Cell İstekler
Açıklaması şöyle
A vtgate’s main job is to forward requests to the vttablets in the local cell. However, vtgates can go cross-cell in two situations:
1. vtgate receives queries to the master, and the master is not in the current cell.
2. vtgate was configured to go to other cells in case no local vttablets were available.

For sending master queries across cells, you must specify an additional cells_to_watch flag. This will make the vtgates watch those additional cells, and will help them keep track of the masters in those cells.

The cells_to_watch flag is a required parameter and must at least include the current cell.
User Management and Authentication
Açıklaması şöyle
Vitess uses its own mechanism for managing users and their permissions through VTGate. As a result, the CREATE USER.... and GRANT... statements will not work if sent through VTGate.
Hata verdiğini görmek için şöyle yaparız
mysql> CREATE USER foo IDENTIFIED BY 'pass';
ERROR 1105 (HY000): syntax error at position 12 near 'USER'

VStream
Vitess VReplication yazısına taşıdım

Hiç yorum yok:

Yorum Gönder

Soft Delete

Giriş Açıklaması  şöyle When using the soft delete mechanism on the database, you might run into a situation where a record with a unique co...