Error with using Neo4j-spark-connector - apache-spark

I have been following the example from https://neo4j.com/blog/neo4j-3-0-apache-spark-connector/ and everything seemed fine until I try the following assignment:
val query = "cypher runtime=compiled MATCH (n) where id(n) < {maxId} return id(n)"
I get the error "Unable to connect to 'localhost' on port 7687, ensure the database is running and that there is a working network connection to it."
I am fairly new to Spark and am not sure how to fix this. When I ran this I had have my Neo4j database on.

Port 7687 is the port for BOLT, the Binary protocol for Neo4j that the Java driver bundled in the Neo4j Spark Connector uses to pull data from Neo4j. So this is a connection error to Neo4j.
What version of Neo4j are you using? Are you using the default config settings for Neo4j?
Did you specify the password for neo4j as specified here:
spark.neo4j.bolt.password=<password>
If you're following the example from the blog post the command to start spark shell would look like this:
$SPARK_HOME/bin/spark-shell \
--conf spark.neo4j.bolt.password=YOUR_PASSWORD_FOR_NEO4J_HERE \
--packages neo4j-contrib:neo4j-spark-connector:1.0.0-RC1,\
graphframes:graphframes:0.1.0-spark1.6

Related

Using Neo4j with PySpark on Databricks: org.neo4j.driver.exceptions.ServiceUnavailableException error

I am trying to query a graph hosted on Neo4j from Databricks using neo4j-spark-connector. I am using the following code to access the graph:
df = spark.read.format("org.neo4j.spark.DataSource")\
.option("url", "bolt://<IP adress>:7687")\
.option("authentication.type", "basic")\
.option("authentication.basic.username", "<username>")\
.option("authentication.basic.password", "<password>")\
.load()
This error is returned:
org.neo4j.driver.exceptions.ServiceUnavailableException: Unable to connect to 18.206.149.168:7687, ensure the database is running and that there is a working network connection to it.
Any idea of what I am missing in the use of the connector here ?
Details on versions/ libraries:
Neo4j Browser version: 4.2.1-patch-3.0
Neo4j Server version: 4.4.8 (enterprise)
Installed neo4j-spark-connector on Databricks:
neo4j-contrib:neo4j-connector-apache-spark_2.12:4.0.1_for_spark_3
I have added in the spark configuration following lines:
spark.neo4j.bolt.password <password>
spark.databricks.passthrough.enabled true
spark.neo4j.bolt.url bolt://<IP adress>:7687
spark.neo4j.bolt.user <username>
Unfortunately, online documentation isn't up-to-date to latest releases of neo4j versions (4+).
I am trying to follow the process explained in this blog by adapting it to the neo4j version I am using.

Spark Job fails connecting to oracle in first attempt

We are running spark job which connect to oracle and fetch some data. Always attempt 0 or 1 of JDBCRDD task fails with below error. In subsequent attempt task get completed. As suggested in few portal we even tried with -Djava.security.egd=file:///dev/urandom java option but it didn't solved the problem. Can someone please help us in fixing this issue.
ava.sql.SQLRecoverableException: IO Error: Connection reset by peer, Authentication lapse 59937 ms.
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:794)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:688)
Issue was with java.security.egd only. Setting it through command line i.e -Djava.security.egd=file:///dev/urandom was not working so I set it through system.setproperty with in job. After that job is no more giving SQLRecoverableException
This Exception nothing to do with Apache Spark ,"SQLRecoverableException: IO Error:" is simply the Oracle JDBC driver reporting that it's connection
to the DBMS was closed out from under it while in use. The real porblem is at
the DBMS, such as if the session died abruptly. Please check DBMS
error log and share with question.
Similer problem you can find here
https://access.redhat.com/solutions/28436
Fastest way is export spark system variable SPARK_SUBMIT_OPTS before running your job.
like this: export SPARK_SUBMIT_OPTS=-Djava.security.egd=file:dev/urandom I'm using docker, so for me full command is:
docker exec -it spark-master
bash -c "export SPARK_SUBMIT_OPTS=-Djava.security.egd=file:dev/urandom &&
/spark/bin/spark-submit --verbose --master spark://172.16.9.213:7077 /scala/sparkjob/target/scala-2.11/sparkjob-assembly-0.1.jar"
export variable
submit job

Error while running Zeppelin paragraphs in Spark on Linux cluster in Azure HdInsight

I have been following this tutorial in order to set up Zeppelin on a Spark cluster (version 1.5.2) in HDInsight, on Linux. Everything worked fine, I have managed to successfully connect to the Zeppelin notebook through the SSH tunnel. However, when I try to run any kind of paragraph, the first time I get the following error:
java.io.IOException: No FileSystem for scheme: wasb
After getting this error, if I try to rerun the paragraph, I get another error:
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
These errors occur regardless of the code I enter, even if there is no reference to the hdfs. What I'm saying is that I get the "No FileSystem" error even for a trivial scala expression, such as parallelize.
Is there a missing configuration step?
I am download the tar ball that the script that you pointed to as I type. But want I am guessing is that your zeppelin install and spark install are not complete to work with wasb. In order to get spark to work with wasb you need to add some jars to the Class path. To do this you need to add something like this to your spark-defaults.conf (the paths might be different in HDInsights, this is from HDP on IaaS)
spark.driver.extraClassPath /usr/hdp/2.3.0.0-2557/hadoop/lib/azure-storage-2.2.0.jar:/usr/hdp/2.3.0.0-2557/hadoop/lib/microsoft-windowsazure-storage-sdk-0.6.0.jar:/usr/hdp/2.3.0.0-2557/hadoop/hadoop-azure-2.7.1.2.3.0.0-2557.jar
spark.executor.extraClassPath /usr/hdp/2.3.0.0-2557/hadoop/lib/azure-storage-2.2.0.jar:/usr/hdp/2.3.0.0-2557/hadoop/lib/microsoft-windowsazure-storage-sdk-0.6.0.jar:/usr/hdp/2.3.0.0-2557/hadoop/hadoop-azure-2.7.1.2.3.0.0-2557.jar
Once you have spark working with wasb, or next step is make those sames jar in zeppelin class path. A good way to test your setup is make a notebook that prints your env vars and class path.
sys.env.foreach(println(_))
val cl = ClassLoader.getSystemClassLoader
cl.asInstanceOf[java.net.URLClassLoader].getURLs.foreach(println)
Also looking at the install script, it trying to pull the zeppelin jar from wasb, you might want to change that config to somewhere else while you try some of these changes out. (zeppelin.sh)
export SPARK_YARN_JAR=wasb:///apps/zeppelin/zeppelin-spark-0.5.5-SNAPSHOT.jar
I hope this helps, if you are still have problems I have some other ideas, but would start with these first.

Flyway connecting to a Database Cluster on Linux

I'm trying to connect to an Oracle Cluster using Flyway-Commandline. It works fine from DOS using:
# Ommitting the other params for brevity: jarDir, locations, user, password, driver etc
flyway clean -url="jdbc:oracle:thin:#(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST = my_host_1)(PORT=8020))(ADDRESS=(PROTOCOL=TCP)(HOST = my_host_2)(PORT=8020))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MY_SERVICE_NAME)))"
But when I do the same on linux I get an error:
ERROR: FlywayException: Unable to obtain Jdbc connection from DataSource
ERROR: Occured in com.googlecode.flyway.core.util.jdbc.JdbcUtils.openConnection() at line 56
ERROR: Caused by oracle.net.ns.NetException: NL Exception was generated
ERROR: Occured in oracle.net.resolver.AddrResolution.resolveAddrTree() at line 626
It works fine on both platforms if I connect directly to one of the hosts directly using:
flyway clean -url=jdbc:oracle:thin:#my_host_1:8020/MY_SERVICE_NAME
The problem is that when one host in the cluster goes down, which happens regularly, this stops working.
This sounds like a problem with your Linux environment and not with Flyway itself.

Cassandra unknown exception

I have managed to set up Cassandra + Thrift and the Python wrapper for Thrift LazyBoy, and I have followed an example mentioned in the LazyBoy Wiki.After testing that example I'm getting an error with an exception.
cassandra.ttypes.InvalidRequestException: InvalidRequestException(why='Keyspace
UserData does not exist in this schema.')
here's the exception.I'm expecting some helping hand.
Thanks.
Make sure that the keyspace 'UserData' exists in your configuration file (conf/storage-conf.xml)
E.g
<Keyspaces>
<Keyspace Name="UserData">
....
</Keyspaces>
For those just starting out with Cassandra/Pycassa then maybe you've been working through this tutorial and you get stuck on the line
col_fam = pycassa.ColumnFamily(pool, 'Standard1')
with an error that looks like
pycassa.cassandra.ttypes.InvalidRequestException: InvalidRequestException(why='Keyspace Keyspace1 does not exist')
To resolve this, start Cassandra
bin/cassandra -f
And then in another terminal window load the sample schema using
bin/cassandra-cli -host localhost --file conf/schema-sample.txt
Then you should make it past that line in the tutorial.

Resources