-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
blazaid
committed
Feb 17, 2024
1 parent
5d0a1da
commit 3a9ace3
Showing
13 changed files
with
460,672 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
networks: | ||
cassandra: | ||
driver: bridge | ||
|
||
services: | ||
node1: | ||
image: cassandra:5.0 | ||
container_name: cassandra1 | ||
hostname: h1 | ||
restart: on-failure | ||
healthcheck: | ||
test: ["CMD", "cqlsh", "-e", "describe keyspaces" ] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 60 | ||
networks: | ||
- cassandra | ||
ports: | ||
- "9042:9042" | ||
volumes: | ||
- ./tmp/cassandra1:/var/lib/cassandra | ||
#- ./etc/cassandra1:/etc/cassandra | ||
environment: &environment | ||
CASSANDRA_SEEDS: cass1,cass2 | ||
CASSANDRA_CLUSTER_NAME: Virgo | ||
CASSANDRA_DC: MilkyWay | ||
CASSANDRA_RACK: R1 | ||
CASSANDRA_ENDPOINT_SNITCH: GossipingPropertyFileSnitch | ||
CASSANDRA_NUM_TOKENS: 128 | ||
MAX_HEAP_SIZE: 256M | ||
HEAP_NEWSIZE: 128M | ||
node2: | ||
image: cassandra:5.0 | ||
container_name: cassandra2 | ||
hostname: h2 | ||
restart: on-failure | ||
healthcheck: | ||
test: ["CMD", "cqlsh", "-e", "describe keyspaces" ] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 60 | ||
networks: | ||
- cassandra | ||
ports: | ||
- "9043:9042" | ||
volumes: | ||
- ./tmp/cassandra2:/var/lib/cassandra | ||
#- ./etc/cassandra2:/etc/cassandra | ||
environment: *environment | ||
depends_on: | ||
node1: | ||
condition: service_healthy | ||
|
||
node3: | ||
image: cassandra:5.0 | ||
container_name: cassandra3 | ||
hostname: h3 | ||
restart: on-failure | ||
healthcheck: | ||
test: ["CMD", "cqlsh", "-e", "describe keyspaces" ] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 60 | ||
networks: | ||
- cassandra | ||
ports: | ||
- "9044:9042" | ||
volumes: | ||
- ./tmp/cassandra3:/var/lib/cassandra | ||
#- ./etc/cassandra3:/etc/cassandra | ||
environment: *environment | ||
depends_on: | ||
node2: | ||
condition: service_healthy | ||
|
||
node4: | ||
image: cassandra:5.0 | ||
container_name: cassandra4 | ||
hostname: h4 | ||
restart: on-failure | ||
healthcheck: | ||
test: ["CMD", "cqlsh", "-e", "describe keyspaces" ] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 60 | ||
networks: | ||
- cassandra | ||
ports: | ||
- "9045:9042" | ||
volumes: | ||
- ./tmp/cassandra4:/var/lib/cassandra | ||
#- ./etc/cassandra4:/etc/cassandra | ||
environment: *environment | ||
depends_on: | ||
node3: | ||
condition: service_healthy | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Objetivo de la práctica | ||
|
||
El objetivo de esta práctica es familiarizarse con las operaciones | ||
básicas de Cassandra, incluyendo la creación de keyspaces, tablas, | ||
inserción, actualización y borrado de datos utilizando CQL (Cassandra | ||
Query Language). | ||
|
||
## Pre-requisitos | ||
|
||
- Tener Docker y Docker Compose instalados, | ||
- Contar con conocimientos básicos de bases de datos NoSQL y Cassandra, | ||
- Entender el funcionamiento básico de contenedores Docker. | ||
|
||
## 1. Configuración del entorno | ||
|
||
1. **Inicio del clúster de Cassandra**. Utiliza el archivo `compose.yml` | ||
proporcionado para iniciar tu clúster de Cassandra | ||
2. **Verifica el estado del clúster**. Asegúrate de que todos los nodos | ||
estén funcionando correctamente mediante `nodetool` (quizá tarde un | ||
poco). | ||
3. **Acceso a Cassandra**. Conéctate al clúster de Cassandra usando | ||
`cqlsh` a través del primer nodo. | ||
|
||
## 2. Creación de un Keyspace y Tablas | ||
|
||
1. **Creación de un _keyspace_**: Crea un keyspace llamado `bbdd2` con | ||
la estrategia de replicación `SimpleStrategy` y un factor de | ||
replicación de 3. | ||
2. **Uso del _keyspace_**: Cambia al keyspace universidad para que todas | ||
las operaciones posteriores se realicen en este keyspace. | ||
3. **Creación de una tabla**: Crea una tabla `estudiantes` con campos | ||
para el `id` del estudiante, `nombre`, `edad` y `carrera`. | ||
|
||
## 3: Inserción y consulta de datos | ||
|
||
1. **Carga de datos**: Carga los datos relativos a los estudiantes en la | ||
tabla `estudiantes`. | ||
2. **Consulta de datos**: Realiza una consulta para verificar que la | ||
inserción se realizó correctamente. | ||
|
||
## 4: Actualización y borrado de datos | ||
|
||
1. **Actualización de datos**: Actualiza la edad de un estudiante. | ||
2. **Borrado de datos**: Elimina un registro de estudiante. | ||
|
||
## 5: Limpieza y finalización | ||
|
||
1. **Borrado de la tabla**. Elimina la tabla `estudiantes`. | ||
2. **Borrado del _keyspace_**. Elimina el keyspace `bbdd2`. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import argparse | ||
import csv | ||
import random | ||
|
||
from faker import Faker | ||
|
||
|
||
fake = Faker(['es_ES', 'en_US', 'it_IT']) | ||
carreras = [ | ||
'Psicología Canina', | ||
'Artes del Café', | ||
'Turismo Espacial', | ||
'Biología Marina', | ||
'Cocina Molecular', | ||
'Diseño de Moda Intergaláctica', | ||
'Historia del Universo Paralelo', | ||
'Música para Plantas', | ||
'Filosofía Cuántica', | ||
'Teoría Práctica' | ||
] | ||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(description='Students generator') | ||
parser.add_argument('n', type=int, help='How many students') | ||
parser.add_argument('output', type=str, help='Output file path') | ||
args = parser.parse_args() | ||
|
||
with open(args.output, 'w', newline='', encoding='utf-8') as f: | ||
writer = csv.writer(f) | ||
writer.writerow(['id', 'nombre', 'edad', 'carrera']) | ||
|
||
for identifier in range(args.n): | ||
nombre = fake.name() | ||
edad = fake.random_int(min=18, max=30) | ||
carrera = random.choice(carreras) | ||
writer.writerow([identifier, nombre, edad, carrera]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[tool.poetry] | ||
name = "student-generator" | ||
version = "0.1.0" | ||
description = "" | ||
authors = ["blazaid <[email protected]>"] | ||
readme = "README.md" | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.10" | ||
faker = "^23.2.1" | ||
|
||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
Empty file.
Oops, something went wrong.