Listing databases in rockmongo - php

I've got mongodb running in following configuration: 1 config server, 2 mongos, 8 shards (4 per mongos). I've got a problem using rockmongo administration tool:
if I connect to mongos router and try to list databases, I receive the following error:
Fatal error: Uncaught exception 'MongoCursorException' with message 'no primary!' in /home/vissi/var/www/rockmongo/app/models/MDb.php:5 ...
This problem exists only in one mongos, connecting to other mongos gives correct listing. Running db.serverStatus() in mongo console shows ... ok => 1 in both mongos.
if I connect to mongod running with shardsvr option, I see only config and local databases.
How should I connect to see all my databases correctly? phpmoadmin (and mongo console) runs show dbs ok.
If you have more than 1500 reputation, please, add rockmongo tag to this question.

The problem was resolved updating mongos at one of the machines from 1.6.5 to 1.7.3.

Related

Looking for more info about why I cannot connect with database Codeigniter 4

I made a small tool using Codeigniter 4 on my local machine in windows env with XAMPP.
I created a MySQL database in a server, pulled the code, and applied the appropriate configs but when I try to use parts of the tool that involve databases I get:
CodeIgniter\Database\Exceptions\DatabaseException #8
Unable to connect to the database.
The exception seems to be trow by BaseConnection.php at line 395
392 // We still don't have a connection?
393 if (! $this->connID)
394 {
395 throw new DatabaseException('Unable to connect to the database.');
396 }
I added a .env setting the environment to development so I can see the error messages.
My server is a shared server running PHP 8.0 with the following enabled modules
I also run a small script in the server but outside to Codeigniter to test password, username, port, and address and it is working fine.
Any help and tips to better understand what is happening or how to found out will be very appreciated.
You can check the writable/log folder and will have a more detailed log.

MySQL 8.0 + phpMyAdmin + docker [caching_sha2_password error]

As mentioned by others (Ref 1,
Ref 2 and Ref 3) the current phpMyAdmin version (4.8.2) + MySQL 8.0.11 + PHP 7.2.8 doesn't work as expected.
The error happens when you try to open phpMyAdmin, where it shows an error message:
#2054 - The server requested authentication method unknown to the client
mysqli_real_connect(): The server requested authentication method unknown to the client [caching_sha2_password]
mysqli_real_connect(): (HY000/2054): The server requested authentication method unknown to the client
As stated in MySQL migration manual here, and described as the solution in Ref 2, you can correct this by executing the following mysql query inside docker:
ALTER USER root IDENTIFIED WITH mysql_native_password BY 'ROOTPASSWORD';
(In order to run this, I use docker exec -it CONTAINERID bash and execute mysql command)
And it works. The main problem is that I need to fire this query as soon as the container starts (the current method is manual and far from scalable). I assume it's possible in different ways:
By executing a PHP script that runs the query after everything has been setup (IMO this is unsafe )
By running the above command in a bash after everything has been setup
The first one is unsafe IMO as the mysql user must have high privileges, although there will be only the root user when this script runs. I haven't tested it yet.
The seconde one is the best IMO, but I can't figure it out how to implement using Dockerfile, as everything I type there runs BEFORE mysql and phpMyAdmin are installed. How could I achieve that?
My current Dockerfile can be seen here and the docker-compose.yml can be seen here.
As a simple solution, you can build your custom mysql image and run the command there. Then mysql will start with this modification already in place.

PHP Redis invalid DB index

I'm connecting to Redis Labs to use redis for our application.
Here is my configurations:
$conf=[
'scheme'=>'tcp',
'host'=>'ec2.cloud.redislabs.com',
'port'=>12860,
'database'=>'selector',
'password'=>'redispassword'
];
Then I do this to load the predis library:
require "lib/predis/autoload.php";
After which I do this:
$client = new Predis\Client($conf);
Then I try to run a command:
$client->hset('comments',"comment:1","{json_encoded_data}");
And this is the error I receive:
PHP Fatal error: Uncaught exception 'Predis\Connection\ConnectionException' with message '`SELECT` failed: ERR invalid DB index [tcp://cloud.redislabs.com:12860]' in /redis/lib/predis/src/Connection/AbstractConnection.php:155
I've looked online and people say I should set the database as 0 however If I do that how do I use my selected database?
Not sure what to do here.
The host parameter is for your instance endpoint:
And RedisLabs only allows one database per instance, so you'll have no problem using 0 in the database parameter:
That is exactly the reason why each of our Redis Cloud instances
allows using just one database (the default, 0-numbered database).
This ensures that any two databases in our service will never compete
on the resources of a single thread. In fact, trying to use any
database other than 0 with our service should produce an error.
Source

Can't change doctrine connection

I'm trying to build a script that imports items from a production database to a local one, but am having problems switching the connection form production to local.
Doctrine_Manager::getInstance()->setCurrentConnection('prod-slave');
// execute query to get data from production, confirm it worked
Doctrine_Manager::getInstance()->setCurrentConnection('local');
// insert data into local database
When I run this I'm getting this error:
PHP Fatal error: Uncaught exception 'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[HY000]:
General error: 1290 The MySQL server is running with the --read-only
option so it cannot execute this statement' in...
If I close the connection to prod-slave before setting it to local I get:
PHP Fatal error: Uncaught exception 'Doctrine_Manager_Exception' with message 'Unknown connection: prod-slave' in...
Notice that in both of these cases, it's still trying to connect to the slave even though I changed the connection to local (In the first case, it must be the slave since it is read-only).
I have also tried manually setting the connections with:
Doctrine_Manager::connection('mysql://path');
Doctrine version: 1.2.3
Symfony version: 1.3.9
Any help would be much appreciated.
Thank you
If you check generated base classes for your models, at the very beginning you will see each of your model is bound to specific connection. So even if you set current connection to another one, the one bound is used.
Solution is to call Doctrine_Manager::getInstance()->bindComponent($component, 'local'); for each of your models.
Instead of using setCurrentConnection try using getConnection
$slave = Doctrine_Manager::getInstance()->getConnection('prod-slave');
$result1 = $slave->execute($some_sql);
$local = Doctrine_Manager::getInstance()->getConnection('local');
$result2 = $local->execute($some_other_sql);
works for me on a symfony 1.4 project.
This should work providing that, in your config/databases.yml, you have the two connections prod-slave and local properly setup. And in your schema files you have bound your tables to the appropriate connections. (Just in case a doc on connections and all that can be found here )

Fatal error: Class 'CassandraClient' not found in /home/dev001/projects/Thrift/gen-php/cassandraTest.php

I have installed cassandra and apache Thrift. I have created a PHP test page to test it.When I am running it returning the following error.
Fatal error: Class 'CassandraClient' not found in /home/dev001/projects/Thrift/gen-php/cassandraTest.php on line 15
When I checked cassandra through the cassandra-cli, Its showing the following error.
power#power-desktop:/home/dev001$ cassandra-cli
org.apache.thrift.transport.TTransportException: java.net.ConnectException: Connection refused
at org.apache.thrift.transport.TSocket.open(TSocket.java:183)
at org.apache.thrift.transport.TFramedTransport.open(TFramedTransport.java:81)
at org.apache.cassandra.cli.CliMain.connect(CliMain.java:79)
at org.apache.cassandra.cli.CliMain.main(CliMain.java:255)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)
at org.apache.thrift.transport.TSocket.open(TSocket.java:178)
... 3 more
Exception connecting to 127.0.0.1/9160. Reason: Connection refused.
Welcome to Cassandra CLI version 1.1.0~rc1
Type 'help;' or '?' for help.
Type 'quit;' or 'exit;' to quit.
[default#unknown]
Please tell me why this happening ?
Seems that you don't have cassandra listening on the correct IP/port. Run a netstat -an to see if it is listening on port 9160.
Having said that:
Cassandra not working with php
Cassandra with PHP - on call of cassandra-test.php I get "Call to undefined method CassandraClient::batch_insert()"
In summary, the consensus among the masses is that you should avoid using raw thrift wherever possible and use one of the maintained client libraries: Which PHP client library to use with Cassandra?
in your terminal type:
# service cassandra start
before using cassandra.
This starts the cassandra deamon. which must be running before sending commands to cassandra
I was getting the same error
but when i started cassandra via cassandra_installation_dir/bin/cassandra and then "cassandra_installation_dir/bin/cassandra-cli --host 192.168.1.90" i was able to log in.
Try this way if that works.

Categories