-
Notifications
You must be signed in to change notification settings - Fork 112
/
database-start.sh
27 lines (25 loc) · 1.17 KB
/
database-start.sh
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
#!/bin/sh
REFACT_CASSANDRA_DIR="$REFACT_PERM_DIR/cassandra"
if [ ! -d "$REFACT_CASSANDRA_DIR" ]; then
mkdir -p "$REFACT_CASSANDRA_DIR"
chown cassandra:cassandra "$REFACT_CASSANDRA_DIR"
if [ ! -z "$(ls /var/lib/cassandra)" ]; then
cp -rp /var/lib/cassandra/* "$REFACT_CASSANDRA_DIR"
fi
cp -rp /var/log/cassandra "$REFACT_CASSANDRA_DIR/log"
fi
# patch cassandra config to work with REFACT_CASSANDRA_DIR
sed -i "s|/var/lib/cassandra|$REFACT_CASSANDRA_DIR|g" /etc/cassandra/cassandra.yaml
# patch cassandra.in.sh for less memory consumption and logging to REFACT_CASSANDRA_DIR/log
REFACT_CASSANDRA_INCLUDE=/usr/sbin/cassandra.in.sh
cp /usr/share/cassandra/cassandra.in.sh "$REFACT_CASSANDRA_INCLUDE"
echo "MAX_HEAP_SIZE=2G" >> "$REFACT_CASSANDRA_INCLUDE"
echo "HEAP_NEWSIZE=400M" >> "$REFACT_CASSANDRA_INCLUDE"
echo "CASSANDRA_LOG_DIR=$REFACT_CASSANDRA_DIR/log" >> "$REFACT_CASSANDRA_INCLUDE"
if [ ! -z "$(service cassandra status | grep 'could not access pidfile')" ]; then
rm /var/run/cassandra/cassandra.pid
fi
if [ ! -z "$(service cassandra status | grep 'not running')" ]; then
service cassandra start
echo "cassandra database started on localhost"
fi