Is it possible to access AppFog services like the MySQL database from Add-ons?
For example if I want to run some jobs on IronWorker and populate the results in my main App database running on AppFog.
If I check the credentials, it looks like these services are only internal IPs?!
Array ( [mysql-5.1] => Array ( [0] => Array ( [name] => dbname [label] => mysql-5.1 [plan] => free [tags] => Array ( [0] => mysql [1] => mysql-5.1 [2] => relational [3] => mysql-5.1 [4] => mysql ) [credentials] => Array ( [name] => d47fb5d7de0024290b53f74466ce00b [hostname] => 10.0.17.107 [host] => 10.0.17.107 [port] => 3306 [user] => uzBFvlo5ciU [username] => uzBFXPo5ciU [password] => p0fSFCOpWKs ) ) ) )
Cheers Stefan
Ok, it looks like I'm right and it isn't possible for production use.
The AppFog Database services are just configured for internal access.
[1] https://groups.google.com/forum/?fromgroups=#!topic/appfog-users/I31ni0pff9I
Related
What is the proper way to define separate read and write connections to separate MySQL databases in app/etc/env.php for Magento 2?
So the key here is to think of the Magento 1.X read write connections as master/slave connections in 2.X. I believe this is an enterprise only feature so community editions users might be out of luck. Below is an excerpt of my app/etc/env.php. We are using haproxy to balance read/write connections to a Percona cluster so unless you have the same setup you will need to configure your hosts to the appropriate IP's.
...
'db' =>
array (
'connection' =>
array (
'default' =>
array (
// HaProxy Write (master) connection
'host' => '127.0.0.1:3308',
'port' => '3308',
'dbname' => 'magento_db',
'username' => 'username',
'password' => 'password',
'active' => '1',
),
),
'slave_connection' =>
array (
'default' =>
array (
// HaProxy Read (slave) connection
'host' => '127.0.0.1:3307',
'port' => '3307',
'dbname' => 'magento_db',
'username' => 'username',
'password' => 'password',
'active' => '1',
),
),
'table_prefix' => '',
),
...
I am working with YII2.0 Multiple DB connection using ajax,i having multiple database like account, customer_1,customer_2..customer_n
in account database having user table then each user in that table have the corresponding DB.
Based on the user_id i like to connect the DB using ajax.is there have any possibility to do this.
Thanks in advance for your idea and suggestion .
you can do something similar as below to create run time db connection. you need to get right dbname and other details from your main database to create below temp connection
//create temp db connection
$config_temp = [
'components' => [
'tempdb' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=HOSTNAME;dbname=DBNAME',
'username' => USERNAME,
'password' => PWD,
'charset' => 'utf8',
],
],
];
$odb = Yii::createObject($config_temp['components']['tempdb']);
//link user group for current org
$sql = "SQL STATEMENT";
$command_temp = $odb->createCommand($sql);
I need to install an app written in Yii 2 on my local computer. I installed composer and initiated the app with:
php /path/to/yii-application/init
Now I need to "create a new database and adjust the components['db'] configuration in common/config/main-local.php accordingly."
I have no clue how to do that.
1) Create database on your server.
2) Open common/config/main-local.php
Edit components to:
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=DATABASE_NAME',
'username' => 'DATABASE_USER',
'password' => 'DATABASE_PASSWORD',
'charset' => 'utf8',
],
If using MAMP with mac then edit dsn line to :
'dsn' => 'mysql:unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock;dbname=DATABASE_NAME'
I am trying to set up a MediaWiki site at work. I want it to be resilient across multiple sites, so what I am planning is 1 master database to take writes, and then a local slave database for each web install. This will mean I will have:
Server 1: MySQL Master
Server 2: MySQL Slave, Apache + MW
Server 3: MySQL Slave, Apache + MW
...
Server N: MySQL Slave, Apache + MW
What I want to happen, is if a site "goes dark", they will still have a local copy of the MW running in Read-Only mode, until it is able to contact the Master MySQL server again. I have set up the below configuration file on 1 of the slave hosts, which works fine. However, once I turn off the Master MySQL server to simulate a loss of connection, MW comes up with a DB error instead of just becoming Read-Only.
$wgDBservers = array(
array('host' => "10.10.10.10",
'dbname' => "db",
'user' => "####",
'password' => "####",
'type' => "mysql",
'flags' => DBO_DEFAULT,
'load' => 0),
array('host' => "localhost",
'dbname' => "db",
'user' => "####",
'password' => "####",
'type' => "mysql",
'flags' => DBO_DEFAULT,
'load' => 1)
);
Have I missed something from the configuration and this is something that I am able to do, or does it not work because it is not intended to work that way? Any help is appreciated.
This is not in any way "best practice" but in lieu of any other answer, I am posting it for anyone needing a quick work-around.
It is a PHP script that sits directly in the LocalSettings.php file and checks the status of the Master Database. The "proper" way to do it would probably be with an extension, but I don't have time to learn how to make one. You need to ensure that the user account that you are using to connect to MySQL, has Read-Only access to the slave database.
$wgDBSite_Master = array('host' => "<master ip>", 'dbname' => "<database>", 'user' => "<user>", 'password' => "<pass>", 'type' => "mysql", 'flags' => DBO_DEFAULT, 'load' => 0);
$Site_MasterTest = mysql_connect($wgDBSite_Master['host'], $wgDBSite_Master['user'], $wgDBSite_Master['password']);
if (!$Site_MasterTest) {
$wgReadOnly = 'Wiki failed to contact the Master server. Your site is currently running Dark. No edits will be saved.<br>Last Error: '.mysql_error();
$wgSiteNotice = $wgReadOnly;
$wgDBservers = array();
}
else {
$wgSiteNotice = 'Everything running normally, Captain';
$wgDBservers = array( $wgDBSite_Master );
}
$wgDBservers[] = array('host' => "localhost", 'dbname' => "<database>", 'user' => '<user>', 'password' => "<pass>", 'type' => "mysql", 'flags' => DBO_DEFAULT, 'load' => 1);
It was working fine, all of sudden my db connection stop working.
below is the dump i got.
Array
(
[hostname] => localhost
[username] => ****
[password] => ****
[database] => *******
[dbdriver] => mysql
[dbprefix] =>
[pconnect] =>
[db_debug] =>
[cache_on] =>
[cachedir] =>
[char_set] => utf8
[dbcollat] => utf8_general_ci
[swap_pre] =>
[autoinit] => 1
[stricton] =>
)
Trying to connect to database: picspeak_dbCannot connect to the database because: Can't connect to local MySQL server through socket 'MySQL' (2)
i don't know how to solve it, please help me