forked from antzucaro/XonStat
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathinstall-instructions-debian8.txt
More file actions
128 lines (106 loc) · 3.99 KB
/
install-instructions-debian8.txt
File metadata and controls
128 lines (106 loc) · 3.99 KB
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
Only works with Ubuntu <=22.04.5 due to dependencies on Python 2.7 and Node.js <=12.22.9
- use new/updated installer: yes
- install OpenSSH server: yes
##########################################
#as user with sudo permissions
#apt-get install sudo
sudo apt-get update
sudo apt-get upgrade
# sudo apt-get install git
sudo apt-get -y install net-tools #for ifconfig and others
#- postgresql database engine for the website (binary db-backup files only compatible with 9.4)
sudo apt-get -y install postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
sudo apt-get -y install postgresql-9.4
sudo systemctrl start postgresql
#- database performance analysis tools (optional)
# see https://pganalyze.com/docs/install/01_enabling_pg_stat_statements
# sudo apt-get -y install postgresql-contrib-9.4 # for extensions like pg_stat_statements
# sudo apt-get -y install curl
#- nodejs for feeder
sudo apt-get -y install nodejs
sudo apt-get -y install npm
sudo apt-get -y install libzmq3-dev
#- python2.7 for main website
sudo apt-get -y install python2.7
sudo ln -s /usr/bin/python2.7 /usr/bin/python
sudo apt-get -y install python-pip
sudo ln -s /usr/bin/pip2 /usr/bin/pip
sudo apt-get -y install python2-dev
sudo apt-get -y install postgresql-server-dev-9.4 # 9.4 on wily, 9.3 on trusty, ... use "apt-cache policy postgresql" to find the right version
sudo python -m pip install pastescript
#- nginx as a reverse proxy for the sites (optional)
sudo apt-get -y install nginx
sudo systemctl enable nginx
#- letsencrypt SSL certificates (optional)
sudo apt-get -y install letsencrypt
#sudo apt-get -y install certbot
sudo apt-get -y install python3-certbot-nginx
sudo certbot --nginx -d qlstats.net -d www.qlstats.net -d api.qlstats.net
##########################################
# as postgres user
sudo su - postgres
createuser -P xonstat #use "xonstat" as password for DB-user
echo "CREATE DATABASE xonstatdb WITH ENCODING='UTF8' OWNER=xonstat CONNECTION LIMIT=-1;" | psql
export PGPASSWORD=xonstat
echo "CREATE SCHEMA xonstat AUTHORIZATION xonstat;" | psql xonstatdb
#echo "CREATE LANGUAGE plpgsql;" | psql xonstatdb
exit
##########################################
# as xonstat user
sudo adduser xonstat
sudo su - xonstat
echo "export PYTHONPATH=/home/xonstat/xonstat/lib/python" >~/.profile
. ~/.profile
git clone https://github.com/PredatH0r/XonStat.git
mv XonStat xonstat
chmod +x xonstat/cronjobs/*.sh
ln -s xonstat/cronjobs/feeder.sh .
ln -s xonstat/cronjobs/paster.sh .
crontab -e
# add these 4 lines to your crontab:
@reboot ~/xonstat/cronjobs/paster.sh
@reboot ~/xonstat/cronjobs/feeder.sh
55 * * * * ~/xonstat/cronjobs/hourly_task.sh
0 12 * * * ~/xonstat/cronjobs/daily_task.sh
# -- end of crontab edit
cd ~/xonstat
mkdir lib
mkdir lib/python
export PYTHONPATH=/home/xonstat/xonstat/lib/python
python setup.py install --home=/home/xonstat/xonstat
cd ~/xonstat/feeder
npm install
npm audit fix
mkdir ql-match-jsons
mkdir ql-match-jsons/errors
# to simplify updates via git:
git config --global user.name "your-name-here"
git config --global user.email "your@email.here"
#--- to update:
#git stash
#git pull --rebase
#git stash pop
#---- option a) create a fresh database
# as xonstat user in ~xonstat
cd ~
git clone https://github.com/PredatH0r/xonstatdb.git
cd xonstatdb
psql xonstatdb <build/build_full.sql
psql xonstatdb <../xonstat/sql/qlstats-init.sql
#---- option b) restore a DB-backup
# copy a backup of /var/lib/postgresql/9.4/ folder to that location
chown -R postgres:postgres /var/lib/postgresql/9.4
##################################
# as xonstat user: test start of feeder and paster
# this will be done by cron and the ~/cronjobs/paster.sh and feeder.sh scripts
cd ~/xonstat/feeder
if [ ! -f cfg1.json ]; then cp cfg.json cfg1.json; fi
node feeder.node.js -c cfg1.json
cd ~/xonstat/xonstat
if [ ! -f qlstats.ini ]; then cp local.ini qlstats.ini; fi
paster serve qlstats.ini
#####################
# block offending IPs
apt-get install -y iptables-persistent
iptables -A INPUT -s 47.79.192.0/18 -j DROP # Alibaba cloud