环境准备:操作系统:Centos 7或以上一.安装Mysql1.建立mysql账号groupadd mysqluseradd -s /sbin/nologin -g mysql -M mysql2.创建my
环境准备:
一.安装Mysql
1.建立mysql账号
groupadd mysql
useradd -s /sbin/nologin -g mysql -M mysql
2.创建mysql软件目录并修改权限
mkdir -p /usr/local/mysql
mkdir -p /data/mysql
mkdir -p /usr/local/mysql/run/
chown -R root:mysql /usr/local/mysql
chown -R mysql:mysql /data/mysql
chmod 775 /usr/local/mysql/run/
3.安装依赖包
yum -y install make GCc-c++ cmake bison-devel ncurses-devel
4.下载源码包并解压
Http://mirrors.sohu.com/mysql/
cd /usr/local/src
tar -zxf mysql-5.7.11.tar.gz
cd mysql-5.7.11
5.编译
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATioN=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE=1 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/boost
6.安装
make && make install
7. 初始化MySQL
cd /usr/local/mysql/bin
./mysqld --initialize --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql --Socket=/var/lib/mysql/mysql.sock --pid-file=/usr/local/mysql/run/mysqld.pid
8. 添加MySQL服务并设置开机启动
cd /usr/local/mysql/support-files
cp mysql.server /etc/init.d/mysqld
cd /etc/init.d/
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
9. 编辑my.cnf文件
vi /etc/my.cnf
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
user = mysql
basedir = /usr/local/mysql
datadir = /data/mysql
pid-file=/usr/local/mysql/run/mysqld.pid
log-error = /var/log/mysql/mysqld.log
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
thread_cache_size = 8
query_cache_size = 8M
tmp_table_size = 16M
#skip-networking
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535
log-bin=mysql-bin
binlog_fORMat = mixed
server-id = 1
expire_logs_days = 10
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
10. 重启MySQL
/etc/init.d/mysql start
Starting MySQL.. SUCCESS!
11. 登录MySQL
cd ../bin/
./mysql -uroot -p //第一次登录MySQL,密码文件在,也可以从make install 最后的一行看到密码,若看不到可以参考以下修改密码的步骤
Enter passWord:
12.忘记root密码可通过以下方法修改
vi /etc/my.cnf
[mysqld]
skip-grant-tables
重启mysqld服务,重新登陆已不需要密码
13.修改root密码
use mysql
update user set authentication_string=PASSWORD('zabbix') where User='root';
14.退出删除mysql.cnf中的skip-grant-tables,以新密码重新登陆即可
15.首次登陆需要重新设置一下新密码,否则任何命令都会提示:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
set password for root@localhost = password('zabbix');
16.创建zabbix数据库
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
二.安装Zabbix
1.安装官方的yum源
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
2.yum安装zabbix-server\zabbix-WEB\zabbix-agent
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
3.初始化数据库
cd /usr/share/doc/zabbix-server-mysql-3.0.*
zcat create.sql.gz | mysql -uroot -pzabbix zabbix
4.编辑zabbix server配置文件
vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
5.开启zabbix server以及agent服务并设置开机启动
systemctl start zabbix-server
systemctl enable zabbix-server
systemctl start zabbix-agent
systemctl enable zabbix-agent
6.确保PHP的配置符合zabbix的要求(默认已含下列配置),并修改timezone为PRC
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
7.开启Apache服务并设置开机启动
systemctl start httpd
systemctl enable httpd
8.打开zabbix页面http://192.168.17.100/zabbix/,首次要求初始化
PHP检查通过
连接mysql数据库
确保mysql.sock协议文件在/var/lib/mysql/下,如果不在可通过my.cnf修改
自定义zabbix server的细节
初始化完成
进入zabbix界面
9.修改语言
Zabbix 3.0.3可以直接在界面上修改为简体中文
三.Agent安装
1.linux OS rpm包安装
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
yum install zabbix-agent -y
sed -i 's/^Server=.*/Server=192.168.17.100/g' /etc/zabbix/zabbix_agentd.conf
sed -i 's/^ServerActive=.*/ServerActive=192.168.17.100/g' /etc/zabbix/zabbix_agentd.conf
sed -i 's/^Hostname=.*/Hostname=TestHost/g' /etc/zabbix/zabbix_agentd.conf
service zabbix-agent start
2.windows OS agent设置
http://www.zabbix.com/downloads/3.0.0/zabbix_agents_3.0.0.win.zip
修改zabbix_agent\conf\zabbix_agentd.win.conf中的hostname
在cmd窗口运行以下命令(64位\32位)
"C:\Program Files\zabbix\bin\win64\zabbix_agentd.exe" -c "C:\Program Files\zabbix\conf\zabbix_agentd.win.conf" -i
"C:\Program Files\zabbix\bin\win64\zabbix_agentd.exe" -c "C:\Program Files\zabbix\conf\zabbix_agentd.win.conf" -s
"C:\Program Files\zabbix\bin\win32\zabbix_agentd.exe" -c "C:\Program Files\zabbix\conf\zabbix_agentd.win.conf" -i
"C:\Program Files\zabbix\bin\win32\zabbix_agentd.exe" -c "C:\Program Files\zabbix\conf\zabbix_agentd.win.conf" -s
3.Linux OS source包安装
groupadd zabbix
useradd zabbix -g zabbix -s /sbin/nologin
cd /usr/local/src/
wget http://ufpr.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz
tar -xzvf zabbix-3.0.3.tar.gz
cd zabbix-3.0.3
./configure --prefix=/usr/local/zabbix/ --enable-agent
make
make install
sed -i 's/^Server=.*/Server=192.168.17.100/g' /usr/local/zabbix/etc/zabbix_agentd.conf
sed -i 's/^ServerActive=.*/ServerActive=192.168.17.100/g' /usr/local/zabbix/etc/zabbix_agentd.conf
sed -i 's/^Hostname=.*/Hostname=TestHost/g' /usr/local/zabbix/etc/abbix_agentd.conf
启动agent服务
/usr/local/zabbix/sbin/zabbix_agentd start
设置开机启动
vi /etc/rc.d/rc.local
添加以下内容
/usr/local/zabbix/sbin/zabbix_agentd start
四.附加配置
1.开放系统防火墙端口
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="192.168.17.0/24" port protocol="tcp" port="80" accept"
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="192.168.17.0/24" port protocol="tcp" port="10050" accept"
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="192.168.17.0/24" port protocol="tcp" port="10051" accept"
firewall-cmd --reload
2.从旧版本的zabbix升级
@旧版本zabbix
停用zabbix-server服务,防止有新的数据产生
service zabbix-server stop
备份旧版本的数据库
mysqldump -uroot -pzabbix zabbix > zabbix.sql
将备份后的数据库传到新的zabbix平台
@新版本zabbix
停止zabbix-server/agent服务
service zabbix-server stop
service zabbix-agent stop
删除zabbix 3.0.3初始化后的数据库
drop database zabbix
导入旧版本的数据库
mysql -uroot -pzabbix zabbix < zabbix.sql
查看日志tail -f /var/log/zabbix/zabbix-server.log,数据库会自动升级
8816:20160527:140441.797 completed 0% of database upgrade
8816:20160527:140441.812 completed 1% of database upgrade
8816:20160527:140441.846 completed 2% of database upgrade
8816:20160527:140441.878 completed 3% of database upgrade
8816:20160527:140441.911 completed 4% of database upgrade
8816:20160527:140441.925 completed 5% of database upgrade
8816:20160527:140441.957 completed 6% of database upgrade
8816:20160527:140441.969 completed 7% of database upgrade
8816:20160527:140441.981 completed 8% of database upgrade
8816:20160527:140441.992 completed 9% of database upgrade
8816:20160527:140442.022 completed 10% of database upgrade
....
重新开启服务,一切正常
service zabbix-server start
service zabbix-agent start
3.中文乱码问题
cd /usr/share/zabbix/fonts
上传任一中文字体到该目录,并修改php文件
vi /usr/share/zabbix/include/defines.inc.php
#('ZBX_GRAPH_FONT_NAME', 'graphfont'); #将graphfont替换为msyh(雅黑字体)文件名即可
#('ZBX_FONT_NAME', 'graphfont'); #将graphfont替换为msyh(雅黑字体)文件名即可
4.设置邮件报警
Zabbix 3.0可以直接在web界面配置邮件报警,不需要脚本的形式
安装Sendmail
yum install sendmail –y
chkconfig sendmail on
service sendmail start
进入管理-报警媒介类型-Email-设置发送邮箱的信息
管理-用户群组,确保用户群组有对监控设备有对应权限
配置-动作,有告警信息时通过Email发送给相关的用户
编辑动作详情
默认接收人:
{TRIGGER.STATUS}: {TRIGGER.NAME}
默认信息:
告警主机:{HOST.NAME}
告警IP:{HOST.IP}
告警时间:{EVENT.DATE}-{EVENT.TIME}
告警等级:{TRIGGER.SEVERITY}
告警信息:{TRIGGER.NAME}
问题详情:{ITEM.NAME}:{ITEM.VALUE}
时间ID:{EVENT.ID}
恢复主题:
恢复{TRIGGER.STATUS}, 服务器:{HOSTNAME1}: {TRIGGER.NAME}已恢复!
恢复信息:
告警主机:{HOST.NAME}
告警IP:{HOST.IP}
告警时间:{EVENT.DATE}-{EVENT.TIME}
告警等级:{TRIGGER.SEVERITY}
告警信息:{TRIGGER.NAME}
问题详情:{ITEM.NAME}:{ITEM.VALUE}
时间ID:{EVENT.ID}
注意:使用部分的邮箱无法正常发送邮件,日志报错:
11707:20160527:165712.955 Login denied: Authentication failed: 535
换成其它邮件就好了
管理-用户-报警媒介,设置接收告警的邮箱地址
关闭监控的zabbix-agent服务,可以收到告警邮件。
5.配置默认主页为zabbix
vi /etc/httpd/conf.d/httpd.conf
修改以下内容:
DocumentRoot "/usr/share/zabbix"
重启服务即可
service httpd restart
--结束END--
本文标题: Zabbix 3.0.3 LTS安装/配置/2.x升级
本文链接: https://lsjlt.com/news/38944.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0