APACHE CASSANDRA – BAŞLANGIÇ 3 – REPLICATION STRATEGY AND FACTOR
İlk yazımızda Cassandra dağıtık bir yapıda çalışabildiğinden
bahsetmiştik. 2 node içeren bir örnek Cassandra dağıtık veritabanı mimarisi
kuracağız. Öncesinde tablo oluştururken kullandığımız iki parametre den
bahsetmekte yarar var.
CREATE KEYSPACE
ornekdatabase WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
Replication Strategy : Temel olarak iki farklı stratejimiz
mevcut. “SimpleStrategy” ve “NetworkTopologyStrategy”.
“SimpleStrategy” için tamamen düz mantık diyebiliriz. Her eklenen node aslında
dairemize ekleniyor. Veri yazımı ise sırayla gerçekleşiyor. Örneğimizde de bu
yapıyı kullanacağız. Ancak datacenter lar kurgusu olması durumunda “NetworkTopologyStrategy”
kullanılır. Tabii aklınıza ilk olarak Cassandra nın datacenter ları tanıtmanın
nasıl olacağı sorusu geliyor. Bu amaçla cassandra.yaml dosyasını açıyoruz.
# - SimpleSnitch:
# Treats Strategy
order as proximity. This can improve cache
# locality when
disabling read repair. Only appropriate
for
# single-datacenter
deployments.
# -
GossipingPropertyFileSnitch
# This should be
your go-to snitch for production use.
The rack
# and datacenter
for the local node are defined in
# cassandra-rackdc.properties
and propagated to other nodes via
# gossip. If cassandra-topology.properties exists, it
is used as a
# fallback,
allowing migration from the PropertyFileSnitch.
# -
PropertyFileSnitch:
# Proximity is
determined by rack and data center, which are
# explicitly
configured in cassandra-topology.properties.
# - Ec2Snitch:
# Appropriate for
EC2 deployments in a single Region. Loads Region
# and Availability
Zone information from the EC2 API. The Region is
# treated as the
datacenter, and the Availability Zone as the rack.
# Only private IPs
are used, so this will not work across multiple
# Regions.
# -
Ec2MultiRegionSnitch:
# Uses public IPs
as broadcast_address to allow cross-region
#
connectivity. (Thus, you should
set seed addresses to the public
# IP as well.) You
will need to open the storage_port or
# ssl_storage_port
on the public IP firewall. (For
intra-Region
# traffic,
Cassandra will switch to the private IP after
# establishing a connection.)
# -
RackInferringSnitch:
# Proximity is
determined by rack and data center, which are
# assumed to
correspond to the 3rd and 2nd octet of each node's IP
# address,
respectively. Unless this happens to
match your
# deployment
conventions, this is best used as an example of
# writing a custom
Snitch class and is provided in that spirit.
#
# You can use a custom Snitch by setting this to the full
class name
# of the snitch, which will be assumed to be on your classpath.
Görüldüğü üzere SimpleSnitch, GossipingPropertyFileSnitch, PropertyFileSnitch,
Ec2Snitch, Ec2MultiRegionSnitch, RackInferringSnitch stratejileri mevcut.
Network tasarımıza seçimimizi yapıyoruz. Dosya, ip ve cloud bazlı destekleri
mevcut.
Replication Factor : Verinin kopyalanacağı toplam node
sayısını belirtiyor.Verilen sayı kadar node a veri yazımı gerçekleşecek.
rpc_address : 0.0.0.0 yapılmalı.
broadcast_rpc_address: 172.30.1.136 (kendi ip adresiniz) node 2 de ise : 172.30.1.156
listen_address: 172.30.1.136 (kendi ip adresiniz) node 2 de ise :
172.30.1.156
- seeds: "172.30.1.136,172.30.1.156" (iki node da aynı)
endpoint_snitch -> RackInferringSnitch
İki node da çalışmaya başladığınızda keyspace,tablo ve ekleme işlemerinin iki node dan da sorgulanabildiğini göreceksiniz.
Yorumlar
Yorum Gönder