background
The original intention of writing this article, is that online articles are numerous, but the same pattern, but also for some of the existing pit was not involved. Strictly in accordance with the online tutorial, then there may be a question of how the various components do not know associated; while this paper telegraf data collection and assembly services of multi-node are summarized ensure that post-deployment according to the article, it is a practical and useful monitoring system.
operating
telegraf deployment
Download: wget https://dl.influxdata.com/telegraf/releases/telegraf-1.8.3_linux_amd64.tar.gz
unpack: tar -zxvf telegraf-1.8.3_linux_amd64.tar.gz
generate a configuration file: telegraf --input-filter cpu: mem: disk: diskio: net --output-filter influxdb: opentsdb config> ../../etc/telegraf/telegraf.d/telegraf.conf
start: ./ usr / bin / telegraf --config [ configuration file path]
(now you can not start the first, component services of the time, you can directly start the service)
influxdb deployment
Download: https: //dl.influxdata.com/influxdb/releases/influxdb-0.13.0_linux_amd64.tar.gz
unpack: tar -zxvf influxdb-0.13.0_linux_amd64.tar.gz
start: ./ usr / bin / influxd RUN
( now you can not start the first, component services of the time, you can directly start the service)
grafana deployment
https://dl.grafana.com/oss/release/grafana-6.4.4.linux-amd64.tar.gz
decompression: tar -zxvf grafana-6.4.4.linux-amd64.tar.gz
start: ./ grafana -server
(now you can not start the first, component services of the time, you can directly start the service)
Component Services of
Now before and after the above operation is completed deployment decompression, etc., into the topic, trying to make all the components of the service process.
Note: This service component operations in Ubuntu 16.04 operating environment, and other linux distributions do not ensure the feasibility of the operation.
The basic idea is: start shell script activated by the method of the above package assembly, stop and restart method of stopping a method (method corresponding to a different service) is restarted, the control script assembly into the / usr / sbin directory (directory theoretically Other you can, as long as the service description file to define the right path, not try, interested students can go under operation); defined the components of the service description file, specify the path control script
Write startup scripts
Our aim is to facilitate scripting commands to perform direct transfer of the components start to end, reboot and other operations, the following script telegraf to serve as an example on how to create a startup script, the script reads as follows
. 1 #! / Bin / the bash 2 # represents the PROG their deployed corresponding to the process name . 3 the PROG = " Telegraf " . 4 paths of the two transducers PATh process set following its own file # . 5 PROG_PATH = " ./telegraf/usr/bin / " . 6 PROG_CONF_PATH = " ./telegraf/etc/telegraf/telegraf.d/telegraf.conf " . 7 PROG_ARGS = " " . 8 PID_PATH = " / var / RUN / " . 9 Start () 10 { . 11 echo " Start the PROG $ " 12 IF [-e " $ PID_PATH / $ PROG.pid" ]; then 13 ## Program is running, exit with error. 14 echo "Error! $PROG is currently running!" 1>&2 15 exit 1 16 else 17 cd $PROG_PATH 18 nohup ./$PROG --config $PROG_CONF_PATH & 19 if [ $? -ne 0 ];then 20 echo "Error! $PROG run failed, please try again!" 21 else 22 pid=`ps ax | grep -i "$PROG" | grep -v grep | awk '{print $2}'` 23 echo "start $PROG ok!" 24 echo $pid > "$PID_PATH/$PROG.pid" 25 exit 0; 26 fi 27 fi 28 } 29 30 stop() 31 { 32 echo "stop $PROG" 33 if [ -e "$PID_PATH/$PROG.pid" ]; then 34 pid=`ps ax | grep -i "$PROG" | grep -v grep | awk '{print $2}'` 35 kill $pid 36 rm -f "$PID_PATH/$PROG.pid" 37 echo "stop $PROG ok!" 38 else 39 echo "Error! $PROG not started!" 1>&2 40 exit 1 41 fi 42 } 43 44 ## Check to see if we are running as root first. 45 ## Found at http://www.cyberciti.biz/tips/shell-root-user-check-script.html 46 if [ "$(id -u)" != "0" ]; then 47 echo "This script must be run as root" 1>&2 48 exit 1 49 fi 50 51 case "$1" in 52 start) 53 start 54 ;; 55 stop) 56 stop 57 ;; 58 restart) 59 stop 60 start 61 ;; 62 *) 63 echo "usage: $0 start|stop|restart" 64 exit 0 65 esac 66 exit
Add Service
Influxd below to create a new service, for example, describes the procedure to add the service. Enter the service description file directory
cd /lib/systemd/system
Create a service description file
vim influxd.service
Wherein the service description file content below
1 [Unit] 2 Description=influxd 3 After=syslog.target network.target remote-fs.target nss-lookup.target 4 5 [Service] 6 Type=forking 7 ExecStart=/usr/sbin/influxd start 8 ExecStop=/usr/sbin/influxd stop 9 PrivateTmp=true 10 11 [Install] 12 WantedBy=multi-user.target
The above script, Description is a description of information services, After express service depends on what services, ExecStart express command service open, ExecStop represents the command to stop the service, according to the above modification can start scripting earlier.
Note: * .service add or modify files, execute commands systemctl daemon-reload reloaded service profile
After the service creation, order execution service influxd start, service telegraf start, service grafana start command to start the service.
Wherein the web page is accessed influx database is *: 8083, grafana access the web pages to *: 3000
Telegraf multi-node deployment
Create a database user
New database user operation performed: (8083 *), the command is the command line or in influxd web page database
CREATE USER "username" WITH PASSWORD 'password' WITH ALL PRIVILEGES
Modify the configuration telegraf
Login deployment of nodes telegraf, modify the configuration file as follows telegraf
summary
Overall, the above set up a monitoring system is a relatively easy task, but may be some problems on the details, will affect the ease of operation; the next lesson, I will explain how to modify some configuration files, so monitor the normal data display panel