操作环境:
centos:6.8,64 位
jdk:1.7
mysql:5.5.49
安装过程如下:
[root@tbwy14 tools]# 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
[root@tbwy14 tools]# useradd nginx -s /sbin/nologin -M
[root@tbwy14 tools]# wget http://nginx.org/download/nginx-1.9.15.tar.gz
[root@tbwy14 tools]# tar xvf nginx-1.9.15.tar.gz
[root@tbwy14 tools]# cd nginx-1.9.15
[root@tbwy14 nginx-1.9.15]#
./configure --prefix=/usr/local/product/nginx1.9.15 --user=www --group=www --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre
[root@tbwy14 nginx-1.9.15]# make
[root@tbwy14 nginx-1.9.15]# make install
[root@tbwy14 nginx-1.9.15]# ln -s /usr/local/product/nginx1.9.15 /usr/local/nginx ==> 创建软链接
[root@tbwy14 nginx-1.9.15]# cd ..
[root@tbwy14 tools]# wget http://cn2.php.net/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
错误:
make: *** [sapi/cli/php] Error 1
make test
make install
解决方案:
使用:make ZEND_EXTRA_LIBS='-liconv'
或者: vim Makefile
添加:-lcrypt
[root@tbwy14 php-5.5.35]# ln -s /usr/local/product/php-5.5.35 /usr/local/php
[root@tbwy14 php-5.5.35]# cp php.ini-production /usr/local/php/etc/php.ini
[root@tbwy14 php-5.5.35]# cd /usr/local/php/etc/
[root@tbwy14 etc]# cp php-fpm.conf.default php-fpm.conf
[root@tbwy14 etc]# vim /usr/local/php/etc/php.ini
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
date.timezone = PRC
groupadd mysql
mkdir -pv /data/mysql
useradd -r -g mysql -d /data/mysql -s /sbin/nologin mysql
chown -R mysql.mysql /data/mysql
安装 cmake 及依赖:
yum install cmake gcc* ncurses-devel -y
下载 MySQL 安装包:
wget http://dev.mysql.com/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
拷贝 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
初始化 MySQL:
cd /usr/local/mysql/scripts
./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/
修改 MySQL 配置文件 my.cnf 中数据目录:
vim /data/mysql/my.cnf
datadir=/data/mysql/
启动 MySQL:
[root@zabbix ~]# /etc/init.d/mysqld start
Starting MySQL... SUCCESS!
[root@tbwy14 scripts]# mysql -u root -p
Enter password: 空
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.49-log Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> 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.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| 3306 |
| mysql |
| performance_schema |
| test |
| zabbix |
+--------------------+
6 rows in set (0.00 sec)
mysql> quit
[root@tbwy14 scripts]# ln -s /tmp/mysql.sock /var/lib/mysql/
[root@tbwy14 scripts]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.49-log Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> quit
[root@tbwy14 scripts]# mysqladmin -uroot password "zabbix"
[root@tbwy14 scripts]# cd /tools/
[root@tbwy14 tools]# tar zxf zabbix-3.0.3.tar.gz && cd zabbix-3.0.3
[root@tbwy14 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
故障:
checking for mysql_config... no
configure: error: MySQL library not found
解决:
yum install mysql-devel -y
故障:
checking for net-snmp-config... no
configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config
解决:
yum install net-snmp-devel -y
[root@tbwy14 zabbix-3.0.3]# yum install net-snmp-devel -y
[root@tbwy14 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
[root@tbwy14 zabbix-3.0.3]# make && make install
创建 zabbix 用户:
[root@zabbix zabbix-3.0.3]# groupadd zabbix
[root@zabbix zabbix-3.0.3]# useradd zabbix -s /sbin/nologin -M -g
zabbix server 需要导入 3 个 sql 文件:
[root@zabbix zabbix-3.0.3]# mysql -uroot -pzabbix zabbix < database/mysql/schema.sql
[root@zabbix zabbix-3.0.3]# mysql -uroot -pzabbix zabbix < database/mysql/images.sql
[root@zabbix zabbix-3.0.3]# mysql -uroot -pzabbix zabbix < database/mysql/data.sql
[root@zabbix zabbix-3.0.3]# pwd
/root/zabbix-3.0.3
zabbix 管理网站配置(nginx):
创建项目目录:
[root@zabbix zabbix-3.0.3]# mkdir /data/web/zabbix.lifec.com -p
[root@zabbix zabbix-3.0.3]# mkdir /data/logs/zabbix -p
将前端文件拷贝到项目目录下:
[root@zabbix zabbix-3.0.3]# cp -rp frontends/php/* /data/web/zabbix.lifec.com/
编辑 nginx 虚拟主机:
[root@zabbix conf]# mkdir extra
[root@zabbix conf]# cd extra/
[root@zabbix extra]# vim zabbix.conf
server {
listen 8027;
server_name zabbix.lifec.com;
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;
}
}
编辑 nginx.conf 配置文件:
[root@zabbix conf]# cat nginx.conf
user 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;
}
编辑 zabbix_server.conf 文件:
[root@zabbix etc]# pwd
/usr/local/zabbix-3.0.2/etc
LogFile=/tmp/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
启动服务
启动 nginx:
[root@zabbix conf]# /usr/local/nginx/sbin/nginx
启动 PHP:
[root@zabbix conf]# /usr/local/php/sbin/php-fpm
启动 zabbix server:
[root@zabbix conf]# /usr/local/zabbix-3.0.3/sbin/zabbix_server
如果启动的时候报错:
[root@zabbix ~]# /usr/local/zabbix-3.0.3/sbin/zabbix_server
/usr/local/zabbix-3.0.2/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
[root@zabbix ~]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/
[root@tbwy14 etc]# /usr/local/zabbix-3.0.3/sbin/zabbix_server
zabbix_server [9640]: user zabbix does not exist
zabbix_server [9640]: cannot run as root!
解决方案:
[root@servere sbin]# groupadd zabbix -g 686
[root@servere sbin]# useradd zabbix -u 686 -g zabbix -s /sbin/nologin
[root@tbwy14 etc]# /usr/local/zabbix-3.0.3/sbin/zabbix_server
添加/etc/hosts 文件:
192.168.119.140 zabbix.lifec.com
查看服务端口:
[root@zabbix conf]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1029/sshd
tcp 0 0 0.0.0.0:8027 0.0.0.0:* LISTEN 3730/nginx
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 3743/zabbix_server
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 3736/php-fpm
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 24922/mysqld
tcp 0 0 :::22 :::* LISTEN 1029/sshd
udp 0 0 0.0.0.0:68 0.0.0.0:* 880/dhclient
将服务加入开机自启动:
[root@zabbix ~]# echo "/usr/local/nginx/sbin/nginx" >>/etc/rc.local
[root@zabbix ~]# echo "/usr/local/php/sbin/php-fpm" >>/etc/rc.local
[root@zabbix ~]# echo "/etc/init.d/mysqld start" >>/etc/rc.local
[root@zabbix ~]# echo "/usr/local/zabbix-3.0.3/sbin/zabbix_server" >>/etc/rc.local
http://192.168.0.26:8027/setup.php
登录 Web
用户名:Admin
密码:zabbix
图形字体新增:
C:\Windows\Fonts 将选择的字体上传到 Linux 服务器的 zabbix 的 fonts 目录:/data/web/zabbix.lifec.com/fonts
并修改以下配置:
vim /data/web/zabbix.lifec.com/include/defines.inc.php
define('ZBX_GRAPH_FONT_NAME', 'DejaVuSans'); // font file name
define('ZBX_GRAPH_FONT_NAME', 'simsun'); // font file name ==> 此行为新增行;
define('ZBX_FONT_NAME', 'DejaVuSans');
define('ZBX_FONT_NAME', 'simsun'); ==> 此行为新增行;
重启服务即可。
[root@tbwy14 fonts]# vim /data/web/zabbix.lifec.com/include/defines.inc.php
define('ZBX_GRAPH_FONT_NAME', 'simkai'); // font file name ==> 此行为新增行;
define('ZBX_FONT_NAME', 'simkai'); ==> 此行为新增行;
[root@tbwy14 fonts]#
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于