您的位置:首页 > 运维架构 > Linux

Centos7.3 yum部署 zabbix-server文档

2017-06-10 08:20 471 查看
一、关闭SElinux
[root@zabbix ~]# vi /etc/selinux/config
       SELINUX=disabled
       SELINUXTYPE=targeted
       重启系统, 如果不想重启系统,使用命令setenforce 0

二、开放防火墙必要的端口:
[root@zabbix ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent
[root@zabbix ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
[root@zabbix ~]# firewall-cmd --zone=public --add-port=10050/tcp --permanent
[root@zabbix ~]# firewall-cmd --zone=public --add-port=10051/tcp --permanent
[root@zabbix ~]# firewall-cmd --reload
三、安装必要工具:
[root@zabbix ~]# yum -y install vim openssl openssl-devel gcc gcc-c++ telnet net-tools
四、安装apache:
[root@zabbix ~]# yum -y install httpd
启动:
[root@zabbix ~]# systemctl start httpd
设置开机启动:
[root@zabbix ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service
五、安装mariaDB:
[root@zabbix ~]# yum -y install mariadb mariadb-server
覆盖配置:
[root@zabbix ~]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
启动:
[root@zabbix ~]# systemctl start mariadb
设置密码以及其他:
[root@zabbix ~]# mysql_secure_installation
/usr/bin/mysql_secure_installation:行379: find_mysql_client: 未找到命令
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, 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 MariaDB
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 MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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] n
... skipping.
By default, MariaDB 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...
... Success!
- 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!
Cleaning up...
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
设置开机启动:
[root@zabbix ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
六、安装php:
[root@zabbix ~]# yum -y install php php-bcmatch php-gd php-mbstring php-mysql php-pdo php-ldap php-pear php-ldap php-devel php-cli
七、配合httpd与php:
[root@zabbix ~]# vim /etc/httpd/conf/httpd.conf
把  DirectoryIndex index.html
改为: DirectoryIndex index.html index.php
重启httpd:
[root@zabbix ~]# systemctl restart httpd
添加index.php文件内容:
[root@zabbix ~]# vim /var/www/html/index.php
<?php
phpinfo();
然后访问一下,看看是否成功:http://172.0.0.53/index.php
八、安装zabbix源:
[root@zabbix ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm 获取http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
警告:/var/tmp/rpm-tmp.ExKdN8: 头V4 DSA/SHA1 Signature, 密钥 ID 79ea5ed4: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:zabbix-release-3.0-1.el7         ################################# [100%]
九、安装zabbix服务(server):
[root@zabbix ~]# yum install zabbix-server-mysql zabbix-web-mysql
十、添加连接的mysql用户与库:
[root@zabbix ~]# mysql -uroot -p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.50-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database zabbix;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'zabbix'@'localhost'
    -> IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> exit;
Bye
十一、导入sql数据:
[root@zabbix ~]# zcat /usr/share/doc/zabbix-server-mysql-3.0.4/create.sql.gz  | mysql -uzabbix -p123456 zabbix
十二、配置zabbix-server:
[root@zabbix ~]# vim /etc/zabbix/zabbix_server.conf
改了对应的配置项
ListenPort=10051
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBSocket=/var/lib/mysql/mysql.sock
DBPort=3306
启动:
[root@zabbix ~]# systemctl start zabbix-server
十三、配置web管理应用:
[root@zabbix ~]# vim /etc/httpd/conf.d/zabbix.conf
      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 always_populate_raw_post_data -1
        php_value date.timezone Asia/Shanghai
重启 apache :
[root@zabbix ~]# systemctl restart httpd
十四、管理web界面:
访问:http://172.0.0.53/zabbix/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: