标签:access 管理 cpu process dbus secure etc min script
简介:--------安装LAMP-------------------------------------------------------
[root@cacti ~]# yum install -y \
httpd \
mariadb-server mariadb \
php \
php-mysql \
php-gd \
libjpeg* \
php-ldap \
php-odbc \
php-pear \
php-xml \
php-xmlrpc \
php-mhash
[root@cacti ~]# vim /etc/httpd/conf/httpd.conf
ServerName www.yun.com:80 ##95行
DirectoryIndex index.html index.php ##164行
[root@cacti ~]# vim /etc/php.ini
date.timezone = PRC ##878行 设置中国时区(去掉分号,添加PRC)
[root@cacti ~]# systemctl start httpd.service
[root@cacti ~]# systemctl start mariadb.service
[root@cacti ~]# netstat -ntap | egrep ‘(3306|80)‘
tcp 0 0 0.0.0.0:3306 0.0.0.0: LISTEN 45660/mysqld
tcp6 0 0 :::80 ::: LISTEN 45388/httpd
[root@cacti ~]# mysql_secure_installation
y
abc123 (自己设置密码)
abc123
n
n
n
y
##进入数据库
[root@cacti ~]# mysql -uroot -p
Enter password: ##输入密码
MariaDB [(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT all privileges ON . TO ‘zabbix‘@‘%‘ IDENTIFIED BY ‘admin123‘;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
##测试
[root@cacti ~]# cd /var/www/html/
[root@cacti html]# vim index.php
<?php
phpinfo();
?>
##浏览器访问服务器:192.168.120.181
##测试完成后删除原来的测试语句
[root@cacti html]# vim index.php
<?php
$link=mysql_connect(‘192.168.120.181‘,‘zabbix‘,‘admin123‘);
if($link) echo "<h1>Success!!</h1>";
else echo "Fail!!";
mysql_close();
?>
##修改完成后,刷新网页
##网页是Success的可以跳过一下问题(如果是Faill,请按以下步骤操作)##
-------------解决本地无法登录问题(可忽略)---------------------------
[root@cacti html]# mysql -uzabbix -p
Enter password:
ERROR 1045 (28000): Access denied for user ‘zabbix‘@‘localhost‘ (using password: YES)
##出错##
##解决方案:
##进入root用户数据库
[root@cacti html]# mysql -uroot -p
MariaDB [(none)]> select user,host from mysql.user;
+--------+-----------+
| user | host |
+--------+-----------+
| zabbix | % |
| root | 127.0.0.1 |
| root | ::1 |
| | cacti |
| root | cacti |
| | localhost |
| root | localhost |
+--------+-----------+
##出现空用户,删除空用户
MariaDB [(none)]> drop user ‘‘@localhost;
Query OK, 0 rows affected (0.02 sec)
MariaDB [(none)]> drop user ‘‘@cacti;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> select user,host from mysql.user;
+--------+-----------+
| user | host |
+--------+-----------+
| zabbix | % |
| root | 127.0.0.1 |
| root | ::1 |
| root | cacti |
| root | localhost |
+--------+-----------+
##空用户已删除
[root@cacti html]# mysql -uzabbix -p
Enter password:
MariaDB [(none)]>
##登录成功
----------------以下开始部署zabbix Server-------
[root@cacti html]# yum install php-bcmath php-mbstring -y
##会自动生成yum源文件,保证系统可以上网
[root@cacti html]# rpm -ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
##安装
[root@cacti yum.repos.d]# yum install zabbix-server-mysql zabbix-web-mysql -y
##生成数据库文件,注意密码不要输成root的(是之前设置的admin123)
[root@cacti yum.repos.d]# zcat /usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz | mysql -uzabbix -p zabbixEnter password:
[root@cacti yum.repos.d]# grep -n ‘^‘[a-Z] /etc/zabbix/zabbix_server.conf
38:LogFile=/var/log/zabbix/zabbix_server.log
49:LogFileSize=0
72:PidFile=/var/run/zabbix/zabbix_server.pid
82:SocketDir=/var/run/zabbix
101:DBName=zabbix
117:DBUser=zabbix
357:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
475:Timeout=4
518:AlertScriptsPath=/usr/lib/zabbix/alertscripts
529:ExternalScripts=/usr/lib/zabbix/externalscripts
565:LogSlowQueries=3000
[root@cacti yum.repos.d]# vim /etc/zabbix/zabbix_server.conf
DBPassword=admin123 ##125行
[root@cacti yum.repos.d]# vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai ##20行(修改时区)
------------------修正图表中文乱码---------------------
[root@cacti yum.repos.d]# vim /usr/share/zabbix/include/defines.inc.php
##shift:输入
:%s /graphfont/kaiti/g
##挂载软件包
[root@cacti yum.repos.d]# mkdir /abc
[root@cacti yum.repos.d]# mount.cifs //192.168.100.10/rhel7 /abc
Password for root@//192.168.100.10/rhel7:
[root@cacti yum.repos.d]# cd /abc/zabbix/
[root@cacti zabbix]# ls
php-bcmath-5.4.16-42.el7.x86_64.rpm php-mbstring-5.4.16-42.el7.x86_64.rpm STKAITI.TTF
[root@cacti zabbix]# cp STKAITI.TTF /usr/share/zabbix/fonts/
##启动服务
[root@cacti zabbix]# systemctl start zabbix-server.service
[root@cacti zabbix]# systemctl enable zabbix-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[root@cacti zabbix]# netstat -anpt | grep zabbix
tcp 0 0 0.0.0.0:10051 0.0.0.0: LISTEN 46594/zabbix_server
tcp6 0 0 :::10051 ::: LISTEN 46594/zabbix_server
[root@cacti zabbix]# systemctl restart httpd.service
http://192.168.120.181/zabbix/ //安装后登录 用户名Admin 密码:zabbix
设置中文环境
Administrator-Users-点击用户-语言中设置
======配置代理端-就是被控服务器----如果服务器也需要被自己监控也需要安装--zabbix-agent=====
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# setenforce 0
##安装yum源
[root@localhost ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
[root@localhost ~]# yum install -y zabbix-agent
[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.120.181 ##98行(IP为之前的监控服务器)
ServerActive=192.168.120.181 ##139行
Hostname=abc ##150行(名字自定义)
##启动服务
[root@localhost ~]# systemctl start zabbix-agent.service
[root@localhost ~]# systemctl enable zabbix-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@localhost ~]# netstat -ntap | grep 10050
tcp 0 0 0.0.0.0:10050 0.0.0.0: LISTEN 45402/zabbix_agentd
tcp6 0 0 :::10050 ::: LISTEN 45402/zabbix_agentd
到网页设置 http://192.168.120.181/zabbix/
选择监控http、ssh(具体监控什么,自己定义)
搭建Zabbix及如何设置监控就详解到这了。
标签:access 管理 cpu process dbus secure etc min script
原文地址:http://blog.51cto.com/13756916/2308906