InfluxDB: Bash script to launch and configure two nodes

I’ve just created a quick bash script because I”m working a little with InfluxDB at the moment. InfluxDB is a time series database written in GO.

The script will setup two influxdb nodes, setup some users and download and load some sample data. It’s developed on a Mac but should work in Linux (not tested yet but let me know if there’s any problem). I do plan further work on this, for example adding in InfluxDB-Relay. The script is available at my github.

Usage is as follows…

Source the script in the shell

. influxdb_setup.sh

This makes the following functions available…

influx_kill                influx_run_q
influx_admin_user          influx_launch_nodes        influx_setup_cluster
influx_config1             influx_mkdir               influx_stress
influx_config2             influx_murder              influx_test_db_user_perms
influx_count_processes     influx_noaa_db_user_perms  influx_test_db_users
influx_create_test_db      influx_noaa_db_users       
influx_curl_sample_data    influx_node1               
influx_http_auth           influx_node2               
influx_import_file         influx_remove_dir

You don’t need to know in detail what most of these do. To setup two nodes just do…

influx_setup_cluster

If all goes well you should see a message like below…

Restarted influx nodes. Logon to node1 with influx -port 8086 -username admin -password $(cat "${HOME}/rhys_influxdb/admin_pwd.txt")

Logon to a node with…

influx -port 8086 -username admin -password $(cat "${HOME}/rhys_influxdb/admin_pwd.txt")

Execute “show databases”…

name
----
test
NOAA_water_database
_internal

Execute “show users”…

user	admin
----	-----
admin	true
test_ro	false
test_rw	false
noaa_ro	false
noaa_rw	false

N.B. Password for these users can be found in text files in $HOME/rhys_influxdb/

Start working with some data…

SELECT * FROM h2o_feet LIMIT 5
name: h2o_feet
time			level description	location	water_level
----			-----------------	--------	-----------
1439856000000000000	between 6 and 9 feet	coyote_creek	8.12
1439856000000000000	below 3 feet		santa_monica	2.064
1439856360000000000	between 6 and 9 feet	coyote_creek	8.005
1439856360000000000	below 3 feet		santa_monica	2.116
1439856720000000000	between 6 and 9 feet	coyote_creek	7.887

To clean everything up you can call…

influx_murder

Please notes this will kill all influxd processes and remove all data files.


Leave a Reply