Zabbix3.0 Install
#install epel-release adn zabbix requires package
yum install epel-release
yum install -y unzip vim lrzsz wget gcc gcc-c++ glibc glibc-devel automakelibaio libaio-devel
ntpdate pool.ntp.org
#install mysql
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
mkdir -p /opt/mysql/{data,log} && chown -R mysql.mysql /opt/mysql
chmod -R 755 /opt/mysql
vim /etc/my.cnf
[client]
port = 3306
socket=/opt/mysql/data/mysql.sock
[mysqld]
port = 3306
user=mysql
socket=/opt/mysql/data/mysql.sock
datadir=/opt/mysql/data
character_set_server=utf8
expire_logs_days = 15
explicit_defaults_for_timestamp=true
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
skip-name-resolve
wait_timeout = 28800
query_cache_type = 1
innodb_file_per_table = 1
innodb_file_format = barracuda
innodb_strict_mode = 1
relay-log = relay-bin
back_log = 512
max_connections = 1024
max_connect_errors = 512
table_open_cache = 512
max_allowed_packet = 1024M
binlog_cache_size = 16M
max_heap_table_size = 64M
read_buffer_size = 2M
read_rnd_buffer_size = 2M
sort_buffer_size = 2M
join_buffer_size = 4M
thread_cache_size = 16
thread_concurrency = 8
query_cache_size = 32M
query_cache_limit = 4M
ft_min_word_len = 4
default-storage-engine = innodb
thread_stack = 256K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 32M
log-bin=mysql-bin
binlog_format=mixed
log_slave_updates
slow_query_log
slow_query_log_file = mysql-slow.log
long_query_time = 2
server-id = 1921683123
key_buffer_size = 128M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 64M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
innodb_use_sys_malloc= on
innodb_buffer_pool_size = 3G
innodb_data_file_path = ibdata1:10M:autoextend
innodb_data_home_dir=/opt/mysql/data
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 1
sync_binlog=1
innodb_log_buffer_size = 16M
innodb_log_file_size = 256M
innodb_log_files_in_group = 5
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_monitor_enable = ‘%‘
performance_schema = ON
performance_schema_instrument = ‘%=on‘
[mysqldump]
quick
max_allowed_packet = 1024M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 65536
log-error=/opt/mysql/log/mysqld_run_error.log
pid-file=/opt/mysql/mysqld.pid
chown mysql.mysql /etc/my.cnf
chmod 755 /etc/my.cnf
rpm -ivh MySQL-server-5.6.26-1.el6.x86_64.rpm
rpm -ivh MySQL-shared-5.6.26-1.el6.x86_64.rpm
rpm -ivh MySQL-client-5.6.26-1.el6.x86_64.rpm
rpm -ivh MySQL-devel-5.6.26-1.el6.x86_64.rpm
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
mysql -u root mysql
UPDATE user SET Password=PASSWORD(‘123456‘) where USER=‘root‘;
flush privileges;
#Create zabbix database
mysql> create database zabbix character set utf8;
mysql> grant all privileges on zabbix.* to [email protected] identified by ‘zabbixpwd‘;
mysql> grant all privileges on zabbix.* to [email protected]"%" identified by "zabbixpwd" ;
mysql> flush privileges;
#Import zabbix db
mysql> source /root/zabbix-3.0.1/database/mysql/schema.sql;
mysql> source /root/zabbix-3.0.1/database/mysql/images.sql;
mysql> source /root/zabbix-3.0.1/database/mysql/data.sql;
#Zabbix and php requires package
yum install -y libpng-devel libpng freetype mcrypt libmcrypt-devel freetype-devel libvpx libvpx-devel openssl openssl-devel policycoreutils nasm nasm* libxml2 libxml2-devel libtiff libtiff-devel gd gd-devel libXpm libXpm-devel gmp gmp-devel bzip2 bzip2-devel libjpeg libjpeg-devel zlib zlib-devel fontconfig fontconfig-devel curl curl-devel mhash mhash-devel enca perl-libintl libcroco gettext gettext-devel t1lib t1lib-devel expat expat-devel systemtap-sdt-devellibicu-devel gd gd-devel enca libxslt libxslt-devel libc-client-devel openldap-devel unixODBC-devel postgresql-devel sqlite-devel aspell-devel net-snmp-devel pcre-devel db4-devel libc-client-devel
ln -s /usr/lib64/libexpat.* /usr/lib/
cp /usr/lib64/libmysqlclient.* /usr/lib/
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zvxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure
make && make install
ln -s /usr/local/lib/libiconv.so.2 /usr/lib64/
#Install PHP
./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d--with-mysqli=/usr/bin/mysql_config --with-ldap --with-mysql --with-mcrypt --with-freetype-dir --with-gettext --with-png-dir --with-openssl --with-jpeg-dir=/usr/lib --with-pcre-dir --with-pcre-regex --with-zlib --with-gd --with-vpx-dir --with-iconv --with-png-dir --with-t1lib --with-gettext --with-gmp --with-xpm-dir=/usr/lib --with-mhash --enable-pcntl --with-xmlrpc --with-libxml-dir --with-libexpat-dir --with-pdo-mysql --with-curl --enable-bcmath --enable-shmop --enable-sysvsem --enable-exif --enable-zip --enable-inline-optimization --enable-shmop --enable-sockets --enable-mbregex --enable-pcntl --enable-dba --enable-calendar --enable-libgcc --enable-fpm --enable-mbstring --enable-gd-native-ttf --enable-ftp --enable-gd-jis-conv --enable-sysvsem --enable-sysvshm--enable-inline-optimization --enable-zip --enable-soap --enable-opcache --disable-maintainer-zts --enable-static --enable-mbstring --enable-intl --enable-sysvmsg --enable-wddx --enable-dtrace --enable-sigchild --enable-phpdbg --enable-mod-charset --enable-re2c-cgoto --enable-embedded-mysqli=shared --enable-shared --enable-session
#Load php.ini
/usr/local/php/bin/php --ini
#Testing php-fpm.conf
/usr/local/php/sbin/php-fpm --test
#php.ini
always_populate_raw_post_data = -1
date.timezone = "Asia/Shanghai"
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
max_input_time = 300
#nginx install
./configure --prefix=/usr/local/nginx --with-http_ssl_module --user=nginx --group=nginx --with-threads --with-pcre=~/pcre-8.35 --with-zlib=~/zlib-1.2.8 --with-mail_ssl_module --with-mail --with-stream --with-http_ssl_module --with-http_dav_module --with-http_auth_request_module --with-http_gzip_static_module --with-http_sub_module --with-stream_ssl_module
#zabbix requires pakages
yum install -y net-snmp net-snmp-devel net-snmp-python net-snmp-utils net-snmp-perl snmptt libssh2-devel openssl-devel OpenIPMI-devel OpenIPMI libssh2 iksemel iksemel-devel fping vim wget libX11 libX11-devel openldap openldap-devel telnet ntpdate
#zabbix install
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-ldap --with-openssl --with-openipmi --with-ssh2
#zabbix client
./configure --prefix=/usr/local/zabbix --enable-agent
#Setting up Zabbix to receive SNMP traps
#http://www.zabbix.org/wiki/Start_with_SNMP_traps_in_Zabbix
cp ~/zabbix-3.0.1/misc/snmptrap/zabbix_trap_receiver.pl /usr/bin
chmod +x /usr/bin/zabbix_trap_receiver.pl
vi /etc/snmp/snmptrapd.conf
# you can set multiple community names:
# authCommunity execute public
# authCommunity execute [email protected]
authCommunity execute public
perl do "/usr/bin/zabbix_trap_receiver.pl";
vi /etc/zabbix/zabbix_server.conf
StartSNMPTrapper=1
SNMPTrapperFile=/tmp/zabbix_traps.tmp
/etc/init.d/zabbix-server restart
chkconfig snmptrapd on
/etc/init.d/snmptrapd restart
mkdir -p /var/log/zabbix_traps_archive
/etc/logrotate.d/zabbix_traps contents :
/tmp/zabbix_traps.tmp {
weekly
size 10M
compress
compresscmd /usr/bin/bzip2
compressoptions -9
notifempty
dateext
dateformat -%Y%m%d
missingok
maxage 365
rotate 10
}
#Testing
#Send test trap:
snmptrap -v 1 -c public 127.0.0.1 ‘.1.3.6.1.6.3.1.1.5.4‘ ‘0.0.0.0‘ 6 33 ‘55‘ .1.3.6.1.6.3.1.1.5.4 s "eth0"
#and check that trap received in the /tmp/zabbix_traps.tmp. You should see:
18:58:38 2014/02/26 ZBXTRAP 127.0.0.1
PDU INFO:
notificationtype TRAP
version 0
receivedfrom UDP: [127.0.0.1]:40780->[127.0.0.1]
errorstatus 0
messageid 0
community public
transactionid 7
errorindex 0
requestid 0
VARBINDS:
DISMAN-EVENT-MIB::sysUpTimeInstance type=67 value=Timeticks: (55) 0:00:00.55
SNMPv2-MIB::snmpTrapOID.0 type=6value=OID: IF-MIB::linkUp.0.33
IF-MIB::linkUp type=4 value=STRING: "eth0" SNMP-COMMUNITY
MIB::snmpTrapCommunity.0 type=4 value=STRING: "public"
SNMPv2-MIB::snmpTrapEnterprise.0 type=6 value=OID: IF-MIB::linkUp
cat >> /etc/services << EOF
zabbix-agent 10050/tcp #Zabbix Agent
zabbix-agent 10050/udp #Zabbix Agent
zabbix-trapper 10051/tcp #Zabbix Trapper
zabbix-trapper 10051/udp #Zabbix Trapper
EOF
解决中文乱码问题:
中文支持:
zabbix实际是有中文语言的,我们可以通过修改web端源文件来开启中文语言。
修改你的 /include/locales.inc.php 这个文件
‘zh_CN‘ => [‘name‘ => _(‘Chinese (zh_CN)‘), ‘display‘ => true], #也就是把false改为true
找到本地 C:\Windows\Fonts\simkai.ttf(楷体)上传到服务器 zabbix 网站目录 fonts 目录下。
Linux
2.2 修改 zabbix php 配置文件
# cd /data/site/www.ttlsa.com/zabbix/
# 我 zabbix 安装目录
# sed -i ‘s/DejaVuSans/simkai/g‘ ./include/defines.inc.php
UserParameter= {使用脚本获取值}
来源: https://d.docs.live.net/227b85655d89fc2d/Zabbix3.0%20Install.docx