i have a problem with yii and storing data in memcache. For my application i use system.caching.CMemCache and the following config:
'servers' => array(
'server1' => array('host' => 'localhost', 'port' => 11211, 'weight' => 50),
'server2' => array('host' => '192.168.0.2', 'port' => 11211, 'weight' => 50)
),
if memcache on both systems is running, everything is ok and the values get spread up on the servers. but if one server fails (or if i stop the memcache manually) the application throw errors like
MemcachePool::get(): Server 192.168.0.2 (tcp 11211, udp 0) failed with: Connection refused (111)
this isn't really nice, i thought if one server failed yii would choose another server for reading and writing or at least produce some cache misses and do not throw an exeption :(
is this normal or are there some configuration issues?
I think its normal you are seeing those messages as discussed here, given you are using memcache extension
And also read this SO.
There are two version of extension for php one is memcache while the other is memcached. You can install each of them on ubuntu box like :
sudo apt-get install php5-memcache
and
sudo apt-get install php5-memcached
Memecached extension handles failover situations ,as I read from the above links and confirm by testing following settings in yii
'cache'=>array(
'class'=>'CMemCache',
'useMemcached'=>true,
'servers'=>array(
array(
'host'=>'localhost',
'port'=>11211,
'weight'=>60,
),
array(
'host'=>'192.168.33.31',
'port'=>11211,
'weight'=>30,
),
),
),
Install the memcached extension for php as described above and add 'useMemcached'=>true, setting to cache configs.As I test on my localhost, it handles the failover situation, but the page response time drops significantly.
Hope this will be helpful.
Is this variable true?
http://www.php.net/manual/en/memcache.ini.php#ini.memcache.allow-failover
Otherwise this link can also be useful:
Memcache : Confusions
(Probably this is only a notice.)
Related
UPDATE: This question has been flagged as a question that has been solved already. But when checked, those previous "similar" questions require users to download the corresponding .dll file which is not applicable for macOS users and other answers did not explicitly elaborate on how to install needed extensions like pdo_sqlsrv, sqlsrv, and ODBC for XAMPP-installed PHP.
I'm trying to connect to MS SQL database using CodeIgniter 3.1.9 via ODBC:
$db['default'] = array(
'dsn' => '',
'hostname' => 'x.x.x.x',
'username' => 'sa',
'password' => 'xxx',
'database' => 'xxx',
'dbdriver' => 'odbc'
But I'm getting this error:
An uncaught Exception was encountered
Type: Error
Message: Call to undefined function odbc_connect()
Filename: /Applications/XAMPP/xamppfiles/htdocs/gpweb/system/database/drivers/odbc/odbc_driver.php
Line Number: 141
PHP is installed via XAMPP. I checked the php.ini file to get information about ODBC and the line below is disabled because of the semi-colon in the beginning:
;extension=php_pdo_odbc.dll
I know it is irrelevant because I'm running on MacOS and .dll files are for Windows (but I still tried enabling it and with more errors):
A PHP Error was encountered
Severity: Core Warning
Message: PHP Startup: Unable to load dynamic library '/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20160303/php_pdo_odbc.dll' - dlopen(/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20160303/php_pdo_odbc.dll, 0x0009): tried: '/Applications/XAMPP/xamppfiles/lib/php_pdo_odbc.dll' (no such file), '/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20160303/php_pdo_odbc.dll' (no such file)
Filename: Unknown
Line Number: 0
Has anyone encountered this issue before and how did you solve it? How can you enable ODBC in MacOS with PHP installed using XAMPP?
I found the solution, missing in php.ini
extension=php_odbc.dll
Unfortunately, macOS users that use XAMPP to install PHP have no way to install extensions like sqlsrv, pdo_sqlsrv, and ODBC, unlike in Windows, where they can download the necessary .dll files and enable extensions in the php.ini.
I've been using CodeIgniter 3.x.x for years to create web applications and MySQL as the database. I wanted to utilize the said PHP library with my other projects requiring MSSQL as the database since CI can do so, provided that you have installed the necessary extensions.
I have scoured the internet and there is really no definite solution to install extensions in XAMPP-installed PHP running macOS.
I gave up and installed PHP using homebrew instead. In your terminal, enter:
$ brew install php
Then installed sqlsrv extension (for M1 ARM64 users)
sudo CXXFLAGS="-I/opt/homebrew/opt/unixodbc/include/" LDFLAGS="-L/opt/homebrew/lib/" pecl install sqlsrv
sudo CXXFLAGS="-I/opt/homebrew/opt/unixodbc/include/" LDFLAGS="-L/opt/homebrew/lib/" pecl install pdo_sqlsrv
Then the ODBC extension:
HOMEBREW_NO_ENV_FILTERING=1 ACCEPT_EULA=Y
brew install msodbcsql17 mssql-tools
Since I cannot use the XAMPP-installed PHP, I have to use the CodeIgniter 4 to use the natively installed PHP:
composer create-project codeigniter4/appstarter project-root
After that, in the /project/app/Config/Database.php of my CodeIgniter 4 project, setup the connection to the database:
public $default = [
'DSN' => '',
'hostname' => 'x.x.x.x', // IP ADDRESS OF THE SQL SERVER
'username' => 'xxx', // USERNAME
'password' => 'xxx', // PASSWORD
'database' => 'xxx', // NAME OF DATABASE
'DBDriver' => 'SQLSRV', // DATABASE DRIVER TO BE USED
'DBPrefix' => '',
'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production'),
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 1433, // DEFAULT PORT FOR SQL SERVER
];
This is not the solution to the original problem (XAMPP-installed PHP), but an alternative solution to connect to MSSQL database using PHP.
REFERENCE:
https://learn.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver16
https://www.codeigniter.com/user_guide/installation/index.html
But still, if you found a way to install sqlsrv and ODBC extensions in XAMPP-installed PHP running macOS, please don't hesitate to post it here.
On a Nextcloud install I am receiving the error
No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the documentation.
So I have installed APCu, Redis, redis-php and made the required settings in NCs config.php
'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\OC\Memcache\Redis',
'memcache.distributed' => '\OC\Memcache\Redis',
'filelocking.enabled' => 'true',
'redis' =>
array (
'host' => '127.0.0.1',
'port' => '6379',
When I test the redis connection
redis-cli ping
I get a
PONG
(This works both w/ localhost and unix socket)
But Nextcloud obviously does not connect to Redis.
The http user is a member of the redis group.
php-redis module is activated.
Solved. The issue was with the location of the above code inside Nextcloud's config.php.
Now it is working as expected.
When I ssh into my local vagrant machine I can execute all artisan commands. Hower outside of it, any commands that needs database access such as artisan migrate gives Access denied for user 'root'#'localhost'. If it is possible, how can I use artisan without having to log in to the vagrant machine?
I would also like to do for example Artisian::call('migrate') for example during testing. But that gives the same error.
The reason for the access denied error is that mysql by default limits access to databases to the local machine. It is possible to open up for remote connections as described here, but it wouldn't be a good idea for production environments.
A better way is to add aliases for the commands you want as described here.
For doing calls to artisan etc in code, Laravel has a built in way of running commands on remote servers. First add connection information to the app/config/remote.php file. For vagrant it should look something like this:
'connections' => array(
'production' => array(
'host' => 'localhost',
'username' => 'vagrant',
'password' => 'vagrant',
'key' => '',
'keyphrase' => '',
'root' => '/vagrant',
),
),
Then execute artisan migrate like this:
SSH::run(array('cd /vagrant', 'php artisan migrate'));
You can do more advanced things as well. Here is the documentation.
I used this guide to install memcached on Centos 6.5
I first checked
/etc/init.d/memcached status and
memcached (pid 14784) is running...
Then restarted
service httpd restart
But when I try to use memcached on software(prosper202) I get
Fatal error: Call to a member function getCapabilities() on a non-object in /var/zpanel/hostdata/zadmin/public_html/******_com/3rd-parties/wurfl/WURFL/CustomDeviceRepository.php on line 72
I don't know whats causing it.
Here is my WURFL configuration file
<?php
include($_SERVER['DOCUMENT_ROOT'] . '/202-config.php');
$configuration = array(
// WURFL File Configuration
'wurfl' => array(
'main-file' => 'wurfl.zip',
'patches' => array("web_browsers_patch.xml"),
),
// Persistence (Long-Term Storage) Configuration
'persistence' => array(
'provider' => 'mysql',
'params' => array('host'=>$dbhost,
'port'=>3306,
'db'=>$dbname,
'user'=>$dbuser,
'pass'=>$dbpass),
),
// Cache (Short-Term Storage) Configuration
'cache' => array(
'provider' => 'memcache',
'params' => 'host='.$mchost.',port=11211,namespace=wurfl',
),
);
Aha! Your issue is not with your installation of memcached. Keep in mind that memcache and memcached are two different caching mechanisms.
You'll want to make sure that your server has memcache or apc installed for WURFL to be able to cache properly.
Type the following to see if memcached exists:
which memcached
Check the memcached version:
memcached -h
we already have a Moodle installation working in this scenario: linux + php5 + freetds + sql server.
but we just can't figure out how to link drupal 7 to sql server in the same manner.
what configs should we use? anyone ever tried this?
drupal simply does not show up in the available databases list.
note: we are already able to connect php to sql server using freetds, but just can't figure out how to do this on Drupal 7.
You can't use sqlsrv module on Linux because it requires PDO_SQLSRV driver that works only on Windows (see this comment)
To use FreeTDS you will need to write a Drupal Database Driver by yourself (similar with sqlsrv). Or don't use the database abstraction layer at all and do the call by yourself inside your module (if you only need MS SQL for parts of you project.
The good news (I hope) is that you can install dblib driver (in Ubuntu: sudo apt-get install php5-mssql) and use the sandbox project. A little info regarding this sandbox projects you can find in author's comment here. How to use it in you settings.php file can be seen here.
dblib database support in Drupal is still experimental, so test it before using it.
No you can't, but you can use drupal odbc driver which works the same way but connect through odbc (https://www.drupal.org/sandbox/pstewart/2010758), all you have to do is to install it (including its server requirement) and change your configuration to something like this (tested on Drupal 7 on Ubuntu Server) :
'external' =>
array (
'default' =>
array (
'odbc_driver' => 'FreeTDS',
'database' => '',
'username' => '',
'password' => '',
'host' => '',
'port' => '1433',
'driver' => 'odbc',
'prefix' => ''
),
),