cacti-0.8.7i使用percona-monitoring-plugins监控mysql等

注意文中RemoteServerIP,cactiserverIP,remoteIP等替换为自己的IP

 

1.MySQL主机添加监控账号,建议所有被监控MySQL服务的主机设置统一的账号和密码
1.1   使用root登录到mysq的命令行
1.2   GRANT SUPER, PROCESS ON *.* TO 'cactiuser'@'cactiserverIP' IDENTIFIED BY "cactipassword";

1.3   flush privileges;
1.4   在cacti服务器上测试账号,mysql -h RemoteServerIP -e "SELECT VERSION()" -u cactiuser -pcactipassword     
     
2.ssh远程自动登录配置
2.1   在cacti服务器上生成ssh的key
      [root@cactiserver ~]# mkdir /etc/cactiuser
      [root@cactiserver ~]# ssh-keygen

      Generating public/private rsa key pair.
      Enter file in which to save the key (/root/.ssh/id_rsa): /etc/cactiuser/id_rsa
      Enter passphrase (empty for no passphrase):
      Enter same passphrase again:
      Your identification has been saved in /etc/cactiuser/id_rsa.
      Your public key has been saved in /etc/cactiuser/id_rsa.pub.
      The key fingerprint is:
      7c:34:8d:33:a0:1c:a0:43:cd:89:41:5e:81:66:2e:84 [email protected]
 

      [root@cactiserver ~]# cd /etc/cactiuser/
      [root@cactiserver cactiuser]# ls
      id_rsa  id_rsa.pub
      [root@cactiserver cactiuser]# chown -R cactiuser id_rsa
      [root@cactiserver cactiuser]# chown -R cactiuser id_rsa.pub
      [root@cactiserver cactiuser]# chown -R cactiuser:cactiuser id_rsa.pub
      [root@cactiserver cactiuser]# chown -R cactiuser:cactiuser id_rsa
      [root@cactiserver cactiuser]# chmod -R 0400 /etc/cactiuser/id_rsa
     
2.2   在被监控的主机上增加用户cactiuser
      [root@remoteServer ~]# cd /home
      [root@remoteServer home]# groupadd cactiuser
      [root@remoteServer home]# useradd cactiuser -g cactiuser
      [root@remoteServer home]# cd /home/cactiuser/
      [root@remoteServer cactiuser]# mkdir .ssh
     
2.3   用SCP把cacti服务器上cactiuser的公共key复制到被监控的主机
      [root@remoteServer cactiuser]# scp id_rsa.pub root@remoteIP:/home/cactiuser/.ssh/
     
2.4   被监控主机配置

      [root@remoteServer ~]# cd /home/cactiuser/.ssh/
      [root@remoteServer .ssh]# mv id_rsa.pub authorized_keys

      [root@remoteServer .ssh]# cd /home/cactiuser

      [root@remoteServer cactiuser]# chown -R cactiuser:cactiuser .ssh
     
2.5   在cacti服务器上测试
      ssh -i /etc/cactiuser/id_rsa cactiuser@remoteIP echo "it works"
     
3.配置文件修改

3.1   把percona-monitoring-plugins-0.9.0\cacti\scripts下ss_get_by_ssh.php和ss_get_mysql_stats.php复制到cacti的scripts文件夹下
3.2   vi ss_get_by_ssh.php
      $ssh_user   = 'cactiuser';                      # SSH username
      $ssh_port   = 22;                               # SSH port
      $ssh_iden   = '-i /etc/cactiuser/id_rsa';       # SSH identity
3.3   $mysql_user = 'cactiuser';
      $mysql_pass = 'cactipassword';
      $mysql_port = 3306;
3.4  测试 

 su -cactiuser -c 'php /usr/local/apache/htdocs/cacti/scripts/ss_get_by_ssh.php --type memory --host RemoteIP --items gu,gv'
gu:611717120 gv:841474048
 

 

 


4.导入模板,新建图像

 

5.图像截图


cacti-0.8.7i使用percona-monitoring-plugins监控mysql等_第1张图片

 

参考链接:

http://www.percona.com/doc/percona-monitoring-plugins/cacti/mysql-templates.html

http://www.percona.com/doc/percona-monitoring-plugins/cacti/ssh-based-templates.html

你可能感兴趣的:(linux,mysql,ssh,cacti,keygen)