This repository has been archived by the owner on Oct 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 100
/
install
executable file
·146 lines (121 loc) · 5.11 KB
/
install
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash -ex
# Graphite installation script for Ubuntu 18.04
# Jason Dixon <[email protected]>
SYNTHESIZE_HOME=$( cd "$( dirname "$0" )" && pwd )
UBUNTU_RELEASE=`lsb_release -a 2>/dev/null | grep '^Descrip' | cut -s -f 2`
GRAPHITE_HOME='/opt/graphite'
GRAPHITE_CONF="${GRAPHITE_HOME}/conf"
GRAPHITE_STORAGE="${GRAPHITE_HOME}/storage"
if [ -z $GRAPHITE_RELEASE ]; then
GRAPHITE_RELEASE='1.1.7'
fi
if [ -z $STATSITE_RELEASE ]; then
STATSITE_RELEASE='master'
fi
if [[ ! $UBUNTU_RELEASE =~ 'Ubuntu 18.04' ]]; then
echo "Sorry, this is only supported for Ubuntu Linux 18.04."
exit 1
fi
if [[ -d $GRAPHITE_HOME ]]; then
echo "Looks like you already have a Graphite installation in ${GRAPHITE_HOME}, aborting."
exit 1
fi
# Update apt since the vagrant image might be old
apt-get update -y
# Install package dependencies from apt
RUNLEVEL=1 apt-get install -y git wget curl netbase collectd memcached \
build-essential automake libtool libffi-dev libcairo2-dev libcairo2 libffi6 \
python3-dev python3-pip fontconfig apache2 libapache2-mod-wsgi-py3
# Download source repositories for Graphite/Carbon/Whisper and Statsite
cd /usr/local/src
git clone https://github.com/graphite-project/graphite-web.git
git clone https://github.com/graphite-project/carbon.git
git clone https://github.com/graphite-project/whisper.git
git clone https://github.com/armon/statsite.git
# Build and install Graphite/Carbon/Whisper and Statsite
mkdir -p /opt/graphite
cd whisper; \
git checkout ${GRAPHITE_RELEASE}; \
python3 setup.py install
cd ../carbon; \
git checkout ${GRAPHITE_RELEASE}; \
pip3 install -r requirements.txt; \
python3 setup.py install
cd ../graphite-web; \
pip3 install django==2.2.9; \
git checkout ${GRAPHITE_RELEASE}; \
pip3 install -r requirements.txt; \
python3 check-dependencies.py; \
python3 setup.py install
cd ../statsite; \
git checkout ${STATSITE_RELEASE}; \
./autogen.sh; \
./configure; make; \
cp statsite /usr/local/sbin/; \
cp sinks/graphite.py /usr/local/sbin/statsite-sink-graphite.py
# Update txamqp to support RabbitMQ 2.4+
# also install service_identity to remove TLS error
pip3 install txamqp service_identity --upgrade
# Install configuration files for Graphite/Carbon and Apache
cp ${SYNTHESIZE_HOME}/templates/statsite/statsite.conf /etc/statsite.conf
mkdir ${GRAPHITE_CONF}/examples
mv ${GRAPHITE_CONF}/*.example ${GRAPHITE_CONF}/examples/
cp ${SYNTHESIZE_HOME}/templates/graphite/conf/* ${GRAPHITE_CONF}/
cp ${SYNTHESIZE_HOME}/templates/collectd/collectd.conf /etc/collectd/
cp ${SYNTHESIZE_HOME}/templates/apache/graphite.conf /etc/apache2/sites-available/
# using systemd units instead of init and upstart files
cp ${SYNTHESIZE_HOME}/templates/systemd/* /etc/systemd/system/
# installing scripts for carbon-cache instances control script
cp ${SYNTHESIZE_HOME}/templates/scripts/* /usr/local/bin/
# Setup the correct Apache site and modules
a2dissite 000-default
a2ensite graphite
a2enmod ssl
a2enmod socache_shmcb
a2enmod rewrite
# Install configuration files for Django
cd ${GRAPHITE_HOME}/webapp/graphite
cp ${SYNTHESIZE_HOME}/templates/graphite/webapp/* .
sed -i -e "s/UNSAFE_DEFAULT/`date | md5sum | cut -d ' ' -f 1`/" local_settings.py
# Setup the Django database
PYTHONPATH=${GRAPHITE_HOME}/webapp django-admin.py migrate --noinput --settings=graphite.settings --run-syncdb
PYTHONPATH=${GRAPHITE_HOME}/webapp django-admin.py collectstatic --noinput --settings=graphite.settings
# Add carbon system user and set permissions
groupadd -g 998 carbon
useradd -c "carbon user" -g 998 -u 998 -s /bin/false carbon
chmod 775 ${GRAPHITE_STORAGE}
chown www-data:carbon ${GRAPHITE_STORAGE}
chown www-data:www-data ${GRAPHITE_STORAGE}/graphite.db
chown -R carbon ${GRAPHITE_STORAGE}/whisper
mkdir -p ${GRAPHITE_STORAGE}/log/carbon-cache/
chown -R carbon ${GRAPHITE_STORAGE}/log
mkdir ${GRAPHITE_STORAGE}/log/apache2
chown -R www-data ${GRAPHITE_STORAGE}/log/webapp
# Setup hourly systemd timer to rebuild Graphite index
cp ${SYNTHESIZE_HOME}/templates/scripts/graphite-build-index /usr/local/bin/graphite-build-index
systemctl daemon-reload
systemctl enable graphite-build-index.timer
systemctl start graphite-build-index.timer
systemctl start graphite-build-index
# Install Grafana
apt-get install -y apt-transport-https
apt-get install -y software-properties-common wget
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
apt-get install grafana
# Bootstrap Grafana datasources and dashboards
mkdir -p /etc/grafana/provisioning/datasources/
mkdir -p /etc/grafana/provisioning/dashboards/
cp ${SYNTHESIZE_HOME}/templates/grafana/provisioning/datasources/* /etc/grafana/provisioning/datasources/
cp ${SYNTHESIZE_HOME}/templates/grafana/provisioning/dashboards/* /etc/grafana/provisioning/dashboards/
systemctl restart grafana-server
# Enabling processes start
/usr/local/bin/carbon-cache enable
systemctl enable statsite
systemctl enable grafana-server
# Start our processes
/usr/local/bin/carbon-cache start
service memcached restart
service collectd restart
service apache2 restart
service statsite restart