31
31
DEBIAN_FRONTEND=noninteractive dpkg -i /tmp/cassandra_0.8.3_all.deb
33
33
HOSTNAME=`hostname -f`
35
36
DEFAULT_JMX_PORT=7199
36
37
DEFAULT_CLUSTER_PORT=7000
37
38
DEFAULT_CLIENT_PORT=9160
39
DEFAULT_CLUSTER_NAME="Test Cluster"
39
41
# Open the necessary ports
40
42
if [ -x /usr/bin/open-port ]; then
46
48
# Persist the data for future use
47
49
fact-add cassandra_hostname ${HOSTNAME}
50
fact-add cassandra_ip ${IP}
48
51
fact-add cassandra_default_jmx_port ${DEFAULT_JMX_PORT}
49
52
fact-add cassandra_default_cluster_port ${DEFAULT_CLUSTER_PORT}
50
53
fact-add cassandra_default_client_port ${DEFAULT_CLIENT_PORT}
54
fact-add cassandra_default_cluster_name ${DEFAULT_CLUSTER_NAME}
52
56
# Update the cassandra environment with the appropriate JMX port
53
mv /etc/cassandra/cassandra-env.sh /etc/cassandra/cassandra-env.sh.orig
54
sed -e s#__jmx_port__#${DEFAULT_JMX_PORT}# ${CWD}/../templates/cassandra_env_sh.tmpl > /etc/cassandra/cassandra-env.sh
55
chown root:root /etc/cassandra/cassandra-env.sh
56
chmod 644 /etc/cassandra/cassandra-env.sh
57
sed -i -e "s/^JMX_PORT=.*/JMX_PORT=\"${DEFAULT_JMX_PORT}\"/" /etc/cassandra/cassandra-env.sh
58
59
# Construct the cassandra.yaml file from the appropriate information above
59
mv /etc/cassandra/cassandra.yaml /etc/cassandra/cassandra.yaml.orig
60
cat ${CWD}/../templates/cassandra_yaml_top.tmpl > /etc/cassandra/cassandra.yaml
61
sed -e s#__hostname__#${HOSTNAME}# ${CWD}/../templates/cassandra_yaml_seeds.tmpl >> /etc/cassandra/cassandra.yaml
62
sed -e s#__cluster_port__#${DEFAULT_CLUSTER_PORT}# \
63
-e s#__hostname__#${HOSTNAME}# \
64
-e s#__client_port__#${DEFAULT_CLIENT_PORT}# \
65
${CWD}/../templates/cassandra_yaml_bottom.tmpl >> /etc/cassandra/cassandra.yaml
67
chown root:root /etc/cassandra/cassandra.yaml
68
chmod 644 /etc/cassandra/cassandra.yaml
60
sed -i -e "s/^cluster_name:.*/cluster_name: \'${DEFAULT_CLUSTER_NAME}\'/" \
61
-e "s/\- seeds:.*/\- seeds: \"${IP}\"/" \
62
-e "s/^storage_port:.*/storage_port: ${DEFAULT_CLUSTER_PORT}/" \
63
-e "s/^listen_address:.*/listen_address: ${IP}/" \
64
-e "s/^rpc_address:.*/rpc_address: ${IP}/" \
65
-e "s/^rpc_port:.*/rpc_port: ${DEFAULT_CLIENT_PORT}/" \
66
/etc/cassandra/cassandra.yaml
70
68
service cassandra status && service cassandra restart || service cassandra start