Cant connect to Mysql master/slave using Entityframework - mysql

I have mysql master slave configuration and i cant connect to it when i specify two ips. I search for connection string and found http://www.connectionstrings.com/mysql-connector-net-mysqlconnection/
Server=serverAddress1, serverAddress2, serverAddress3;Database=myDataBase;
Uid=myUsername;Pwd=myPassword;
So its looks simple but when i specify my two ips i get error "No such host is known"
I also found https://blogs.oracle.com/MySqlOnWindows/entry/how_to_using_replication_load and tried it but strange thing is that then it much slower. So now i am lost i cant use my replication.
PS. I am not sure if it make sense but i am running that on Azure

You should specify server in specific config section
<configSections>
<section name="MySQL" type="MySql.Data.MySqlClient.MySqlConfiguration, MySql.Data, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
</configSections>
<MySQL>
<Replication>
<ServerGroups>
<Group name="MasterSlave">
<Servers>
<Server name="master" IsMaster="true" connectionstring=" server=<server>;port=<port>;uid=<user>;password=<password>;"/>
<Server name="slave" IsMaster="false" connectionstring=" server=<server>;port=<port>;uid=<user>;password=<password>;"/>
</Servers>
</Group>
</ServerGroups>
</Replication>
</MySQL>
Then use following as a connection string:
"server=MasterSlave;database=sakila;"
Source: https://blogs.oracle.com/MySqlOnWindows/entry/how_to_using_replication_load

Related

Google Omaha installer hangs

I'm trying to get Google Omaha to work, and even though I feel I'm really close for some reason it is not.
I've read the few guides and tutorials available online for it and finally managed to get the client built. I've also installed the docker package provided by Crystalnix and as far as I can tell everything is setup as it should.
For some reason however the installation process gets stuck after the API request for the package information is made.
The last response from the server looks as follows:
<response protocol="3.0" server="prod">
<daystart elapsed_seconds="62157" elapsed_days="4372"/>
<app status="ok" appid="{XXX-XXX-XXX}">
<updatecheck status="ok">
<urls>
<url codebase="http://updates.example.com/static/media/build/Product/stable/win/78065329307666/"/>
</urls>
<manifest version="71.0.57.18">
<packages>
<package required="true" hash="6uZwsU9+WCZ1oR3ovGnFyrTCqhM=" name="install.exe" size="59309528"/>
</packages>
<actions>
<action successsaction="default" run="install.exe" event="install"/>
</actions>
</manifest>
</updatecheck>
</app>
</response>
After this request is being retried for three times the installer hangs with this error: Unable to connect to the Internet. If you use a firewall, please whitelist ProductUpdate.exe
What could the issue for this be?
LE: this is the complete Omaha log file https://pastebin.com/QALnk7X7

Installing WSO2 greg and API manager on different VM with shared MySQL

I'm installing greg and APi manager using this configuration:
1 VM for MySQL
1 VM for API
1 VM for BAM
1 VM for greg
All latest currrent releases
I'm wandering which is the best configuration.
My idea was having all the tool to place data in MySQL, but I'm wandering on how to ling all the DB in the various config files
APi should point to registry runniong on his VM and to the BAM instance, but looking on the registru moaster-datasource.xml I found also this:
<datasource>
<name>WSO2AM_DB</name>
<description>The datasource used for API Manager database</description>
<jndiConfig>
<name>jdbc/WSO2AM_DB</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:h2:repository/database/WSO2AM_DB;DB_CLOSE_ON_EXIT=FALSE</url>
<username>wso2carbon</username>
<password>wso2carbon</password>
<driverClassName>org.h2.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
</configuration>
</definition>
</datasource>
That imply that registry has access to API manager DB ... what for?
I'll have to add also ESB and BPS so this deployment architecture becomes complex.
Any hints
Thanks
Luca
WSO2 servers are using H2 database which is shipped by default. So if you start up a fresh pack which will run on its own database instance.
In order to share the registry data between servers, you will have to configure registry mounting. This will be helpful to create JDBC mounting. But if you have one instance of a server, then you can omit clustering part from the article. You can follow the same configuration for other servers as well (BAM, API manager and BPS) to configure JDBC mounting. So that all your data will be stored in MySql and shared across servers.
If you need to store users information also in JDBC and share it across servers, then you will have to add another data source into master-datasource.xml and use it in CARBON-HOME/repository/conf/user-mgt.xml instead of the default data source.
API manager is having few different data sources for its own purposes. That doesn't mean to have any relationship with registry. By default "WSO2CarbonDB" is only used for registry and user manager purposes as stated in the description of each data sources.
You can use mounted database to resolve your issue . please refer [1] for how to mount guide.
[1]. http://ajithvblogs.blogspot.com/2012/09/create-jdbc-mount-to-wso2-governance.html
Thank You,
Dharshana

How do you configure jetty to allow access from an external server?

I've seen this asked before, with no good answers, how do you configure jetty to allow access from an external server? I've just started messing around with solr and jetty and am using the example jetty instance that comes with solr.
solr is running fine on localhost, and I can query it from sites on the same server. However, I can't access the solr instance from another server. I've googled and read quite a bit in the last few days, but have not been able to discover what's keeping jetty from allowing non localhost access to solr.
Based on what I've read, I have tried added the following line to example/etc/jetty.xml
<Set name="Host">0.0.0.0</Set>
and still got no external response
then tried
<Set name="Host">x.x.x.x</Set>
where x.x.x.x is my server's IP address
and
<Set name="Host">host.domain.com</Set>
where host.domain.com is my server's FQDN
These both resulted in the error
java.net.BindException: Cannot assign requested address
when I started.
The start command I'm using is
sudo java -jar start.jar etc/jetty.xml
You can point me to where I can read on this or spoon feed me, I don't care. I'd just like to get past this hurdle so I can keep learning about setting up and using solr.
you should add a file called clientaccesspolicy.xml for cross domain access to your static web files directory:
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-methods="*" http-request-headers="*">
<domain uri="http://*"/>
<domain uri="https://*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
you should set you static directory to jetty using this code:
ResourceHandler staticHandler = new ResourceHandler();
staticHandler.setResourceBase("static/dir");
handlers.addHandler(staticHandler);

Google Web Toolkit (GWT) web app with MySQL working fine in Eclipse but not working on openSUSE server

I've written a GWT web app which is hosted on an external openSUSE server. I use Google's GWT RPC to communicate with the server and send data from my client to the server where a MySQL database gets updated. Everything works perfectly fine in Eclipse but as soon as I move my /war directory to the server (including the necessary mysql-connector-java-5.1.18-bin.jar file for the java-connector), the local SQL database on my server is not getting updated. Why is it not working? Is this some kind of mysql config issue?
I have set up a database on the server with the exact same name and table as the one on my local machine (where I was debugging with Eclipse). I do not get any errors from GWT (so the server access works fine) and my SQL log files also show no errors.
I have tried to restart mysql, checked that port 3306 for mysql is open and listening, disabled the firewall, and tried both localhost and 127.0.0.1 for the host.
I cannot figure out what the problem is, PLEASE someone help me! I'm going crazy here!
Here is my server side code which works fine in Eclipse but not on the server!
package com.mycompany.mywebapp.server;
#SuppressWarnings("serial")
public class GreetingServiceImpl extends RemoteServiceServlet implements
GreetingService {
public String[] greetServer(String[] input) {
//Data is entered into MySQL database on server side
Connection con = null;
Statement st = null;
String url = "jdbc:mysql://127.0.0.1:3306/testdb";
String user = "username";
String password = "pass";
try{
con = DriverManager.getConnection(url,user,password); //establishes connection to database
st = con.createStatement(); //object for sending SQL statements to database
for (int i=0;i<input.length;i++){
String DataToSend = input[i];
String part1 = DataToSend.substring(0,DataToSend.indexOf("["));
String part2 = DataToSend.substring(DataToSend.indexOf("["),DataToSend.indexOf("]")+1);
//store values into mysql database
String query = "INSERT INTO boundingboxes(name, box) VALUES('"+part1+"','"+part2+"')";
st.executeUpdate(query);
}
}catch (SQLException ex){
Logger lgr = Logger.getLogger(Version.class.getName());
lgr.log(Level.SEVERE, ex.getMessage(), ex);
}finally{
//make sure to avoid null pointerexception
try{
if (st !=null){
st.close();
}
if (con != null){
con.close();
}
}catch (SQLException ex){
Logger lgr = Logger.getLogger(Version.class.getName());
lgr.log(Level.WARNING, ex.getMessage(), ex);
}
}
return input;
}
}
I found the solution to my problems:
To get rid of the NoClassDefFoundError, the external .jar files used by your app should be copied into the /WEB-INF/lib/ directly.
Apache requires an extra configuration step for jdbc-msql. Firstly, make sure that you have set the correct GRANT permissions set up for your SQL database.
Next, follow his solution which is taken from: http://dev.mysql.com/doc/refman/5.0/en/connector-j-usagenotes-j2ee.html#connector-j-usagenotes-tomcat
First, install the .jar file that comes with Connector/J in $CATALINA_HOME/common/lib so that it is available to all applications installed in the container.
Next, Configure the JNDI DataSource by adding a declaration resource to $CATALINA_HOME/conf/server.xml in the context that defines your web application:
<Context ....>
...
<Resource name="jdbc/MySQLDB"
auth="Container"
type="javax.sql.DataSource"/>
<!-- The name you used above, must match _exactly_ here!
The connection pool will be bound into JNDI with the name
"java:/comp/env/jdbc/MySQLDB"
-->
<ResourceParams name="jdbc/MySQLDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<!-- Don't set this any higher than max_connections on your
MySQL server, usually this should be a 10 or a few 10's
of connections, not hundreds or thousands -->
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>
<!-- You don't want to many idle connections hanging around
if you can avoid it, only enough to soak up a spike in
the load -->
<parameter>
<name>maxIdle</name>
<value>5</value>
</parameter>
<!-- Don't use autoReconnect=true, it's going away eventually
and it's a crutch for older connection pools that couldn't
test connections. You need to decide whether your application
is supposed to deal with SQLExceptions (hint, it should), and
how much of a performance penalty you're willing to pay
to ensure 'freshness' of the connection -->
<parameter>
<name>validationQuery</name>
<value>SELECT 1</value> <-- See discussion below for update to this option -->
</parameter>
<!-- The most conservative approach is to test connections
before they're given to your application. For most applications
this is okay, the query used above is very small and takes
no real server resources to process, other than the time used
to traverse the network.
If you have a high-load application you'll need to rely on
something else. -->
<parameter>
<name>testOnBorrow</name>
<value>true</value>
</parameter>
<!-- Otherwise, or in addition to testOnBorrow, you can test
while connections are sitting idle -->
<parameter>
<name>testWhileIdle</name>
<value>true</value>
</parameter>
<!-- You have to set this value, otherwise even though
you've asked connections to be tested while idle,
the idle evicter thread will never run -->
<parameter>
<name>timeBetweenEvictionRunsMillis</name>
<value>10000</value>
</parameter>
<!-- Don't allow connections to hang out idle too long,
never longer than what wait_timeout is set to on the
server...A few minutes or even fraction of a minute
is sometimes okay here, it depends on your application
and how much spikey load it will see -->
<parameter>
<name>minEvictableIdleTimeMillis</name>
<value>60000</value>
</parameter>
<!-- Username and password used when connecting to MySQL -->
<parameter>
<name>username</name>
<value>someuser</value>
</parameter>
<parameter>
<name>password</name>
<value>somepass</value>
</parameter>
<!-- Class name for the Connector/J driver -->
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<!-- The JDBC connection url for connecting to MySQL, notice
that if you want to pass any other MySQL-specific parameters
you should pass them here in the URL, setting them using the
parameter tags above will have no effect, you will also
need to use & to separate parameter values as the
ampersand is a reserved character in XML -->
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/test</value>
</parameter>

The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM’

I have an ASP.NET web application written in VB.NET. One part of the application makes an AJAX call to an internal ASMX file which in turn makes a call to a remote web service which is just a single ASMX file. Normally this works fine and has been deployed a couple of times and works fine. One client however, is getting the message from the AJAX call:
The HTTP request is unauthorized with client authentication scheme
'Anonymous'. The authentication header received from the server was
'NTLM’.
I have scoured a large amount of websites trying to fix this but I can’t seem to find any answer that works for me.
I have been unable to replicate the error on my test server, which is the same as the client, Win2003 IIS6.
The remote web service is deployed on Windows 2008 r2 – IIS7.5. The remote service is deployed using ‘Anonymous’ authentication only. The client deployment is set up with Anonymous and ‘Integrated Windows Authentication’. I have tried changing the authentication levels on both implementations but cannot replicate the issue. The closest I have come is when I set the remote service IIS authentication to
The HTTP request is unauthorized with client authentication scheme
'Ntlm'. The authentication header received from the server was ''.
In the web.config file the reference to the remote service is:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="SVCMappingSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://svc.website.com/services/myService.asmx" binding="basicHttpBinding" bindingConfiguration="SVCMappingSoap" contract="SVCMappingService.SVCMappingSoap" name="SVCMappingSoap"/>
</client>
</system.serviceModel>
I have tried changing a number of the setting in the <security> section but still unable to replicate.
I am not sure of your total server setup.
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
</security>
instead of above one please try with below configuration
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
please go through below links, you can more idea on those and you can change the config based on your requirements:
http://blogs.msdn.com/b/publicsector/archive/2005/10/19/482833.aspx
http://fczaja.blogspot.com/2009/10/http-request-is-unauthorized-with.html
http://ddkonline.blogspot.com/2009/11/fix-http-request-is-unauthorized-with.html
I had to change the default generated
<security mode="Transport"/>
into
<security mode="Transport" >
<transport clientCredentialType="Ntlm"/>
</security>
One more comment for this problem:
If you are not using HTTPS,
<security mode="Transport"/>
is not supported. You can use
<security mode="TransportCredentialOnly">
instead.