external distributed memcache not workking - memcached

this is my first post on here.
I installed the latest version of Nextcloud (19.0.0) on one machine and try to split all the services to different vm's. that means DB (mariadb), Storage, redis (for file locking), memcached (distributed cache) on different machines, all of which are running Ubuntu 20.04 LTS. This setup is a bit janky, but it helps me better understand, how each service functions. The DB-Server and Redis are working fine. Now I want to get memcached to work. as soon as i add the parameters i get an internal server error. this is what I have in my config.php
array (
0 => '10.10.10.45',
1 => 'nextcloudtest.test.lan',
),
'datadirectory' => '/nextcloud-data',
'dbtype' => 'mysql',
'version' => '19.0.0.12',
'overwrite.cli.url' => 'https://nextcloudtest.test.lan',
'htaccess.RewriteBase' => '/',
'dbname' => 'nextcloud',
'dbhost' => '10.10.10.49',
'dbport' => '3306',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'nextcloud',
'dbpassword' => 'password',
'installed' => true,
// 'memcache.local' => '\OC\Memcache\APCu',
'memcache.distributed' => '\\OC\Memcache\\Memcached',
'memcached_servers' => array(
array('10.10.10.47', 11211),
),
'memcache.locking' => '\\OC\\Memcache\\Redis',
'filelocking.enabled' => 'true',
'redis' =>
array (
'host' => '10.10.10.46',
'port' =>6379,
'timeout' => 0.0,
),
);
Then i get this error in the nextcloud.log
\\OC\\Memcache\\Memcached not available for distributed cache","Code":0
I did set the bind address in the memcached.conf to 0.0.0.0 so it accepts all incoming connections and also added a rule to the firewall to allow incoming connections on port 11211.
I hope you guys cane give me some tipps.

Related

SQLSTATE[HY000] [1045] Access denied for user - OVH Eloquent

For a project I use Slim 3 - Twig and Eloquent. On development mode, all works perfectly, but on production, hosted in the OVH shared server, I can't access to the database.
I'm hundred percent sure of credentials and the database was not created right now.
This is my code :
$capsule = new \Illuminate\Database\Capsule\Manager;
$capsule->addConnection($config['db']);
$capsule->bootEloquent();
$capsule->setAsGlobal();
Where $config['db'] contains the informations required by Eloquent :
$config = [
'settings' => [
'debug' => true,
'displayErrorDetails' => true
],
'db' => [
'driver' => 'mysql',
'host' => '****.mysql.db',
'database' => '****',
'username' => '****',
'password' => '****',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => ''
]
]
What I have to do to make it work ?
Ok ... I get the solution.
... Suspense ...
I have to remove spaces around the big arrows in my beautiful formatted array.
Yes. I'm gonna cry.

ZfcUserDoctrineMongoODM Configuration examples

I am trying to configure ZendFramwork 2 to use MongoDB as the storage for user Authentication.
I already have installed what I believe are the correct modules and have a correctly installed instance of ZF2 running on Nginx. I also have an instance of Mongo running and I am already using this for another project. The modules declaration in application.config.php looks like this
'modules' => array(
'Application',
'ZfcBase',
'ZfcUser',
'ZfcUserDoctrineMongoODM',
'DoctrineModule',
'DoctrineMongoODMModule'
)
Documentation is a bit thin on how to configure the system to get it working. Can anyone provide any code fragments around configuring the database settings to allow Mongo to run with ZfcUser, this is where I am at a loss now.
Any help, clues or cheat sheets would be greatly appreciated.
Darren Breeze
Have a look at Doctrine Mongo ODM module readme https://github.com/doctrine/DoctrineMongoODMModule :
copy
vendor/doctrine/doctrine-mongo-odm-module/config/module.doctrine-mongo-odm.local.php.dist
into your application's config/autoload directory, rename it to
module.doctrine-mongo-odm.local.php and make the appropriate changes.
With this config file you can configure your mongo connection, add
extra annotations to register, add subscribers to the event manager,
add filters to the filter collection, and drivers to the driver chain.
So you have something like this at your autoload config:
<?php
return array(
'doctrine' => array(
'connection' => array(
'odm_default' => array(
'server' => 'localhost',
'port' => '27017',
// 'connectionString' => null,
// 'user' => null,
// 'password' => null,
// 'dbname' => null,
// 'options' => array()
),
),
....
'configuration' => array(
'odm_default' => array(
... 'default_db' => 'myappdb',
)
)
So tune it and try to register at user/register. Collection name is user by default.

Flush default cache

I am using a couchbase memcached bucket for my cakephp default cache. I would like to be able to flush the cache when I change the schema within my cakephp app. There is a method to clear the cache however it is asking for arguments.
How do I use this method to clear / flush the cache?
Edit: my bootstrap contains the setup for the cache config
Cache::config('default', array(
'engine' => 'Memcache',
'prefix' => Inflector::slug(APP_DIR) . '_',
'servers' => array(
'127.0.0.1:11211' // localhost, default port 11211
), //[optional]
'duration' => 7200,
'serialize' => false,
'persistent' => true, // [optional] set this to false for non-persistent connections
'compress' => false,
'probability' => 100
)
);
Cache::clear(false, 'default'); // Default configuration, shortcut Cache::clear()
Cache::clear(false, '_cake_core_'); // General framework caching
Cache::clear(false, '_cake_model_'); // Cache for model and datasource caches

Yii mongodbsuite two and more database connections

How to make two or more database connections in Yii mongodbsuite?
I added 2 DB components in main.php:
'components' => array(
'mongodb' => array(
'class' => 'common\extensions\MongoDB',
'connectionString' => 'mongodb://localhost:27017/table1',
'dbName' => 'table1',
'fsyncFlag' => false,
'persistentConnection' => 'x',
'replicaSet' => false,
'safeFlag' => true,
'useCursor' => false,
),
'mongodb2' => array(
'class' => 'common\extensions\MongoDB',
'connectionString' => 'mongodb://localhost:27017/table2',
'dbName' => 'table2',
'fsyncFlag' => false,
'persistentConnection' => 'x',
'replicaSet' => false,
'safeFlag' => true,
'useCursor' => false,
),
)
But how to use mongodb2 in query (ex: ->findByAttributes()) i don't know.
Please provide some example queries using the mongodb2 connection above.
I just add 'mongodb2' => array to 'components' => array and add to models (ex: User) who extends EMongoDocument:
public function getMongoDBComponent() {return Yii::app()->mongodb2;}
And it is work!
Have a look at Multiple db support in Yii.
Basically you have to modify your active record class by overriding the getDbConnection() methods. (In the given link you have a better example using an intermediate inheritance layer)

Need help with Zend_Form_Element_Captcha in localhost and web hosting environment

Currently I'm develping a web application using Zend framework.
My problem is that I have to write 2 set of codes for the captcha element for my localhost (window environment running XAMPP ) and web hosting (linux environment).
My question is that is there a better way to code it, so that it works both my localhost and web hosting environment? At the moment is just so annoying to keep changing the codes when I upload to the web host enviroment.
Thanks so much in advance. :)
Here is my code for my web hosting environment
array('captcha' => array(
'captcha' => 'Image',
'wordLen' => 3,
'timeout' => 600,
'font' => '../font/arial.ttf',
'imgurl' => '../images/captcha/',
'fontsize' =>20,
'expiration' =>20,
'lineNoiseLevel' =>0,
'DotNoiseLevel' =>10,
)
)
);
It work perfectly on the web host but if i run it in my localhost window environment i get blank captcha the text doesn't get generated.
This is what i currently have for my localhost and its work fine.
array('captcha' => array(
'captcha' => 'Image',
'wordLen' => 3,
'timeout' => 600,
'font' => 'C:\WINDOWS\Fonts\arial.ttf',
'imgurl' => 'http://localhost/images/captcha',
'fontsize' =>20,
'expiration' =>20,
'lineNoiseLevel' =>0,
'DotNoiseLevel' =>10,
)
)
);
Use APPLICATION_PATH for the font .
From http://framework.zend.com/manual/en/zend.captcha.adapters.html the default is "./images/captcha/" . So not needed.
Hope it helps you.