View Full Version : Can't load images into MySQL (ERROR 13: Can't get stat of ...)
I'm trying to do a fresh install of Zabbix 1.1beta5. I've read through the forums, but still I had no luck loading the images into the MySQL database using images.sql.
Here's what I did (I followed the instructions at http://www.zabbix.com/manual/v1.1/install_server.php):
Create zabbix user:
# su -
# useradd -m zabbix
# passwd zabbix
# su - zabbix
Download zabbix 1.1beta5:
# wget http://surfnet.dl.sourceforge.net/sourceforge/zabbix/zabbix-1.1beta5.tar.gz
# tar zxvf zabbix-1.1beta5.tar.gz
# rm -f zabbix-1.1beta5.tar.gz
# mv zabbix-1.1beta5 zabbix
# cd zabbix
Create database and load schema and data:
# mysql -uroot -p<password>
mysql> create database zabbix;
mysql> quit
# cd create/mysql
# cat schema.sql | mysql -uroot -p<password> zabbix
# cd ../data
# cat data.sql | mysql -uroot -p<password> zabbix
# cat images.sql | mysql -uroot -p<password> zabbix
ERROR 13 (HY000) at line 24: Can't get stat of '/home/zabbix/zabbix/create/data/images/Hub.png' (Errcode: 13)
Now, I've searched all over for this error, but none of the solutions seem to work for me:
The image.sql file has full paths and they're correct paths too
The max_allowed_packet variable is set to 16777216 (default for the package I installed), which should be enough (right?)
The MySQL root user has File_priv
I tried to copy the images over to /tmp, chmod them 777 and then load them, but still I get this error
My configuration:
CentOS 4.2
Mysql 4.1.12
Maybe the docs need some more info on this issue, as I've read many posts from people who have problems loading the images into the database.
From the documentation:
Note: Unfortunately MySQL does not support relative path in statement load_file(). You may want to edit images.sql to replace locations of image files. Also make sure that MySQL super-user (usually mysql) has read access to these files. If you still have any problems, copy images to directory /tmp, assign read permissions, change load_file() in images.sql, and execute images.sql. Additionally you may need to increase max_allowed_packets in MySQL configuration file.
I read that and I think I addressed all of those possible solutions in my post. Am I wrong?
KarmaPolice
04-01-2006, 18:01
I read that and I think I addressed all of those possible solutions in my post. Am I wrong?
what does your images.sql file look like?
This is images.sql:
--
-- Zabbix
-- Copyright (C) 2000,2001,2002,2003,2004 Alexei Vladishev
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
--
--
-- Dumping data for table `images`
--
insert into images values(1,1,"Hub",load_file("/home/zabbix/zabbix/create/data/images/Hub.png"));
insert into images values(2,1,"Hub (small)",load_file("/home/zabbix/zabbix/create/data/images/Hub_small.png"));
insert into images values(3,1,"Network",load_file("/home/zabbix/zabbix/create/data/images/Network.png"));
insert into images values(4,1,"Network (small)",load_file("/home/zabbix/zabbix/create/data/images/Network_small.png"));
insert into images values(5,1,"Notebook",load_file("/home/zabbix/zabbix/create/data/images/Notebook.png"));
insert into images values(6,1,"Notebook (small)",load_file("/home/zabbix/zabbix/create/data/images/Notebook_small.png"));
insert into images values(7,1,"Phone",load_file("/home/zabbix/zabbix/create/data/images/Phone.png"));
insert into images values(8,1,"Phone (small)",load_file("/home/zabbix/zabbix/create/data/images/Phone_small.png"));
insert into images values(9,1,"Printer",load_file("/home/zabbix/zabbix/create/data/images/Printer.png"));
insert into images values(10,1,"Printer (small)",load_file("/home/zabbix/zabbix/create/data/images/Printer_small.png"));
insert into images values(11,1,"Router",load_file("/home/zabbix/zabbix/create/data/images/Router.png"));
insert into images values(12,1,"Router (small)",load_file("/home/zabbix/zabbix/create/data/images/Router_small.png"));
insert into images values(13,1,"Satellite",load_file("/home/zabbix/zabbix/create/data/images/Satellite.png"));
insert into images values(14,1,"Satellite (small)",load_file("/home/zabbix/zabbix/create/data/images/Satellite_small.png"));
insert into images values(15,1,"Server",load_file("/home/zabbix/zabbix/create/data/images/Server.png"));
insert into images values(16,1,"Server (small)",load_file("/home/zabbix/zabbix/create/data/images/Server_small.png"));
insert into images values(17,1,"UPS",load_file("/home/zabbix/zabbix/create/data/images/UPS.png"));
insert into images values(18,1,"UPS (small)",load_file("/home/zabbix/zabbix/create/data/images/UPS_small.png"));
insert into images values(19,1,"Workstation",load_file("/home/zabbix/zabbix/create/data/images/Workstation.png"));
insert into images values(20,1,"Workstation (small)",load_file("/home/zabbix/zabbix/create/data/images/Workstation_small.png"));
I haven't touched the paths as the images are indeed in /home/zabbix/zabbix/create/data/images/.
Please pay attention to my post. Copy images to /tmp, assign read permissions (chmod guo+r *) to image files, modify paths in images.sql and, viola!, your problem is solved.
I'm sorry, but that's simply not true. By the way, the png images are already mode 644, so the chmod command changes nothing about the read permissions. But well, I did it anyway.
I did the following:
$ cd zabbix/create/data/images
$ cp * /tmp/
$ cd /tmp
$ chmod guo+r *
$ cd /home/zabbix/zabbix/create/data
$ vi images.sql
(Edited the paths)
$ cat images.sql | mysql -uroot -p<password> zabbix
ERROR 13 (HY000) at line 24: Can't get stat of '/tmp/Hub.png' (Errcode: 13)
So, it's still not working. :(
The images are indeed in /tmp though and have read permissions for all:
$ ls -l /tmp
total 160
-rw-r--r-- 1 zabbix zabbix 1960 Jan 4 18:45 Hub.png
-rw-r--r-- 1 zabbix zabbix 992 Jan 4 18:45 Hub_small.png
-rw-r--r-- 1 zabbix zabbix 1960 Jan 4 18:45 Network.png
-rw-r--r-- 1 zabbix zabbix 992 Jan 4 18:45 Network_small.png
-rw-r--r-- 1 zabbix zabbix 1923 Jan 4 18:45 Notebook.png
-rw-r--r-- 1 zabbix zabbix 920 Jan 4 18:45 Notebook_small.png
-rw-r--r-- 1 zabbix zabbix 3386 Jan 4 18:45 Phone.png
-rw-r--r-- 1 zabbix zabbix 1315 Jan 4 18:45 Phone_small.png
-rw-r--r-- 1 zabbix zabbix 1762 Jan 4 18:45 Printer.png
-rw-r--r-- 1 zabbix zabbix 951 Jan 4 18:45 Printer_small.png
-rw-r--r-- 1 zabbix zabbix 1960 Jan 4 18:45 Router.png
-rw-r--r-- 1 zabbix zabbix 992 Jan 4 18:45 Router_small.png
-rw-r--r-- 1 zabbix zabbix 2703 Jan 4 18:45 Satellite.png
-rw-r--r-- 1 zabbix zabbix 1187 Jan 4 18:45 Satellite_small.png
-rw-r--r-- 1 zabbix zabbix 1596 Jan 4 18:45 Server.png
-rw-r--r-- 1 zabbix zabbix 820 Jan 4 18:45 Server_small.png
-rw-r--r-- 1 zabbix zabbix 2276 Jan 4 18:45 UPS.png
-rw-r--r-- 1 zabbix zabbix 861 Jan 4 18:45 UPS_small.png
-rw-r--r-- 1 zabbix zabbix 2326 Jan 4 18:45 Workstation.png
-rw-r--r-- 1 zabbix zabbix 1056 Jan 4 18:45 Workstation_small.png
Have you modified paths to /tmp in images.sql as advised?!
Yes (that's why there's now /tmp in the error). Here is my images.sql for the files in /tmp:
--
-- Zabbix
-- Copyright (C) 2000,2001,2002,2003,2004 Alexei Vladishev
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
--
--
-- Dumping data for table `images`
--
insert into images values(1,1,"Hub",load_file("/tmp/Hub.png"));
insert into images values(2,1,"Hub (small)",load_file("/tmp/Hub_small.png"));
insert into images values(3,1,"Network",load_file("/tmp/Network.png"));
insert into images values(4,1,"Network (small)",load_file("/tmp/Network_small.png"));
insert into images values(5,1,"Notebook",load_file("/tmp/Notebook.png"));
insert into images values(6,1,"Notebook (small)",load_file("/tmp/Notebook_small.png"));
insert into images values(7,1,"Phone",load_file("/tmp/Phone.png"));
insert into images values(8,1,"Phone (small)",load_file("/tmp/Phone_small.png"));
insert into images values(9,1,"Printer",load_file("/tmp/Printer.png"));
insert into images values(10,1,"Printer (small)",load_file("/tmp/Printer_small.png"));
insert into images values(11,1,"Router",load_file("/tmp/Router.png"));
insert into images values(12,1,"Router (small)",load_file("/tmp/Router_small.png"));
insert into images values(13,1,"Satellite",load_file("/tmp/Satellite.png"));
insert into images values(14,1,"Satellite (small)",load_file("/tmp/Satellite_small.png"));
insert into images values(15,1,"Server",load_file("/tmp/Server.png"));
insert into images values(16,1,"Server (small)",load_file("/tmp/Server_small.png"));
insert into images values(17,1,"UPS",load_file("/tmp/UPS.png"));
insert into images values(18,1,"UPS (small)",load_file("/tmp/UPS_small.png"));
insert into images values(19,1,"Workstation",load_file("/tmp/Workstation.png"));
insert into images values(20,1,"Workstation (small)",load_file("/tmp/Workstation_small.png"));
After some more Googling around I'm pretty sure the error results from SELinux not allowing MySQL access to the files. SELinux comes enabled by default on modern Red Hat style systems (http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/selinux-guide/).
I found this bug report (which mentions Zabbix by the way):
http://bugs.mysql.com/bug.php?id=14147
I'm trying to figure out a way to let MySQL load these files without disabling SELinux completely. I'll probably need to use the chcon command. I'll investigate some more.
Yes (that's why there's now /tmp in the error)
Sorry, I missed this.
After some more Googling around I'm pretty sure the error results from SELinux not allowing MySQL access to the files. SELinux comes enabled by default on modern Red Hat style systems. Perhaps you may try to copy the image files to a directory which is read accessible by MySQL (/var/lib/mysql, whatever).
cameronsto
04-01-2006, 19:33
Try chmod ugo+rx on the directory the images are in. I think the script needs execute rights as well in order to be able to execute within the directory. If it really is selinux, can't you just disable it temporarily to import the images? http://fedora.redhat.com/docs/selinux-faq-fc3/index.html#id2826056
-cameron
Yes, that worked! Copying the files there gave them the root:object_r:mysqld_db_t security context, which allows reading by MySQL (there may be others, I don't know, I just read an article on SELinux the other day).
You might want to think about the installation procedure. More systems will be running SELinux, maybe there is a nicer way to get things installed. Maybe (temporarily) disabling SELinux is the nicest, maybe doing this copy/context hack is the nicest, maybe there is another way. Maybe at least add a note about SELinux in the documentation.
Phew... Anyway, thanks for the help! I appreciate it.
Q: How do I temporarily turn off enforcing mode without having to reboot?
A: This situation usually arises when you can't perform an action that is being prevented by policy. Run the command setenforce 0 to turn off enforcing mode in real time. When you are finished, run setenforce 1 to turn enforcing back on.
Yes, that would have probably been the nicest solution. Maybe add this suggestion to the installation instructions?