centos6.8 系統 zabbix3.4.9 msyql5.7.22 php5.6.24 在centos6上面源碼部署zabbix.3.4 問題比較多,需要花不少時間去解決,建議在centos7上面部署zabbix3.4 我這因為公司提供的是centos6.8的系統
1、準備 LNMP環境
nginx部署
nginx部署
[[email protected] tools]# yum install pcre pcre-devel openssl-devel -y
[[email protected] tools]# wget http://nginx.org/download/nginx-1.6.3.tar.gz
[[email protected] tools]# tar xf nginx-1.6.3.tar.gz
[[email protected] tools]# cd nginx-1.6.3
[[email protected] nginx-1.6.3]# useradd -s /sbin/nologin -M nginx
[[email protected] nginx-1.6.3]# ./configure --prefix=/application/nginx-1.6.3 --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module
[[email protected] nginx-1.6.3]# make && make install
[[email protected] nginx-1.6.3]# ln -s /application/nginx-1.6.3/ /application/nginx
[[email protected] nginx-1.6.3]# /application/nginx/sbin/nginx -t 檢查文法
[[email protected] 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 [email protected]: 3DQp3jeZlC!h
mysql -uroot -p
mysql> update mysql.user set authentication_string = password("[email protected]") 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
[[email protected] libiconv-1.14]
# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
[[email protected] tools]
# yum install zlib-devel libxml2-devel libjpeg-devel libiconv-devel -y
[[email protected] tools]
# yum install freetype-devel libpng-devel gd-devel curl-devel libxslt-devel -y
[[email protected] libiconv-1.14]
# yum -y install libmcrypt-devel mhash mhash-devel mcrypt libxslt-devel
[[email protected] tools]
# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
[[email protected] tools]
# tar xf libiconv-1.14.tar.gz
[[email protected] tools]
# cd libiconv-1.14
[[email protected] libiconv-1.14]
# ./configure --prefix=/usr/local/libiconv
[[email protected] libiconv-1.14]
# make && make install
[[email protected] tools]# wget http://cn2.php.net/distributions/php-5.6.24.tar.gz
[[email protected] tools]# tar xf php-5.6.24.tar.gz
[[email protected] tools]# cd php-5.6.24
[[email protected] 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
- 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
- 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
[[email protected] application]
# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/
[[email protected] application]
# touch ext/phar/phar.phar
[[email protected] 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 [email protected] identified by 'xxx';
Query OK, 0 rows affected, 1 warning (0.00 sec)
由于zabbix啟動腳本路徑預設指向的是/usr/local/sbin路徑,是以,需要提前建立軟連結
[[email protected] zabbix-3.4.9]# ln -s /application/zabbix-server/sbin/* /usr/local/sbin/
[[email protected] zabbix-3.4.9]# ln -s /application/zabbix-server/bin/* /usr/local/bin/
[r[email protected] zabbix-3.4.9]# mkdir /application/nginx/html/zabbix
[[email protected] zabbix-3.4.9]# cp -ar /server/tools/zabbix-3.4.9/frontends/php/* /application/nginx/html/zabbix/
[[email protected] zabbix-3.4.9]# cd /server/tools/zabbix-3.4.9/database/mysql/
[[email protected] 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
解決zabbix中文亂碼
[root fonts]# pwd
/application/nginx/html/zabbix/fonts
[[email protected] fonts]# ll
總用量 36264
-rw-r--r-- 1 1001 1001 756072 5月 9 17:57 DejaVuSans.ttf
-rw-r--r-- 1 root root 14602860 6月 11 2009 msyhbd.ttf
-rw-r--r-- 1 root root 21767952 6月 11 2009 msyh.ttf
[root fonts]# mv DejaVuSans.ttf /opt/
[root include]# pwd
/application/nginx/html/zabbix/include
[root include]# vim defines.inc.php
s/DejaVuSans/msyhbd/g 替換為新的字型
轉載于:https://www.cnblogs.com/hellojackyleon/p/9109188.html