操作系统版本:CentOS release 6.9 官网文档:https://www.zabbix.com/documentation/4.0/manual/installation/install 一、升级libcurl到7.57 yum install openssl-devel -y yum install gcc make -y mkdir -p /data/soft cd /data/soft wg
操作系统版本:CentOS release 6.9
官网文档:https://www.zabbix.com/documentation/4.0/manual/installation/install
一、升级libcurl到7.57
yum install openssl-devel -y yum install gcc make -y mkdir -p /data/soft cd /data/soft wget https://curl.se/download/curl-7.57.0.tar.gz tar xvzf curl-7.57.0.tar.gz cd curl-7.57.0 ./configure make make install echo "/usr/local/lib" >> /etc/ld.so.conf二、php5.6安装
rpm -ivh https://mirror.webtatic.com/yum/el6/latest.rpm yum -y install php56w php56w-common php56w-fpm php56w-gd php56w-bcmath php56w-xml php56w-xmlrpc php56w-soap php56w-mbstring php56w-mcrypt php56w-ldap php56w-mysql php56w-pdo php56w-opcache php -v php-fpm -v三、Mysql 5.7 安装
可以选择yum安装或者手动安装:
1、yum 安装
rpm -ivh https://repo.mysql.com//mysql57-community-release-el6-11.noarch.rpm yum makecache yum install mysql mysql-server mysql-devel -y2、rpm包安装
rpm包下载地址:https://dev.mysql.com/downloads/mysql/
tar xvf mysql-5.7.20-1.el6.x86_64.rpm-bundle.tar rpm -Uvh mysql-community-common-*.rpm mysql-community-server-*.rpm mysql-community-client-*.rpm mysql-community-libs-*.rpm mysql-community-devel-*.rpm四、安装其他依赖软件
1、fping
yum install fping -y2、net-snmp
yum install net-snmp net-snmp-devel net-snmp-utils -y3、OpenIPMI
yum install OpenIPMI OpenIPMI-devel ipmitool -y4、libxml2
yum install libxml2-devel -y5、java(>=1.6,openjdk)
yum -y install java-1.7.0-openjdk java-1.7.0-openjdk-devel vi /etc/profile export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk.x86_64 export CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib export PATH=$PATH:$JAVA_HOME/bin source /etc/profile java -version6、其他
如果服务器是新服务器,可能需要安装以下依赖:
yum -y install libevent-devel yum -y install pcre*五、编译安装Zabbix 4.0 LTS
1、创建zabbix用户、用户组
groupadd zabbix useradd -g zabbix -s /sbin/nologin zabbix2、下载zabbix源码包:
https://cdn.zabbix.com/zabbix/sources/stable/4.0/zabbix-4.0.32.tar.gz
3、开始编译安装:
cd /data/soft tar xvzf zabbix-4.0.32.tar.gz cd zabbix-4.0.32 mkdir /opt/zabbix-4.0.32 ./configure --prefix=/opt/zabbix-4.0.32 --enable-server --enable-agent --enable-java --with-mysql --with-openipmi --with-net-snmp --with-libcurl --with-libxml2 make make install4、安装后处理:
cp misc/init.d/fedora/core5/zabbix_* /etc/init.d/ chmod +x /etc/init.d/zabbix_* \cp -r /opt/zabbix-4.0.32/share/* /usr/local/share/ ln -s /opt/zabbix-4.0.32/sbin/zabbix_server /usr/local/sbin/zabbix_server ln -s /opt/zabbix-4.0.32/sbin/zabbix_agentd /usr/local/sbin/zabbix_agentd5、安装目录赋权:
chown -R zabbix. /opt/zabbix-4.0.32六、配置web服务(nginx)
yum安装nginx:
yum install nginx -y部署zabbix前端代码:
mkdir -p /data/www/zabbix-4.0.32 ln -s /data/www/zabbix-4.0.32 /data/www/zabbix \cp -r frontends/php/* /data/www/zabbix chown -R nginx. /data/www chmod 755 /data修改php配置:
PHP_INI="/etc/php.ini" FPM_CONF="/etc/php-fpm.d/www.conf" sed -i '/^;default_charset/cdefault_charset = "utf-8"' $PHP_INI sed -i '/^expose_php/cexpose_php = Off' $PHP_INI sed -i '/^max_execution_time/cmax_execution_time = 600' $PHP_INI sed -i '/^max_input_time/cmax_input_time = 600' $PHP_INI sed -i '/^memory_limit/cmemory_limit = 256M' $PHP_INI sed -i '/^post_max_size/cpost_max_size = 32M' $PHP_INI sed -i '/^upload_max_filesize/cupload_max_filesize = 300M' $PHP_INI sed -i '/^max_file_uploads/cmax_file_uploads = 30' $PHP_INI sed -i '/^;always_populate_raw_post_data/calways_populate_raw_post_data = -1' $PHP_INI sed -i '/^;date.timezone/cdate.timezone = "Asia/Shanghai"' $PHP_INI sed -i '/^disable_functions/cdisable_functions = exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,dl,popen,show_source syslog,readlink,symlink,popepassthru,stream_socket_server' $PHP_INI sed -i 's/user = apache/user = nginx/' $FPM_CONF sed -i 's/group = apache/group = nginx/' $FPM_CONF sed -i '/^pm = dynamic/cpm = static' $FPM_CONF sed -i '/^pm.max_children/cpm.max_children = 10' $FPM_CONF sed -i '/^;pm.status_path/cpm.status_path = /php-status' $FPM_CONF sed -i '/^;request_terminate_timeout/crequest_terminate_timeout=600' $FPM_CONF sed -i '/^;request_slowlog_timeout/crequest_slowlog_timeout=3' $FPM_CONF setfacl -R -m u:nginx:rwx /var/lib/php启动php-fpm:
service php-fpm start修改/etc/nginx/nginx.conf
user nginx; worker_processes auto; error_log /data/logs/nginx_error.log crit; worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; } http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; proxy_buffer_size 16k; proxy_buffers 4 64k; proxy_busy_buffers_size 128k; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 256k; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; server_tokens off; log_format access '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for '; access_log /data/logs/access.log access; reset_timedout_connection on; include conf.d/*.conf; }创建/etc/nginx/conf.d/zabbix.conf
server { listen 80; server_name _; location / { root /data/www/zabbix; index index.php; } location ~ \.php$ { root /data/www/zabbix; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.old mkdir -p /data/logs chown -R nginx. /data/logs usermod -aG zabbix nginx启动nginx:
nginx -t && service nginx start七、数据库初始化
service mysqld start获取mysql临时密码,用于首次登陆MySQL:
grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}'初始化zabbix数据库:
mysql -uroot -p mysql> set password=password('Admin@#123'); mysql> create database zabbix character set utf8 collate utf8_bin; mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'Zabbix@#123'; mysql> quit; cd database/mysql mysql -uzabbix -p'Zabbix@#123' zabbix < schema.sql mysql -uzabbix -p'Zabbix@#123' zabbix < images.sql mysql -uzabbix -p'Zabbix@#123' zabbix < data.sql八、修改zabbix配置文件
1、创建zabbix日志目录
mkdir /var/log/zabbix chown zabbix. /var/log/zabbix/2、修改zabbix_server.conf
cd /opt/zabbix-4.0.32/etc/ vi zabbix_server.conf LogFile=/var/log/zabbix/zabbix_server.log LogFileSize=100 DBName=zabbix DBUser=zabbix DBPassword=Zabbix@#123 DBSocket=/var/lib/mysql/mysql.sock StartPollers=15 JavaGateway=127.0.0.1 JavaGatewayPort=10052 StartJavaPollers=5 StartSNMPTrapper=1 HousekeepingFrequency=1 Timeout=30 AlertScriptsPath=/opt/zabbix-4.0.32/share/zabbix/alertscripts ExternalScripts=/opt/zabbix-4.0.32/share/zabbix/externalscripts LogSlowQueries=3000 Include=/opt/zabbix-4.0.32/etc/zabbix_server.conf.d/3、修改zabbix_agentd.conf
vi zabbix_agentd.conf LogFile=/var/log/zabbix/zabbix_agentd.log Server=127.0.0.1 ServerActive=127.0.0.1 Hostname=Zabbix server Timeout=30 Include=/opt/zabbix-4.0.32/etc/zabbix_agentd.conf.d/4、zabbix java-gateway
cd /opt/zabbix-4.0.32/sbin/zabbix_java sed -i 's/kill/kill -9/' shutdown.sh九、启动服务
启动zabbix:
service zabbix_server start service zabbix_agentd start设置开机启动:
chkconfig mysqld on chkconfig php-fpm on chkconfig nginx on chkconfig zabbix_server on chkconfig zabbix_agentd on启动zabbix java-gateway:
cd /opt/zabbix-4.0.32/sbin/zabbix_java ./startup.sh十、安装完毕,访问zabbix frontend
http://zabbix前端IP/
【本文由:防ddos攻击 http://www.558idc.com/gfcdn.html提供,感恩】