Install on the operating system CentOS release 6.5 (Final), pay attention to configure the yum source, you can use 163 or Alibaba Cloud's yum source.
One zabbix server installation and configuration
1、Nginx 安装(安装包为nginx-1.6.3.tar.gz)
yum install pcre pcre-devel openssl-devel –y
tar xf nginx-1.6.3.tar.gz
cd nginx-1.6.3/
useradd -s /sbin/nologin -M nginx
./configure --prefix=/usr/local/nginx-1.6.3/ --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
ln -s /usr/local/nginx-1.6.3/ /usr/local/nginx
/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -s stop
2. Install mysql (the installation package is mysql-5.5.49-linux2.6-x86_64.tar)
useradd -s /sbin/nologin -M mysql
mv mysql-5.5.49-linux2.6-x86_64 /usr/local/mysql-5.5.49
ln -s /usr/local/mysql-5.5.49/ /usr/local/mysql
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ --user=mysql
chown -R mysql.mysql /usr/local/mysql
cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf
/usr/local/mysql/bin/mysqld_safe &
3、Php 安装 (安装包为php-5.6.24.tar.gz )
yum install -y libxml2
yum install libxml2-devel
yum install -y libcurl-devel
yum install -y libjpeg-devel
yum install -y libpng-devel
yum install -y freetype-devel
yum -y install libxslt-devel
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
tar zxf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
make & make install
ln -s /usr/local/mysql/lib/libmysqlclient.so /usr/lib/
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
tar xf php-5.6.24.tar.gz
cd php-5.6.24/
./configure --prefix=/usr/local/php5.6.24 --with-mysql=/usr/local/mysql \
--with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath \
--enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl \
--enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf \
--with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip \
--enable-soap --enable-short-tags --enable-static --with-xsl \
--with-fpm-user=nginx --with-fpm-group=nginx --enable-ftp --with-gettext
make & make install (If you make a compilation error, you can run make clean all and then compile)
cp php.ini-production /usr/local/php/lib/php.ini
cat php-fpm.conf
[global]
[www]
user = nginx
group = nginx
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
Start PHP
php-fpm
4 Integration
The contents of vi /usr/local/nginx/conf/nginx.conf are as follows:
server {
listen 80;
server_name centos.yun;
access_log /data/logs/nginx/centos.yun.access.log access;
index index.html index.php index.html;
root /data/site/centos.yun;
location /
{
try_files $uri $uri/ /index.php?$args;
}
location ~ ^(.+.php)(.*)$ {
fastcgi_split_path_info ^(.+.php)(.*)$;
include fastcgi.conf;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/tmp/php- cgi.sock; (modified according to actual content)
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
vi /usr/local/nginx/html/zabbix/info.php
<?php
phpinfo();
?>
vi /usr/local/php/lib/php.ini modify the parameters inside
5. 安装zabbix server(安装包为zabbix-3.2.3.tar.gz )
tar xf zabbix-3.2.3.tar.gz
cd zabbix-3.2.3
./configure --prefix=/usr/local/zabbix-server --enable-server --with-mysql=/usr/local/mysql-5.5.49/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2 --enable-agent --enable-proxy
make install
groupadd zabbix
useradd -g zabbix zabbix
cd /usr/local/nginx/html/zabbix/
cp -a /root/zabbix-3.2.3/frontends/php/* .
cd /root/zabbix-3.2.3/database/mysql/
/usr/local/mysql/bin/mysql
create database zabbix default charset utf8;
grant all privileges on zabbix.* to zabbix@'192.%' identified by 'zabbix';
grant all privileges on zabbix.* to zabbix@'localhost' identified by 'zabbix';
/usr/local/mysql/bin/mysql -uzabbix -pzabbix zabbix < schema.sql
/usr/local/mysql/bin/mysql -uzabbix -pzabbix zabbix < images.sql
/usr/local/mysql/bin/mysql -uzabbix -pzabbix zabbix < data.sql
vi /usr/local/zabbix-server/etc/zabbix_server.conf
DBHost=192.168.3.4
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/usr/local/mysql/mysql.sock
/usr/local/zabbix-server/sbin/zabbix_server -c /usr/local/zabbix-server/etc/zabbix_server.conf
To test snmp, install
yum install net-snmp net-snmp-utils
test snmp access
snmpwalk -v 2c -c yang 14.1.8.1 1.3.6.1.2.1.2.2.1.10.2
6 Configure auto-start
Add to the configuration file in /etc/rc.local
/usr/local/nginx/sbin/nginx
/usr/local/mysql/bin/mysqld_safe &
/usr/local/php5.6.24/sbin/php-fpm
/usr/local/zabbix-server/sbin/zabbix_server -c /usr/local/zabbix-server/etc/zabbix_server.conf
Two zabbix aent installation and configuration
1. Install
rpm -Uvh on centos6.5 http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-agent-3.2.4-1.el6.x86_64.rpm
vi /etc/ zabbix/zabbix_agentd.conf
Server=Zabbix Server IP
ServerActive=Zabbix Server IP
Hostname=AgentName
Include= /etc/zabbix/zabbix_agentd.conf.d/
Do not configure this option, otherwise it will cause the agent to find conf recursively and fail to start. After testing, the above situation did not happen.
This option can be configured, and when customizing the return parameters, you need to use the configuration file in this directory
/etc/init.d/zabbix-agent start
chkconfig zabbix-agent on
2. Install and
close selinux
sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
setenforce 0 on centos7.
Firewall settings
Allow port 10050 of
zabbix -agent to pass firewall-cmd --permanent --add -port=10050/tcp
firewall-cmd --reload
Experiment with the successful
environment as follows : CentOS Linux release 7.2.1511
machine 1: zabbix server 192.168.1.10
machine 2: zabbix-agent 192.168.1.11
***********192.168.1.11***************************
#yum localinstall -y http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
#yum install -y zabbix-agent
#cp /etc/zabbix/zabbix_agentd.conf{,.original}
#vim /etc/zabbix/zabbix_agentd.conf #编辑zabbix_agentd.conf 文件
SourceIP=192.168.1.10
Server=192.168.1.10
ServerActive=192.168.1.10
Hostname=edm.cookie.com
#systemctl enable zabbix-agent.service
#systemctl start zabbix-agent.service
#vim /etc/sysconfig/iptables Set up the firewall and open port 10050 to the
zabbix server -A INPUT -s 192.168.1.10 -p tcp -m state --state NEW -m tcp --dport 10050 -j ACCEPT
#systemctl restart iptables
*************Test ****192.168.1.10***********************
zabbix_get -s 192.168.1.11 -p 10050 -k 'agent.ping'
3. Windows installation
install
zabbix_agentd.exe -cc:\zabbix_agent\conf\zabbix_agentd.win.conf -i
find the configuration file zabbix_agentd.win.conf under conf, the contents that need to be modified are: LogFile, Server, Hostname, ServerActive. argument
runs
zabbix_agentd.exe -cc: \ zabbix_agent \ conf \ zabbix_agentd.win.conf -s
uninstall
zabbix_agentd.exe -cc: \ zabbix_agent \ conf \ zabbix_agentd.win.conf -d
when configured in zabbix server interface, you can Enter IP address
Three zabbix mail alarm settings
cd /usr/local/src/
wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
yum install perl-Net-SSLeay perl-IO-Socket-SSL -y
tar -xvf sendEmail-v1.56.tar.gz
cd sendEmail-v1.56
cp -ra sendEmail /usr/local/bin/
chmod +x /usr/local/bin/sendEmail
chown zabbix:zabbix /usr/local/bin/sendEmail
/usr/local/bin/sendEmail -f [email protected] -t [email protected] -s smtp.jiaying.tv -u "zabbxitest" -o message-content-type=html -o message-charset=utf8 -o tls=auto -xu [email protected] -xp xxxxxxx -m "我是邮件内容"
/usr/local/bin/sendEmail -f [email protected] -t [email protected] -s smtp.163.com -u "zabbxitest" -o message-content-type=html -o message-charset=utf8 -o tls=auto -xu [email protected] -xp xxxxxxx -m "this is a test"
/usr/local/bin/sendEmail -f [email protected] -t [email protected] -s smtp.163.com -u "zabbix is OK" -o message-content-type=html -o message-charset=utf8 -o tls=auto -xu [email protected] -xp xxxxxx -m "zabbix is OK"
cd /usr/local/zabbix-server/share/zabbix/alertscripts/
vi sendmail.sh
#!/bin/bash
to=$1
subject=$2
body=$3
/usr/local/bin/sendEmail -f [email protected] -t "$to" -s smtp.jiaying.tv -u "$subject" -o message-content-type=html -o message-charset=utf8 -xu [email protected] -xp xxxxxxxx! -m "$body"
chmod a+x sendmail.sh
chown zabbix:zabbix sendmail.sh
Make the following settings in the interface:
1. Management-Alert Media Type-Email (or script setting), if you want to set the script, you need to define three script parameters {ALERT.SENDTO} {ALERT.SUBJECT} {ALERT.MESSAGE}
2 Set Zabbix user alarm email address 3. Set Zabbix trigger alarm action. If you use a script to alarm, you need to
set up to send emails every 2 hours from 7-22 every morning.
* 7-23/2 * * * /usr/local/zabbix-server/share/zabbix/alertscripts/zabbixok.sh