当我启动zabbix服务器时,日志显示如下:
# tail 300f /tmp/zabbix_server.log
[Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/usr/local/mysql/tmp/mysql.sock'
我的mysql正在运行,mysql的帐号(zabbix)正在运行;
[root@localhost data]# ps aux |grep mysql
root 49035 0.0 0.0 113264 1616 pts/2 S 17:00 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --user=mysql
mysql 49170 0.0 5.5 1274804 215428 pts/2 Sl 17:00 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/var/lib/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock
root 49628 0.0 0.0 112660 972 pts/2 S+ 17:22 0:00 grep --color=auto mysql
[root@localhost data]# /usr/local/mysql/bin/mysql -u zabbix -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.20 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| zabbix |
+--------------------+
2 rows in set (0.00 sec)
mysql>
袜子在这里:
[root@localhost data]# cd /var/lib/mysql/
[root@localhost mysql]# ll
total 188504
drwxr-xr-x 2 mysql mysql 4096 Jan 24 12:30 mysql
srwxrwxrwx 1 mysql mysql 0 Jan 24 17:00 mysql.sock
-rw------- 1 mysql mysql 6 Jan 24 17:00 mysql.sock.lock
drwxr-xr-x 2 mysql mysql 8192 Jan 24 12:30 performance_schema
drwxr-xr-x 2 mysql mysql 12288 Jan 24 15:12 zabbix
[root@localhost mysql]#
我的zabbix_server.conf
LogFile=/tmp/zabbix_server.log
DBName=zabbix
DBUser=zabbix
DBPassword=123456
出了什么问题,请帮帮我。
首先非常感谢你
答案 0 :(得分:1)
您的数据库套接字看起来像/var/lib/mysql/mysql.sock
。
因此,您需要为此配置zabbix_server.conf:
DBSocket=/var/lib/mysql/mysql.sock
Doc:https://www.zabbix.com/documentation/3.4/manual/appendix/config/zabbix_server
答案 1 :(得分:0)
像这样安装
useradd zabbix
yum install net-snmp-devel libxml2-devel libcurl-devel
./configure --prefix=/usr/local/zabbix-3.4.6/ --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
make
make install
cp /home/zabbix/zabbix-3.4.6/misc/init.d/fedora/core/zabbix_server /etc/init.d/
mysql添加帐号:
create database zabbix character set utf8;
grant all on zabbix.* to zabbix@localhost identified by '123456';
flush privileges;
use zabbix;
source /home/zabbix/zabbix-3.4.6/database/mysql/schema.sql
source /home/zabbix/zabbix-3.4.6/database/mysql/images.sql;
source /home/zabbix/zabbix-3.4.6/database/mysql/data.sql;
exit;
答案 2 :(得分:0)
只需重新启动运行Zabbix的服务器即可。