##序 默认grafana使用sqlite3进行相关配置存储,使用本地文件进行session存储,不太方便进行分布式扩展,这里改为mysql。
##修改配置文件
[database]; Either "mysql", "postgres" or "sqlite3", it's your choicetype = mysqlhost = 192.168.99.100:3306name = grafanauser = rootpassword = root[session]provider = mysqlprovider_config = root:root@tcp(192.168.99.100:3306)/grafanacookie_name = grafana_sessioncookie_secure = falsesession_life_time = 86400
##配置mysql
docker run --name grafana-mysql -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 -d mysql:5.6.35CREATE DATABASE IF NOT EXISTS grafana default charset utf8 COLLATE utf8_general_ci;CREATE TABLE `session` ( `key` CHAR(16) NOT NULL, `data` BLOB, `expiry` INT(11) UNSIGNED NOT NULL, PRIMARY KEY (`key`)) ENGINE=MyISAM DEFAULT CHARSET=utf8;
##运行 查看表结构:
mysql> use grafana;Query OK, 0 rows affected (0.00 sec)mysql> show tables;+--------------------+| Tables_in_grafana |+--------------------+| alert || alert_notification || annotation || api_key || dashboard || dashboard_snapshot || dashboard_tag || data_source || migration_log || org || org_user || playlist || playlist_item || plugin_setting || preferences || quota || session || star || temp_user || user |+--------------------+20 rows in set (0.01 sec)
代表切换成功。
##doc