CentOS7下安装搭建Cacti

1.搭建lamp环境

配置apache

[root@cacti-server ~]# yum -y install httpd

[root@cacti-server ~]# systemctl start httpd

[root@cacti-server ~]# systemctl enable httpd

[root@cacti-server ~]# firewall-cmd --permanent --add-service=http

success

[root@cacti-server ~]# firewall-cmd --reload

success

配置mariadb

[root@cacti-server ~]# yum -y install mariadb-server mysql-devel

[root@cacti-server ~]# systemctl start mariadb

[root@cacti-server ~]# mysql_secure_installation

Set root password? [Y/n]

Remove anonymous users? [Y/n] y

Disallow root login remotely? [Y/n] y

Remove test database and access to it? [Y/n] y

Reload privilege tables now? [Y/n] y

[root@cacti-server ~]# mysql -u root -p

MariaDB [(none)]> grant all privileges on *.* to test@localhost identified by 'RedHat'; 创建用于测试php和mariadb连通性的用户

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;

[root@cacti-server ~]# systemctl restart mariadb

[root@cacti-server ~]# systemctl enable mariadb

[root@cacti-server ~]# firewall-cmd --permanent --add-port=3306/tcp

success

[root@cacti-server ~]# firewall-cmd --reload

success

[server]
character_set_server = utf8mb4
collation-server = utf8mb4_unicode_ci

back_log = 500
max_connections = 1500 max_connect_errors = 100000 table_open_cache = 5000 max_allowed_packet = 16M binlog_cache_size = 1M max_heap_table_size = 832M sort_buffer_size = 8M join_buffer_size = 64M thread_cache_size = 100 query_cache_size = 64M query_cache_limit = 2M ft_min_word_len = 4 thread_stack = 192K tmp_table_size = 64M innodb_large_prefix = ON transaction_isolation = REPEATABLE-READ innodb_doublewrite = OFF innodb_buffer_pool_size = 8G innodb_flush_method = O_DIRECT innodb_file_per_table innodb_thread_concurrency = 16 innodb_flush_log_at_trx_commit = 1 innodb_log_buffer_size = 8M innodb_log_file_size = 256M innodb_log_files_in_group = 2 innodb_max_dirty_pages_pct = 90 innodb_lock_wait_timeout = 120 innodb_flush_log_at_timeout = 3 innodb_io_capacity = 1500 innodb_read_io_threads = 32 innodb_write_io_threads = 16 innodb_additional_mem_pool_size = 80M

配置php

[root@cacti-server ~]# yum install phpspine.conf.dist-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-snmp php-ldap php-fpm

[root@cacti-server ~]# vim /etc/php.ini 

date.timezone =PRC      修改时区

[root@cacti-server ~]# vim /var/www/html/index.php    编辑测试页面

    $conn=mysql_connect('localhost','test','redhat');

    if ($conn)

      echo "database connect ok";

    else

      echo "database connect failure";

?>

    phpinfo()

?>

[root@cacti-server ~]# systemctl restart httpd

测试

2.安装配置cacti

下载软件

[root@cacti-server ~]# cd /usr/local/src/

[root@cacti-server src]# wget http://www.cacti.net/downloads/cacti-0.8.8f.tar.gz

[root@cacti-server src]# tar zxvf cacti-0.8.8f.tar.gz

[root@cacti-server src]# mv cacti-0.8.8f /var/www/html/cacti

创建cacti数据库和cacti用户,赋予权限

[root@cacti-server ~]# mysql -u root -p

MariaDB [(none)]> create database cacti default character set utf8;

MariaDB [(none)]> grant all privileges on cacti.* to cacti@localhost identified by 'redhat';

MariaDB [(none)]> flush privileges;

把cacti.sql导入数据库

[root@cacti-server cacti]# mysql -ucacti -predhat cacti < /var/www/html/cacti/cacti.sql

编辑config.php和global.php

[root@cacti-server cacti]# vim /var/www/html/cacti/include/config.php|global.php

$database_type = "mysql";

$database_default = "cacti";

$database_hostname = "localhost";

$database_username = "cacti";

$database_password = "redhat";

$database_port = "3306";

$database_ssl = false;

安装rrdtool以生成图像

[root@cacti-server src]# yum -y install rrdtool rrdtool-devel rrdtool-php rrdtool-perl

[root@cacti-server src]# yum -y install gd gd-devel php-gd    ---rrdtool绘制图像需要的图形库

安装snmp服务

[root@cacti-server cacti]# yum -y install net-snmp net-snmp-utils php-snmp net-snmp-libs

编辑配置文件

[root@cacti-server ~]# vim /etc/snmp/snmpd.conf

41  com2sec notConfigUser  127.0.0.1      public

62  access  notConfigGroup ""  any    noauth    exact  all none none

85  view all    included  .1          80

[root@cacti-server ~]# systemctl restart snmpd.service

[root@cacti-server ~]# systemctl enable snmpd.service

授权目录权限

[root@cacti-server ~]# useradd -r -M cacti

[root@cacti-server ~]# chown -R cacti /var/www/html/cacti/rra/

[root@cacti-server ~]# chown -R cacti /var/www/html/cacti/log/

配置一个抓图的计划任务

[root@cacti-server ~]# crontab -e

*/5 * * * * /usr/bin/php  /var/www/html/cacti/poller.php >> /tmp/cacti_rrdtool.log

浏览器访问cacti管理页面进行安装

 

报错

MySQL TimeZone Support ERROR: Your Cacti database login account does not have access to the MySQL TimeZone database. Please provide the Cacti database account "select" access to the "time_zone_name" table in the "mysql" database, and populate MySQL's TimeZone information before proceeding

 

**bash环境下执行 mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

mysql环境下

mysql> use mysql;

mysql> GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost;

mysql> flush privileges;**

 xampp环境下

   ln -s opt/lampp/var/mysql/mysql.sock /var/lib/mysql/

  mysql_tzinfo_to_sql /usr/share/zoneinfo | /opt/lampp/bin/mysql -uroot -p mysql

转载于:https://www.cnblogs.com/chenmx/p/7786820.html

你可能感兴趣的:(CentOS7下安装搭建Cacti)