zabbix3.4 源码部署

centos6.8  系统    zabbix3.4.9   msyql5.7.22   php5.6.24  在centos6上面源码部署zabbix.3.4 问题比较多,需要花不少时间去解决,建议在centos7上面部署zabbix3.4    我这因为公司提供的是centos6.8的系统

1、准备 LNMP环境

nginx部署

nginx部署
[root@centos02 tools]#  yum install pcre pcre-devel openssl-devel -y
[root@centos02 tools]# wget  http://nginx.org/download/nginx-1.6.3.tar.gz 
[root@centos02 tools]# tar xf nginx-1.6.3.tar.gz 
[root@centos02 tools]# cd nginx-1.6.3
[root@centos02 nginx-1.6.3]# useradd -s /sbin/nologin -M nginx
[root@centos02 nginx-1.6.3]# ./configure --prefix=/application/nginx-1.6.3 --user=nginx --group=nginx  --with-http_stub_status_module --with-http_ssl_module
[root@centos02 nginx-1.6.3]# make && make install    
[root@centos02 nginx-1.6.3]# ln -s /application/nginx-1.6.3/ /application/nginx
[root@centos02 nginx-1.6.3]#  /application/nginx/sbin/nginx -t   检查语法
[root@centos02 nginx-1.6.3]#  /application/nginx/sbin/nginx   启动nginx

mysql  去官方下载5.7.22版本

https://dev.mysql.com/downloads/mysql/5.7.html#downloads

yum install -y gcc gcc-c++ cmake bison ncurses-devel

 
tar xf mysql-boost-5.7.22.tar.gz tar xf mysql-5.7.22.tar.gz cd mysql-5.7.22

cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DSYSCONFDIR=/etc/my.cnf \
-DMYSQL_DATADIR=/data/mysql/ \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_TCP_PORT=3306 \
-DEFAULT_CHARSET=utf8 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DWITH_BOOST=./boost \
#-DWITH_SYSTEMD=1  #该参数在centos7上面才需要


make -j 6
make install


 cat /etc/my.cnf
[mysqld]
datadir=/data/mysql
socket=/tmp/mysql.sock
basedir=/usr/local/mysql

# basic setting
user=mysql
port=3306
server-id=11

#log
slow_query_log_file = /binlog/mysqlog/slow.log
slow_query_log = 1

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/binlog/mysqlog/err.log

[mysql]
socket=/tmp/mysql.sock



初始化数据
useradd -M -s /sbin/nologin mysql
cd /usr/local/mysql/bin
./mysqld --initialize --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql --socket=/tmp/mysql.sock --log-error=/binlog/mysqlog/err.log --log-bin=/binlog/mysqlog/mysql-bin

cp /server/tools/mysql-5.7.22/support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld 

ln -s /usr/local/mysql/bin/mysql /usr/bin

可能会遇到的问题

grep 'temporary password' /binlog/mysqlog/err.log

2018-05-29T04:52:17.888490Z 1 [Note] A temporary password is generated for root@localhost: 3DQp3jeZlC!h

mysql -uroot -p

mysql> update mysql.user set authentication_string = password("0a4c6d5@f9c5b016") where user="root" ;   #设置root密码

Mysql5.7 密码过期解决

ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.

mysql> select * from mysql.user where user='root' \G


x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
plugin: mysql_native_password
authentication_string: *CF9A80CD3544352D311C63FBF98FF969B4B7AB10
password_expired: Y
password_last_changed: 2018-05-29 12:52:18
password_lifetime: NULL
account_locked: N
1 row in set (0.00 sec)


mysql> update user set password_expired='N' where user='root'; #密码过期解决方法

php

[root@centos02 libiconv-1.14] # wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
[root@centos02 tools] # yum install zlib-devel libxml2-devel libjpeg-devel libiconv-devel -y
[root@centos02 tools] # yum install freetype-devel libpng-devel gd-devel curl-devel libxslt-devel -y
[root@centos02 libiconv-1.14] # yum -y install libmcrypt-devel mhash mhash-devel mcrypt libxslt-devel 
[root@centos02 tools] # wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz 
[root@centos02 tools] # tar xf libiconv-1.14.tar.gz 
[root@centos02 tools] # cd libiconv-1.14
[root@centos02 libiconv-1.14] # ./configure --prefix=/usr/local/libiconv
[root@centos02 libiconv-1.14] # make && make install

[root@centos02 tools]# wget http://cn2.php.net/distributions/php-5.6.24.tar.gz [root@centos02 tools]# tar xf php-5.6.24.tar.gz [root@centos02 tools]# cd php-5.6.24 [root@centos02 php-5.6.24]# ./configure \

--prefix=/application/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-safe-mode \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--with-curlwrappers \
--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-zend-multibyte \
--enable-static \
--with-xsl \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-ftp \
--with-gettext


可能遇到的如下报错

/server/tools/php-5.6.24/ext/iconv/iconv.c:1195: undefined reference to `libiconv_open'
/server/tools/php-5.6.24/ext/iconv/iconv.c:1209: undefined reference to `libiconv_open'
/server/tools/php-5.6.24/ext/iconv/iconv.c:1328: undefined reference to `libiconv'
/server/tools/php-5.6.24/ext/iconv/iconv.c:1280: undefined reference to `libiconv'
/server/tools/php-5.6.24/ext/iconv/iconv.c:1312: undefined reference to `libiconv'
/server/tools/php-5.6.24/ext/iconv/iconv.c:1470: undefined reference to `libiconv_close'
/server/tools/php-5.6.24/ext/iconv/iconv.c:1380: undefined reference to `libiconv'
/server/tools/php-5.6.24/ext/iconv/iconv.c:1411: undefined reference to `libiconv'
/server/tools/php-5.6.24/ext/iconv/iconv.c:1467: undefined reference to `libiconv_close'
/server/tools/php-5.6.24/ext/iconv/iconv.c:1454: undefined reference to `libiconv'

解决办法

在执行完 ./configure ... 之后,修改下 Makefile,找到其中的

 
   
PHP
  
  1. EXTRA_LIBS = -lcrypt -lz -lcrypt -lrt -lmysqlclient -lmcrypt -lldap -llber -lfreetype -lpng -lz -ljpeg -lcurl -lz -lrt -lm -ldl -lnsl -lrt -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lxml2-lz -lm -lcrypt

在后面添加 -liconv,即修改为:

 
   
PHP
  
  1. EXTRA_LIBS = -lcrypt -lz -lcrypt -lrt -lmysqlclient -lmcrypt -lldap -llber -lfreetype -lpng -lz -ljpeg -lcurl -lz -lrt -lm -ldl -lnsl -lrt -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lxml2-lz -lm -lcrypt -liconv
[root@centos02 application] # ln -s /usr/local/mysql/lib/libmysqlclient.so.18  /usr/lib64/
[root@centos02 application] # touch ext/phar/phar.phar
[root@centos02 application] # make && make install

curl 7.19.7  系统默认版本,升级该软件版本,否则后面邮件功能会有问题  参考官方说明https://www.zabbix.com/documentation/3.4/zh/manual/installation/install

cat /etc/yum.repos.d/curl.repo 
[CityFan]
name=City Fan Repo
baseurl=http://nervion.us.es/city-fan/yum-repo/rhel$releasever/$basearch/
enabled=1
gpgcheck=0

yum install libcurl

 
 

 curl -V
curl 7.60.0 (x86_64-redhat-linux-gnu) libcurl/7.60.0 OpenSSL/1.0.1e zlib/1.2.3 c-ares/1.14.0 libssh2/1.8.0 nghttp2/1.6.0
Release-Date: 2018-05-16
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz HTTP2 UnixSockets HTTPS-proxy Metalink

yum -y install net-snmp-devel  libevent-devel   java-devel -y

 编译安装zabbix3.4   去官方下载源码包

 ./configure --prefix=/application/zabbix-server --enable-server --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-agent --enable-proxy --enable-java
make install


mysql> create database zabbix character set utf8 collate utf8_bin;

Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'xxx';

Query OK, 0 rows affected, 1 warning (0.00 sec)

由于zabbix启动脚本路径默认指向的是/usr/local/sbin路径,因此,需要提前建立软链接

[root@Yeahka-6 zabbix-3.4.9]# ln -s /application/zabbix-server/sbin/* /usr/local/sbin/

[root@Yeahka-6 zabbix-3.4.9]# ln -s /application/zabbix-server/bin/* /usr/local/bin/

[root@Yeahka-6 zabbix-3.4.9]# mkdir /application/nginx/html/zabbix

[root@Yeahka-6 zabbix-3.4.9]#  cp -ar /server/tools/zabbix-3.4.9/frontends/php/* /application/nginx/html/zabbix/

[root@Yeahka-6 zabbix-3.4.9]# cd /server/tools/zabbix-3.4.9/database/mysql/

[root@Yeahka-6 mysql]# ll

总用量 4872

-rw-r--r-- 1 1001 1001 2873211 5月   9 17:58 data.sql

-rw-r--r-- 1 1001 1001 1978341 5月   9 17:57 images.sql

-rw-r--r-- 1 1001 1001  134791 5月   9 17:58 schema.sql

 mysql -uzabbix -pxxx zabbix < schema.sql

mysql -uzabbix -pxxx zabbix < images.sql

 mysql -uzabbix -pxxx zabbix < data.sql

cp /server/tools/zabbix-3.4.9/misc/init.d/fedora/core/zabbix_server /etc/init.d/

 cp /server/tools/zabbix-3.4.9/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/

 

默认的用户名是Admin,密码是zabbix

 附上配置

cat /application/nginx/conf/nginx.conf
worker_processes  2;
events {
    worker_connections  1024;
}
http {
log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       9999;
        server_name  192.168.11.147;
        location / {
            root   html;
            index  index.php index.html index.htm;
        }
         
          
        location ~ .*\.(php|php5)?$ {
            root  html;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
               }
         access_log  logs/access_zabbix.log  main;        
   }
             
    server {
        listen       9997;
        server_name  bbs.martin.com;
        location / {
            root   html/bbs;
            index  index.php index.html index.htm;
        }
       
              
        location ~ .*\.(php|php5)?$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
               }
         access_log  logs/access_bbs.log  main;       
    }
###status
   server{
      listen 9998;
      server_name 192.168.11.147;
      location / {
      stub_status on;
      access_log off;
        }
   }
}

 cat /application/php/etc/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

 

猜你喜欢

转载自www.cnblogs.com/hellojackyleon/p/9109188.html