(推荐使用CentOS6.7 64位系统)
安装yum的axel插件,使yum支持多线程下载:
rpm -ivh http://pkgs.repoforge.org/axel/axel-2.4-1.el6.rf.x86_64.rpm
cp axelget.conf /etc/yum/pluginconf.d/
cp axelget.py /usr/lib/yum-plugins/
下载163 yum源:
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo -O CentOS-Base.repo
cp -p /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
mv -f CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo
安装epel yum源:
rpm -ivh http://mirrors.sohu.com/fedora-e ... ease-6-8.noarch.rpm
sed -i 's/^mirrorlist=https/mirrorlist=http/' /etc/yum.repos.d/epel.repo
nginx的yum源:
cat > /etc/yum.repos.d/nginx.repo << 'EOF'
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
enabled=1
gpgcheck=0
EOF
安装Mysql的yum源:
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
安装zabbix的yum源:
rpm -ivh http://repo.zabbix.com/zabbix/2. ... .2-1.el6.noarch.rpm
关闭selinux:
setenforce 0
sed -i '/^SELINUX=/c\SELINUX=disabled' /etc/selinux/config
安装nginx、php、mysql、zabbix:
yum clean all
yum install nginx php-fpm php-soap php-bcmath php-xml php-opcache php-gd php-mcrypt php-pdo php-mysql php-mbstring php-xmlrpc
yum install mysql mysql-server mysql-devel
yum install zabbix-server-mysql zabbix-server zabbix-agent zabbix-get zabbix-sender
修改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 '/^;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/apache/nginx/g' $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
启动php-fpm:
service php-fpm start
修改/etc/nginx/nginx.conf
user nginx;
worker_processes 4;
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
部署zabbix前端代码:
wget http://nchc.dl.sourceforge.net/p ... abbix-2.2.10.tar.gz -O zabbix-2.2.10.tar.gz
tar xvzf zabbix-2.2.10.tar.gz
mkdir -p /data/www/zabbix
\cp -r zabbix-2.2.10/frontends/php/* /data/www/zabbix
chown -R nginx. /data/www
chmod 755 /data
启动nginx:
nginx -t && service nginx start
设置http认证:
yum -y install httpd-tools
htpasswd -cdb jzcec.pass jzcec 7BXyj1fG
chmod 644 jzcec.pass
cp jzcec.pass /etc/nginx/
在/etc/nginx/conf.d/zabbix.conf中server里加入下面两行:
auth_basic "Authorized users only";
auth_basic_user_file jzcec.pass;
重启nginx:
service nginx restart
启动前先修改/etc/my.cnf优化mysql
启动mysql:
service mysqld start
设置mysql root密码:
/usr/bin/mysqladmin -u root password 'zabbix@jzcec'
创建zabbix数据库和用户:
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
mysql> exit
初始化zabbix数据库:
cd /usr/share/doc/zabbix-server-mysql-2.2.10/create/
mysql -uzabbix -pzabbix zabbix < schema.sql
mysql -uzabbix -pzabbix zabbix < images.sql
mysql -uzabbix -pzabbix zabbix < data.sql
配置zabbix:
vi /etc/zabbix/zabbix_server.conf
vi /etc/zabbix/zabbix_agentd.conf
mkdir -p /etc/zabbix/externalscripts
mkdir -p /etc/zabbix/alertscripts
chown -R zabbix.zabbix /etc/zabbix
启动zabbix server和agent:
service zabbix-server start
service zabbix-agent start
安装完毕,最后访问Zabbix:
http://zabbix-frontend-ip/
设置开机启动:
chkconfig mysqld on
chkconfig php-fpm on
chkconfig nginx on
chkconfig zabbix-server on
chkconfig zabbix-agent on
做mysql partition(表分区),导入表分区的存储过程:
https://www.zabbix.org/wiki/Docs/howto/mysql_partition
调用方法:
mysql -uzabbix -pzabbix zabbix -e "CALL partition_maintenance_all('zabbix');"
设置到cron定时任务,每天执行。
部署zabbix zatree插件:
https://github.com/spide4k/zatree
官网LAMP部署文档:
https://www.zabbix.com/documenta ... stall_from_packages
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com