I am trying to connect to ProxySQL from PHP with mysqlnd using the local socket, but I get
"No such file or directory"
, as the socket would not exist. The same code can connect to the mysql socket with no problem.
Basically I am reproducing what was described at:
https://www.percona.com/blog/2017/09/19/proxysql-improves-mysql-ssl-connections/
<?php
$i = 10000;
$user = 'percona';
$pass = 'percona';
while($i>=0) {
$mysqli = mysqli_init();
// ProxySQL
$link = mysqli_real_connect($mysqli, "localhost", $user, $pass, "", 6033, "/tmp/proxysql.sock")
or die(mysqli_connect_error());
$info = mysqli_get_host_info($mysqli);
$i--;
mysqli_close($mysqli);
unset($mysqli);
}
?>
This throws:
mysqli_real_connect(): (HY000/2002): No such file or directory
The socket file (/tmp/proxysql.sock) is in fact there:
$ ls -all /tmp
total 12
drwxrwxrwt. 11 root root 4096 Oct 7 17:33 .
dr-xr-xr-x. 28 root root 4096 Sep 20 17:42 ..
drwxrwxrwt. 2 root root 6 Aug 8 02:40 .font-unix
drwxrwxrwt. 2 root root 6 Aug 8 02:40 .ICE-unix
srwxrwxrwx 1 proxysql proxysql 0 Oct 7 17:11 proxysql.sock
I can use the mysql client to connect through it:
$ mysql -u myuser -p --socket /tmp/proxysql.sock --prompt='ProxySQLClient> '
If in the above PHP code I replace the socket file with the MySQL socket, then that works. It is only the proxysql.sock which doesn't work with mysqlnd.
I am using:
mysqlnd version mysqlnd 5.0.12-dev - 20150407
ProxySQL version 2.0.6
Any idea why the proxysql.sock is not accepted by mysqlnd?
UPDATE: Following #EternalHour's suggestion below, I have also tried moving the proxysql.sock file out of /tmp, but unfortunately that didn't make a difference. I am still receiving the same error.
EDIT (2019-10-08): It turns out this issue has nothing to do with PHP, as netcat throws the same problem too, whether the socket files in in /tmp or in /var/sockets/:
$ nc -U /tmp/proxysql.sock
Ncat: No such file or directory.
Out of the 3 nodes of the ProxySQL cluster running on the same OS, same kernel version, 1 has this issue, the other 2 allows connection to the socket file in /tmp/proxsql.sock, although over there too, sometimes restarting ProxySQL results in the socket file being created as private (eg not available to other applications)
Many MySQL Clients have a special handling of the wordlocalhost. localhost doesn't mean "use the resolver to resolve localhost and connect via TCP" but "use unix domain socket on the default path" to use TCP use 127.0.0.1 instead. If proxySQL also provides a unix domain socket provide that path.
I am sorry everyone, the issue was embarrassingly simple - it was simply my fault.
When I was changing the socket file's location in ProxySQL Admin I was using the following
update global_variables set variable_value='0.0.0.0:6033;/tmp/proxysql.sock ' where variable_name='mysql-interfaces';
SAVE MYSQL VARIABLES TO DISK;
Yes, that is a space at the end of "/tmp/proxysql.sock ".
When I was changing it to different locations, I only rewrote the first half of that (the folder), never the filename, so I just keep copying the space and hence always got file or directory not found...
Problem solved!
Sorry about it
Related
I'm attempting to create a simple CGI script using CentOS 7, Apache 2.4 and Ruby 2.0. All tools installed from official packages.
My script, which resides at /var/www/cgi-bin/test.cgi is:
#!/usr/bin/ruby
puts "Content-Type: text/plain\n\n"
begin
file = File.open("test.log", "a")
file.puts("foobar")
file.close
rescue Exception
puts "pwd: #{`pwd`}"
puts $!.inspect
end
When I load http://myhost/cgi-bin/test.cgi, I get the following:
pwd: /var/www/cgi-bin
#<Errno::EACCES: Permission denied - test.log>
However:
[root#host cgi-bin]# ls -l /var/www/cgi-bin
total 8
-rwxr-xr-x. 1 root root 153 Jul 10 22:03 env.cgi
-rwxr-xr-x. 1 root root 359 Jul 11 00:45 test.cgi
-rw-rw-rw-. 1 root root 0 Jul 11 00:42 test.log
How (and where) can I write data from inside this cgi script if not to a world-writable file in the script's own working directory?
SELinux was blocking the file writes. "setenforce Permissive" allowed them to go through. Edited /etc/sysconfig/selinux and rebooted to make permanent.
My apache user generate one file :
# ls -lsa /tmp/reference_file.csv
76 -rwxrwxrwx 1 apache apache 69921 Aug 16 14:14 /tmp/reference_file.csv
the user and the group belong to apache, but when i am trying to change it :
su -l apache -s /bin/bash
-bash-3.00$ whoami
apache
-bash-3.00$ chown explorer:btunix /tmp/reference_file.csv
chown: changing ownership of `/tmp/reference_file.csv': Operation not permitted
I tried to another folder, but the result was the same, I ve also checked attribut :
# lsattr /tmp/reference_file.csv
------------- /tmp/reference_file.csv
there is no immutable attribut
How can I do ?
Thanks
There are criteria associated with chown. Only super-user can chown files willy-nilly. Whether you can give away a file that you own depends on your UNIX flavor and how associated kernel configuration parameters (like K_CHOWN_MAY_GIVE_AWAY, for argument's sake) may have been, well, configured. This is the most GENERALLY correct answer.
I am trying to get a local LDAP proxy cache running. The idea is this:
Currently a computer (A) is sending all ldap requests to a remote ldap server (L)
Instead of that, there should be a proxy cache "server" running on A to act as an intermediate between A and L. The cache would store all queries and all their attributes (until it is filled up and then it starts "recycling").
OpenLDAP's Proxy Cache Engine looks pretty good, but there is not much information about how to set it up. There is an example config file, but I cannot get it to work.
When connected to the internet, running this command will successfully bind me.
ldapwhoami -vvv -h localhost -D "CN=Melka Martin,OU=something,OU=else,(...),DC=int,DC=somedomain,DC=com" -x -w <passwd>
However, each following request will still pool the remote LDAP server (as shown by sniffing the connection, and when the machine is disconnected from the internet, the local bind fails).
In the slapd output there is a lot of stuff, but the elligible:
56449abd QUERY NOT ANSWERABLE
56449abd QUERY CACHEABLE
This is the current config file, which should cache all the bind requests
database ldap
suffix "dc=int,dc=somedomain,dc=com"
rootdn "cn=admin,dc=int,dc=somedomain,dc=com"
rootpw <something>
uri ldap://dc-04.int.somedomain.com:389
overlay pcache
pcache hdb 100000 1 1000 100
pcacheAttrset 0 *
pcacheTemplate (sn=) 0 3600
pcacheBind (sn=) 0 3600 sub dc=int,dc=somedomain,dc=com
cachesize 200
directory /var/lib/ldap
index objectClass eq
index cn eq,sub
I have created the /var/lib/ldap directory, added a default DB_CONFIG file in there and then edited the slapd.conf file. If there are more things to do to set it up properly, could you instruct me?
I am a little confused about the rootdn/rootpw directives. They are used to write into the remote LDAP server, correct?
Edit: Below here is the original issue, which was resolved by using the full proper DN.
As this is supposed to only be a proxy cache, I shouldn't need to set up a local database. So the config file looks like this:
include /etc/openldap/schema/core.schema
include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/nis.schema
moduleload pcache.la
database ldap
suffix "dc=int,dc=somedomain,dc=com"
rootdn "dc=int,dc=somedomain,dc=com"
uri ldap://dc-04.int.somedomain.com:389
overlay pcache
pcache hdb 100000 1 1000 100
pcacheAttrset 0 *
pcacheTemplate (sn=) 0 3600
cachesize 20
directory /var/lib/ldap
index objectClass eq
index cn eq,sub
Now I would expect that any request to ldap://localhost would mirror to the remote LDAP, if not in the cache.
I use this command to test the auth on the remote server:
ldapwhoami -vvv -h dc-04.int.somedomain.com -p 389 -D melka#somedomain.com -x -w <passwd>
Which works well, I get the auth.
However, when I try to run the same command on localhost:
ldapwhoami -vvv -h localhost -p 389 -D melka#somedomain.com -x -w <passwd>
It fails, saying
ldap_initialize( ldap://localhost:389 )
ldap_bind: Invalid DN syntax (34)
additional info: invalid DN
Slapd is listening on localhost, netstat contains this line:
tcp 0 0 0.0.0.0:389 0.0.0.0:* LISTEN 10352/slapd
Is there something I am missing?
Thanks
melka#somedomain.com
That may be a DN in the target LDAP system, who knows, but it certainly isn't in OpenLDAP. You need to provide a proper Distinguished Name.
I am rebuilding an Icinga server that has been left behind by a previous employee. I have everything up and running, except for a bunch of MIB files for 3com switches that I cannot get to work.
The server is a CentOS 6 OpenVZ container.
In the original server there is a bunch of mib files in the default location at /usr/share/snmp/mibs/ and the 3com ones at /usr/share/snmp/mibs/3Com_4500/MIBs. The 3Com mibs work fine:
/usr/lib/nagios/plugins/check_snmp -H 10.10.111.11 -P 2c -C public -o hwDevMFanStatus.65536 -s "active(1)" -m A3COM-HUAWEI-LswDEVM-MIBSNMP OK - active(1) |
In the new server, the MIBs in the 3com folder do not get acknowledged and I get errors like the following:
/usr/lib/nagios/plugins/check_snmp -H 10.10.111.11 -P2c -C someuser -o hwDevMFanStatus.65536 -s "active(1)" -m A3COM-HUAWEI-LswDEVM-MIB
External command error: No log handling enabled - turning on stderr logging
Cannot find module (A3COM-HUAWEI-LswDEVM-MIB): At line 0 in (none)
hwDevMFanStatus.65536: Unknown Object Identifier (Sub-id not found: (top) -> hwDevMFanStatus)
/etc/snmp/snmpd.conf is identical for both servers and so is /etc/sysconfig/snmp.
set does not show any ENV variable related to snmp or mib.
Thanks
You are confusing snmpd.conf and snmp.conf the former being the configuration file for the SNMP daemon whereas Net-SNMP applications use snmp.conf.
The mibs/mibdirs directives you are interested in would be specified in snmp.conf (see also man snmp.conf.
I am trying to configure Magento to use memcache for session. I have installed memcached and also php5-memcache. I have also added "extension=memcache.so" in memcache.ini.
I have made sure the memcached instance is also running in the localhost port number 11213. However, when I try to login to Magento admin I get an error -
Warning: Unknown: Failed to write session data (memcache). Please verify that the current setting of session.save_path is correct (tcp://127.0.0.1:11213?persistent=0&weight=2&timeout=10&retry_interval=10) in Unknown on line 0
The following is the memcache configuration in local.xml -
<session_save><![CDATA[memcache]]></session_save>
<session_save_path><![CDATA[tcp://127.0.0.1:11213?persistent=0&weight=2&timeout=10&retry_interval=10]]></session_save_path>
The following are the grep for memcached,
www-data 1329 1 0 08:13 ? 00:00:00 /usr/bin/memcached -d -m 64 -p 11213 -u www-data -l 127.0.0.1
www-data 1511 1 0 08:18 ? 00:00:00 /usr/bin/memcached -d -m 64 -p 11211 -u www-data -l 127.0.0.1
www-data 1518 1 0 08:18 ? 00:00:00 /usr/bin/memcached -d -m 64 -p 11212 -u www-data -l 127.0.0.1
I have been meddling up with this for a couple of days now and I am not sure what the issue. Any help is appreciated.
Thanks,
G
Please note there is a difference between memcache and memcached. I’ve found that the Magento sessions integration expects you to use this:
<session_save><![CDATA[memcached]]></session_save>
You should install the PHP memcached libraries, as well.