centos6.5 yum 安装zabbix

前端之家收集整理的这篇文章主要介绍了centos6.5 yum 安装zabbix前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

关掉相关安全设置,要不出现一大堆乱七八糟的问题

service iptables stop

chkconfig iptables off

setenforce 0

sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config

卸载相关软件包(如果有的话),保持干净环境

yum remove -y MysqL* httpd* PHP* Nginx* zabbix*

安装软件包和依赖包

yum -y install wget gcc automake autoconf libtool make cmake bzip2 zlib-devel tree \

pam-devel vim-enhanced man ntpdate unzip telnet python perl perl-devel gcc-c++ zcat \

redhat-lsb tcpdump sysstat lsof git nfs-utils expect traceroute htop lrzsz pyMysqL\

MysqL-python libffi-devel libxml2 libxml2-devel libxslt-devel readline-devel \

libffi epel-release openssl-devel python-devel

安装msyql数据库

MysqL建议使用5.6版本,CentOS6默认为5.1,不建议使用,性能偏低。

rpm -ivh http://dev.MysqL.com/get/MysqL-community-release-el6-5.noarch.rpm

yum install MysqL-server -y #此过程会因为网路问题偏慢,可以去鲁两发

修改msyql配置参数

sed -i '/^socket/i\port = 3306' /etc/my.cnf

sed -i '/^socket/a\skip-external-locking\nkey_buffer_size = 256M\nmax_allowed_packet = 1M\ntable_open_cache = 256\nsort_buffer_size = 1M\nread_buffer_size = 1M\nread_rnd_buffer_size = 4M\nmyisam_sort_buffer_size = 64M\nthread_cache_size = 8\nquery_cache_size= 16M\nthread_concurrency = 4\ncharacter-set-server=utf8\ninnodb_file_per_table=1' /etc/my.cnf

[root@localhost ~]# egrep -v '^#|^$' /etc/my.cnf

[MysqLd]

datadir=/var/lib/MysqL

port = 3306

socket=/var/lib/MysqL/MysqL.sock

skip-external-locking

key_buffer_size = 256M

max_allowed_packet = 1M

table_open_cache = 256

sort_buffer_size = 1M

read_buffer_size = 1M

read_rnd_buffer_size = 4M

myisam_sort_buffer_size = 64M

thread_cache_size = 8

query_cache_size= 16M

thread_concurrency = 4

character-set-server=utf8

innodb_file_per_table=1

symbolic-links=0

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[MysqLd_safe]

log-error=/var/log/MysqLd.log

pid-file=/var/run/MysqLd/MysqLd.pid

启动MysqL

/etc/init.d/MysqLd start

创建zabbxi数据和用户

MysqL -e 'CREATE DATABASE `zabbix` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;'

MysqL -e "GRANT ALL PRIVILEGES on *.* to zabbix@'' IDENTIFIED BY 'zabbix';"

MysqL -e "flush privileges"

安装PHP5.6

rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm

yum install PHP56w PHP56w-MysqL PHP56w-gd PHP56w-imap \

PHP56w-ldap PHP56w-odbc PHP56w-pear PHP56w-xml PHP56w-xmlrpc \

PHP56w-mcrypt PHP56w-mbstring PHP56w-devel PHP56w-pecl-memcached \

PHP56w-common PHP56w-pdo PHP56w-cli PHP56w-pecl-memcache PHP56w-bcmath PHP56w-fpm

快速设置

sed -i "s/post_max_size.*/post_max_size=16M/" /etc/PHP.ini

sed -i "s/max_execution_time.*/max_execution_time=300/" /etc/PHP.ini

sed -i "s/max_input_time.*/max_input_time=300/" /etc/PHP.ini

sed -i "s#;date.timezone.*#date.timezone=Asia/Shanghai#" /etc/PHP.ini

sed -i "s/apache/Nginx/g" /etc/PHP-fpm.d/www.conf

sed -i "s#;always_populate_raw_post_data = -1#always_populate_raw_post_data = -1#" /etc/PHP.ini

chown Nginx.Nginx -R /var/lib/PHP

升级libcurl(zabbix3.0以上的版本说需要curl版本最低7.20.0l支持SMTP的验证,自行查看下版本号)

rpm -ivh http://mirror.city-fan.org/ftp/contrib/yum-repo/city-fan.org-release-1-13.rhel6.noarch.rpm

yum upgrade libcurl

升级完成后可以卸载此yum

rpm -e city-fan.org-release

常见问题:

国内很多线路都不能访问city-fan.org的,一般情况下会下载升级,当遇到这样的问题时,你可以直接修改本地主机解析,方法如下:

编辑:/etc/hosts 文件,在尾部添加

212.56.100.58 www.city-fan.org

212.56.100.58 mirror.city-fan.org

[root@localhost ~]# curl -V

curl 7.51.0 (x86_64-redhat-linux-gnu) libcurl/7.51.0 OpenSSL/1.0.1e zlib/1.2.3 c-ares/1.12.0 libssh2/1.8.0 nghttp2/1.6.0

Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp

Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz HTTP2 UnixSockets Metalink

安装 zabbix

添加用户

groupadd zabbix

安装yum源和 zabbix

rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm

yum install -y zabbix-server-MysqL zabbix-web-MysqL zabbix-get zabbix-agent \

zabbix-java-gateway zabbix-proxy-MysqL zabbix-sender

配置 zabbix

zabbix数据导入zabbix

zcat /usr/share/doc/zabbix-server-MysqL-3.0.5/create.sql.gz |MysqL -uzabbix -pzabbix zabbix

快速设置

sed -i '/DBPassword=/a\DBPassword=zabbix' /etc/zabbix/zabbix_server.conf

sed -i '/DBHost=/a\DBHost=' /etc/zabbix/zabbix_server.conf

[root@localhost ~]# egrep -v '^$|^#' /etc/zabbix/zabbix_server.conf

LogFile=/var/log/zabbix/zabbix_server.log

LogFileSize=0

PidFile=/var/run/zabbix/zabbix_server.pid

DBHost=localhost

DBName=zabbix

DBUser=zabbix

DBPassword=zabbix

SNMPTrapperFile=/var/log/snmptrap/snmptrap.log

Timeout=4

AlertScriptsPath=/usr/lib/zabbix/alertscripts

ExternalScripts=/usr/lib/zabbix/externalscripts

LogSlowQueries=3000

安装Nginx

useradd Nginx

yum install -y Nginx

root@localhost ~]# sed -i "/worker_processes/cworker_processes $( grep "processor" /proc/cpuinfo| wc -l );" /etc/Nginx/Nginx.conf

[root@localhost ~]# cat> /etc/Nginx/conf.d/zabbix.conf <<'EOF'

server{

listen 80;

server_name _;

index index.PHP;

root /data/web/zabbix;

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {

expires 30d;

}

location ~* \.PHP$ {

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.PHP;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

EOF

修改配置文件

设置权限,并把zabbixPHP文件放到web目录

chown Nginx.Nginx -R /etc/zabbix/

cp -r /usr/share/zabbix/ /data/web/zabbix

root@localhost ~]# cd /etc/Nginx/conf.d/

root@localhost conf.d]# rm -f virtual.conf

root@localhost conf.d]# mv default.conf default.conf.bak

root@localhost conf.d]# /etc/init.d/Nginx restart

Stopping Nginx: [ OK ]

Starting Nginx: [ OK ]

启动并访问

/etc/init.d/Nginx start

/etc/init.d/PHP-fpm start

/etc/init.d/zabbix-server start

/etc/init.d/zabbix-agent restart

chkconfig Nginx on

chkconfig PHP-fpm on

chkconfig MysqL on

chkconfig zabbix-agent on

chkconfig zabbix-server on

原文链接:https://www.f2er.com/centos/379714.html

猜你在找的CentOS相关文章