一、cacti概述
1、安装软件 yum install -y httpd php php-mysql php-snmp php-xml php-ldap php-gd php-mbstring php-posix 2、设置时区 [root@localhost ~]# vim /etc/php.ini [PHP] …… date.timezone = Asia/Shanghai #878行 3、开机启动httpd systemctl start httpd && systemctl enable httpd 4、安装db cat >/etc/yum.repos.d/MariaDB.repo<<EOF [mariadb] name = MariaDB baseurl = http://yum./10.3/centos7-amd64 gpgkey=https://yum./RPM-GPG-KEY-MariaDB gpgcheck=1 EOF 4.2 安装DB yum install -y MariaDB-server MariaDB-client MariaDB-devel 4.3 启动db,并设置开机启动 systemctl start mariadb && systemctl enable mariadb 4.4 初始化数据库,设定密码,除了开始直接回车,其他的选择都输入Y。 [root@localhost ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! ...... Enter current password for root (enter for none): //初始数据库密码为空,直接按回车键 OK, successfully used password, moving on... ...... Set root password? [Y/n] Y //输入root管理员密码 New password: Re-enter new password: Password updated successfully! ...... Remove anonymous users? [Y/n] Y //删除匿名账号 ... Success! ...... Disallow root login remotely? [Y/n] Y //禁止root管理员从远程登录 ... Success! ....... Remove test database and access to it? [Y/n] Y //删除test数据库并取消对它的访问权限 ...... Reload privilege tables now? [Y/n] Y //刷新授权表,让初始化后的设定立即生效 ... Success! 4.5 配置MariaDB参数 [root@cacti ~]# vim /etc/my.cnf.d/server.cnf [server] # this is only for the mysqld standalone daemon character_set_server = utf8mb4 collation-server = utf8mb4_unicode_ci max_heap_table_size = 256M max_allowed_packet = 16777216 tmp_table_size = 64M join_buffer_size = 64M innodb_file_per_table = ON innodb_buffer_pool_size = 1024M innodb_doublewrite = OFF innodb_flush_log_at_timeout = 3 innodb_read_io_threads = 32 innodb_write_io_threads =16 innodb_file_format = Barracuda innodb_large_prefix = 1 5、安装snmp yum install –y net-snmp net-snmp-libs net-snmp-utils net-snmp-devel net-snmp-perl 5.1 配置snmp vim /etc/snmp/snmpd.conf ...... //修改default为本机(cacti服务器)的ip,修改public为自己的团体名(一般不改),42行 com2sec notConfigUser 192.168.95.234 public //把systemview改成all ,供所有snmp 访问权限 64行 access notConfigGroup "" any noauth exact all none none view all included .1 80 // 去掉#号 85行 ...... 5.2 启动snmp并设置开机启动 systemctl start snmpd.service && systemctl enable snmpd.service 5.3 验证snmp是否生效 snmpwalk -v 2c -c public localhost 6、安装RRDTool 绘图工具 yum -y install lm_sensors gcc gcc-c++ libart_lgpl-devel zlib-devel libpng-devel freetype-devel gettext-devel glib2-devel pcre-devel pango-devel cairo-devel libxml2-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker rrdtool 7、安装spine yum install -y dos2unix autoconf automake binutils libtool cpp glibc-headers glibc-devel help2man 7.2 下载cacti-spine-1.2.12,这里版本要与cacti相同, cd /usr/local/src wget https://www./downloads/spine/cacti-spine-1.2.12.tar.gz 7.3 编译安装cacti-spine tar zxvf cacti-spine-1.2.12.tar.gz cd cacti-spine-1.2.12 ./bootstrap ./configure make && make install chown root:root /usr/local/spine/bin/spine chmod +s /usr/local/spine/bin/spine ———————————————— 如果make时出现 /usr/bin/ld: cannot find -lmysqlclient collect2: ld returned 1 exit status make: *** [spine] Error 1 原因: 编译你的工程代码之前之前, 先处理一下mysql的库,默认查找libmysqlclient_r.so, 可是mysql默认为libmysqlclient.so, 内容完全一样,做个链接即可 请在root下执行 cd /usr/local/mysql/lib/mysql/ (库所在目录) ln -s libmysqlclient.so.15.0.0 libmysqlclient_r.so ———————————————— 7.4 编辑spine.conf cp /usr/local/spine/etc/spine.conf.dist /etc/spine.conf vim /etc/spine.conf #找到里面对应参数,根据实际情况修改,这里测试就不改了 DB_Host localhost DB_Database cacti DB_User cactiuser DB_Pass cactiuser DB_Port 3306 8、 安装cacti cd /usr/local/src wget https://www./downloads/cacti-1.2.12.tar.gz tar zxvf cacti-1.2.12.tar.gz mv cacti-1.2.12 /var/www/html/cacti 8.1 创建cacti数据库,创建数据库用户cactiuser,设置用户相关授权 [root@localhost src]# mysql -uroot -p MariaDB [(none)]> create database cacti; Query OK, 1 row affected (0.002 sec) MariaDB [(none)]> grant all on cacti.* to cactiuser@localhost identified by "cactiuser"; Query OK, 0 rows affected (0.003 sec) MariaDB [(none)]> grant select on mysql.time_zone_name to 'cactiuser'@'localhost' identified by 'cactiuser'; Query OK, 0 rows affected (0.001 sec) 8.2 导入 Cacti 默认数据库 MariaDB [(none)]> use cacti; Database changed MariaDB [cacti]> source /var/www/html/cacti/cacti.sql; ...... MariaDB [cacti]> flush privileges; Query OK, 0 rows affected (0.00 sec) MariaDB [cacti]> quit 测试: #出现信息 /usr/local/spine/bin/spine 8.3 配置数据库时区 [root@localhost ~]# mysql_tzinfo_to_sql /usr/share/zoneinfo/ | mysql -u root -p mysql Enter password: Warning: Unable to load '/usr/share/zoneinfo//leapseconds' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo//tzdata.zi' as time zone. Skipping it. 8.4 配置config.php [root@localhost ~]# vim /var/www/html/cacti/include/config.php ...... $database_type = 'mysql'; $database_default = 'cacti'; $database_hostname = 'localhost'; $database_username = 'cactiuser'; $database_password = 'cactiuser'; $database_port = '3306'; $database_retries = 5; $database_ssl = false; $database_ssl_key = ''; $database_ssl_cert = ''; $database_ssl_ca = ''; ...... 8.5 创建日志文件,后续安装时用的到 touch /var/www/html/cacti/log/cacti.log touch /var/www/html/cacti/log/cacti_stderr.log 9、创建用户cactiuser,并授权 useradd cactiuser chown apache.apache /var/www/html/cacti/ -R chown cactiuser /var/www/html/cacti/{rra,log}/ -R chmod 777 /var/www/html/cacti/{rra,log}/ -R 10、重启服务 systemctl restart httpd && systemctl restart mariadb && systemctl restart snmpd 11、配置页面 修改vi /etc/my.cnf.d/server.cnf,根据警告信息,本着没有就加,不对就改的原则配置以下参数 systemctl restart httpd && systemctl restart mariadb && systemctl restart snmpd
|
|
来自: 昵称30760057 > 《待分类》