huangfen2002 发表于 2019-1-18 10:05:56

Centos6.8部署Zabbix

  一、安装Nginx

  # yum -y install pcre-devel pcre openssl openssl-devel zlib zlib-devel gcc gcc-c++
  # groupadd nginx && useradd -g nginx -s /sbin/nologin nginx
  # tar xf nginx-1.10.2.tar.gz -C /usr/src/
  # cd /usr/src/nginx-1.10.2/
  # ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module
  # make && make install
  # ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
  # cd /usr/local/nginx/conf/
  # cp nginx.conf nginx.conf.bak
  修改nginx.conf配置文件
http://s1.运维网.com/images/20180206/1517896968240769.png
  # nginx -t
  nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
  nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
  # nginx
  # ps -ef | grep nginx
  root       9908      10 14:03 ?      00:00:00 nginx: master process nginx
  nginx      9909   99080 14:03 ?      00:00:00 nginx: worker process
  root       9911   73890 14:03 pts/1    00:00:00 grep nginx
  # netstat -anpt | grep nginx
  tcp      0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      9908/nginx
  下一步进行测试

http://s1.运维网.com/images/20180206/1517897137954161.png
  二、安装MySQL
  # yum -y install tree nmap lrzsz dos2unix cmake bison ncurses ncurses-devel
  # groupadd mysql && useradd -g mysql -s /sbin/nologin mysql
  # mkdir /usr/local/mysqldb
  # tar xf mysql-5.6.34.tar.gz -C /usr/src/
  # cd /usr/src/mysql-5.6.34/
  # cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/usr/local/mysqldb -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1
  # make && make install
  # chown -R mysql:mysql /usr/local/mysql
  # chown -R mysql:mysql /usr/local/mysqldb/
  # cd /usr/local/mysql
  # scripts/mysql_install_db --user=mysql -datadir=/usr/local/mysqldb/
  # cp support-files/my-default.cnf /etc/my.cnf
  修改my.cnf配置文件

http://s1.运维网.com/images/20180206/1517899072293673.png
  # cp support-files/mysql.server /etc/init.d/mysqld
  # echo "PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH" >> /etc/profile
  # echo "export PATH" >> /etc/profile
  # source /etc/profile
  # chkconfig --add mysqld
  # chkconfig --level 35mysqld on
  # service mysqld start
  三、安装PHP
  # yum-y install epel-release
  # yum -y update
  # yum -y install zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel libxslt-devel libmcrypt-devel mhash mcrypt
  # tar xf libiconv-1.14.tar.gz -C /usr/src/
  # cd /usr/src/libiconv-1.14/
  # ./configure --prefix=/usr/local/libiconv && make && make install
  # tar xf php-5.6.22.tar.gz -C /usr/src/
  # cd /usr/src/php-5.6.22/
  # ./configure --prefix=/usr/local/php --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --with-gettext --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-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=nginx --with-fpm-group=nginx --enable-ftp --enable-opcache=no --with-mysql=/usr/local/mysql/ --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd
  # ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/
  # cd ext/phar/phar/
  # cp phar.php ./phar.phar
  # cd /usr/src/php-5.6.22/
  # make && make install
  # cp php.ini-development /usr/local/php/lib/php.ini
  # cd /usr/local/php/etc/
  # cp php-fpm.conf.default php-fpm.conf
  # vim /usr/local/php/lib/php.ini
  372 max_execution_time = 300
  382 max_input_time = 300
  393 memory_limit = 128M
  660 post_max_size = 30M
  925 date.timezone = Asia/Shanghai
  703 always_populate_raw_post_data = -1
  # /usr/local/php/sbin/php-fpm
  # netstat -anpt | grep php-fpm
  tcp      0      0 127.0.0.1:9000            0.0.0.0:*                   LISTEN      28545/php-fpm
  四、安装zabbix
  # yum -y install mysql-devel libxml2-devel net-snmp-devel libcurl-devel
  # useradd -M -s /sbin/nologin zabbix
  # mkdir /var/log/zabbix
  # chown zabbix.zabbix /var/log/zabbix/
  # tar xf zabbix-3.0.3.tar.gz -C /usr/src/
  # cd /usr/src/zabbix-3.0.3/
  # ./configure --prefix=/usr/local/ --enable-server --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2 --sysconfdir=/etc/zabbix--enable-agent
  # make && make install
  # cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
  # cd /etc/zabbix/
  # cp zabbix_server.conf zabbix_server.conf.bak
  # vim zabbix_server.conf
  38 LogFile=/var/log/zabbix/zabbix_server.log
  77 DBHost=localhos
  87 DBName=zabbix
  103 DBUser=zabbix
  111 DBPassword=zabbix
  118 DBSocket=/var/lib/mysql/mysql.sock
  126 DBPort=3306
  # cp zabbix_agentd.conf zabbix_agentd.conf.bak
  # vim zabbix_agentd.conf
  30 LogFile=/var/log/zabbix/zabbix_agentd.log
  91 Server=192.168.200.101
  132 ServerActive=192.168.200.201:10051
  262 Include=/etc/zabbix/zabbix_agentd.conf.d/
  278 UnsafeUserParameters=1
  # cd /usr/src/zabbix-3.0.3/
  # mysql -uroot -p123456
  mysql> create database zabbix character set utf8;
  Query OK, 1 row affected (0.02 sec)
  mysql> grant all on zabbix.* to zabbix@localhost identified by 'zabbix';
  Query OK, 0 rows affected (0.01 sec)
  mysql> flush privileges;
  Query OK, 0 rows affected (0.01 sec)
  mysql> exit
  # mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
  # mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql
  # mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql
  # cp -rf frontends/php/ /usr/local/nginx/html/zabbix
  # chown -R nginx.nginx /usr/local/nginx/html/zabbix/
  # cd /usr/local/nginx/html/zabbix/
  # mv setup.php setup.php.lock
  # chmod 600 setup.php.lock
  # /etc/init.d/zabbix_server start
  Starting zabbix_server:                                    [确定]
  # /etc/init.d/zabbix_agentd start
  Starting zabbix_agentd:                                    [确定]
  # netstat -anpt | grep zabbix
  tcp      0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      36910/zabbix_agentd
  tcp      0      0 0.0.0.0:10051               0.0.0.0:*                   LISTEN      36849/zabbix_server
  下面进入浏览器界面进行初始化配置

http://s1.运维网.com/images/20180207/1517974454356639.png
http://s1.运维网.com/images/20180207/1517974505976925.png
  填写数据库地址、用户名、密码信息

http://s1.运维网.com/images/20180207/1517974570558790.png
http://s1.运维网.com/images/20180207/1517974871294651.png
  以上基本的初始化完成了,看一下zabbix的主界面,因为默认界面是英文的,需要手工设置一下
http://s1.运维网.com/images/20180207/1517975518706110.png
  更改语言设置项,完成后点击update即可
http://s1.运维网.com/images/20180207/1517975598271260.png
  但是还有一些小瑕疵,就是现实面板上有乱码
http://s1.运维网.com/images/20180207/1517975794815881.png
  解决办法:在Windows中找一个喜欢的字体(控制面板à外观和个性化à字体),把字体上传到服务器的/usr/local/nginx/html/zabbix/fonts目录下
  

  # mv SIMSUN.TTC SIMSUN.ttf
  zabbix fonts]# cd ../include/
  zabbix include]# vim defines.inc.php
  define('ZBX_GRAPH_FONT_NAME',         'SIMSUN'); // font file name
  define('ZBX_FONT_NAME', 'SIMSUN');
  zabbix include]#/etc/init.d/zabbix_server restart
  http://s1.运维网.com/images/20180207/1517981623745624.png



页: [1]
查看完整版本: Centos6.8部署Zabbix