-
Notifications
You must be signed in to change notification settings - Fork 6
/
cassandra_node_config_pretune_compaction
executable file
·62 lines (52 loc) · 1.75 KB
/
cassandra_node_config_pretune_compaction
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
cassandra_conf_dir=/etc/dse/cassandra
date=$(date +%F)
cassandraenv_backup="cassandra-env.sh.$date"
cassandrayaml_backup="cassandra.yaml.$date"
cd "$cassandra_conf_dir"
#
# Create backup files if they don't exist
#
if [ ! -f "$cassandraenv_backup" ] ; then
( set -x
cp cassandra-env.sh "$cassandraenv_backup"
chown cassandra:cassandra "$cassandraenv_backup"
)
fi
if [ ! -f "$cassandrayaml_backup" ] ; then
( set -x
cp cassandra.yaml "$cassandrayaml_backup"
chown cassandra:cassandra "$cassandrayaml_backup"
)
fi
#
# Generate cassandra-env.sh.new
#
MAX_HEAP_SIZE="50G"
HEAP_NEWSIZE="8G"
# Change values and uncomment if needed
cat cassandra-env.sh \
| sed -e "s:^[#]*\(MAX_HEAP_SIZE\=\).*:MAX_HEAP_SIZE\=\"$MAX_HEAP_SIZE\":" \
| sed -e "s:^[#]*\(HEAP_NEWSIZE\=\).*:HEAP_NEWSIZE\=\"$HEAP_NEWSIZE\":" \
> cassandra-env.sh.new
(set -x; chown cassandra:cassandra cassandra-env.sh.new)
(set -x; diff cassandra-env.sh cassandra-env.sh.new)
#
# Generate cassandra-env.sh.new
#
concurrent_reads=128
concurrent_writes=256
memtable_flush_writers=24
concurrent_compactors=10
compaction_throughput_mb_per_sec=0
cat cassandra.yaml \
| sed -e "s:.*\(concurrent_reads\:\).*:concurrent_reads\: $concurrent_reads:" \
| sed -e "s:.*\(concurrent_writes\:\).*:concurrent_writes\: $concurrent_writes:" \
| sed -e "s:.*\(memtable_flush_writers\:\).*:memtable_flush_writers\: $memtable_flush_writers:" \
| sed -e "s:.*\(concurrent_compactors\:\).*:concurrent_compactors\: $concurrent_compactors:" \
| sed -e "s:.*\(compaction_throughput_mb_per_sec\:\).*:compaction_throughput_mb_per_sec\: $compaction_throughput_mb_per_sec:" \
> cassandra.yaml.new
(set -x; chown cassandra:cassandra cassandra.yaml.new)
(set -x; diff cassandra.yaml cassandra.yaml.new)
cat <</EOF >/dev/null
/EOF