zabbix ip address:192.168.1.50
yum -y install gcc gcc-c++ autoconf httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-bcmath mysql-connector-odbc mysql-devel libdbi-dbd-mysql net-snmp-devel curl-devel unixODBC-devel OpenIPMI-devel java-devel
[root@zabbix etc]# vi php.ini
date.timezone = Asia/Shanghai
max_execution_time = 300
post_max_size = 32M/100M
max_input_time=300
memory_limit = 128M/256M
mbstring.func_overload = 2/4
[root@zabbix etc]# chkconfig mysqld on
[root@zabbix etc]# chkconfig httpd on
[root@zabbix etc]# service mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h zabbix password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[ OK ]
Starting mysqld: [ OK ]
[root@zabbix etc]# service httpd on
Usage: httpd {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}
[root@zabbix etc]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.1.50 for ServerName
[ OK ]
shell#groupadd zabbix -g 201
shell#useradd -g zabbix -u 201 -m zabbix
[root@zabbix etc]# passwd zabbix
shell#./configure --prefix=/usr/zabbix --sysconfdir=/etc/zabbix --enable-server --enable-proxy --enable-agent --enable-ipv6 --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-openipmi --with-unixodbc --with-ldap --with-ssh2 --enable-java
configure: error: SSH2 library not found
1、 checking for SSH2 support... no
configure: error: SSH2 library not found
[root@localhost zabbix-2.4.4]# yum install SSH
[root@localhost zabbix-2.4.4]# yum install libssh2-devel.i686
2、 checking for LDAP support... no
configure: error: Invalid LDAP directory - unable to find ldap.h
[root@localhost zabbix-2.4.4]# yum install openldap openldap-devel
yum list openldap
yum list openldap-devel
libssh2-devel-1.4.2-1.el6_6.1.i686.rpm
libssh2-devel-1.4.2-1.el6_6.1.x86_64.rpm
configure: error: Invalid OPENIPMI directory - unable to find ipmiif.h
[root@zabbix zabbix-3.2.6]# rpm -qa | grep OpenIPMI
OpenIPMI-2.0.16-14.el6.x86_64
OpenIPMI-libs-2.0.16-14.el6.x86_64
OpenIPMI-libs-2.0.16-14.el6.i686
OpenIPMI-devel-2.0.16-14.el6.i686.rpm
OpenIPMI-devel-2.0.16-14.el6.x86_64.rpm
mysql> update mysql.user set password=password('zabbix') where user='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Shell#cd PATH/zabbix-2.0.8 (确保路径在 zabbix 源码下面)
Shell#cd PATH/zabbix-2.0.8 (确保路径在 zabbix 源码下面)
shell#mysqladmin -uroot password 'mysql_pass'; (设置 mysql 的 root 密码)
Shell#mysql -uroot -p (登陆数据库)
mysql>create database zabbix character set utf8;
(注意,此处要特别注意数据库字符集的问题,如果数据库是非 utf8 字符,则 web 页面改
为中文,是会出现乱码的。 )
mysql>grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
mysql>flush privileges;
确保以上操作都正常,测试下数据库连接是否正常
Shell#mysql -uzabbix -pzabbix zabbix
导入 zabbix 数据库
[root@zabbix database]# pwd
/root/zabbix-3.2.6/database
下面的导入路径,请修改成自己的路径(导入有先后顺序)
[root@zabbix mysql]# mysql -u zabbix -pzabbix zabbix < ./schema.sql
[root@zabbix mysql]# mysql -u zabbix -pzabbix zabbix < ./images.sql
[root@zabbix mysql]# mysql -u zabbix -pzabbix zabbix < ./data.sql
拷贝 service 启动脚本
shell#cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
shell#chmod 755 /etc/init.d/zabbix_*
shell#sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/#g" /etc/init.d/zabbix_server
shell#sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/#g" /etc/init.d/zabbix_agentd
配置 zabbix_server.conf 服务端文件
路径: /etc/zabbix/zabbix_server.conf
修改主要参数即可正常工作
DBName=zabbix 数据库名称
DBUser=zabbix 数据库用户
DBPassword=zabbix 数据库密码
[root@zabbix zabbix]# egrep -v "(#|^$)" /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
DBPort=3306
StartPollers=20 (测试环境默认值即可)
StartTrappers=20 (测试环境默认值即可)
StartPingers=20 (测试环境默认值即可)
StartDiscoverers=20 (测试环境默认值即可)
MaxHousekeeperDelete=5000 (测试环境默认值即可)
CacheSize=1024M (测试环境默认值即可)
StartDBSyncers=16 (测试环境默认值即可)
HistoryCacheSize=1024M (测试环境默认值即可)
TrendCacheSize=1024M (测试环境默认值即可)
AlertScriptsPath=/etc/zabbix/alertscripts
LogSlowQueries=1000
[root@zabbix zabbix]# egrep -v "(#|^$)" /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
DBPort=3306
StartPollers=160
StartTrappers=20
StartPingers=100
StartDiscoverers=120
MaxHousekeeperDelete=5000
CacheSize=512M
StartDBSyncers=16
HistoryCacheSize=512M
TrendCacheSize=512M
Timeout=4
AlertScriptsPath=/etc/zabbix/alertscripts
LogSlowQueries=3000
配置 zabbix_agentd.conf 文件
/etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1 此处添加服务端的 ip,如服务器不为本机,则需要填写远端 zabbix_server
的 ip 地址
ServerActive=127.0.0.1 此处修改为服务端的 ip
/tmp/zabbix_agentd.log 修改日志路径
UnsafeUserParameters=0 默认是不启用自定义脚本功能的,要自定义 key,需开启,设置为
1
Include=/etc/zabbix/zabbix_agentd.conf.d/ 自定义的agentd配置文件可以写在这个目录下面
LogFile=/var/log/zabbix/zabbix_agentd.log
EnableRemoteCommands=0
Server=127.0.0.1,192.168.1.89
StartAgents=8
ServerActive=192.168.1.89:10051
Hostname=nat.kx1d.com
Timeout=30
Include=/etc/zabbix/zabbix_agentd.conf.d/
UnsafeUserParameters=1
[root@zabbix zabbix]# egrep -v "(#|^$)" /etc/zabbix/zabbix_agentd.conf
LogFile=/var/log/zabbix/zabbix_agentd.log
EnableRemoteCommands=0
Server=192.168.1.50,127.0.0.1
StartAgents=8
ServerActive=192.168.1.50:10051
Hostname=Zabbix server
Timeout=30
Include=/etc/zabbix/zabbix_agentd.conf.d/
UnsafeUserParameters=1
[root@zabbix zabbix]# cd /root/zabbix-3.2.6
cp -r ./frontends/php/ /var/www/html/zabbix
chown -R apache.apache /var/www/html/zabbix
shell#chkconfig zabbix_server on
shell#chkconfig zabbix_agentd on
shell#service zabbix_server start
shell#service zabbix_agentd start
zabbix default user
Admin/zabbix
cannot set MySQL character set to "utf8"
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
max_connections=1000
mysql> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
yum -y install gcc gcc-c++ autoconf httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-bcmath mysql-connector-odbc mysql-devel libdbi-dbd-mysql net-snmp-devel curl-devel unixODBC-devel OpenIPMI-devel java-devel
[root@zabbix etc]# vi php.ini
date.timezone = Asia/Shanghai
max_execution_time = 300
post_max_size = 32M/100M
max_input_time=300
memory_limit = 128M/256M
mbstring.func_overload = 2/4
[root@zabbix etc]# chkconfig mysqld on
[root@zabbix etc]# chkconfig httpd on
[root@zabbix etc]# service mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h zabbix password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[ OK ]
Starting mysqld: [ OK ]
[root@zabbix etc]# service httpd on
Usage: httpd {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}
[root@zabbix etc]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.1.50 for ServerName
[ OK ]
shell#groupadd zabbix -g 201
shell#useradd -g zabbix -u 201 -m zabbix
[root@zabbix etc]# passwd zabbix
shell#./configure --prefix=/usr/zabbix --sysconfdir=/etc/zabbix --enable-server --enable-proxy --enable-agent --enable-ipv6 --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-openipmi --with-unixodbc --with-ldap --with-ssh2 --enable-java
configure: error: SSH2 library not found
1、 checking for SSH2 support... no
configure: error: SSH2 library not found
[root@localhost zabbix-2.4.4]# yum install SSH
[root@localhost zabbix-2.4.4]# yum install libssh2-devel.i686
2、 checking for LDAP support... no
configure: error: Invalid LDAP directory - unable to find ldap.h
[root@localhost zabbix-2.4.4]# yum install openldap openldap-devel
yum list openldap
yum list openldap-devel
libssh2-devel-1.4.2-1.el6_6.1.i686.rpm
libssh2-devel-1.4.2-1.el6_6.1.x86_64.rpm
configure: error: Invalid OPENIPMI directory - unable to find ipmiif.h
[root@zabbix zabbix-3.2.6]# rpm -qa | grep OpenIPMI
OpenIPMI-2.0.16-14.el6.x86_64
OpenIPMI-libs-2.0.16-14.el6.x86_64
OpenIPMI-libs-2.0.16-14.el6.i686
OpenIPMI-devel-2.0.16-14.el6.i686.rpm
OpenIPMI-devel-2.0.16-14.el6.x86_64.rpm
mysql> update mysql.user set password=password('zabbix') where user='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Shell#cd PATH/zabbix-2.0.8 (确保路径在 zabbix 源码下面)
Shell#cd PATH/zabbix-2.0.8 (确保路径在 zabbix 源码下面)
shell#mysqladmin -uroot password 'mysql_pass'; (设置 mysql 的 root 密码)
Shell#mysql -uroot -p (登陆数据库)
mysql>create database zabbix character set utf8;
(注意,此处要特别注意数据库字符集的问题,如果数据库是非 utf8 字符,则 web 页面改
为中文,是会出现乱码的。 )
mysql>grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
mysql>flush privileges;
确保以上操作都正常,测试下数据库连接是否正常
Shell#mysql -uzabbix -pzabbix zabbix
导入 zabbix 数据库
[root@zabbix database]# pwd
/root/zabbix-3.2.6/database
下面的导入路径,请修改成自己的路径(导入有先后顺序)
[root@zabbix mysql]# mysql -u zabbix -pzabbix zabbix < ./schema.sql
[root@zabbix mysql]# mysql -u zabbix -pzabbix zabbix < ./images.sql
[root@zabbix mysql]# mysql -u zabbix -pzabbix zabbix < ./data.sql
拷贝 service 启动脚本
shell#cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
shell#chmod 755 /etc/init.d/zabbix_*
shell#sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/#g" /etc/init.d/zabbix_server
shell#sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/#g" /etc/init.d/zabbix_agentd
配置 zabbix_server.conf 服务端文件
路径: /etc/zabbix/zabbix_server.conf
修改主要参数即可正常工作
DBName=zabbix 数据库名称
DBUser=zabbix 数据库用户
DBPassword=zabbix 数据库密码
[root@zabbix zabbix]# egrep -v "(#|^$)" /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
DBPort=3306
StartPollers=20 (测试环境默认值即可)
StartTrappers=20 (测试环境默认值即可)
StartPingers=20 (测试环境默认值即可)
StartDiscoverers=20 (测试环境默认值即可)
MaxHousekeeperDelete=5000 (测试环境默认值即可)
CacheSize=1024M (测试环境默认值即可)
StartDBSyncers=16 (测试环境默认值即可)
HistoryCacheSize=1024M (测试环境默认值即可)
TrendCacheSize=1024M (测试环境默认值即可)
AlertScriptsPath=/etc/zabbix/alertscripts
LogSlowQueries=1000
[root@zabbix zabbix]# egrep -v "(#|^$)" /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
DBPort=3306
StartPollers=160
StartTrappers=20
StartPingers=100
StartDiscoverers=120
MaxHousekeeperDelete=5000
CacheSize=512M
StartDBSyncers=16
HistoryCacheSize=512M
TrendCacheSize=512M
Timeout=4
AlertScriptsPath=/etc/zabbix/alertscripts
LogSlowQueries=3000
配置 zabbix_agentd.conf 文件
/etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1 此处添加服务端的 ip,如服务器不为本机,则需要填写远端 zabbix_server
的 ip 地址
ServerActive=127.0.0.1 此处修改为服务端的 ip
/tmp/zabbix_agentd.log 修改日志路径
UnsafeUserParameters=0 默认是不启用自定义脚本功能的,要自定义 key,需开启,设置为
1
Include=/etc/zabbix/zabbix_agentd.conf.d/ 自定义的agentd配置文件可以写在这个目录下面
LogFile=/var/log/zabbix/zabbix_agentd.log
EnableRemoteCommands=0
Server=127.0.0.1,192.168.1.89
StartAgents=8
ServerActive=192.168.1.89:10051
Hostname=nat.kx1d.com
Timeout=30
Include=/etc/zabbix/zabbix_agentd.conf.d/
UnsafeUserParameters=1
[root@zabbix zabbix]# egrep -v "(#|^$)" /etc/zabbix/zabbix_agentd.conf
LogFile=/var/log/zabbix/zabbix_agentd.log
EnableRemoteCommands=0
Server=192.168.1.50,127.0.0.1
StartAgents=8
ServerActive=192.168.1.50:10051
Hostname=Zabbix server
Timeout=30
Include=/etc/zabbix/zabbix_agentd.conf.d/
UnsafeUserParameters=1
[root@zabbix zabbix]# cd /root/zabbix-3.2.6
cp -r ./frontends/php/ /var/www/html/zabbix
chown -R apache.apache /var/www/html/zabbix
shell#chkconfig zabbix_server on
shell#chkconfig zabbix_agentd on
shell#service zabbix_server start
shell#service zabbix_agentd start
zabbix default user
Admin/zabbix
cannot set MySQL character set to "utf8"
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
max_connections=1000
mysql> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
本文档详述了在Linux上安装Zabbix的过程,包括安装依赖、配置MySQL、设置Zabbix用户、编译和安装Zabbix源码,以及启动和配置Zabbix服务端和代理。遇到的SSH2和LDAP配置问题也给出了解决方案。

822

被折叠的 条评论
为什么被折叠?



