学习资料: ITIL培训基地专家讲堂直播 300期视频回放
关于zabbix及相关服务软件版本 Linux:centos 6.6 nginx:1.9.15 MySQL:5.5.49 PHP:5.5.35[url=][/url]安装nginx$ yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre* make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel$ useradd nginx -s /sbin/nologin -M$ wget download/nginx-1.9.15.tar.gz && tar xvf nginx-1.9.15.tar.gz && cd nginx-1.9.15$ ./configure --prefix=/usr/local/product/nginx1.9.14 --user=www --group=www --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre$ make && make install$ ln -s /usr/local/product/nginx1.9.14 /usr/local/nginx // 创建软链接 --with-http_stub_status_module:支持nginx状态查询 --with-http_ssl_module:支持https --with-http_spdy_module:支持google的spdy,想了解请百度spdy,这个必须有ssl的支持 --with-pcre:为了支持rewrite重写功能,必须制定pcre[url=][/url]安装PHP$ wget get/php-5.5.35.tar.gz/from/this/mirror$ mv mirror php-5.5.35.tar.gz && tar xvf php-5.5.35.tar.gz && cd php-5.5.35$ ./configure --prefix=/usr/local/product/php-5.5.35 --with-config-file-path=/usr/local/product/php-5.5.35/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath$ make && make install$ ln -s /usr/local/product/php-5.5.35 /usr/local/php$ cp php.ini-production /usr/local/php/etc/php.ini$ cd /usr/local/php/etc/$ cp php-fpm.conf.default php-fpm.conf max_execution_time = 300 memory_limit = 128M post_max_size = 16M upload_max_filesize = 2M max_input_time = 300 date.timezone = PRC[url=][/url]安装MySQL$ groupadd mysql$ mkdir -pv /data/mysql$ useradd -r -g mysql -d /data/mysql -s /sbin/nologin mysql$ chown -R mysql.mysql /data/mysql$ yum install cmake gcc* ncurses-devel -y $ wget get/Downloads/MySQL-5.5/mysql-5.5.49.tar.gz$ tar -xvf mysql-5.5.49.tar.gz && cd mysql-5.5.49$ cmake -DCMAKE_INSTALL_PREFIX=/usr/local/product/mysql5.5.49 -DDEFAULT_CHARSET=utf8 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DDEFAULT_COLLATION=utf8_general_ci$ make && make install$ ln -s /usr/local/product/mysql5.5.49 /usr/local/mysql$ chown -R mysql.mysql /usr/local/mysql$ cd /usr/local/mysql/support-files/$ cp my-medium.cnf /data/mysql/my.cnf$ cp mysql.server /etc/init.d/mysqld$ chmod +x /etc/init.d/mysqld$ cd /usr/local/mysql/scripts$ ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/ datadir=/data/mysql/$ /etc/init.d/mysqld startmysql> create database zabbix default charset utf8;Query OK, 1 row affected (0.00 sec)mysql> grant all privileges on zabbix.* to zabbix@'localhost' identified by 'zabbix';Query OK, 0 rows affected (0.03 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)$ mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)解决办法:$ ln -s /tmp/mysql.sock /var/lib/mysql/$ mysqladmin -uroot password "zabbix"[url=][/url]安装zabbix server$ wget projects/zabbix/files/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz$ tar zxf zabbix-3.0.3.tar.gz && cd zabbix-3.0.3$ ./configure --prefix=/usr/local/zabbix-3.0.3/ --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2$ make && make install故障1: checking for mysql_config... no configure: error: MySQL library not found解决: $ yum install mysql-devel -y故障2: checking for net-snmp-config... no configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config解决: $ yum install net-snmp-devel -y$ groupadd zabbix$ useradd zabbix -s /sbin/nologin -M -g zabbix$ mysql -uroot -pzabbix zabbix < database/mysql/schema.sql $ mysql -uroot -pzabbix zabbix < database/mysql/images.sql$ mysql -uroot -pzabbix zabbix < database/mysql/data.sql[url=][/url]zabbix管理网站配置(nginx)$ mkdir /data/web/ -p$ mkdir /data/logs/zabbix -p$ cp -rp frontends/php/* /data/web/ /$ pwd /usr/local/nginx/conf$ cd extra/$ vim zabbix.confserver {listen 16888;server_name ;access_log /data/logs/zabbix/zabbix.lifec.com.access.log main;index index.html index.php index.html;root /data/web/zabbix.lifec.com;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_index index.php; fastcgi_param PATH_INFO $fastcgi_path_info;}}$ vim nginx.confuser nginx;worker_processes 1;#error_log logs/error.log warning;#error_log logs/error.log notice;#error_log logs/error.log info;pid logs/nginx.pid;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; include extra/*.conf;}$ vim etc/zabbix_server.confLogFile=/tmp/zabbix_server.logPidFile=/tmp/zabbix_server.pidDBHost=localhostDBName=zabbixDBUser=zabbixDBPassword=zabbix[url=][/url]启动服务$ /usr/local/nginx/sbin/nginx$ /usr/local/php/sbin/php-fpm$ /usr/local/zabbix-3.0.3/sbin/zabbix_server如果启动的时候报错:$ /usr/local/zabbix-3.0.2/sbin/zabbix_server /usr/local/zabbix-3.0.2/sbin/zabbix_server: error while loa** shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory$ ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/10.0.0.1 $ echo "/usr/local/nginx/sbin/nginx" >>/etc/rc.local$ echo "/usr/local/php/sbin/php-fpm" >>/etc/rc.local $ echo "/etc/init.d/mysqld start" >>/etc/rc.local$ echo "/usr/local/zabbix-3.0.3/sbin/zabbix_server" >>/etc/rc.local[url=][/url]web端配置zabbix浏览器安装:[url=]http://10.0.0.1:16888[/url]
需要下载文件,上传到指定的服务器目录中并修改属组
$ pwd /data/web/ /conf$ chown 1000:1000 zabbix.conf.php
$ vim /data/web/ /include/locales.inc.php'zh_CN' => ['name' => _('Chinese (zh_CN)'), 'display' => true],$ unzip yaheiFont_CHS.zip //文件在git的fonts目录里 $ rz msyh.ttf$ cd /data/web/ /fonts$ mv DejaVuSans.ttf DejaVuSans_bak$ mv msyh.ttf DejaVuSans.ttf$ chown 1000:1000 DejaVuSans.ttf//重启服务即可[url=][/url]zabbix-agent 安装$ rpm -Uvh zabbix/3. ... .3-1.el6.x86_64.rpmerror: Failed dependencies: libodbc.so.2()(64bit) is needed by zabbix-agent-3.0.3-1.el6.x86_64解决办法:$ yum -y install unixODBC$ vim /etc/zabbix/zabbix_agentd.conf PidFile=/var/run/zabbix/zabbix_agentd.pidLogFile=/var/log/zabbix/zabbix_agentd.logLogFileSize=0Server=10.0.0.1ServerActive=10.0.0.1Hostname=8.8.8.8Include=/etc/zabbix/zabbix_agentd.d/[url=][/url]自动注册和自动发现区别
- 自动发现:
适用于提供相同服务的Server群组,因为自动发现是批量添加Discovery Host的,你可以让所有主机链接同一个模板,并且让他们提供相同的服务。没错,如果你学过Shell,并且能写出批量部署服务的脚本,那么这个自动发现再适合你不过了。 - 自动注册:
自动注册呢,它是比较灵活的,根据HostMetadata的value来匹配规则,并且通过不同的值来执行不同的操作。
也就是说,如果是普通Server,你只要把value设置为Linux,并且让它链接普通的模板
如果是MysqlServer,你可以把value设置为Mysql,并且让它链接Mysql和普通的模板。
自动发现
ii.端口自动发现
$ cat /etc/zabbix/zabbix_scripts/dport_check.d/tes.conf127.0.0.1:12066:docker_tes//#IP:#PORT:#DESC
|