有道云笔记连接http://note.youdao.com/noteshare?id=e8c71bdd66395ad373d94a782df8dfba&sub=12F495B54D03492D8A9FC1BC2C3D2AA9
链接:https://pan.baidu.com/s/1acq0eSonxUvyciaICYNghg
提取码:k3ut
安装LAMP (linux Apache mysql php)
源码安装zabbix server
配置zabbix web页面
在zabbix服务端安装agent端
在另一台Linux上安装agent端
zabbix-server:
仅主机:192.168.120.23
zabbix-agent:
仅主机:192.168.120.13
需要软件:
zabbix-3.4.3编译源码包
Mysql-5.7.17-glibc
系统自带Apache(1.3.12或以上)
php-5.6.30(要求5.4.0或以上)
libmcrypt-2.5.8
libevent-2.1.8
pcre-8.01
什么叫LAMP: Linux apache mysql php/perl/
还有LNMP nginx
yum -y install httpd httpd-devel
useradd mysql
tar xf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
cd /usr/local/
mv mysql-5.7.17-linux-glibc2.5-x86_64/ mysql
chown -R mysql:mysql mysql/
./mysqld --initialize --datadir=/data
PATH=$PATH:/usr/local/mysql/bin
vim /root/.bash_profile
mysqld_safe --skip-grant-tables &
mysql>flush privileges;
mysql>alter user root@localhost identified by ‘123’;
mysql>flush privileges;
[root@mysql-tar ~]# cat /etc/my.cnf
[mysqld]
datadir=/data
socket=/tmp/mysql.sock
user=mysql
symbolic-links=0
log-error=/data/mysqld.log
pid-file=/data/mysqld.pid
lower_case_table_names=1
[mysql]
socket=/tmp/mysql.sock
[root@mysql-tar ~]#
# yum install -y gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses curl openssl-devel db4-devel libXpm-devel libX11-devel gmp-devel readline-devel libxslt-devel expat-devel xmlrpc-c libcurl libcurl-devel
[root@zabbix-server ~]# tar xf libmcrypt-2.5.8.tar.gz
[root@zabbix-server ~]# cd libmcrypt-2.5.8
[root@zabbix-server libmcrypt-2.5.8]# ./configure && make && make install
tar -xf php-5.6.30.tar.gz -C /usr/loca
[root@zabbix-server php-5.6.30]# ./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-apxs2=/usr/sbin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-inline-optimization --enable-fpm --enable-soap --with-libxml-dir --with-xmlrpc --with-openssl --with-mcrypt --with-mhash --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --disable-mbregex --disable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-pdo-mysql --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear
[root@zabbix-server php-5.6.30]# make ; make install
[root@zabbix-server ~]# cd php-5.6.30
[root@zabbix-server php-5.6.30]# cp php.ini-production /etc/php.ini
[root@zabbix-server php-5.6.30]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@zabbix-server php-5.6.30]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@zabbix-server php-5.6.30]# chmod +x /etc/init.d/php-fpm
[root@zabbix-server php-5.6.30]# /usr/local/php/sbin/php-fpm -t
[25-Dec-2017 12:47:10] NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful
[root@zabbix-server php-5.6.30]#
[root@zabbix-server php-5.6.30]# chkconfig --add php-fpm
[root@zabbix-server php-5.6.30]# chkconfig php-fpm on
[root@zabbix-server php-5.6.30]# service php-fpm start
Starting php-fpm done
[root@zabbix-server php-5.6.30]# vim /usr/local/php/etc/php-fpm.conf
listen = 127.0.0.1:8000
[root@zabbix-server zabbix-3.4.3]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
[root@zabbix-server zabbix-3.4.3]# netstat -tnulp|grep fpm
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 73066/php-fpm
[root@zabbix-server zabbix-3.4.3]#
# vim /etc/httpd/conf/httpd.conf
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.html index.html.var
LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so
[root@zabbix-server ~]# yum -y install curl libcurl-devel net-snmp net-snmp-devel perl-DBI libdbi-dbd-mysql mysql-devel gcc gcc-c++ make libxml2 libxml2-devel
[root@zabbix-server ~]# groupadd zabbix
[root@zabbix-server ~]# useradd -g zabbix zabbix
# tar xf libevent-2.1.8-stable.tar.gz
# cd libevent-2.1.8-stable
[root@zabbix-server libevent-2.1.8-stable]# ./configure && make && make install
[root@zabbix-server ~]# tar xf pcre-8.01.tar.gz
[root@zabbix-server ~]# cd pcre-8.01
[root@zabbix-server pcre-8.01]#
[root@zabbix-server pcre-8.01]# ./configure && make && make install
[root@zabbix-server ~]# yum install net-snmp -y
[root@zabbix-server ~]# yum -y install unixODBC unixODBC-devel
[root@zabbix-server ~]# yum install mysql-connector-odbc -y
[root@management_platform zabbix_soft]# tar xf libssh2-1.8.0.tar.gz
[root@management_platform zabbix_soft]# cd libssh2-1.8.0
[root@management_platform libssh2-1.8.0]# ./configure && make && make install
[root@zabbix-server ~]# tar xf zabbix-3.4.3.tar.gz
[root@zabbix-server ~]# cd zabbix-3.4.3
[root@zabbix-server zabbix-3.4.3]# ./configure --prefix=/usr/local/zabbix-server --enable-server --with-mysql --with-net-snmp --with-unixodbc --with-libcurl --with-libxml2 --enable-agent --enable-ipv6 --enable-proxy --with-ssh2 && make install
[root@zabbix-server zabbix-3.4.3]#
mysql> create database zabbix charset utf8;
mysql> grant all on zabbix.* to zabbix@localhost identified by '123';
mysql> flush privileges;
[root@zabbix-server zabbix-3.4.3]# mysql -uzabbix -p123 zabbix < database/mysql/schema.sql
[root@zabbix-server zabbix-3.4.3]# mysql -uzabbix -p123 zabbix < database/mysql/images.sql
[root@zabbix-server zabbix-3.4.3]# mysql -uzabbix -p123 zabbix < database/mysql/data.sql
[root@zabbix-server zabbix-3.4.3]# cp -R frontends/php /var/www/zabbix/
[root@zabbix-server zabbix-3.4.3]# chmod 777 /var/www/zabbix/php/conf
[root@zabbix-server ~]# mkdir /var/log/zabbix
[root@zabbix-server ~]# chown -R zabbix:zabbix /var/log/zabbix/
[root@zabbix-server etc]# vim /usr/local/zabbix-server/etc/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123
DBSocket= /data/mysql.sock
DBPort = 3306
Timeout=4
LogSlowQueries=3000
[root@zabbix-server zabbix-3.4.3]# cp misc/init.d/fedora/core/zabbix_server /etc/init.d/
[root@zabbix-server zabbix-3.4.3]# chkconfig --add zabbix_server
[root@zabbix-server zabbix-3.4.3]# chkconfig zabbix_server on
[root@zabbix-server zabbix-3.4.3]# ln -s /usr/local/zabbix-server/bin /usr/bin/
[root@zabbix-server zabbix-3.4.3]# cp /usr/local/zabbix-server/sbin/zabbix_server /usr/local/sbin/
[root@zabbix-server zabbix-3.4.3]# ln -s /usr/local/lib/libevent-2.1.so.6 /usr/lib64/
[root@zabbix-server zabbix-3.4.3]# service zabbix_server start
Starting zabbix_server: [ OK ]
[root@zabbix-server zabbix-3.4.3]#
#Vim /root/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/zabbix-server/bin
# source /root/.bash_profile
编辑zabbix前端的配置文件:/etc/httpd/conf.d/zabbix.conf
# Zabbix monitoring system php web frontend
Alias /zabbix /var/www/zabbix/php
<Directory "/var/www/zabbix/php">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
#Require all granted
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
# php_value date.timezone Europe/Riga
php_value date.timezone Asia/Shanghai
</IfModule>
</Directory>
修改httpd配置文件中servername:
# vim /etc/httpd/conf/httpd.conf
ServerName localhost:80
[root@zabbix-server conf]# service httpd start
Starting httpd: [ OK ]
[root@zabbix-server ~]# chkconfig --add httpd
[root@zabbix-server ~]# chkconfig httpd on
[root@zabbix-server conf]# service zabbix_server restart
Shutting down zabbix_server: [ OK ]
Starting zabbix_server: [ OK ]
[root@zabbix-server conf]#
在浏览器中访问zabbix server:http://192.168.120.23/zabbix
登录zabbix web:
默认web用户及密码:admin ,zabbix
[root@zabbix-server etc]# cp /root/zabbix-3.4.3/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
[root@zabbix-server etc]# chkconfig --add zabbix_agentd
[root@zabbix-server etc]# chkconfig zabbix_agentd on
[root@zabbix-server etc]# cat /usr/local/zabbix-server/etc/zabbix_agentd.conf
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=172.16.120.23
ServerActive=172.16.120.23
Hostname=mysql-tar
UnsafeUserParameters=1
[root@zabbix-server etc]
[root@zabbix-server etc]# ln -s /usr/local/zabbix-server/sbin/zabbix_agentd /usr/local/sbin/
[root@zabbix-server etc]# service zabbix_agentd start
Starting zabbix_agentd: [ OK ]
[root@zabbix-server etc]#
所需软件:
Zabbix-3.4.3编译源码包
Pcre-8.01
[root@rhat-6-zabbix-agent ~]# groupadd zabbix
[root@rhat-6-zabbix-agent ~]# useradd -g zabbix ==zabbix==
先安装好编译工具:
[root@rhat-6-zabbix-agent ~]# yum install gcc-c++ -y
安装pcre:
[root@rhat-6-zabbix-agent ~]# tar xf pcre-8.01.tar.gz
[root@rhat-6-zabbix-agent ~]# cd pcre-8.01
[root@rhat-6-zabbix-agent pcre-8.01]# ./configure && make && make install
[root@rhat-6-zabbix-agent ~]# tar xf zabbix-3.4.3.tar.gz
[root@rhat-6-zabbix-agent ~]# cd zabbix-3.4.3
[root@rhat-6-zabbix-agent zabbix-3.4.3]# ./configure --prefix=/usr/local/zabbix-agent --enable-agent && make install
创建日志目录并授权:
[root@rhat-6-zabbix-agent fedora]# mkdir /var/log/zabbix
[root@rhat-6-zabbix-agent fedora]# chown -R zabbix:zabbix /var/log/zabbix/
修改agent配置文件:
[root@rhat-6-zabbix-agent zabbix-agent]# vim /usr/local/zabbix-agent/etc/zabbix_agentd.conf
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=192.168.120.23
ServerActive=192.168.120.23
Hostname=mysql-rpm
UnsafeUserParameters=1
Timeout=8
[root@rhat-6-zabbix-agent fedora]# cp /root/zabbix-3.4.3/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
[root@rhat-6-zabbix-agent fedora]# chkconfig --add zabbix_agentd
[root@rhat-6-zabbix-agent fedora]# chkconfig zabbix_agentd on
[root@rhat-6-zabbix-agent fedora]# ln -s /usr/local/zabbix-agent/sbin/zabbix_agentd /usr/local/sbin/
[root@rhat-6-zabbix-agent fedora]# service zabbix_agentd start
Starting zabbix_agentd: [ OK ]
[root@rhat-6-zabbix-agent fedora]#
# cp /root/zabbix-3.4.3/conf/zabbix_agentd/userparameter_examples.conf /usr/local/zabbix-agent/etc/zabbix_agentd.conf.d/
# cp /root/zabbix-3.4.3/conf/zabbix_agentd/userparameter_mysql.conf /usr/local/zabbix-agent/etc/zabbix_agentd.conf.d/ ##监控MySQL
PATH=$PATH:$HOME/bin:/usr/local/zabbix-agent/bin
# source /root/.bash_profile
原文:https://www.cnblogs.com/qluzzh/p/10800253.html