symlink sed base author imm auth entos 上传 alert
Centos7 下安装部署 Zabbix3.4
主要参考官方文档:
https://www.zabbix.com/documentation/3.4/zh/manual/installation/install_from_packages
一、系统基本配置
1. 配置 IP 地址
1)编辑 /etc/sysconfig/network-scripts/ifcfg-eth0 文档,修改成如下内容:
2)重启网络服务
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.17.100.211
NETMASK=255.255.255.0
GATEWAY=172.17.100.1
DNS1=202.106.0.20
DNS2=8.8.8.8
# systemctl restart network.service
3)验证
# ifconfig -a 或 ip a
2. 更改主机名称
hostnamectl set-hostname zabbix
备注:
也可以使用 nmtui 命令修改网络 IP 地址和主机名称
3. 配置允许 root 账号远程登录
1)编辑 / etc/ssh/sshd_config 文档,修改成如下内容:
PermitRootLogin yes
2)重启 ssh 服务
# systemctl restart sshd.service
4. 关闭 IPV6
1)修改 / etc/sysctl.conf 配置文件
# sed -i '$a net.ipv6.conf.all.disable_ipv6 =1\nnet.ipv6.conf.default.disable_ipv6 =1' /etc/sysctl.conf
2)执行下面的命令来使设置生效.
# sysctl -p
5. 关闭防火墙
1)使用下列指令关闭防火墙
2)查看 firewalld 状态
# systemctl stop firewalld (关闭防火墙)
# systemctl disable firewalld (禁止开机启动)
6. 禁用 SElinux(一定要关闭,否则有些功能不能正常使用)
# firewall-cmd --state
not running
1)修改 / etc/selinux/config 配置文件
# sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
2)确认是否修改成功
3)重启系统
# cat /etc/selinux/config |grep -v ^# |grep -v ^$
SELINUX=disabled
SELINUXTYPE=targeted
# reboot
4)重启后,查看 SELinux 状态
二、安装数据库
# sestatus
SELinux status: disabled
1. 安装 Mariadb 数据库(最新版本的 linux 系统,默认的是 Mariadb.)
# yum install -y mariadb mariadb-server
2. 启动 mariadb
# systemctl start mariadb
3. 设置开机自启动
# systemctl enable mariadb
4. 安全初始化,设置 root 密码等
5. 测试登录
#mysql_secure_installation 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] yes
New password: (输入:123456)
Re-enter new password: (输入:123456)
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] y
... Success!
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 !
# mysql -uroot -p123456
三、安装 Zabbix
先在网站 "http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/" 下载 "zabbix-release-3.4-2.el7.noarch.rpm" 文件,通过 xftp 软件先将上传到 / root / 目录下
1. 安装 zabbix
# rpm -ivh zabbix-release-3.4-2.el7.noarch.rpm
2. 安装 server 和 web 端,基于 mysql 数据库
# yum install -y zabbix-server-mysql zabbix-web-mysql
3. 初始化 zabbix DB
1)登录数据库
2)测试 zabbix 帐号能否正常使用
# mysql -uroot -p123456
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
MariaDB [(none)]> grant all privileges on zabbix.* to root@localhost identified by '123456';
MariaDB [(none)]> quit;
Bye
[root@zabbix ~]# mysql -uzabbix -p123456
3)导入数据
4. 修改 Zabbix Server 配置,并启动 Zabbix Server 服务
# cd /usr/share/doc/zabbix-server-mysql-3.4.5/ (由于安装的版本有可能不一样,需要到 / usr/share/doc / 下确定)
# zcat create.sql.gz | mysql -uroot -p123456 zabbix
1)修改配置文件
2)检查 zabbix_server.conf 配置文件修改结果
# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
3)启动 zabbix-server 服务
# cat /etc/zabbix/zabbix_server.conf |grep -v ^# |grep -v ^$
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
# systemctl start zabbix-server
4)开机自启动 zabbix-server 服务
# systemctl enable zabbix-server
5)查看 zabbix-server 运行情况
# systemctl status zabbix-server
四、配置 zabbix 管理界面
1. 编辑 PHP 配置
2. 查看修改结果
# vi /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
3. 配置开启 zh_CN 语言显示(默认是开启的)
# cat /etc/httpd/conf.d/zabbix.conf |grep -v ^# |grep -v ^$
Alias /zabbix /usr/share/zabbix
Options FollowSymLinks
AllowOverride None
Require all granted
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
# vi /usr/share/zabbix/include/locales.inc.php
如果参数是: 'zh_CN' => ['name' => _('Chinese (zh_CN)'), 'display' => false],
需要修改为: 'zh_CN' => ['name' => _('Chinese (zh_CN)'), 'display' => true],
4. 启动 Apache 服务
# systemctl start httpd
5. 开机启动 Apache 服务
# systemctl enable httpd
6. 查看 Apache 服务运行情况
# systemctl status httpd
五、登陆 Zabbix 管理页面,显示 Zabbix 安装向导.
1. 登录管理页面
http://172.17.100.211/zabbix/ (IP:172.17.100.211,需要更换成你自己的 IP 地址)
2. 输入密码:123456
3.zabbix web 用户名及密码分别是:Admin/zabbix
Centos7 下安装部署 Zabbix3.4
来源: http://www.bubuko.com/infodetail-2452608.html