Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

[Question] Database schema load #6

Open
msimonin opened this issue Jul 25, 2013 · 4 comments
Open

[Question] Database schema load #6

msimonin opened this issue Jul 25, 2013 · 4 comments

Comments

@msimonin
Copy link

Hi,

Can we load the database schema from this puppet module, or do we need to do it after applying the recipe ?
Very nice job, I'm currently using it on the Grid'5000 testbed (https://www.grid5000.fr/mediawiki/index.php/Grid5000:Home) !

Best Regards

Matt

@joschi
Copy link
Contributor

joschi commented Jul 25, 2013

Hi Matt,

thanks for your feedback! Currently it's not possible to create a (I suppose CQL3) schema in Cassandra with this Puppet module but it might make sense to implement that feature.

Would you mind describing your use case (and how you currently create the keyspaces and schemas) in a little more detail?

Best regards
Jochen

@ghost ghost assigned joschi Jul 25, 2013
@msimonin
Copy link
Author

Hey,

Yes could be nice to have this feature :) cql3 or "raw" cassandra.
Basically, after installing the cassandra cluster, I run on one node :

 cassandra-cli -f <schema_file> (or cqlsh -f <schema_file>)

Regards,

Matt

@msimonin
Copy link
Author

There can be a problem when loading the schema just after installing cassandra.
It requires some time for the cassandra nodes to be up and running and to accept connections (connection exception is raised if I try to load the schema just after the installation).
I don't know how we can handle this with puppet

Matt

@nikolavp
Copy link

We are currently using something like the following:

define cassandra::configure(
  $content = undef,
  $source = undef) {
    include ::cassandra

    $config_file = "${cassandra::base_path}/puppet-tmp/${title}"

    file { $config_file:
      content => $content,
      source  => $source,
      owner   => $cassandra::user,
      group   => $cassandra::user,
      notify  => Exec["configure-keyspaces-${title}"],
    }

    exec {"configure-keyspaces-${title}":
      user         => $cassandra::user,
      # Check that cassandra has started up with nodetool and then execute the main script
      command      => "${cassandra::base_path}/bin/nodetool status && ${cassandra::base_path}/bin/cassandra-cli -h ${cassandra::bindaddress} -f ${config_file} > ${config_file}.log 2>&1",
      provider     => 'shell',
      tries        => 3,
      refreshonly  => true
      try_sleep    => 2,
    }
  Class['cassandra::service'] -> Cassandra::Configure<| |>
}

Some things to note...

  • cassandra::base_path is the location in which cassandra is installed - you can change this as needed
  • we are using nodetool status see if cassandra is already up and only then we call cassandra-cli(the && is sort of hacky...)
  • we try 3 times with a sleep of 2 seconds(this is enough on our machines)
  • the source and content parameters should be self explanatory

nikolavp

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants