Centos7.x下安裝Zabbix 3.0
阿新 • • 發佈:2018-11-11
環境:Centos7.x 64位,選擇7.x是因為7版本以上的PHP版本為5.4,不需要升級PHP版本。
1、安裝Apache
[[email protected] ~]# yum install httpd
2、安裝MySQL的源和Zabbix的源
[[email protected] ~]#rpm -vhi http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm [[email protected] ~]#rpm -vhi http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-release-el6-5.noarch.rpm
3、安裝Zabbix-Server和Zabbix-Agent
[[email protected] ~]#yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
4、安裝MySQL
[[email protected] ~]# yum install -y mysql-community-server
5、啟動Apache、zabbix和MySQL
[[email protected] ~]# systemctl start mysqld.service
[[email protected] ~]# systemctl start zabbix-server.service
[[email protected] ~]# systemctl start httpd.service
[[email protected] ~]# systemctl start zabbix-agent.service
6、設定開機啟動
[[email protected] ~]# /sbin/chkconfig mysqld on
[[email protected] ~]# /sbin/chkconfig zabbix-server on
[[email protected] ~]# /sbin/chkconfig httpd on
7、初始化MySQL資料庫
[[email protected] ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
... Failed! Not critical, keep moving...
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Cleaning up...
建立zabbix資料庫,建立zabbix賬戶
[[email protected] ~]# mysql -uroot -p
...
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
8、匯入預設的Zabbix資料庫資訊
[[email protected] ~]# zcat /usr/share/doc/zabbix-server-mysql-3.0.22/create.sql.gz | mysql zabbix -uzabbix -pzabbix
Warning: Using a password on the command line interface can be insecure.
9、修改Zabbix_server.conf的配置檔案
[[email protected] ~]# grep ^DB /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=root
DBPassword=zabbix
10、修改配置檔案/etc/httpd/conf.d/zabbix.conf,時區改成Asia/Shanghai
[[email protected] ~]# vim /etc/httpd/conf.d/zabbix.conf
#
# Zabbix monitoring system php web frontend
#
ias /zabbix /usr/share/zabbix
▽
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value max_input_vars 10000
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
11、關閉SELinux和Firewall
[[email protected] zabbix]# systemctl stop firewalld.service
[[email protected] zabbix]# setenforce 0
[[email protected] ~]# vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
12、將Apache的預設目錄改為zabbix的預設目錄
[[email protected] zabbix]# vim /etc/httpd/conf/httpd.conf
#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed. This address appears on some server-generated pages, such
# as error documents. e.g. [email protected]
#
ServerAdmin [email protected]
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all denied
</Directory>
#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
#
# DocumentRoot: The directory out of which you will serve your
documents. By default, all requests are taken from this directory, but
▽ symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/usr/share/zabbix"
#
# Relax access to content within /var/www.
#
<Directory "/usr/share/zabbix">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
在瀏覽器輸入本機的ip進行訪問,確保機器的80埠狀態為開啟
[[email protected] ~]# netstat -anp | grep 80
tcp6 0 0 :::80 :::* LISTEN 26402/httpd
tcp6 0 0 192.168.10.133:80 192.168.10.1:63800 TIME_WAIT -
tcp6 0 0 192.168.10.133:80 192.168.10.1:63941 TIME_WAIT -
tcp6 0 0 192.168.10.133:80 192.168.10.1:63981 FIN_WAIT2 -
tcp6 0 0 192.168.10.133:80 192.168.10.1:63940 TIME_WAIT -
tcp6 0 0 192.168.10.133:80 192.168.10.1:63912 TIME_WAIT -
tcp6 0 0 192.168.10.133:80 192.168.10.1:63934 TIME_WAIT -
tcp6 0 0 192.168.10.133:80 192.168.10.1:63942 TIME_WAIT -
tcp6 0 0 192.168.10.133:80 192.168.10.1:63847 TIME_WAIT -
tcp6 0 0 192.168.10.133:80 192.168.10.1:63882 TIME_WAIT -
unix 2 [ ] DGRAM 23331 2802/rsyslogd
unix 3 [ ] STREAM CONNECTED 19804 665/dbus-daemon /run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 50280 26221/mysqld /var/lib/mysql/mysql.sock
點選Next step,進行下一步操作。
如果這裡的PHP版本不對,請自行升級PHP版本。
保持預設,點選Next step
成功安裝Zabbix
預設管理員賬號為Admin,密碼為zabbix。注意大小寫
注意:請登入成功後馬上修改zabbix的密碼,並且移除web目錄內的setup.php檔案
[[email protected] ~]# mv /usr/share/zabbix/setup.php /usr/share/zabbix/setup.php.bak