Skip to content

Commit fa98601

Browse files
authored
Merge pull request #11 from cdivita/replication-and-logging
Replication and logging
2 parents 6d00de4 + 6d392f0 commit fa98601

File tree

4 files changed

+75
-1
lines changed

4 files changed

+75
-1
lines changed

dynamic_group.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
resource "random_id" "dynamic_group" {
2+
byte_length = 2
3+
}
4+
5+
resource "oci_identity_dynamic_group" "redis_dynamic_group" {
6+
7+
provider = oci.homeregion
8+
9+
compartment_id = var.tenancy_ocid
10+
11+
name = "redis-cluster-dynamic-group-${random_id.dynamic_group.hex}"
12+
description = "Dynamic group of Redis cluster Compute instances"
13+
14+
matching_rule = "tag.${oci_identity_tag_namespace.ArchitectureCenterTagNamespace.name}.${oci_identity_tag.ArchitectureCenterTag.name}.value = '${var.release}'"
15+
}

redis_logging.tf

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
resource "oci_logging_log_group" "redis_log_group" {
2+
3+
compartment_id = var.compartment_ocid
4+
display_name = "Redis Log Group"
5+
}
6+
7+
resource "oci_logging_log" "redis_log" {
8+
9+
display_name = "Redis Logs"
10+
11+
is_enabled = true
12+
log_group_id = oci_logging_log_group.redis_log_group.id
13+
log_type = "CUSTOM"
14+
retention_duration = "30"
15+
}
16+
17+
resource "oci_logging_unified_agent_configuration" "redis_log_agent_config" {
18+
19+
compartment_id = var.compartment_ocid
20+
21+
description = "Log Agent configuration for Redis nodes"
22+
display_name = "redis-log-agent-config"
23+
24+
group_association {
25+
group_list = [
26+
oci_identity_dynamic_group.redis_dynamic_group.id
27+
]
28+
}
29+
30+
is_enabled = true
31+
32+
service_configuration {
33+
34+
configuration_type = "LOGGING"
35+
36+
destination {
37+
log_object_id = oci_logging_log.redis_log.id
38+
}
39+
40+
sources {
41+
42+
name = "redis_server"
43+
44+
parser {
45+
46+
parser_type = "REGEXP"
47+
expression = "^(?<pid>\\d+):(?<role>[XCSM]) (?<time>[^\\]]*) (?<level>[\\.\\-\\*\\#]) (?<message>.+)$"
48+
time_format = "%d %B %Y %H:%M:%S.%L"
49+
}
50+
51+
paths = [
52+
"/tmp/redis-server.log"
53+
]
54+
55+
source_type = "LOG_TAIL"
56+
}
57+
}
58+
}

scripts/redis_bootstrap_master.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ cluster-node-timeout 5000
3131
cluster-slave-validity-factor 0
3232
appendonly yes
3333
requirepass ${redis_password}
34+
masterauth ${redis_password}
3435
EOF
3536

3637
# Configure Sentinel

scripts/redis_bootstrap_replica.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ cluster-node-timeout 5000
3232
cluster-slave-validity-factor 0
3333
appendonly yes
3434
requirepass ${redis_password}
35+
masterauth ${redis_password}
3536
EOF
3637

37-
3838
sleep 30
3939
#/usr/local/bin/redis-server $REDIS_CONFIG_FILE --daemonize yes
4040
#nohup /usr/local/bin/redis-server $REDIS_CONFIG_FILE > /tmp/redis-server.log &

0 commit comments

Comments
 (0)