Centos 6.8 x86_64平台 LNMP+zabbix
1安装php7.0
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm yum install -y php70w php70w-bcmath php70w-common php70w-cli php70w-mysql php70w-pdo php70w-gd php70w-fpm php70w-intl php70w-mbstring php70w-mcrypt php70w-xml php70w-xmlrpc php70w-opcache php70w-ldap php70w-pearsed -i 's/post_max_size = 8M/post_max_size = 16M/g' /etc/php.ini
sed -i 's/max_input_time = 60/max_input_time = 300/g' /etc/php.ini sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /etc/php.ini sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php.ini sed -i 's/;date.timezone =/date.timezone = PRC/g' /etc/php.iniservice php-fpm start
2,nginx的安装(当前版本1.12.1)
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm yum install -y nginx3,安装mysql5.6.37
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
yum install -y mysql-community-server mysql-community-devel
mysql的基础配置(根据系统硬件配置)my.cnf
[client] port = 3306 default-character-set=utf8[mysqld]
port = 3306 skip-name-resolve character-set-server=utf8 skip-external-locking max_connections=1000 max_connect_errors=10 default-storage-engine=INNODB innodb_log_file_size = 128M innodb_log_buffer_size = 8M innodb_flush_log_at_trx_commit = 2 innodb_lock_wait_timeout = 50 innodb_flush_method=O_DIRECTdefault-time-zone = '+8:00'
event_scheduler=ON open_files_limit=51200service mysqld start
mysql_secure_installation
4,nginx和php的融合
mkdir -p /var/www/html chown -R nginx:nginx /var/www/html vi /etc/nginx/conf.d/default.conf #location / { root /var/www/html; index index.php index.html index.htm; #} location ~ \.php$ { # root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcig_read_timeout 120; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }service nginx start
echo '<?php phpinfo(); ?>' > /var/www/html/index.php
http://IP检验lnmp安装成功5,系统内核参数调整(针对nginx和php)
cat >> /etc/security/limits.conf<<-EOF * soft nofile 65535 * hard nofile 65535 EOF cat >> /etc/sysctl.conf<<-EOF net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_fin_timeout = 10 net.ipv4.tcp_keepalive_time = 30 net.ipv4.ip_local_port_range = 1024 65000 net.ipv4.tcp_max_syn_backlog = 8192 net.ipv4.tcp_max_tw_buckets = 8000 net.core.somaxconn = 262144 net.ipv4.tcp_keepalive_probes = 5 net.ipv4.tcp_keepalive_intvl = 20 net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.ipv4.tcp_rmem = 4096 87380 16777216 net.ipv4.tcp_wmem = 4096 65536 16777216 net.core.netdev_max_backlog = 32768 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_synack_retries = 2 net.ipv4.tcp_syn_retries = 2 net.ipv4.tcp_retries2 = 5 net.ipv4.tcp_mem = 41943040 73400320 94371840 net.ipv4.tcp_max_orphans = 3276800 fs.file-max = 1300000kernel.printk_ratelimit = 30
kernel.printk_ratelimit_burst = 200 EOF sysctl -p使生效 6,安装zabbix server zabbix只会以普通用户运行,如果root环境下运行,zabbix会主动尝试以zabbix身份运行,若系统没有zabbix用户需建立 groupadd zabbix useradd -g zabbix zabbixyum install -y net-snmp-devel curl curl-devel libxml2-devel
wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.2.7/zabbix-3.2.7.tar.gz
tar zxvf zabbix-3.2.7.tar.gz cd zabbix-3.2.7 ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 make && make installmysql -u root -p
mysql>create database zabbix default charset utf8; mysql>use zabbix; mysql>source /root/zabbix-3.2.7/database/mysql/schema.sql mysql>source /root/zabbix-3.2.7/database/mysql/images.sql mysql>source /root/zabbix-3.2.7/database/mysql/data.sql mysql>grant all privileges on zabbix.* to 'zabbix'@'%' identified by 'uiop789'; mysql>flush privileges; mysql>exit vi /usr/local/etc/zabbix_server.conf DBName=zabbix DBUser=zabbix DBPassword=uiop789 DBPort=3306启动zabbix_server
/usr/local/sbin/zabbix_server -c /usr/local/etc/zabbix_server.conf 默认端口10051 netstat -anp | grep 10051 tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 23830/zabbix_server配置客户端(监控sever本身)
vi /usr/local/etc/zabbix_agentd.conf
Server=127.0.0.1 ServerActive=127.0.0.1 Hostname=Zabbix server启动客户端(客户端和服务端时间同步,设置crontab:0 0 * * * /usr/sbin/ntpdate -U 210.72.145.44)
/usr/local/sbin/zabbix_agentd -c /usr/local/etc/zabbix_agentd.conf
netstat -anp | grep 10050
关闭killall zabbix_agentd
拷贝前端文件
cp -rp frontens/php/* /var/www/html/zabbix/ chown nginx.nginx -R /var/www/html/zabbix/根据以上设置直接http://IP/zabbix,即可看到前端配置提示,当然你也可以自定义vhost后重启nginx
登录zabbix 默认用户名:Admin:zabbix
单机Admin图像在language里选择Chinese_simple,update后界面就变成中文的了,随后添加模板、添加主机、各种监控走起
cp /root/zabbix-3.2.7/misc/init.d/fedora/core5/* /etc/init.d/
service zabbix_server start/stop/restart service zbbbix_agentd start/stop/restartchkconfig --add zabbix_server
chkconfig --add zabbix_agentdchkconfig --list zabbix_server
chkconfig --list zabbix_agentdchkconfig --level 35 zabbix_server on
chkconfig --level 35 zabbix_agentd on客户端独立安装zabbix_agentd
wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.2.7/zabbix-3.2.7.tar.gz tar zxvf zabbix-3.2.7.tar.gz cd zabbix-3.2.7 ./configure --enable-agent make && make installvi /usr/local/etc/zabbix_agentd.conf
Server=zabbix_server IP
ServerActive=zabbix_server IP Hostname=uniq_name_clientgroupadd zabbix
useradd -g zabbix zabbix 启动:/usr/local/sbin/zabbix_agentd -c /usr/local/etc/zabbix_agentd.conf