Update solr config files in solrcloud - solrcloud

Hi fellow SOLR developers,
https://cwiki.apache.org/confluence/display/solr/Using+ZooKeeper+to+Manage+Configuration+Files This link says the below
To update or change your SolrCloud configuration files:
1. Download the latest configuration files from ZooKeeper, using the
source control checkout process.
2. Make your changes. Commit your changed file to source control.
3. Push the changes back to ZooKeeper.
4. Reload the collection so that the changes will be in effect.
But I was wondering if there are some examples or articles somewhere which can help me do this. For instance, how would one download the latest config files from zookeeper? Or should I know Zoopkeeper in-and-out to do this?
Version 5.3.1
I updated the synonym file in the "C:\12345\solrcloud\solr-5.3.1\example\example-DIH\solr\db\conf" folder and I'm using the below command
zkcli -zkhost localhost:2181,localhost:2182,localhost:2183 -cmd upconfig -confname db_config -confdir "C:\12345\solrcloud\solr-5.3.1\example\example-DIH\solr\db\conf"
But the file doesn't seem to change nor the query seem to work. I reloaded the core which did not help too. I even tried restarting my solrcloud.

My Brother, you are using upconfig command....
Same way there is a command called downconfig with same parameters.
So your order of execution will be :
Downconfig
Change the config
Upconfig
Downconfig command :
bin/solr zk downconfig -z 111.222.333.444:2181 -n mynewconfig -d /path/to/configset
Upconfig command :
bin/solr zk upconfig -z 111.222.333.444:2181 -n mynewconfig -d /path/to/configset

I think this short code can help to download the configs of solrcloud from zookeeper.
public void exportSynonyms(...) {
try {
final CloudSolrClient cloudSolrClient = ... //Retrieve the Solr client
final String configName = cloudSolrClient.getDefaultCollection();
final Path configPath = ... //Get or create temporary local file path
cloudSolrClient.downloadConfig(configName, configPath);
// Do something
cloudSolrClient.uploadConfig(configPath, configName);
// Reload the collection
} catch (RestClientException | SolrServiceException | IOException var11){
this.handleException(var11);
}
}
And I met the same problem and asked it on
https://cwiki.apache.org/confluence/display/solr/Using+ZooKeeper+to+Manage+Configuration+Files?focusedCommentId=65147407#comment-65147407
Hope it can help you.

After you update the file in Zookeeper, you need to tell solr to reload the collection, this tells solr to get the new configuration from Zookeeper.
See the Reload Solr Collection REST call:
https://cwiki.apache.org/confluence/display/solr/Collections+API#CollectionsAPI-api2

Related

How do I access a Sqlite3 database from an Electron AppImage .mount point?

OS: Linux 5.9.16-1-MANJARO
Electron version: 10.1.5
BetterSqlite version: 7.1.2
I am currently writing an application using Electron and BetterSqlite.
I build the AppImage like this:
npm run build && electron-builder build
This is how I access the database from my code:
db = new Database(
path.join(__dirname, `/${dbName}`).replace("/app.asar", "")
);
I have added the database file to use using:
"extraResources": [
"public/build/Database.db"
],
But when I open the AppImage i get the following error message:
SqliteError: attempt to write a readonly database
The database seems to be inaccessible due to the /tmp/.mountxxx point being readonly.
This behavior does not occur when I open the application in the development folder since it's not a readonly directory.
Is there a way to use the database from the /tmp/.mountxxx directory?
How would I got about accessing the database another way?
Thank you in advance.
I have searched for a way to use the AppImage mount point to read and write but I have not found anything. I will be using the user's home directory to store the database
As the error says when an AppImage is executed the AppDir is mounted as RO filesystem.
To workaround this you need to copy the database file into the user home using an startup script. By example you can copy it to "$HOME/.cache/com.myapp/appdata.db" then use this new copy.

Using Laravel's File::makeDirectory to create a folder in the public directory

I have the following code in my controller - I am trying to create a directory structure to save files into:
use File;
...
$path = public_path().'/shared/uploads/images/brands/400';
if (!File::exists($path)) {
File::makeDirectory($path, $mode = 0755, true, true);
}
When I run the controller I get the following error:
Intervention\Image\Exception\NotWritableException: Can't write image data to path (/home/tony/Git/website/public/shared/uploads/images/brands/800/17.png) in file /home/tony/Git/website/vendor/intervention/image/src/Intervention/Image/Image.php on line 150
Looking in my public directory I can see no directory structure has been created.
Looking at other examples of this code doing similar/same thing I can't see any difference with my code except that I am creating the directories in the public folder.
As always, any help appreciated.
This was a permission issue.
On my development machine I simply changed the owner of /shared to www-data:www-data:
sudo chown www-data:www-data ./shared/
Once I'd done that the controller worked fine, creating the rest of the directory structure.

Hosting Symfony 4 app with EasyDeployBundle on server without /usr/local/bin/composer

For a Symfony 4 app I have chosen a Web Cloud plan from the hosting provider OVH.
For the deployment I have decided to use the EasyDeployBundle which looks very promising. This is my config file:
<?php
use EasyCorp\Bundle\EasyDeployBundle\Deployer\DefaultDeployer;
return new class extends DefaultDeployer
{
public function configure()
{
return $this->getConfigBuilder()
->server('ovh')
->deployDir('directory/path/at/server')
->repositoryUrl('git#github.com:foo/bar.git')
->repositoryBranch('master')
;
}
}
I have .ssh/config file with the following entry:
Host ovh
Hostname sshcloud.foobar.hosting.ovh.net
Port 12345
User foobar
Note: all values are dummies, just for illustrational purposes.
When I run:
php bin/console deploy --dry-run -v
everything goes fine, but when I actually try to deploy I get the following error:
The command "ssh ovh 'which /usr/local/bin/composer'" failed.
The problem is that I have no write-access to the directory /usr/local/bin/ on the server. The composer.phar is in my home directory and I can't move it to the provisioned destination.
Is there any possibility to tell EasyDeployBundle to look for composer in another directory?
I should really read the manuals, in particular when I'm linking them in my question.
There is a method remoteComposerBinaryPath that accepts custom path to composer. I have amended the method configure like this:
public function configure()
{
return $this->getConfigBuilder()
->server('ovh')
->deployDir('directory/path/at/server')
->repositoryUrl('git#github.com:foo/bar.git')
->repositoryBranch('master')
->remoteComposerBinaryPath('composer.phar')
;
}
On the server I created .bashrc in my home folder and added the line:
export PATH=$PATH:/home/foobar
and now the deployment is passing this hurdle.
I have now another problem, but at least this one is solved and maybe the answer can help other people too.

Remove local Git repo when working with JGit

I am building a small tool to propose some Git commands to users not familiar with Git. The commands are not intended to modify the repo, just consult some information.
I am creating the tool in Java, using JGit which seems to be the best match to do this kind of stuff.
The issue I face so far is that I create a temporary folder to host the repo content, but I am unable to delete it automatically at the end of the execution.
Here is the code (I removed the try/catch stuff to simplify the reading):
// Create temporary folder
Path folderPath = Paths.get(System.getProperty("user.dir"));
File localRepoFolder = Files.createTempDirectory(folderPath, "local-repo").toFile();
// Clone the repo
CloneCommand clone = new CloneCommand();
clone.setURI("https://myrepo");
clone.setNoCheckout(true);
clone.setDirectory(localRepoFolder);
clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider("user", "password"));
Git gitRepo = clone.call();
// Do some stuff
[...]
// Cleanup before closing
gitRepo.getRepository().close();
gitRepo.close();
localRepoFolder.deleteOnExit();
I searched quite a lot on this topic, but I get everywhere that it should be automatically deleted... Am I missing something?
I would use something like Apache Commons IO (http://commons.apache.org/proper/commons-io/) which has a FileUtils.deleteDirectory

solr cloud: RROR: Error loading config name for collection

I'm trying to create a new collection with solr-cloud setup, fails with the following:
ERROR: Error loading config name for collection test
I tried deleting the collection:
sudo /opt/solr/bin/solr delete -c test
but with the same results
My setup: solr-cloid with external zookeeper and 5 solr nodes
How do I purge it or reload it again ?
thanks
Solr is not able to find configuration files in zookeeper. Solrcloud try to recreate the core from zookeeper configuration file.
Looks like you have deleted zookeeper configuration node for collection test.
Two steps to completely purge collection test:
Stop solr and Delete folder "test" if exists from Solr home folder.(default: /var/lib/solr)
Navigate to zookeeper node and edit clusterstate.json . Remove entries of collection test. I wanted to start fresh so reset clusterstate.json file to default i.e {}
you should disable autoAddReplicas property of solr before shutting down any solrnode.
Check if the config folder exists in zookeeper. If this is the case, try to link the collection with the configname using the commmand:
zkcli.sh -cmd linkconfig -collection collectionname -confname configname

Resources