how to set compressor for compressed wire transfer between mongodb atlas and spring application - spring-data-mongodb

I try to set up the compression for the messages transferred between mongodb atlas cluster to spring application. I followed this link: https://mongodb.github.io/mongo-java-driver/3.6/driver/tutorials/compression/. My connection string in spring is:
data:
mongodb:
uri: mongodb+srv://userName:password#xxxxxxx.mongodb.net/test?compressors=zlib&retryWrites=true&w=majority
database: mydb
It does not let server compress the result to transfer. Looks I missed config on the server-side for the zlib compression. What should I do to enable this? Searched through MongoDB Atlas management pages, but could not find anywhere to set it up.

Related

Uploading Databases

How does one go about uploading a database like Apache Cassandra after creating one? Furthermore, is there a way to upload/share only its skeleton structure, without the data gathered in it? I'm on MacOS and would like to use Python to do all of this. Thank you!
Based on your second comment, I guessed it to mean you want the database to be remotely accessible to clients/apps not installed locally.
Clients/apps connect to Cassandra on the IP address set for rpc_address and the CQL port set for native_transport_port (default is 9042) set in cassandra.yaml.
You mentioned that your Cassandra instance is running on your laptop so only clients/apps running on your local network can access it if you configure rpc_address to an IP address accessible on the network (default is localhost).
If you're just trying out Cassandra and want to collaborate with other developer friends, try Astra and launch Cassandra instance on the free-tier (no credit card required). With it you can share the database credentials with your friends and they can connect to it over the internet.
You can connect to Astra from your Python app using the Python driver. Otherwise, Astra includes Stargate.io pre-configured and ready to use. Stargate is a data access gateway that lets you connect to Cassandra from your app using REST API, GraphQL API or JSON/Doc API without having to learn CQL. For more info, see Connecting to your Astra database. Cheers!

how to add mongodb replica Set in spring boot project

i am new to mongodb repleca set
spring boot 2.2.2
mongo db driver 3.12.1
spring.data.mongodb.uri=mongodb://user:pass#server1:27017,server2:27017,server3:27017/DB?replicaSet=‌mongodb_rs
always getting the following error while fetching data from DB
19-02-2020 12:05:27.753 [http-nio-2053-exec-1] INFO org.mongodb.driver.cluster.info - No server chosen by com.mongodb.client.internal.MongoClientDelegate$1#594215be from cluster description ClusterDescription{type=REPLICA_SET, connectionMode=MULTIPLE, serverDescriptions=[]}. Waiting for 30000 ms before timing out

MongoDB replication set without restarting database

I have a mongoDB database running in one server. This is its configuration file:
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
ssl:
mode: requireSSL
PEMKeyFile: /etc/ssl/mongo.pem
#processManagement:
#security:
security:
authorization: enabled
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
setParameter:
failIndexKeyTooLong: false
I have created a service to launch the mongoDB each time the server starts or each time the database is down.
This configuration is working so far.
Now I have cloned this server into another one. The configuration is identical except for the server IP and the server domain.
This new server is working too but I would like to connect both databases so the new database is synchronized with the first one as with a master-slave configuration.
I think this is the typical case of a Mongo DB Replication Set with 2 databases. But I’m not very expert with databases and after reading lots of documents I don’t understand very much how to do it.
For example, it seems that all options require to turn off master database before making the synchronization, but in my case the master database is in a production environment so I would like to avoid this. Is there any option to configure the replication set without having to restart the master mongoDB instance?
I’ve checked the reference of the replication options in the connfiguration file too but I don’t know how to use them.
In conclusion, is there any tutorial about how to create a replication set with 2 mongodb databases and if it’s possible without having to restart the master (in production environment) database?

How to start Titan graph server and connect with gremlin?

I've been playing with Titan graph server for a while now. And my feeling is that, despite an extensive documentation, there is a lack of Getting started from scratch tutorial.
My final goal is to have a titan running on cassandra and query with StartTheShift/thunderdome.
I have seen few ways of starting Titan:
Using Rexster
from this link, I was able to run a titan server with the following steps:
download rexster-server 2.3
download titan 0.3.0
copy all files from titan-all-0.3.0/libs to rexster-server-2.3.0/ext/titan
edit rexster-server-2.3.0/rexster.xml and add (between a ):
<graph>
<graph-name>geograph</graph-name>
<graph-type>com.thinkaurelius.titan.tinkerpop.rexster.TitanGraphConfiguration</graph-type>
<graph-read-only>false</graph-read-only>
<graph-location>/Users/vallette/projects/DATA/gdb</graph-location>
<properties>
<storage.backend>local</storage.backend>
<storage.directory>/Users/vallette/projects/DATA/gdb</storage.directory>
<buffer-size>100</buffer-size>
</properties>
<extensions>
<allows>
<allow>tp:gremlin</allow>
</allows>
</extensions>
</graph>
for a berkeleydb
or:
<graph>
<graph-name>geograph</graph-name>
<graph-type>com.thinkaurelius.titan.tinkerpop.rexster.TitanGraphConfiguration</graph-type>
<graph-location></graph-location>
<graph-read-only>false</graph-read-only>
<properties>
<storage.backend>cassandra</storage.backend>
<storage.hostname>77.77.77.77</storage.hostname>
</properties>
<extensions>
<allows>
<allow>tp:gremlin</allow>
</allows>
</extensions>
</graph>
for a cassandra db.
launch the server with ./bin/rexster.sh -s -c rexster.xml
dowload rexster console and run it with bin/rexster-console.sh
you can now connect to your graph with g = rexster.getGraph("geograph")
The problem with this method is that you are connected via rexster and not gremlin so you do not have autocompletion. The advantage is that you can name your database (here geograph).
Using Titan server with cassandra
start the server with ./bin/titan.sh config/titan-server-rexster.xml config/titan-server-cassandra.properties
create a file called cassandra.local with
storage.backend=cassandrathrift
storage.hostname=127.0.0.1
start titan gremlin and connect with g = TitanFactory.open("cassandra-es.local")
this works fine.
Using titan server with BerkeleyDB
From this link:
download titan 0.3.0
start the server with ./bin/titan.sh config/titan-server-rexster.xml config/titan-server-berkeleydb.properties
launch titan gremlin: ./bin/gremlin.sh
but once I try to connect to the database (graph) in gremlin with g = TitanFactory.open('graph') it creates a new database called graph in the directory I'm in. If i execute this where my directory (filled) is I get:
Could not instantiate implementation: com.thinkaurelius.titan.diskstorage.berkeleyje.BerkeleyJEStoreManager
Could someone clarify these process, and tell me what I'm doing wrong.
Thanks
According to the documentation TitanFactory.open() takes either the name of a config file or the name of a directory to open or create a database in.
If what steven says is true, there would be two ways to connect to the database with a BerkelyDB backend:
Start the database through bin/titan.sh. Connect to the database through the rexster console.
DON'T start the database using bin/titan.sh. Use the gremlin console instead: TitanFactory.open("database-location"). This will open the database. But this does not have a rexster server. Nothing else will be able to access the database but the gremlin console.
With Titan Server/BerkeleyDB, you should attempt to connect via RexPro or REST (Thunderdome should connect over REST). You can't open another Titan-based connection to BerkeleyDB as Titan Server already owns that.
This is different than Titan Server/Cassandra where connectivity occurs over RexPro or REST, but also through embedded Cassandra which enables connectivity over thrift via TitanFactory.open('graph')
It's also possible to access Titan from python using these two libraries:
https://github.com/StartTheShift/thunderdome
and
https://github.com/espeed/bulbs.
Thunderdome is currently Titan-specific, and bulbs is generic. A (possibly biased) comparison between Thunderdome and Bulbs is given on Thunderdome's wiki: https://github.com/StartTheShift/thunderdome/wiki/Bulbs-VS-thunderdome
If you need autocompletion, you can use iPython and enable autocompletion in your iPython config.

how to display the database name and change the database properties in java (spring framework)

I have a requirement to display the database name on the screen that is connected by the web application (which is configured through the datasource on weblogic server with spring data xml having all the configurations) and also is there any way to switch from current database to different datasource (database server) while working/running on the web application (with user screen).
Thanks.
As far as I know, there is no straight-forward way to know this info. One way I can think of doing this is to parse the spring config XML file using an XML parser for the desired element - even that too will only give you the JNDI name of the datasource your app would be using. I hope you have a mechanism to determine which JDBC JNDI name maps to which database. If you don't have that information, you would have to use JMX (MBeans) to connect to the Weblogic environment to get that info.

Resources