grafana依赖mysql存储数据,首先需要安装mysql
安装mysql
解压
# groupadd mysql # useradd -s /sbin/nologin -g mysql mysql # tar xf mysql-5.6.14.tar.gz -C /usr/local/src/
编译参数
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/app/mysql-5.6.14 -DMYSQL_DATADIR=/data/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_USER=mysql -DWITH_DEBUG=0
编译
# make –j 8 # make install # mkdir /data/mysql
初始化
# cp support-files/mysql.server /etc/init.d/mysqld # chmod +x /etc/init.d/mysqld # chkconfig --add mysqld
启动脚本
# chown -R root.mysql /usr/local/mysql # chown -R mysql.mysql /data/mysql # yum install wget ncurses-devel #./scripts/mysql_install_db --user=mysql --basedir=/usr/local/app/mysql-5.6.14 --datadir=/data/mysql
PATH、头文件、库文件及man帮助文档配置
# echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile # echo "/usr/local/mysql/lib/" >> /etc/ld.so.conf # ln -sv /usr/local/mysql/include/ /usr/include/mysql # echo "MANPATH /usr/local/mysql/man" >> /etc/man.config
设置密码
# mysqladmin -uroot password '81-ES-BJVM'
安全设置
mysql> drop database test; mysql> drop user ''@'BJVM-ES-81'; mysql> drop user ''@'localhost'; mysql> drop user 'root'@'::1'; mysql> drop user ''@'BJVM-ES-81';
安装grafana
[root@elk ~]# tar xf grafana-3.1.1-1470047149.linux-x64.tar.gz [root@elk ~]# tar xf grafana-3.1.1-1470047149.linux-x64.tar.gz -C /usr/local/app/ [root@elk ~]# ln -sv /usr/local/app/grafana-3.1.1-1470047149 /usr/local/grafana [root@elk ~]# cd /usr/local/grafana
修改配置文件custom.ini
# cp conf/defaults.ini conf/custom.ini
data = /data/grafana/data logs =/data/grafana/log plugins = /data/grafana/plugins http_addr = 10.80.2.156 type = mysql host = 10.80.2.81:3306 name = grafana user = grafana password =
授权
# mkdir –pv /data/grafana/{data,log,plugins}
# mysql> create database grafana;
# mysql> grant all privileges on grafana.* to grafana@’10.80.2.81’ identified by “”;