├── .foodcritic ├── .gitignore ├── .kitchen.yml ├── .rspec ├── .rubocop.yml ├── .travis.yml ├── Berksfile ├── CONTRIBUTING.md ├── ChangeLog.md ├── Gemfile ├── LICENSE ├── README.md ├── Rakefile ├── TESTING.md ├── Thorfile ├── Vagrantfile ├── attributes ├── config.rb ├── datastax.rb ├── default.rb └── systemd.rb ├── chefignore ├── libraries ├── config_helpers.rb └── matchers.rb ├── metadata.rb ├── recipes ├── config.rb ├── datastax.rb ├── default.rb ├── envvars.rb ├── opscenter_agent.rb ├── opscenter_agent_datastax.rb ├── opscenter_agent_tarball.rb ├── opscenter_server.rb ├── repositories.rb ├── systemd.rb ├── tarball.rb └── user.rb ├── spec ├── config_spec.rb ├── default_spec.rb ├── opscenter_agent_datastax_spec.rb ├── opscenter_agent_tarball_spec.rb ├── rendered_templates │ ├── cassandra-env.sh │ ├── cassandra-metrics.yaml │ ├── cassandra-rackdc.properties │ ├── cassandra-topology.properties │ ├── cassandra.yaml │ ├── jvm.options │ ├── logback-tools.xml │ └── logback.xml ├── repositories_spec.rb ├── seed_selection_spec.rb ├── spec_helper.rb └── systemd_spec.rb ├── templates └── default │ ├── cassandra-cli.erb │ ├── cassandra-env.sh.erb │ ├── cassandra-metrics.yaml.erb │ ├── cassandra-rackdc.properties.erb │ ├── cassandra-topology.properties.erb │ ├── cassandra.envvars.erb │ ├── cassandra.service.erb │ ├── cassandra.yaml.erb │ ├── cqlsh.erb │ ├── debian.cassandra.init.erb │ ├── jmxremote.access.erb │ ├── jmxremote.password.erb │ ├── jvm.options.erb │ ├── log4j-server.properties.erb │ ├── logback-tools.xml.erb │ ├── logback.xml.erb │ ├── opscenter-agent.conf.erb │ ├── opscenterd.conf.erb │ └── rhel.cassandra.init.erb └── test └── integration ├── default └── serverspec │ └── default_spec.rb ├── dsc21 └── serverspec │ └── default_spec.rb ├── dse └── serverspec │ └── dse_spec.rb ├── helpers └── serverspec │ └── spec_helper.rb ├── opscenter-agent-datastax └── serverspec │ └── opscenter_datastax_agent_spec.rb ├── opscenter-server-datastax └── serverspec │ └── opscenter_datastax_agent_spec.rb └── tarball └── serverspec └── tarball_spec.rb /.foodcritic: -------------------------------------------------------------------------------- 1 | ~FC007 2 | ~FC014 3 | ~FC023 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | .rbx 3 | *.class 4 | .kitchen/ 5 | .kitchen.local.yml 6 | tmp/ 7 | *# 8 | .#* 9 | \#*# 10 | .*.sw[a-z] 11 | *.un~ 12 | pkg/ 13 | .idea/ 14 | 15 | # Berkshelf 16 | .vagrant 17 | /cookbooks 18 | Berksfile.lock 19 | 20 | # Bundler 21 | .vendor 22 | Gemfile.lock 23 | bin/* 24 | .bundle/* 25 | .DS_Store 26 | -------------------------------------------------------------------------------- /.kitchen.yml: -------------------------------------------------------------------------------- 1 | --- 2 | driver: 3 | name: <%= ENV['KI_DRIVER'] || 'vagrant' %> 4 | 5 | provisioner: 6 | name: chef_zero 7 | product_name: chef 8 | product_version: 12.21.1 9 | attributes: 10 | java: 11 | jdk_version: 8 12 | cassandra: 13 | # install_java: false 14 | setup_jamm: true 15 | notify_restart: true 16 | config: 17 | cluster_name: test 18 | 19 | platforms: 20 | - name: ubuntu-14.04 21 | run_list: 22 | <% if (ENV['KI_DRIVER'] == 'docker') then %> 23 | driver_config: 24 | provision_command: 25 | - apt-get update && apt-get install net-tools 26 | - curl -L https://www.opscode.com/chef/install.sh | bash -s -- -v 12.21.1 27 | - env GEM_HOME=/tmp/verifier/gems GEM_PATH=/tmp/verifier/gems GEM_CACHE=/tmp/verifier/gems/cache /opt/chef/embedded/bin/gem install thor busser busser-serverspec serverspec bundler && chown -R kitchen:kitchen /tmp/verifier 28 | require_chef_omnibus: false 29 | use_sudo: false 30 | <% else %> 31 | # without additional memory, ubuntu suites will fail 32 | customize: 33 | memory: 1024 34 | <% end %> 35 | 36 | - name: centos-7.3 37 | run_list: 38 | - recipe[yum] 39 | 40 | suites: 41 | - name: default 42 | run_list: 43 | - recipe[cassandra-dse::default] 44 | 45 | - name: opscenter-agent-datastax 46 | attributes: 47 | cassandra: 48 | opscenter: 49 | agent: 50 | server_host: 0.0.0.0 51 | use_chef_search: false 52 | run_list: 53 | - recipe[cassandra-dse::default] 54 | - recipe[cassandra-dse::opscenter_agent_datastax] 55 | 56 | - name: opscenter-server-datastax 57 | run_list: 58 | - recipe[cassandra-dse::default] 59 | - recipe[cassandra-dse::opscenter_server] 60 | 61 | - name: dsc22 62 | attributes: 63 | cassandra: 64 | package_name: dsc22 65 | version: 2.2.7 66 | release: 1 67 | run_list: 68 | - recipe[cassandra-dse::default] 69 | 70 | - name: dsc30 71 | attributes: 72 | java: 73 | jdk_version: 8 74 | cassandra: 75 | package_name: dsc30 76 | version: 3.0.6 77 | release: 1 78 | setup_jna: true 79 | user_home: '/home/cassandra' 80 | driver: 81 | customize: 82 | memory: 1280 83 | run_list: 84 | - recipe[cassandra-dse::default] 85 | 86 | - name: tarball 87 | attributes: 88 | cassandra: 89 | install_method: tarball 90 | version: "3.9" 91 | driver: 92 | customize: 93 | memory: 1280 94 | run_list: 95 | - recipe[cassandra-dse::default] 96 | 97 | - name: dse 98 | run_list: 99 | - recipe[cassandra-dse::default] 100 | attributes: 101 | cassandra: 102 | dse: 103 | credentials: 104 | databag: false 105 | username: <%= ENV['CASSANDRA_DSE_USERNAME'] %> 106 | password: <%= ENV['CASSANDRA_DSE_PASSWORD'] %> 107 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --format documentation --color 2 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | DisplayCopNames: true 3 | Include: 4 | - 'test/**/*' 5 | - spec 6 | - Rakefile 7 | - Guardfile 8 | Exclude: 9 | - Berksfile 10 | - Vagrantfile 11 | - Thorfile 12 | - Gemfile 13 | - bin/* 14 | - vendor/**/* 15 | 16 | Layout/ExtraSpacing: 17 | Enabled: false 18 | Metrics/AbcSize: 19 | Enabled: false 20 | Metrics/BlockLength: 21 | Enabled: false 22 | Metrics/CyclomaticComplexity: 23 | Enabled: false 24 | Metrics/LineLength: 25 | Enabled: false 26 | Metrics/MethodLength: 27 | Enabled: false 28 | Metrics/PerceivedComplexity: 29 | Max: 14 30 | Style/StringLiterals: 31 | Enabled: false 32 | Style/Encoding: 33 | Enabled: false 34 | Style/GuardClause: 35 | Enabled: false 36 | Style/NumericLiterals: 37 | Enabled: false 38 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | bundler_args: --without integration development 3 | rvm: 4 | - 2.3 5 | branches: 6 | only: 7 | - master 8 | script: bundle exec rake unit 9 | dist: trusty 10 | -------------------------------------------------------------------------------- /Berksfile: -------------------------------------------------------------------------------- 1 | source 'https://api.berkshelf.com' 2 | 3 | metadata 4 | 5 | # how come tests do not pick up these from metadata.rb? :/ 6 | cookbook 'java', '>= 1.50' 7 | cookbook 'ulimit' 8 | cookbook 'apt' 9 | cookbook 'yum' 10 | cookbook 'ark' 11 | cookbook 'systemd' 12 | cookbook 'chef_handler', '~> 3.0.2' 13 | 14 | cookbook 'build-essential' 15 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Workflow 4 | 5 | This cookbook uses a pretty standard GitHub workflow: 6 | 7 | * Fork it 8 | * [Run the tests](./TESTING.md) 9 | * Create a branch, make your changes 10 | * Run the tests again 11 | * Push your branch 12 | * Submit a pull request 13 | * Be patient 14 | 15 | ## Documentation Updates 16 | 17 | All new attributes introduced must be added to the README file. If any attributes are removed 18 | or their behavior changes, please strees it in the pull request message. 19 | 20 | 21 | ## Pull Requests that Slip Under the Radar 22 | 23 | If you get no response of any kind of **several days**, feel free to mention one of the 24 | maintainers in a pull request comment: 25 | 26 | * @michaelklishin 27 | * @vkhatri 28 | 29 | Please be respectful to the maintainers and do not abuse the above method. They do receive notifications 30 | about issues and pull requests. Unjustified additional mentions will not be appreciated. 31 | -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | ## Changes Between 4.5.0 and 4.6.0 (unreleased) 2 | 3 | No changes yet. 4 | 5 | 6 | ## Changes Between 4.4.0 and 4.5.0 (25-12-2017) 7 | 8 | This release contains **potentially breaking changes**. 9 | 10 | ### Chef 13-compatible Attribute Syntax 11 | 12 | The cookbook now uses the standardized node attribute syntax. 13 | 14 | GitHub issue: [#365](https://github.com/michaelklishin/cassandra-chef-cookbook/pull/365) 15 | 16 | 17 | ## More Supported Cassandra Versions 18 | 19 | Supported 3.x versions now include `3.10.x` and `3.11.x`. 20 | 21 | Contributed by Yaniv Marom Nachumi. 22 | 23 | GitHub issue: [#367](https://github.com/michaelklishin/cassandra-chef-cookbook/pull/367) 24 | 25 | 26 | ### jamm Installation Now Requires the User to Opt-in 27 | 28 | **This is a potentially breaking change**. 29 | 30 | `cassandra.setup_jamm` must be set to `true`, similarly to `cassandra.setup_priam` and `cassandra.setup_jna`. 31 | 32 | Contributed by Romain Gerard. 33 | 34 | GitHub issue: [#363](https://github.com/michaelklishin/cassandra-chef-cookbook/pull/363). 35 | 36 | 37 | ### Test Suite Fixes 38 | 39 | Contributed by Brian Skarda. 40 | 41 | GitHub issue: [#361](https://github.com/michaelklishin/cassandra-chef-cookbook/pull/361). 42 | 43 | 44 | ### Add Missing Directories to DSE Recipe 45 | 46 | The commitlog and saved_caches directories are added to the datastax installation method. 47 | 48 | Contributed by Brian Skarda. 49 | 50 | GitHub issue: [#360](https://github.com/michaelklishin/cassandra-chef-cookbook/pull/360). 51 | 52 | ## Changes Between 4.3.0 and 4.4.0 (13-07-2017) 53 | 54 | This release contains **potentially breaking changes**. 55 | 56 | ### `cassandra-env.sh` and JVM Options Synced with Cassandra 3 57 | 58 | This is a **potentially breaking change**. 59 | 60 | GitHub issue: [#328](https://github.com/michaelklishin/cassandra-chef-cookbook/pull/328). 61 | 62 | Contributed by William Dauchy. 63 | 64 | ### Configurable DSE Repo URI 65 | 66 | GitHub issue: [#346](https://github.com/michaelklishin/cassandra-chef-cookbook/pull/346) 67 | 68 | Contributed by Eyal Zekaria. 69 | 70 | ### Delayed systemd Service Notifications 71 | 72 | GitHub issue: [#353](https://github.com/michaelklishin/cassandra-chef-cookbook/pull/353) 73 | 74 | Contributed by Ignasi Barrera. 75 | 76 | ### Restart on-failure Condition in systemd Service Unit 77 | 78 | GitHub issue: [#342](https://github.com/michaelklishin/cassandra-chef-cookbook/pull/342) 79 | 80 | Contributed by Victor Demonchy. 81 | 82 | ### Support for JVM Agents 83 | 84 | GitHub issue: [#348](https://github.com/michaelklishin/cassandra-chef-cookbook/pull/348) 85 | 86 | Contributed by @mihasya. 87 | 88 | ### Pre-created Hints Directory 89 | 90 | Hints directory will be created if configured. 91 | 92 | GitHub issue: [#340](https://github.com/michaelklishin/cassandra-chef-cookbook/pull/340) 93 | 94 | Contributed by Ryan Scheidter. 95 | 96 | ### Support for More Service Management Tools 97 | 98 | GitHub issue: [#341](https://github.com/michaelklishin/cassandra-chef-cookbook/pull/341) 99 | 100 | Contributed by @yanivmn. 101 | 102 | ### More Cassandra Versions Covered 103 | 104 | GitHub issue: [#347](https://github.com/michaelklishin/cassandra-chef-cookbook/pull/347) 105 | 106 | Contributed by @mihasya. 107 | 108 | ### Spec Suite Improvements 109 | 110 | GitHub issues: [#334](https://github.com/michaelklishin/cassandra-chef-cookbook/pull/334), 111 | [#339](https://github.com/michaelklishin/cassandra-chef-cookbook/pull/339) 112 | 113 | Contributed by Grant Ridder and Virender Khatri. 114 | 115 | ### Rubocop Fixes 116 | 117 | GitHub issue: [#344](https://github.com/michaelklishin/cassandra-chef-cookbook/pull/344) 118 | 119 | Contributed by Romain Hardouin. 120 | 121 | 122 | 123 | ## Changes Between 4.2.0 and 4.3.0 (10-01-2017) 124 | 125 | ### systemd Support 126 | 127 | Contributed by William Dauchy, Romain Gerard, Jean-Francois Weber-Marx. 128 | 129 | ### Update jamm Versions for Several Cassandra Series (e.g. 3.x) 130 | 131 | Contributed by William Dauchy and Corentin Chary. 132 | 133 | ### Cassandra Version Changes Force Node Restarts 134 | 135 | Thanks to a neat template generation trick by William Dauchy. 136 | 137 | ### Custom Sections in `opscenterd.conf` 138 | 139 | Contributed by eyalzek. 140 | 141 | ### JMX Authentication Support 142 | 143 | Contributed by Andrew Nolan. 144 | 145 | ### Make Sure that System Directory Permissions Are Unmodified 146 | 147 | Contributed by Jean-Francois Weber-Marx. 148 | 149 | ### Bring Back Support for `native_transport_max_threads` 150 | 151 | Contributed by Corentin Chary. 152 | 153 | ### Corrected `bin` Paths When Installing via Packages 154 | 155 | Contributed by Barthelemy Vessemont. 156 | 157 | ### `cassandra_metrics` Are Now Configurable 158 | 159 | Contrbuted by eyalzek. 160 | 161 | ### Ensure `source_dir` and `installation_dir` Minus the Leaf Directory Exist 162 | 163 | Contributed by Michal Jankowski. 164 | 165 | ### Permissions of Optional JAR Files 166 | 167 | ...are now set to `0440`. 168 | 169 | ### Updated Package Checksums 170 | 171 | Contributed by Michal Jankowski. 172 | 173 | ### Correctly Create `commitlog_dir` and `saved_caches_dir` 174 | 175 | Contributed by Ryan Scheidter. 176 | 177 | 178 | 179 | ## Changes Between 4.1.0 and 4.2.0 (22-09-2016) 180 | 181 | ### More Reliable Upgrades 182 | 183 | Contributed by Seth Rosenblum. 184 | 185 | ### Temp Directory Attributes 186 | 187 | `cassandra.tmp_dir` is a new attribute that controls JNA and 188 | JVM temporary directory (`java.io.tmpdir`) location. 189 | 190 | Contributed by Jack Bracken. 191 | 192 | ### Jamm Version Updates for 3.x Releases 193 | 194 | Contributed by Corentin Chary and Anthony Rabier. 195 | 196 | ### Hints Directory Not Set for C* 2.x 197 | 198 | Hints directory is no longer set for C* 2.x as it's only 199 | supported in 3.x. 200 | 201 | Contributed by William Dauchy. 202 | 203 | ### More Reasonable Streaming Operation Socket Timeout 204 | 205 | `cassandra.config.streaming_socket_timeout_in_ms` now defaults to 1 hour. 206 | 207 | Contributed by Dimitris Verraros. 208 | 209 | ### Syslog Appender 210 | 211 | Add syslog appender to log to remote servers. 212 | 213 | Contributed by Andrew Nolan. 214 | 215 | ### More Reliable Data Directory Management 216 | 217 | Contributed by Michael Saffitz. 218 | 219 | ### 3.x Package Naming Fixes 220 | 221 | Contributed by Jason J. W. Williams. 222 | 223 | ### OpsCenter Agent [Chef] Environment Fixes 224 | 225 | Contributed by Radek Wierzbicki. 226 | 227 | ### New 3.x Settings 228 | 229 | Contributed by Otavio Fernandes. 230 | 231 | ### Java 8 JVM Tuning options 232 | 233 | A number of tuning options have been added to the cookbook to provide more 234 | knobs to control performance in the JVM. This work is centered around the 235 | use-case of Oracle JDK 8 with the G1 GC. 236 | 237 | Contributed by Matthew Silvey. 238 | 239 | ## Changes Between 4.0.0 and 4.1.0 (Dec 28, 2015) 240 | 241 | ### DSE Compatibiilty Bug Fixes 242 | 243 | For example, the `cassandra` package shouldn't be installed 244 | when DSE is provisioned. 245 | 246 | Contributed by Bill Warner and Dimitris Verraros. 247 | 248 | 249 | ### OpsCenter Agent Has TLS Disabled by Default 250 | 251 | ...and is now configured correctly when overridden. 252 | 253 | Contributed by Michael Belt. 254 | 255 | 256 | ### Support Configuration of `commitlog_total_space_in_mb` 257 | 258 | The attribute `node[:cassandra][:config][:commitlog_total_space_in_mb]` takes on the cassandra default of `4096` and may be reconfigured. 259 | 260 | Contributed by Geoff Hichborn 261 | 262 | ### additional chefspec tests to at least cover all resources 263 | 264 | Tested with chef 0.9.0 but prior and later versions should still work. 265 | 266 | run with 267 | ``` 268 | rake unit 269 | ``` 270 | 271 | Contributed by Bill Warner. 272 | 273 | ### Default to localhost-only JMX 274 | 275 | The attribute `node[:cassandra][:local_jmx]` defaults to `true` now, making 276 | JMX listen on localhost only. This is the default since cassandra 2.0.14 and 277 | 2.1.4 and fixes the remote code execution exploit from CVE-2015-0225. 278 | 279 | Should you choose to enable remote JMX access by setting this to false, be aware 280 | that this cookbook currently does not support configuring authentication for JMX, 281 | so you should limit access to the JMX port by other means, such as firewalling. 282 | 283 | Contributed by Bernhard Weisshuhn. 284 | 285 | ### Priam Support 286 | 287 | See `node[:cassandra][:setup_priam]` and related node attributes. 288 | 289 | Contributed by Scott McMaster. 290 | 291 | 292 | ### init.d Script Fix (Debian) 293 | 294 | Node IP address is now correctly passed to `nodetool`. 295 | 296 | Contributed by Scott McMaster. 297 | 298 | ### Default Seed Discovery Fix 299 | 300 | Default seed discovery query will now respect `node[:cassandra][:config][:cluster_name]`. 301 | 302 | Contributed by Robert Berger. 303 | 304 | ### jamm Version Fix 305 | 306 | The cookbook will now pick the correct jamm version for the Cassandra 307 | version it is asked to provision. 308 | 309 | Contributed by Robert Berger. 310 | 311 | 312 | ## Changes Between 3.5.0 and 4.0.0 313 | 314 | `4.0.0` has **breaking changes in attribute structure**. 315 | 316 | ### Node Config Attributes Moved 317 | 318 | Node configuration attributes are now under `node['cassandra']['config']`. Since 319 | there are many of them, please [consult the default attributes file](https://github.com/michaelklishin/cassandra-chef-cookbook/blob/master/attributes/config.rb). 320 | 321 | ### SHA 256 Checksums 322 | 323 | SHA256 is now used instead of MD5 for checksums. The cookbook 324 | now provides checksums for Cassandra versions up to 2.2.0. 325 | 326 | ### 2.2.0 by Default 327 | 328 | The cookbook now provisions Cassandra 2.2.0 by default. 329 | 330 | 331 | ## Changes Between 3.4.0 and 3.5.0 332 | 333 | ### Seed Discovery Using Chef Search 334 | 335 | The cookbook will now use Chef search to discover seed nodes. 336 | The exact query used is configurable. Search is disabled by default. 337 | 338 | GH issues: [#204](https://github.com/michaelklishin/cassandra-chef-cookbook/issues/204), 339 | [#205](https://github.com/michaelklishin/cassandra-chef-cookbook/pull/205). 340 | 341 | The following node attribute snippet enables Chef search and will list 342 | IP addresses of nodes with roles `cassandra` and `cassandra-seed`: 343 | 344 | ``` json 345 | "cassandra": { 346 | "seed_discovery": { 347 | "use_chef_search": true, 348 | "search_query": "role:cassandra-seed OR role:cassandra" 349 | } 350 | } 351 | ``` 352 | 353 | 354 | ### `:data_dir` Array Handling 355 | 356 | `cassandra-dse::tarball` now handles arrays of data dirs. 357 | 358 | Contributed by Bryce Lynn. 359 | 360 | GH issue: [#154](https://github.com/michaelklishin/cassandra-chef-cookbook/issues/154). 361 | 362 | 363 | 364 | ## Changes Between 3.3.0 and 3.4.0 365 | 366 | ### FD_LIMIT in Init Script 367 | 368 | `FD_LIMIT` value in the init script is now corrently 369 | set to the `node[:cassandra][:limits][:nofile]` value. 370 | 371 | Contributed by Rich Schumacher. 372 | 373 | GH issue: [#201](https://github.com/michaelklishin/cassandra-chef-cookbook/pull/201). 374 | 375 | 376 | 377 | ## Changes Between 3.2.0 and 3.3.0 378 | 379 | ### Ensure conf Directory Exists 380 | 381 | If Cassandra conf directory doesn't exist, it will be created. 382 | 383 | Contributed by Ahmed Ferdous. 384 | 385 | 386 | ## Changes Between 2.7.x and 3.2.0 387 | 388 | The cookbook has a new name: `cassandra-dse`, and is [available from 389 | Chef Supermarket](https://supermarket.chef.io/cookbooks/cassandra-dse). 390 | 391 | Main recipe names is therefore now `cassandra-dse::default`. 392 | 393 | Multiple bug fixes. 394 | 395 | 396 | ## Changes Between 2.7.0 and 2.7.x 397 | 398 | * Virender Khatri: Updated README for v2.1 399 | * Virender Khatri: C* version 2.1.x version support 400 | * Virender Khatri: Disabled <2.1 cassandra parameters for 2.1 401 | * Virender Khatri: Added 2.1 cassandra parameters 402 | * Virender Khatri: jamm_version attribute for C* version dependency 403 | * Virender Khatri: Added logback config files for v2.1 404 | * Virender Khatri: Disabled jna for v2.1 and later 405 | * MikeB: Fixed check for Java Attribute UseCondCardMark addition for x86_64 arch 406 | * Virender Khatri: Added yum node attributes for DSE 407 | * Virender Khatri: Added apt node attributes for DSE/DSC 408 | * Lars Pfannenschmidt: Fixed UseCondCardMark is only supported under 64-Bit systems 409 | * Chris: Updated README for yum and jna attr 410 | * Chris: Added yum node attributes for DSE 411 | * Chris: Added Refactor attributes in .kitchen.yml 412 | * Chris: Added node Oracle Java version for minimum Java version requirement 413 | * Chris: Added java version for minimum Java version requirement 414 | * Xynergy: Fixed C* release attribute for datastax 415 | * Virender Khatri: Moved node C* sub directories attributes to recipe 416 | * Virender Khatri: Added C* service notifies for init.d and other files 417 | * Virender Khatri: Added few Java Parameters 418 | * Virender Khatri: Renamed default attributesrb to common.rb and moved attributes among other attributes files 419 | * Tim Nicholas: Added log4j root logger attribute 420 | * Tim Nicholas: Added cassandra-rackdc.properties.erb for datastax recipe 421 | * Tim Nicholas: Fixed directory/files structure and ownership for datastax recipe 422 | * Tim Nicholas: Added C* encryption 423 | * Anthony Acquanita: Updated README for datastax recipe being default 424 | * Virender Khatri: Fixed indent and C* service name / notify 425 | * Alex Groleau: Added node default service action attribute for C* service 426 | * Alex Groleau: Fixed jna var issue 427 | * Michael Klishin: Updated Changelog 428 | 429 | ## Changes Between 2.6.0 and 2.7.0 430 | 431 | ### Chef 11.10 Compatibility 432 | 433 | Contributed by Virender Khatri. 434 | 435 | ### Extra Slash to File Between Path Components 436 | 437 | `log_dir` now always has at least one slash, regardless of whether there 438 | is a trailing slash in the user-provided attribute value. 439 | 440 | GH issue: #86. 441 | 442 | Contributed by Federico Silva. 443 | 444 | ### New Attribute for User Home (`$HOME`) 445 | 446 | `user_home` is a new attribute that customizes Cassandra user `$HOME` location. 447 | 448 | Contributed by Virender Khatri. 449 | 450 | ### Removed JNA Recipe 451 | 452 | The JNA recipe is no longe needed. 453 | 454 | Contributed by Virender Khatri. 455 | 456 | ### Default Attributes for DataStax Enterprise 457 | 458 | The cookbook now provides default node attributes specific 459 | to the DSE recipe. 460 | 461 | Contributed by Anton Chebotaev. 462 | 463 | 464 | ## Changes Between 2.5.0 and 2.6.0 465 | 466 | ### Ubuntu 12.04 Compatibility 467 | 468 | Contributed by Anton Chebotaev. 469 | 470 | 471 | ## Changes Between 2.4.0 and 2.5.0 472 | 473 | ### Chef-friendly Version 474 | 475 | The cookbook now uses a 3 component version that's compatible 476 | with Chef server (no longer uses `-pre` for dev versions). 477 | 478 | Contributed by Anton Chebotaev. 479 | 480 | ### Init Script Improvements 481 | 482 | * Added check for C* binary 483 | * Added check for nodetool binary 484 | * Added extra pre-steps for C* service stop: disable thrift, disable gossip, node drain 485 | 486 | Contributed by Virender Khatri. 487 | 488 | ### Disabling Xss Output in Nodetool 489 | 490 | Contributed by Virender Khatri. 491 | 492 | ### Cassandra 2.0.9 493 | 494 | Default Cassandra version provisioned is now `2.0.9`. 495 | 496 | Contributed by Maksim Rusan. 497 | 498 | ### Corrected yum Package Release For DSC 2.0 499 | 500 | Corrects yum package release for dsc20 2.0.8. 501 | 502 | GH issue: #73. 503 | 504 | Contributed by Brent Theisen. 505 | 506 | 507 | ## Changes Between 2.3.0 and 2.4.0 508 | 509 | ### apt Pinning 510 | 511 | When package provisioning is used on Debianoids, 512 | apt will be pinned to the exact version to avoid 513 | unexpected upgrades. 514 | 515 | Contributed by [klamontagne](https://github.com/klamontagne). 516 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'buff-extensions', '2.0.0' 4 | gem 'listen', '3.1.5' 5 | gem 'ruby_dep', '1.5.0' 6 | 7 | gem 'chef', '~> 12' 8 | gem 'berkshelf' 9 | gem 'chefspec' 10 | gem 'foodcritic' 11 | gem 'rake' 12 | gem 'rubocop' 13 | 14 | gem 'nokogiri', '>= 1.13.5' 15 | 16 | group :integration do 17 | gem 'guard', '~> 2.6' 18 | gem 'guard-foodcritic', '~> 2.1.0' 19 | gem 'guard-rspec', '~> 4.2' 20 | gem 'kitchen-docker' 21 | gem 'kitchen-vagrant' 22 | gem 'test-kitchen' 23 | end 24 | 25 | group :test do 26 | gem 'coveralls', require: false 27 | end 28 | 29 | group :development do 30 | gem 'stove' 31 | end 32 | 33 | # Uncomment these lines if you want to live on the Edge: 34 | # 35 | # group :development do 36 | # gem "berkshelf", github: "berkshelf/berkshelf" 37 | # gem "vagrant", github: "mitchellh/vagrant", tag: "v1.6.3" 38 | # end 39 | # 40 | # group :plugins do 41 | # gem "vagrant-berkshelf", github: "berkshelf/vagrant-berkshelf" 42 | # gem "vagrant-omnibus", github: "schisamo/vagrant-omnibus" 43 | # end 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2012-2015 Michael Klishin and contributors 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'foodcritic' 2 | require 'rubocop/rake_task' 3 | require 'rspec/core/rake_task' 4 | 5 | desc 'Run all lints' 6 | task lint: %w[foodcritic rubocop] 7 | task unit: %w[foodcritic rubocop spec] 8 | task default: %w[foodcritic rubocop spec integration:vagrant] 9 | task docker: %w[foodcritic rubocop spec integration:docker] 10 | 11 | desc 'Run Rubocop Lint Task' 12 | task :rubocop do 13 | RuboCop::RakeTask.new 14 | end 15 | 16 | desc 'Run FoodCritic Lint Task' 17 | FoodCritic::Rake::LintTask.new do |fc| 18 | fc.options = { 19 | fail_tags: ['any'] 20 | } 21 | end 22 | 23 | desc 'Run Chef Spec Test' 24 | task :spec do 25 | RSpec::Core::RakeTask.new(:spec) 26 | end 27 | 28 | namespace :integration do 29 | desc 'Run integration tests with kitchen-vagrant' 30 | task :vagrant do 31 | require 'kitchen' 32 | Kitchen.logger = Kitchen.default_file_logger 33 | Kitchen::Config.new.instances.each do |instance| 34 | instance.test(:always) 35 | end 36 | end 37 | 38 | begin 39 | desc 'Run integration tests with kitchen-docker' 40 | task :docker do 41 | ENV['KI_DRIVER'] = 'docker' 42 | require 'kitchen' 43 | Kitchen.logger = Kitchen.default_file_logger 44 | Kitchen::Config.new.instances.each do |instance| 45 | instance.test(:always) 46 | end 47 | end 48 | rescue LoadError 49 | puts '>>>>> kitchen gem not loaded, omitting tasks' unless ENV['CI'] 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /TESTING.md: -------------------------------------------------------------------------------- 1 | # Testing 2 | 3 | ## Install Dependencies 4 | 5 | First install dependencies with 6 | 7 | bundle install 8 | 9 | ## Test Suites 10 | 11 | This cookbook contains several test suites, each with its own Rake task: 12 | 13 | * `rake lint` will run Rubocop and Food Critic 14 | * `rake unit` will run unit tests 15 | * `rake integration:vagrant` will run integration tests in a local Vagrant VM (and thus requires VirtualBox or Vagrant VMware plugin to be installed) 16 | * `rake integration:docker` will run integration tests in a Docker contains (and thus requires Docker to be installed) 17 | -------------------------------------------------------------------------------- /Thorfile: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require 'bundler' 4 | require 'bundler/setup' 5 | require 'berkshelf/thor' 6 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 5 | VAGRANTFILE_API_VERSION = '2'.freeze 6 | 7 | Vagrant.require_version '>= 1.5.0' 8 | 9 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 10 | # All Vagrant configuration is done here. The most common configuration 11 | # options are documented and commented below. For a complete reference, 12 | # please see the online documentation at vagrantup.com. 13 | 14 | config.vm.hostname = 'cassandra-berkshelf' 15 | 16 | # Set the version of chef to install using the vagrant-omnibus plugin 17 | config.omnibus.chef_version = :latest 18 | 19 | # Every Vagrant virtual environment requires a box to build off of. 20 | config.vm.box = 'chef/centos-6.5' 21 | 22 | # The url from where the 'config.vm.box' box will be fetched if it 23 | # doesn't already exist on the user's system. 24 | # config.vm.box_url = "https://dl.dropbox.com/u/31081437/Berkshelf-CentOS-6.3-x86_64-minimal.box" 25 | 26 | # Assign this VM to a host-only network IP, allowing you to access it 27 | # via the IP. Host-only networks can talk to the host machine as well as 28 | # any other machines on the same network, but cannot be accessed (through this 29 | # network interface) by any external networks. 30 | config.vm.network :private_network, type: 'dhcp' 31 | 32 | # Create a forwarded port mapping which allows access to a specific port 33 | # within the machine from a port on the host machine. In the example below, 34 | # accessing "localhost:8080" will access port 80 on the guest machine. 35 | 36 | # Share an additional folder to the guest VM. The first argument is 37 | # the path on the host to the actual folder. The second argument is 38 | # the path on the guest to mount the folder. And the optional third 39 | # argument is a set of non-required options. 40 | # config.vm.synced_folder "../data", "/vagrant_data" 41 | 42 | # Provider-specific configuration so you can fine-tune various 43 | # backing providers for Vagrant. These expose provider-specific options. 44 | # Example for VirtualBox: 45 | # 46 | # config.vm.provider :virtualbox do |vb| 47 | # # Don't boot with headless mode 48 | # vb.gui = true 49 | # 50 | # # Use VBoxManage to customize the VM. For example to change memory: 51 | # vb.customize ["modifyvm", :id, "--memory", "1024"] 52 | # end 53 | # 54 | # View the documentation for the provider you're using for more 55 | # information on available options. 56 | 57 | # The path to the Berksfile to use with Vagrant Berkshelf 58 | # config.berkshelf.berksfile_path = "./Berksfile" 59 | 60 | # Enabling the Berkshelf plugin. To enable this globally, add this configuration 61 | # option to your ~/.vagrant.d/Vagrantfile file 62 | config.berkshelf.enabled = true 63 | 64 | # An array of symbols representing groups of cookbook described in the Vagrantfile 65 | # to exclusively install and copy to Vagrant's shelf. 66 | # config.berkshelf.only = [] 67 | 68 | # An array of symbols representing groups of cookbook described in the Vagrantfile 69 | # to skip installing and copying to Vagrant's shelf. 70 | # config.berkshelf.except = [] 71 | 72 | config.vm.provision :chef_solo do |chef| 73 | chef.json = { 74 | cassandra: { 75 | cluster_name: 'vagrant-test' 76 | } 77 | } 78 | 79 | chef.run_list = [ 80 | 'recipe[cassandra-dse::default]' 81 | ] 82 | end 83 | end 84 | -------------------------------------------------------------------------------- /attributes/config.rb: -------------------------------------------------------------------------------- 1 | default['cassandra']['config']['cluster_name'] = nil 2 | default['cassandra']['config']['auto_bootstrap'] = true 3 | default['cassandra']['config']['hinted_handoff_enabled'] = true 4 | default['cassandra']['config']['max_hint_window_in_ms'] = 10_800_000 # 3 hours 5 | default['cassandra']['config']['hinted_handoff_throttle_in_kb'] = 1024 6 | default['cassandra']['config']['max_hints_delivery_threads'] = 2 7 | default['cassandra']['config']['permissions_validity_in_ms'] = 2000 8 | default['cassandra']['config']['authenticator'] = 'org.apache.cassandra.auth.AllowAllAuthenticator' 9 | default['cassandra']['config']['authorizer'] = 'org.apache.cassandra.auth.AllowAllAuthorizer' 10 | default['cassandra']['config']['partitioner'] = 'org.apache.cassandra.dht.Murmur3Partitioner' 11 | default['cassandra']['config']['disk_failure_policy'] = 'stop' # options: stop,best_effort,ignore 12 | default['cassandra']['config']['key_cache_size_in_mb'] = nil # empty str for auto = (min(5% of Heap (in MB), 100MB)) 13 | default['cassandra']['config']['key_cache_save_period'] = 14_400 # in seconds 14 | default['cassandra']['config']['key_cache_keys_to_save'] = nil # 100 15 | default['cassandra']['config']['row_cache_size_in_mb'] = 0 16 | default['cassandra']['config']['row_cache_save_period'] = 0 # in seconds 17 | default['cassandra']['config']['row_cache_keys_to_save'] = nil # 100 18 | default['cassandra']['config']['row_cache_provider'] = 'SerializingCacheProvider' 19 | default['cassandra']['config']['commitlog_sync'] = 'periodic' # 'batch' or 'periodic' 20 | default['cassandra']['config']['commitlog_sync_batch_window_in_ms'] = 50 # only applies to 'batch' sync 21 | default['cassandra']['config']['commitlog_sync_period_in_ms'] = 10_000 # only applies to 'periodic' sync 22 | default['cassandra']['config']['commitlog_segment_size_in_mb'] = 32 23 | default['cassandra']['config']['commitlog_total_space_in_mb'] = 4096 24 | default['cassandra']['config']['concurrent_reads'] = 32 # suggested at 16 * number of drives 25 | default['cassandra']['config']['concurrent_writes'] = 32 # suggested at 8 * number of cpu cores 26 | default['cassandra']['config']['trickle_fsync'] = false 27 | default['cassandra']['config']['trickle_fsync_interval_in_kb'] = 10_240 28 | default['cassandra']['config']['listen_address'] = node['ipaddress'] 29 | default['cassandra']['config']['broadcast_address'] = node['ipaddress'] 30 | default['cassandra']['config']['rpc_address'] = '0.0.0.0' 31 | default['cassandra']['config']['rpc_port'] = '9160' 32 | default['cassandra']['config']['storage_port'] = 7000 33 | default['cassandra']['config']['ssl_storage_port'] = 7001 34 | default['cassandra']['config']['native_transport_port'] = '9042' 35 | 36 | if node['cassandra']['version'] < '2.0' 37 | default['cassandra']['config']['memtable_flush_queue_size'] = 4 38 | default['cassandra']['config']['in_memory_compaction_limit_in_mb'] = 64 39 | default['cassandra']['config']['concurrent_compactors'] = nil 40 | default['cassandra']['config']['multithreaded_compaction'] = false 41 | default['cassandra']['config']['compaction_preheat_key_cache'] = true 42 | default['cassandra']['config']['native_transport_min_threads'] = nil 43 | default['cassandra']['config']['native_transport_max_threads'] = nil 44 | end 45 | 46 | default['cassandra']['config']['start_native_transport'] = true 47 | default['cassandra']['config']['start_rpc'] = true 48 | default['cassandra']['config']['rpc_keepalive'] = true 49 | default['cassandra']['config']['rpc_server_type'] = 'sync' # 'sync' or 'hsha' 50 | default['cassandra']['config']['rpc_min_threads'] = 16 51 | default['cassandra']['config']['rpc_max_threads'] = 2048 52 | default['cassandra']['config']['thrift_framed_transport_size_in_mb'] = 15 53 | default['cassandra']['config']['thrift_max_message_length_in_mb'] = 16 54 | default['cassandra']['config']['incremental_backups'] = false 55 | default['cassandra']['config']['snapshot_before_compaction'] = false 56 | default['cassandra']['config']['auto_snapshot'] = true 57 | default['cassandra']['config']['column_index_size_in_kb'] = 64 58 | default['cassandra']['config']['compaction_throughput_mb_per_sec'] = 16 59 | default['cassandra']['config']['read_request_timeout_in_ms'] = 10_000 60 | default['cassandra']['config']['range_request_timeout_in_ms'] = 10_000 61 | default['cassandra']['config']['write_request_timeout_in_ms'] = 10_000 62 | default['cassandra']['config']['truncate_request_timeout_in_ms'] = 60_000 63 | default['cassandra']['config']['request_timeout_in_ms'] = 10_000 64 | default['cassandra']['config']['cross_node_timeout'] = false 65 | default['cassandra']['config']['streaming_socket_timeout_in_ms'] = 86400000 66 | default['cassandra']['config']['stream_throughput_outbound_megabits_per_sec'] = 400 67 | default['cassandra']['config']['endpoint_snitch'] = 'SimpleSnitch' # endpoint_snitch config 68 | default['cassandra']['config']['dynamic_snitch_update_interval_in_ms'] = 100 69 | default['cassandra']['config']['dynamic_snitch_reset_interval_in_ms'] = 600_000 70 | default['cassandra']['config']['dynamic_snitch_badness_threshold'] = 0.1 71 | default['cassandra']['config']['request_scheduler'] = 'org.apache.cassandra.scheduler.NoScheduler' 72 | default['cassandra']['config']['phi_convict_threshold'] = 8 73 | default['cassandra']['config']['index_interval'] = 128 74 | default['cassandra']['config']['num_tokens'] = 256 75 | default['cassandra']['config']['internode_compression'] = 'dc' # all, dc, none 76 | default['cassandra']['config']['inter_dc_tcp_nodelay'] = false 77 | 78 | # C* 2.1.0 79 | if node['cassandra']['version'] >= '2.1' 80 | default['cassandra']['config']['broadcast_rpc_address'] = node['ipaddress'] 81 | default['cassandra']['config']['tombstone_failure_threshold'] = 100_000 82 | default['cassandra']['config']['tombstone_warn_threshold'] = 1000 83 | default['cassandra']['config']['sstable_preemptive_open_interval_in_mb'] = 50 84 | default['cassandra']['config']['memtable_allocation_type'] = 'heap_buffers' 85 | default['cassandra']['config']['index_summary_capacity_in_mb'] = nil 86 | default['cassandra']['config']['index_summary_resize_interval_in_minutes'] = 60 87 | default['cassandra']['config']['concurrent_counter_writes'] = 32 88 | default['cassandra']['config']['counter_cache_save_period'] = 7200 89 | default['cassandra']['config']['counter_cache_size_in_mb'] = nil 90 | default['cassandra']['config']['counter_write_request_timeout_in_ms'] = 5000 91 | default['cassandra']['config']['commit_failure_policy'] = 'stop' 92 | default['cassandra']['config']['cas_contention_timeout_in_ms'] = 1000 93 | default['cassandra']['config']['batch_size_warn_threshold_in_kb'] = 5 94 | default['cassandra']['config']['batchlog_replay_throttle_in_kb'] = 1024 95 | end 96 | 97 | # C* server encryption configuration options 98 | default['cassandra']['config']['server_encryption_options']['internode_encryption'] = 'none' # none, all, dc, rack 99 | default['cassandra']['config']['server_encryption_options']['keystore'] = 'conf/.keystore' 100 | default['cassandra']['config']['server_encryption_options']['keystore_password'] = 'cassandra' 101 | default['cassandra']['config']['server_encryption_options']['truststore'] = 'conf/.truststore' 102 | default['cassandra']['config']['server_encryption_options']['truststore_password'] = 'cassandra' 103 | 104 | # More advanced option defaults... (matching the default file comments) 105 | # Default values provided but not actually installed in the config so the 106 | # defaults can change with versions in the expected, unmanaged way. 107 | default['cassandra']['config']['server_encryption_options']['enable_advanced'] = false 108 | 109 | if node['cassandra']['config']['server_encryption_options']['enable_advanced'] 110 | default['cassandra']['config']['server_encryption_options']['protocol'] = 'TLS' 111 | default['cassandra']['config']['server_encryption_options']['algorithm'] = 'SunX509' 112 | default['cassandra']['config']['server_encryption_options']['store_type'] = 'JKS' 113 | default['cassandra']['config']['server_encryption_options']['cipher_suites'] = '[TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA]' 114 | default['cassandra']['config']['server_encryption_options']['require_client_auth'] = false 115 | end 116 | 117 | # C* client encryption configuration options 118 | default['cassandra']['config']['client_encryption_options']['enabled'] = false 119 | default['cassandra']['config']['client_encryption_options']['keystore'] = 'conf/.keystore' 120 | default['cassandra']['config']['client_encryption_options']['keystore_password'] = 'cassandra' 121 | default['cassandra']['config']['client_encryption_options']['require_client_auth'] = false 122 | 123 | if node['cassandra']['config']['client_encryption_options']['require_client_auth'] 124 | # trust store only configured if require_client_auth is true. 125 | default['cassandra']['config']['client_encryption_options']['truststore'] = 'conf/.truststore' 126 | default['cassandra']['config']['client_encryption_options']['truststore_password'] = 'cassandra' 127 | end 128 | 129 | # More advanced option defaults... (matching the default file comments) 130 | # Default values provided but not actually installed in the config so the 131 | # defaults can change with versions in the expected, unmanaged way. 132 | default['cassandra']['config']['client_encryption_options']['enable_advanced'] = false 133 | 134 | if node['cassandra']['config']['client_encryption_options']['enable_advanced'] 135 | default['cassandra']['config']['client_encryption_options']['protocol'] = 'TLS' 136 | default['cassandra']['config']['client_encryption_options']['algorithm'] = 'SunX509' 137 | default['cassandra']['config']['client_encryption_options']['store_type'] = 'JKS' 138 | default['cassandra']['config']['client_encryption_options']['cipher_suites'] = '[TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA]' 139 | end 140 | -------------------------------------------------------------------------------- /attributes/datastax.rb: -------------------------------------------------------------------------------- 1 | 2 | default['cassandra']['package_name'] = 'dsc22' 3 | default['cassandra']['tools_package_name'] = 'python-cql' 4 | default['cassandra']['release'] = '1' 5 | 6 | default['cassandra']['yum']['repo'] = 'datastax' 7 | default['cassandra']['yum']['description'] = 'DataStax Repo for Apache Cassandra' 8 | default['cassandra']['yum']['baseurl'] = 'http://rpm.datastax.com/community' # for dsc (not dse) 9 | default['cassandra']['yum']['dse_uri'] = 'rpm.datastax.com/enterprise' # for dse 10 | default['cassandra']['yum']['mirrorlist'] = nil 11 | default['cassandra']['yum']['gpgcheck'] = false 12 | default['cassandra']['yum']['enabled'] = true 13 | default['cassandra']['yum']['options'] = '' 14 | default['cassandra']['yum']['action'] = :create 15 | 16 | default['cassandra']['apt']['repo'] = 'datastax' 17 | default['cassandra']['apt']['uri'] = 'https://debian.datastax.com/community/' # for dsc (not dse) 18 | default['cassandra']['apt']['dse_uri'] = 'debian.datastax.com/enterprise' # for dse 19 | default['cassandra']['apt']['distribution'] = 'stable' 20 | default['cassandra']['apt']['components'] = %w[main] 21 | default['cassandra']['apt']['repo_key'] = 'https://debian.datastax.com/debian/repo_key' 22 | default['cassandra']['apt']['action'] = :add 23 | -------------------------------------------------------------------------------- /attributes/default.rb: -------------------------------------------------------------------------------- 1 | default['systemd']['units_dir'] = '/etc/systemd/system' 2 | 3 | default['java']['jdk_version'] = '7' 4 | default['java']['install_flavor'] = 'oracle' 5 | default['java']['set_default'] = true 6 | default['java']['oracle']['accept_oracle_download_terms'] = true 7 | 8 | default['cassandra']['tarball_purge'] = false 9 | default['cassandra']['install_method'] = 'datastax' 10 | default['cassandra']['install_java'] = true 11 | default['cassandra']['notify_restart'] = false 12 | default['cassandra']['initial_token'] = '' 13 | default['cassandra']['service_name'] = 'cassandra' 14 | default['cassandra']['user'] = 'cassandra' 15 | default['cassandra']['group'] = 'cassandra' 16 | default['cassandra']['setup_user'] = true 17 | default['cassandra']['setup_user_limits'] = true 18 | default['cassandra']['user_home'] = nil 19 | default['cassandra']['system_user'] = true 20 | default['cassandra']['version'] = '2.2.0' 21 | default['cassandra']['use_systemd'] = false 22 | default['cassandra']['use_initd'] = true 23 | 24 | # jamm library was added in v0.8.0 and 25 | # not required for later versions 26 | default['cassandra']['setup_jamm'] = false 27 | 28 | default['cassandra']['setup_priam'] = false 29 | default['cassandra']['priam']['base_url'] = "http://search.maven.org/remotecontent?filepath=com/netflix/priam/priam-cass-extensions/#{node['cassandra']['version']}" 30 | default['cassandra']['priam']['jar_name'] = "priam-cass-extensions-#{node['cassandra']['version']}.jar" 31 | default['cassandra']['priam']['sha256sum'] = '9fde9a40dc5c538adee54f40fa9027cf3ebb7fd42e3592b3e6fdfe3f7aff81e1' 32 | 33 | default['cassandra']['pid_dir'] = '/var/run/cassandra' 34 | default['cassandra']['dir_mode'] = '0755' 35 | default['cassandra']['service_action'] = %i[enable start] 36 | default['cassandra']['jmx_port'] = 7199 37 | default['cassandra']['local_jmx'] = true 38 | default['cassandra']['jmx_remote_rmi_port'] = '$JMX_PORT' 39 | default['cassandra']['jmx_remote_authenticate'] = false 40 | default['cassandra']['jmx']['user'] = 'cassandra' 41 | default['cassandra']['jmx']['password'] = 'cassandra' 42 | 43 | default['cassandra']['limits']['memlock'] = 'unlimited' 44 | default['cassandra']['limits']['nofile'] = 48_000 45 | default['cassandra']['limits']['nproc'] = 'unlimited' 46 | 47 | default['cassandra']['templates_cookbook'] = 'cassandra-dse' 48 | 49 | default['cassandra']['root_dir'] = '/var/lib/cassandra' # data/ subdir added to this root 50 | default['cassandra']['log_dir'] = '/var/log/cassandra' 51 | default['cassandra']['rootlogger'] = 'INFO,stdout,R' 52 | 53 | # Seed node discovery 54 | default['cassandra']['seeds'] = node['ipaddress'] 55 | 56 | default['cassandra']['seed_discovery']['use_chef_search'] = false 57 | default['cassandra']['seed_discovery']['count'] = 3 58 | default['cassandra']['seed_discovery']['search_role'] = 'cassandra-seed' 59 | default['cassandra']['seed_discovery']['search_query'] = nil 60 | 61 | default['cassandra']['jbod']['slices'] = nil 62 | default['cassandra']['jbod']['dir_name_prefix'] = 'data' 63 | 64 | default['cassandra']['logback']['file']['max_file_size'] = '20MB' 65 | default['cassandra']['logback']['file']['max_index'] = 20 66 | default['cassandra']['logback']['file']['min_index'] = 1 67 | default['cassandra']['logback']['file']['pattern'] = '%-5level [%thread] %date{ISO8601} %F:%L - %msg%n' 68 | 69 | default['cassandra']['logback']['debug']['enable'] = false 70 | default['cassandra']['logback']['debug']['max_file_size'] = '20MB' 71 | default['cassandra']['logback']['debug']['max_index'] = 20 72 | default['cassandra']['logback']['debug']['min_index'] = 1 73 | default['cassandra']['logback']['debug']['pattern'] = '%-5level [%thread] %date{ISO8601} %F:%L - %msg%n' 74 | 75 | default['cassandra']['logback']['stdout']['enable'] = true 76 | default['cassandra']['logback']['stdout']['pattern'] = '%-5level [%thread] %date{ISO8601} %F:%L - %msg%n' 77 | 78 | default['cassandra']['logback']['syslog']['enable'] = false 79 | default['cassandra']['logback']['syslog']['host'] = 'localhost' 80 | default['cassandra']['logback']['syslog']['facility'] = 'USER' 81 | default['cassandra']['logback']['syslog']['pattern'] = '%-5level [%thread] %F:%L - %msg%n' 82 | 83 | default['cassandra']['logback']['override_loggers'] = {} 84 | 85 | default['cassandra']['log4j'] = {} 86 | 87 | data_dir = [] 88 | if !node['cassandra']['jbod']['slices'].nil? 89 | node['cassandra']['jbod']['slices'].times do |slice_number| 90 | data_dir << ::File.join(node['cassandra']['root_dir'], "#{node['cassandra']['jbod']['dir_name_prefix']}#{slice_number}") 91 | end 92 | else 93 | data_dir << ::File.join(node['cassandra']['root_dir'], 'data') 94 | end 95 | 96 | default['cassandra']['data_dir'] = data_dir 97 | 98 | default['cassandra']['max_heap_size'] = nil 99 | default['cassandra']['heap_new_size'] = nil 100 | default['cassandra']['xss'] = '256k' 101 | default['cassandra']['vnodes'] = true 102 | default['cassandra']['enable_assertions'] = true 103 | default['cassandra']['internode_compression'] = 'all' # all, dc, none 104 | default['cassandra']['jmx_server_hostname'] = false 105 | default['cassandra']['metrics_reporter']['enabled'] = false 106 | default['cassandra']['metrics_reporter']['name'] = 'metrics-graphite' 107 | default['cassandra']['metrics_reporter']['jar_url'] = 'http://search.maven.org/remotecontent?filepath=com/yammer/metrics/metrics-graphite/2.2.0/metrics-graphite-2.2.0.jar' 108 | default['cassandra']['metrics_reporter']['sha256sum'] = '6b4042aabf532229f8678b8dcd34e2215d94a683270898c162175b1b13d87de4' 109 | default['cassandra']['metrics_reporter']['jar_name'] = 'metrics-graphite-2.2.0.jar' 110 | default['cassandra']['metrics_reporter']['config'] = {} # should be a hash of relevant config 111 | 112 | default['cassandra']['jamm']['version'] = jamm_version(node['cassandra']['version']) 113 | default['cassandra']['jamm']['base_url'] = jamm_url(node['cassandra']['jamm']['version']) 114 | default['cassandra']['jamm']['jar_name'] = "jamm-#{node['cassandra']['jamm']['version']}.jar" 115 | default['cassandra']['jamm']['sha256sum'] = jamm_sha256sum(node['cassandra']['jamm']['version']) 116 | 117 | # log configuration files 118 | default['cassandra']['log_config_files'] = node['cassandra']['version'] =~ /^[0-1]|^2.0/ ? %w[log4j-server.properties] : %w[logback.xml logback-tools.xml] 119 | 120 | # Heap Dump and Out of Memory handling 121 | default['cassandra']['heap_dump'] = true 122 | default['cassandra']['heap_dump_dir'] = nil 123 | default['cassandra']['on_oom'] = 'kill -9 %p' 124 | 125 | # GC tuning options 126 | default['cassandra']['jvm']['g1'] = false 127 | default['cassandra']['jvm']['gcdetail'] = true 128 | 129 | default['cassandra']['jvm']['max_gc_pause_millis'] = 200 130 | default['cassandra']['jvm']['heap_occupancy_threshold'] = 45 131 | default['cassandra']['jvm']['parallel_ref_proc'] = false 132 | default['cassandra']['jvm']['max_parallel_gc_threads'] = nil 133 | default['cassandra']['jvm']['max_conc_gc_threads'] = nil 134 | default['cassandra']['jvm']['g1_rset_updating_pause_time_percent'] = 5 135 | default['cassandra']['jvm']['g1_heap_region_size'] = 0 136 | default['cassandra']['jvm']['always_pre_touch'] = false 137 | default['cassandra']['jvm']['use_biased_locking'] = true 138 | default['cassandra']['jvm']['use_tlab'] = true 139 | default['cassandra']['jvm']['resize_tlab'] = true 140 | 141 | default['cassandra']['jvm']['agentpath'] = nil 142 | default['cassandra']['jvm']['misc_java_agents'] = [] 143 | 144 | default['cassandra']['jvm']['misc_jvm_options'] = [] 145 | 146 | default['cassandra']['gc_survivor_ratio'] = 8 147 | default['cassandra']['gc_max_tenuring_threshold'] = 1 148 | default['cassandra']['gc_cms_initiating_occupancy_fraction'] = 75 149 | default['cassandra']['log_gc'] = '${CASSANDRA_HOME}/logs/gc.log' 150 | 151 | default['cassandra']['jna']['base_url'] = 'https://github.com/twall/jna/raw/4.0/dist' 152 | default['cassandra']['jna']['jar_name'] = 'jna.jar' 153 | default['cassandra']['jna']['sha256sum'] = 'dac270b6441ce24d93a96ddb6e8f93d8df099192738799a6f6fcfc2b2416ca19' 154 | 155 | default['cassandra']['tarball']['url'] = 'auto' 156 | 157 | default['cassandra']['opscenter']['version'] = nil 158 | default['cassandra']['opscenter']['server']['package_name'] = 'opscenter' 159 | default['cassandra']['opscenter']['server']['port'] = '8888' 160 | default['cassandra']['opscenter']['server']['interface'] = '0.0.0.0' 161 | default['cassandra']['opscenter']['server']['authentication'] = false 162 | 163 | default['cassandra']['opscenter']['cassandra_metrics']['ignored_keyspaces'] = %w[system OpsCenter] 164 | default['cassandra']['opscenter']['cassandra_metrics']['ignored_column_families'] = [] 165 | default['cassandra']['opscenter']['cassandra_metrics']['1min_ttl'] = 604800 166 | default['cassandra']['opscenter']['cassandra_metrics']['5min_ttl'] = 2419200 167 | default['cassandra']['opscenter']['cassandra_metrics']['2hr_ttl'] = 31536000 168 | 169 | default['cassandra']['opscenter']['custom_configuration'] = {} 170 | 171 | default['cassandra']['opscenter']['agent']['package_name'] = 'datastax-agent' 172 | default['cassandra']['opscenter']['agent']['download_url'] = nil 173 | default['cassandra']['opscenter']['agent']['checksum'] = nil 174 | default['cassandra']['opscenter']['agent']['install_dir'] = '/opt' 175 | default['cassandra']['opscenter']['agent']['install_folder_name'] = 'opscenter_agent' 176 | default['cassandra']['opscenter']['agent']['binary_name'] = 'opscenter-agent' 177 | # if nil, will use search to get IP by server role 178 | default['cassandra']['opscenter']['agent']['server_host'] = nil 179 | default['cassandra']['opscenter']['agent']['use_chef_search'] = true 180 | default['cassandra']['opscenter']['agent']['server_role'] = 'opscenter_server' 181 | default['cassandra']['opscenter']['agent']['use_ssl'] = false 182 | default['cassandra']['opscenter']['agent']['conf_dir'] = '/var/lib/datastax-agent/conf' 183 | -------------------------------------------------------------------------------- /attributes/systemd.rb: -------------------------------------------------------------------------------- 1 | # Restart cassandra on failure conditions by default 2 | # Check out the link below for the list of possible values and their meaning: 3 | # https://www.freedesktop.org/software/systemd/man/systemd.service.html#Restart= 4 | default['cassandra']['systemd']['restart_condition'] = 'on-failure' 5 | -------------------------------------------------------------------------------- /chefignore: -------------------------------------------------------------------------------- 1 | # Put files/directories that should be ignored in this file when uploading 2 | # or sharing to the community site. 3 | # Lines that start with '# ' are comments. 4 | 5 | # OS generated files # 6 | ###################### 7 | .DS_Store 8 | Icon? 9 | nohup.out 10 | ehthumbs.db 11 | Thumbs.db 12 | 13 | # SASS # 14 | ######## 15 | .sass-cache 16 | 17 | # EDITORS # 18 | ########### 19 | \#* 20 | .#* 21 | *~ 22 | *.sw[a-z] 23 | *.bak 24 | REVISION 25 | TAGS* 26 | tmtags 27 | *_flymake.* 28 | *_flymake 29 | *.tmproj 30 | .project 31 | .settings 32 | mkmf.log 33 | 34 | ## COMPILED ## 35 | ############## 36 | a.out 37 | *.o 38 | *.pyc 39 | *.so 40 | *.com 41 | *.class 42 | *.dll 43 | *.exe 44 | */rdoc/ 45 | 46 | # Testing # 47 | ########### 48 | .watchr 49 | .rspec 50 | spec/* 51 | spec/fixtures/* 52 | test/* 53 | features/* 54 | Guardfile 55 | Procfile 56 | 57 | # SCM # 58 | ####### 59 | .git 60 | */.git 61 | .gitignore 62 | .gitmodules 63 | .gitconfig 64 | .gitattributes 65 | .svn 66 | */.bzr/* 67 | */.hg/* 68 | */.svn/* 69 | 70 | # Berkshelf # 71 | ############# 72 | cookbooks/* 73 | tmp 74 | 75 | # Cookbooks # 76 | ############# 77 | CONTRIBUTING 78 | CHANGELOG* 79 | 80 | # Strainer # 81 | ############ 82 | Colanderfile 83 | Strainerfile 84 | .colander 85 | .strainer 86 | 87 | # Vagrant # 88 | ########### 89 | .vagrant 90 | Vagrantfile 91 | 92 | # Travis # 93 | ########## 94 | .travis.yml 95 | 96 | # Coverage # 97 | ########## 98 | coverage/ 99 | 100 | # Berkshelf 101 | Berksfile.lock 102 | 103 | # Bundler 104 | Gemfile.lock 105 | -------------------------------------------------------------------------------- /libraries/config_helpers.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: cassandra 3 | # Libraries:: config_helpers 4 | # 5 | 6 | require 'yaml' 7 | 8 | def cassandra_yaml_config(c) 9 | config = JSON.parse(c.to_hash.dup.to_json) 10 | config.each do |k, v| 11 | config.delete(k) if k.nil? || v.nil? 12 | end 13 | 14 | # remove eval attributes 15 | config['client_encryption_options'].delete('enable_advanced') # if config.key?('client_encryption_options') 16 | config['server_encryption_options'].delete('enable_advanced') # if config.key?('server_encryption_options') 17 | 18 | # delete num_tokens if vnodes is not set 19 | config.delete('num_tokens') unless node['cassandra']['vnodes'] 20 | # delete initial_token if vnodes is set 21 | config.delete('initial_token') if node['cassandra']['vnodes'] 22 | # remove row_cache_provider if row_cache_provider == SerializingCacheProvider 23 | config.delete('row_cache_provider') if config.key?('row_cache_provider') && config['row_cache_provider'] == 'SerializingCacheProvider' 24 | # remove commitlog_sync_period_in_ms if commitlog_sync_batch_window_in_ms is not set 25 | config.delete('commitlog_sync_period_in_ms') unless config.key?('commitlog_sync_batch_window_in_ms') 26 | # remove commitlog_sync_period_in_ms if commitlog_sync != periodic 27 | config.delete('commitlog_sync_period_in_ms') if config.key?('commitlog_sync') && config['commitlog_sync'] != 'periodic' 28 | # remove commitlog_sync_batch_window_in_ms if commitlog_sync == periodic 29 | config.delete('commitlog_sync_batch_window_in_ms') if config.key?('commitlog_sync') && config['commitlog_sync'] == 'periodic' 30 | 31 | config['start_rpc'] = cassandra_bool_config(config['start_rpc']) 32 | config['rpc_keepalive'] = cassandra_bool_config(config['rpc_keepalive']) 33 | Hash[config.sort].to_yaml 34 | end 35 | 36 | def cassandra_bool_config(config_val) 37 | if config_val.is_a?(String) 38 | config_val 39 | elsif config_val 40 | 'true' 41 | else 42 | 'false' 43 | end 44 | end 45 | 46 | def hash_to_yaml_string(hash) 47 | hash.to_hash.to_yaml 48 | end 49 | 50 | def discover_seed_nodes 51 | # use chef search for seed nodes 52 | if node['cassandra']['seed_discovery']['use_chef_search'] 53 | if Chef::Config[:solo] 54 | Chef::Log.warn("Chef Solo does not support search, provide the seed nodes via node attribute node['cassandra']['seeds']") 55 | node['ipaddress'] 56 | else 57 | Chef::Log.info('Cassandra seed discovery using Chef search is enabled') 58 | q = node['cassandra']['seed_discovery']['search_query'] || 59 | "chef_environment:#{node.chef_environment} "\ 60 | "AND role:#{node['cassandra']['seed_discovery']['search_role']} "\ 61 | "AND cassandra_config_cluster_name:#{node['cassandra']['config']['cluster_name']}" 62 | Chef::Log.info("Will discover Cassandra seeds using query '#{q}'") 63 | xs = search(:node, q).map { |node| node['ipaddress'] }.sort.uniq 64 | Chef::Log.debug("Discovered #{xs.size} Cassandra seeds using query '#{q}'") 65 | 66 | if xs.empty? 67 | node['ipaddress'] 68 | else 69 | xs.take(node['cassandra']['seed_discovery']['count']).join(',') 70 | end 71 | end 72 | elsif node['cassandra']['seeds'].is_a?(Array) 73 | node['cassandra']['seeds'].join(',') 74 | else 75 | node['cassandra']['seeds'] 76 | end 77 | end 78 | 79 | # eval packaged jamm jar version 80 | def jamm_version(version) 81 | case version.to_s.strip 82 | when /^0.[0-7]/ 83 | '0.2.5' 84 | when /^0.8/ 85 | '0.2.2' 86 | when /^1|^2.0/ 87 | '0.2.5' 88 | when /^2.1.[0-1]$/ 89 | '0.2.6' 90 | when /^2.1.[2-3]$/ 91 | '0.2.8' 92 | when /^2.1/ 93 | '0.3.1' 94 | when /^2.2/ 95 | '0.3.1' 96 | when /^3.[0-9]/ 97 | '0.3.1' 98 | end 99 | end 100 | 101 | def jamm_url(version) 102 | owner = if version.to_s.strip == '0.2.5' 103 | 'stephenc' 104 | else 105 | 'jbellis' 106 | end 107 | 108 | "https://repo1.maven.org/maven2/com/github/#{owner}/jamm/#{version}" 109 | end 110 | 111 | def jamm_sha256sum(version) 112 | case version.to_s.strip 113 | when '0.2.2' 114 | 'unknown' 115 | when '0.2.5' 116 | 'e3dd1200c691f8950f51a50424dd133fb834ab2ce9920b05aa98024550601cc5' 117 | when '0.2.6' 118 | 'c9577bba0321eeb5358fdea29634cbf124ae3742e80d729f3bd98e0e23726dbf' 119 | when '0.2.8' 120 | '79d44f1b911a603f0a249aa59ad6ea22aac9c9b211719e86f357646cdf361a42' 121 | when '0.3.0' 122 | 'debe2f8137c703d81eb9623b457e82eee2b305d834c1a8cfb65ad1f9c8f31f95' 123 | when '0.3.1' 124 | 'b599dc7a58b305d697bbb3d897c91f342bbddefeaaf10a3fa156c93efca397ef' 125 | end 126 | end 127 | 128 | # C* tarball sha256sum 129 | def tarball_sha256sum(version) 130 | sha256sums = { 131 | '1.0.0' => '7d30f8c5fea71a5d0031a0630cf536a20f47c03d6f292a3394d42c447aad4942', '1.0.1' => '90f733a56ddd735c70f412cdabafd5b42a1f63d96c0ada906c2a38e3d3312ede', '1.0.10' => 'bcaad3192cfd650f643b97bdc7e695da425a3bbc6db6c80c9ce9f0210872dc9d', 132 | '1.0.11' => '86b8aa865697f75c280b46aa576eef5e2961b699d3f65a56f39b9e23c822cc83', '1.0.12' => '97f2896263960aa53faa201b07d5a89d531d5e2ab3d9d788e5fc5bc5e9ef985a', '1.0.2' => '1b35c0daaa84f38c67f80c29f37222746f6f1c82900421301d88634f06f0ac79', 133 | '1.0.3' => '1daeef80d5df5db234aee893cb49c3cf55f1a9136406ed0ee17f9f0473170258', '1.0.4' => 'b1ae1df31cb201b51db4fc5843e00eb34db998f10aff8bda31ee5d1b242d9fb7', '1.0.5' => 'd7c2edacddd91f4b01548747ae56c27e3bf2c20a3fc09826810530d3d33343c4', 134 | '1.0.6' => 'a1610344b78164d238415112f523639e8c33b0a3a14b427e8b910017cf060d13', '1.0.7' => 'd0f6062ab75b1348ac9bcc844b6bd7a57dcea5680fe586e25c749db589eddd8d', '1.0.8' => 'b8cc374752deb34b98797b7fb03b892332ebabfb37f4eae0c115482e19b659c6', 135 | '1.0.9' => '0c0597b4e5f5b6eff66d1b9c98ab806be9d2f38c95d5c968407914f5c76fcde1', '1.1.0' => 'ea763057a7b9e5d78a574f310df3081a406af3de9d336d155a679e14d461b303', '1.1.1' => 'b3935a3d300c13a360ffe850672d0a5f767b9834ac6a870868d491ffd0ea2b89', 136 | '1.1.10' => '191ac7fc9f60bfdbe1f5682cb3bdcefcc53d9b5bfb943826fd6d73664d87815a', '1.1.11' => '246ff0348f6e45cb0d7d2c67245fb6d5fb891cbb35b86591416ffcfc183c6ccb', '1.1.12' => '3600f6e86e76974b38b2bf90fabff99ab2a443f444d55a93f3c677c8edbe3785', 137 | '1.1.2' => 'dfeacf663c74bc9de6949c96bbb46afd9567fcbe0925773bc59aad2a4e2e60e8', '1.1.3' => '485c1e0d3025d660a8df16e3c77c29b579f924a0ec6b552f075a417dd9204e64', '1.1.4' => '10d59524264a08cf59007856a0618c2a3f35a5590c0b807ea1a4f1172526998b', 138 | '1.1.5' => '08313fbfd5cc7d91a637a2a27c5c6bb4d3bf6ce8ff5eae9a14c20474faa8cf12', '1.1.6' => 'c21d568313fe7832d9a1b6be0ff39aa5febfee530a1941e89da65f49c6556171', '1.1.7' => 'cce6203c539d40d87a7a278bd056163440a43d75f9ef26ffa42dacbd57cb426a', 139 | '1.1.8' => 'c536232a7bd9ca189e9f1edb6dcaff349bb966d5bf74527d245d3b0b1b22327d', '1.1.9' => '2e86f29fdb1c4eb14b24db34dddbca409cc5176bf0b8e04521dc6fe9104f474d', '1.2.0' => '47bd459fd103a539ef148089f4c8050eeaa950b0b19a798f69905a942fc59510', 140 | '1.2.1' => '0b971ac9e27e48ecca54a4e45a19f26854482a25bdcba6b8b6f742b580e505f1', '1.2.10' => '8e759ca5f92745ad5e74c4e6ba1a0f3bf28cd6b0ff1d5a2a3c2adbc38b61236f', '1.2.11' => '008faeb5846b7a6e789caa0582056f8c95f361bef4d1939176f464fdb2d11f9a', 141 | '1.2.12' => '2883ca8d5103881bd3b27c76819598f1e67a2d7d299ef26d8b982a34fb787d17', '1.2.13' => 'b2430e6fb7039bf17fa6a72f33bd637864895b6316548f7fe3504c5c773b7dcb', '1.2.14' => 'dff728768e5ff2115ac41c2e9599bc4e5ed2f2fb67512c1b4c14bf0a093f7736', 142 | '1.2.15' => '9b35afb9d0fee7ac52858b4018ecf8bc69d7ad58049303a2ee8d44b8592b258b', '1.2.16' => '5ff7a844fca5ec326729001703aaca436543e560485ac50a1c9a5185c205ec46', '1.2.17' => 'fbd96369a113a3eabea7d784fe9f6cadf7598ade38443fa0d70d48ff66aaf576', 143 | '1.2.18' => '7f76aca107b8674d370bf4c37815027dd0d30e8f6e57b7471e050201729ddb92', '1.2.19' => '1c0c6e62dc612a43d6cb54bc70054876576a6cae7b90aca2162aa379df1b787e', '1.2.2' => '435c921864ec90ddb5be88af2f9023173a6f57c7bcb428f9ed0409a57484546f', 144 | '1.2.3' => 'b1860c4d3d6f667ead0c752e328c184c89893721f4d9237db1d9426b17dd4e6a', '1.2.4' => '0679c170b97f95b1677ae3f3e03cfa80a1dc645af5f1236f9a389f8610390a9a', '1.2.5' => '45d7c89000c0f2c8bc44de2de1bfb2943b74517591361ce8d3f4d97ad4508a0c', 145 | '1.2.6' => '0535c2888c9b057fe987ff8468f5dce5830d0b935b2ff1d61c4077b59f27d79c', '1.2.7' => '2c43e8e42a5980679f6375e88131b307784c0c8be8ff92710ae202e89a71c8c7', '1.2.8' => '664198714f31089e2b4cb7b3e0c329483a5e1d2d82563bf0e4fd345350e8f980', 146 | '1.2.9' => '786202a03320bd3fe4ac60c515a322075d1aa3ca15e0860ea3598c6e097baa15', '2.0.0' => '53b101481d0ff528e5dde1ee35cd92107719c0265fb0bfebb0e5cd3fe89e403d', '2.0.1' => '4e25ece07320667ba38a142063080bc18e4d37d7c010ce7b2f2d7c2af3d8740b', 147 | '2.0.10' => '962ab35b1767ed4c56eb9a2a6b9df374097dc48d4f1c718945cab3a977e5d9fa', '2.0.11' => 'f74c94e63c9dcb0cef6b627ea80ee0ad86da46ad7e7318bc6adf6821861d286b', '2.0.12' => 'af6f59e7b187d5c9744fd791156d24fd6cef8b3f65bf3dcbe5ae9400817abe88', 148 | '2.0.13' => '384cd45ec9c26e7b88250a212b79b82659e1687e2227e5cd5a2920fb25fe7764', '2.0.14' => '5396cda7a66929e9c9ea0a2eeb9f2b54327df1a42f407bc82fb1cc1648d87a1b', '2.0.15' => '007a4601c84ccb22b8a4e301d4102c2dbebde07ac9bb7e5d7581271a91ab3d03', 149 | '2.0.16' => 'c523deaaefd3450dcdda0d53e0f93243dd51b018ec32f6bca5c1f73a557dfbba', '2.0.2' => 'f65ed7821a2744a055535571923461c9ef8020242aac0a406f96e9f7cbce2819', '2.0.3' => '8129040b84ad086898f8a99680fd6eb54bb1ba81983d33f7217ec1ae0bb92607', 150 | '2.0.4' => 'f0be26d5a6a4e41fc5c0fdff8ecc4e5250c4a5cf45497904566f795bea1a2c35', '2.0.5' => '3b61ca8da88c6a14e4079b76de3052c53041ebb717a362f0d7489e775381e7c6', '2.0.6' => 'e7679bddb3029f87cf50936bc348cc07a9e6c557cd9a553aa69542d06a3d274a', 151 | '2.0.7' => '9ef94b58ab863d402f3827d5e98c7d01bf4ce02ec8383bdbf97218aced6694a7', '2.0.8' => '7d81ddf7e8ebe59ffa5ff5ace25171a56eb77404c9a5d1675a5031a17e85447e', '2.0.9' => '9cd8378235809007406d493e87ffa0e873b6868a2a7a351f7fbffe9614fa9845', 152 | '2.1.0' => 'da99c4ebc8de925dc6b493443b70d2183cf3090b1aad6b6b918efa9565f264dd', '2.1.1' => 'e9d10c2ccc6124d516772e672aef61732f763ff326967dc7fbcc3f1123a29901', '2.1.2' => '995182b62aada179648146a8fdd6f61881b23a33e77fe92c666c1816dad897be', 153 | '2.1.3' => 'df4ef06cd86c6c8a6bc1afee982279250a7a500aac20de55da48e43d0e3cebc3', '2.1.4' => 'fb5debada72905f169866ca43c21ade4782f9c036b160894e42b9072190cb7f1', '2.1.5' => '2d768e2fba9c576289e26247e2ed0b36fb802e06fa0a141783b765d63daf36ff', 154 | '2.1.6' => 'c2123b9d82b57868ad03c57720d9f4c99934fe292d571242a3b51337063409f7', '2.1.7' => 'add1a34b8e07dacb16df6b8dbe50c66d77cb46b89f66424103e2fd4459b79089', '2.1.8' => '3a0cc64efd529ffdc1600f6b3ad1946af85cc01544e2b469499aa81b10b722f5', 155 | '2.1.9' => '7a33598d3b06cfbf9fd1264f1ad03a03a3d2c716c2e941b79b134cd2e781dc82', '2.1.12' => '013ba98f70d2d77831a5336b6897d1f6fbb99a321616acffbd56747af85ff159', '2.1.13' => '102fffe21b1641696cbdaef0fb5a2fecf01f28da60c81a1dede06c2d8bdb6325', 156 | '2.1.14' => '6f79830829c058899890e18bd881c5fe0ff949774b86aca5930cb6f01e7a1999', '2.1.15' => 'f72a5ac5753d5afc8a4e9ddcc383f9ed7cae79f9cbd80fdf272cfd5e1fc986f9', '2.1.16' => 'a95ba4e2c9345b31310d14507e8889797cc626bc793fd341fff8ff8cba3131cd', 157 | '2.2.0' => '6405eb063e7c8a44a485ac12b305c00ad62c526cc021bcce145c29423ae7b0a2', '2.2.1' => '06cad23535333b4dd72596bc9bd0606afd1a1ea74f2a91df571e3e00c51c473f', '2.2.4' => '48af862becea9ec70999976212d13e2cfb85dcacf565729e763146f86d9365a4', 158 | '2.2.5' => '149d2448d0543fb1d5f87a73a7a5e0f589319908426c3a45b20c85563e164f1f', '2.2.6' => 'fe9a56c842bad309ab7fbeb5adcda1757f650ec092ae2c926e6d0b4a8d7e89ad', '2.2.7' => 'eb09a744dfac4c645678d1ae0dd34483825c408f3ef08f81dc24b4307c9d5199', 159 | '2.2.8' => 'eab09bfe27ac09558aa1bb2b391559d932b89cea94cf254d350395786d7b4a67', '2.2.9' => '65c372c4a9fdd3c701eaef0a38e54c26817a89e423626c980779907828a282f1', 160 | '3.0.0' => 'e268c8eeb25e02c1de18899f6aaa57a5a3636045070026ab4467c993f9559bec', '3.0.1' => '90d734946d15573ba7c6654ed047f0f3a8abd8bd134954ec96b8acb3ec677b05', 161 | '3.0.2' => 'f9b7d29a3966fa1ae2e78920aed31a16bc3dbf56fd35690d146fea745c20353f', '3.0.3' => '555417f0d3b5c73fda7388a23becba28f2b87b1d6de082b7afde8d56b29ba4dd', '3.0.4' => '620e2aad12f6609ec3cd5f8ddf7ec16f9ccd9c1ca2a8c4e9acf1f9fc49e24ad0', 162 | '3.0.5' => '92d28a97ed4a78080855090f6193dab26f4677c8799c64aadbebca3220c016ee', '3.0.6' => '8129a910d90f270af9b61c15d12d86f6b7a34de3f86614dd6112854989fd7e87', '3.0.7' => '0d9918e3a51fc81c319eb70acc1a65bc5a157b04d72296e255c8afc17f72963c', 163 | '3.0.8' => '5852a9506f133f1b534d5d5faf1a8a56850bda7a623a19b3f180ae3b309a9009', '3.0.9' => '0f30304045ad1c257449c9506a3786faa7651b13d7522c1b3d0492cc80804d9a', '3.0.10' => 'bab04ef8ad997197a0e4f02250ed71240f339a44209b8d9f941ee6291130fa9a', 164 | '3.1' => '238e5cde3bf90e81ba66ef3e8d68c051be02f8c51e3a0cb2a8a57abdfc8ba570', '3.1.1' => '8eec9dc11f1119cfff042be85d308de81a74d4266fb227eeeb799741085dade4', '3.2' => '80ccb14e08313c4c87b6c7d703676a20d948116544f2a0d2eb1c93a22d1be423', 165 | '3.2.1' => '9995b953ce6263da6dd0fdc39100ba0013a3e597f2cbbff43dc1a812795f75ca', '3.3' => 'd98e685857d80f9eb93529f7b4f0f2c369ef40974866c8f8ad8edd3d6e0bf7e3', '3.4' => '6fea829d5c9e3c34448d519fb9744e645de921d12702cf2bc10b36f17d738794', 166 | '3.5' => 'b575990dfa53567bc67407318330f9406750f4543a9d385b0fce326eb430bf4f', '3.6' => 'a568f80e224c497a7fb0edaad760960c79fef772d8c66ebf3960434982e8d079', '3.7' => '335f5344c4e6b98ec51324d821fa06e99101145ac6e83b5f6ede8c0ca5d15748', 167 | '3.8' => 'cfae17f040c836dbe37e1d14737c804f60995d30e3a9d03ab6f42d373f0e2efc', '3.9' => '27cf88a6bce1ee2fb1a1c936094b9200ad844414c2b5b1491ba4991fcc0fd693', '3.10' => 'c09c3f92d4f80d5639e3f1624c9eec45d25793bbb6b3e3640937b68a9c6d107f', 168 | '3.11.1' => '6feed696759e2f3219e0ebde13f4c9080cac0744a77eb3cb43af136ab527f0ed', '3.11.2' => 'e922770ad95d5288d42442c3cfa1475938597b38418b7be5c4234a9de388c720', '3.11.3' => 'd82e0670cb41b091e88fff55250ce945c4ea026c87a5517d3cf7b6b351d5e2ba' 169 | } 170 | sha256sum = sha256sums[version] 171 | raise "sha256sum is missing for cassandra tarball version #{sha256sum}" unless sha256sum 172 | sha256sum 173 | end 174 | -------------------------------------------------------------------------------- /libraries/matchers.rb: -------------------------------------------------------------------------------- 1 | if defined?(ChefSpec) 2 | def put_ark(resource_name) 3 | ChefSpec::Matchers::ResourceMatcher.new(:ark, :put, resource_name) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /metadata.rb: -------------------------------------------------------------------------------- 1 | name 'cassandra-dse' 2 | maintainer 'Michael S. Klishin' 3 | maintainer_email 'michael@clojurewerkz.org' 4 | license 'Apache 2.0' 5 | description 'Installs/configures Apache Cassandra' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | source_url 'https://github.com/michaelklishin/cassandra-chef-cookbook' if respond_to?(:source_url) 8 | issues_url 'https://github.com/michaelklishin/cassandra-chef-cookbook/issues' if respond_to?(:issues_url) 9 | version '4.6.0' 10 | depends 'java', '< 8.0.0' 11 | depends 'ulimit' 12 | depends 'apt' 13 | depends 'yum' 14 | depends 'ark' 15 | depends 'systemd' 16 | depends 'chef_handler', '~> 3.0.2' 17 | 18 | chef_version '>= 12.9.1' 19 | 20 | %w[ubuntu centos redhat fedora amazon].each do |os| 21 | supports os 22 | end 23 | -------------------------------------------------------------------------------- /recipes/config.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: cassandra-dse 3 | # Recipe:: config 4 | # 5 | # Copyright 2015, Virender Khatri 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # TODO: update referenced attributes for config 21 | node.default['cassandra']['config']['data_file_directories'] = node['cassandra']['data_dir'] 22 | node.default['cassandra']['config']['saved_caches_directory'] = node['cassandra']['saved_caches_dir'] 23 | node.default['cassandra']['config']['commitlog_directory'] = node['cassandra']['commitlog_dir'] 24 | 25 | node.default['cassandra']['seeds'] = discover_seed_nodes 26 | 27 | node.default['cassandra']['config']['seed_provider'] = [{ 28 | 'class_name' => 'org.apache.cassandra.locator.SimpleSeedProvider', 29 | 'parameters' => [ 30 | 'seeds' => discover_seed_nodes 31 | ] 32 | }] 33 | 34 | # touch log files 35 | [ 36 | ::File.join(node['cassandra']['log_dir'], 'system.log'), 37 | ::File.join(node['cassandra']['log_dir'], 'boot.log') 38 | ].each do |f| 39 | file f do 40 | owner node['cassandra']['user'] 41 | group node['cassandra']['group'] 42 | mode '0644' 43 | end 44 | end 45 | 46 | # create if missing 47 | directory '/usr/share/java' do 48 | owner 'root' 49 | group 'root' 50 | mode '00755' 51 | end 52 | 53 | if node['cassandra'].attribute?('tmp_dir') 54 | directory node['cassandra']['tmp_dir'] do 55 | action :create 56 | recursive true 57 | owner node['cassandra']['user'] 58 | group node['cassandra']['group'] 59 | mode '0755' 60 | end 61 | end 62 | 63 | # delete properties on the basis of C* version 64 | # C* <= 2.0 65 | if node['cassandra']['version'][0..2] <= '2.0' 66 | ruby_block 'smash >= 2.1-attributes' do 67 | block do 68 | node.rm('cassandra', 'config', 'broadcast_rpc_address') 69 | node.rm('cassandra', 'config', 'tombstone_failure_threshold') 70 | node.rm('cassandra', 'config', 'tombstone_warn_threshold') 71 | node.rm('cassandra', 'config', 'sstable_preemptive_open_interval_in_mb') 72 | node.rm('cassandra', 'config', 'memtable_allocation_type') 73 | node.rm('cassandra', 'config', 'index_summary_capacity_in_mb') 74 | node.rm('cassandra', 'config', 'index_summary_resize_interval_in_minutes') 75 | node.rm('cassandra', 'config', 'concurrent_counter_writes') 76 | node.rm('cassandra', 'config', 'counter_cache_save_period') 77 | node.rm('cassandra', 'config', 'counter_cache_size_in_mb') 78 | node.rm('cassandra', 'config', 'counter_write_request_timeout_in_ms') 79 | node.rm('cassandra', 'config', 'commit_failure_policy') 80 | node.rm('cassandra', 'config', 'cas_contention_timeout_in_ms') 81 | node.rm('cassandra', 'config', 'batch_size_warn_threshold_in_kb') 82 | node.rm('cassandra', 'config', 'batchlog_replay_throttle_in_kb') 83 | node.rm('cassandra', 'config', 'permissions_validity_in_ms') 84 | end 85 | end 86 | end 87 | 88 | # C* 2.1.0 89 | if node['cassandra']['version'][0..2] >= '2.1' 90 | ruby_block 'smash < 2.0-attributes' do 91 | block do 92 | node.rm('cassandra', 'config', 'memtable_flush_queue_size') 93 | node.rm('cassandra', 'config', 'in_memory_compaction_limit_in_mb') 94 | node.rm('cassandra', 'config', 'multithreaded_compaction') 95 | node.rm('cassandra', 'config', 'compaction_preheat_key_cache') 96 | node.rm('cassandra', 'config', 'native_transport_min_threads') 97 | end 98 | end 99 | end 100 | 101 | # C* 3.x 102 | if node['cassandra']['version'][0..2] >= '3.0' 103 | node.default['cassandra']['config']['hints_directory'] = \ 104 | ::File.join(node['cassandra']['root_dir'], 'hints') 105 | end 106 | 107 | # configuration files 108 | template ::File.join(node['cassandra']['conf_dir'], 'cassandra.yaml') do 109 | cookbook node['cassandra']['templates_cookbook'] 110 | source 'cassandra.yaml.erb' 111 | owner node['cassandra']['user'] 112 | group node['cassandra']['group'] 113 | mode '0644' 114 | notifies :restart, 'service[cassandra]', :delayed if node['cassandra']['notify_restart'] 115 | end 116 | 117 | template ::File.join(node['cassandra']['conf_dir'], 'jvm.options') do 118 | cookbook node['cassandra']['templates_cookbook'] 119 | source 'jvm.options.erb' 120 | owner node['cassandra']['user'] 121 | group node['cassandra']['group'] 122 | mode '0644' 123 | notifies :restart, 'service[cassandra]', :delayed if node['cassandra']['notify_restart'] 124 | end 125 | 126 | template ::File.join(node['cassandra']['conf_dir'], 'cassandra-env.sh') do 127 | cookbook node['cassandra']['templates_cookbook'] 128 | source 'cassandra-env.sh.erb' 129 | owner node['cassandra']['user'] 130 | group node['cassandra']['group'] 131 | mode '0644' 132 | notifies :restart, 'service[cassandra]', :delayed if node['cassandra']['notify_restart'] 133 | end 134 | 135 | node['cassandra']['log_config_files'].each do |f| 136 | template ::File.join(node['cassandra']['conf_dir'], f) do 137 | cookbook node['cassandra']['templates_cookbook'] 138 | source "#{f}.erb" 139 | owner node['cassandra']['user'] 140 | group node['cassandra']['group'] 141 | mode '0644' 142 | notifies :restart, 'service[cassandra]', :delayed if node['cassandra']['notify_restart'] 143 | end 144 | end 145 | 146 | template ::File.join(node['cassandra']['conf_dir'], 'cassandra-rackdc.properties') do 147 | source 'cassandra-rackdc.properties.erb' 148 | owner node['cassandra']['user'] 149 | group node['cassandra']['group'] 150 | mode '0644' 151 | variables(rackdc: node['cassandra']['rackdc']) 152 | notifies :restart, 'service[cassandra]', :delayed if node['cassandra']['notify_restart'] 153 | only_if { node['cassandra'].attribute?('rackdc') } 154 | end 155 | 156 | # diff 157 | template ::File.join(node['cassandra']['conf_dir'], 'cassandra-topology.properties') do 158 | cookbook node['cassandra']['templates_cookbook'] 159 | source 'cassandra-topology.properties.erb' 160 | owner node['cassandra']['user'] 161 | group node['cassandra']['group'] 162 | mode '0644' 163 | variables(snitch: node['cassandra']['snitch_conf']) 164 | notifies :restart, 'service[cassandra]', :delayed if node['cassandra']['notify_restart'] 165 | only_if { node['cassandra'].attribute?('snitch_conf') } 166 | end 167 | 168 | # setup metrics reporter 169 | 170 | remote_file "/usr/share/java/#{node['cassandra']['metrics_reporter']['jar_name']}" do 171 | source node['cassandra']['metrics_reporter']['jar_url'] 172 | checksum node['cassandra']['metrics_reporter']['sha256sum'] 173 | only_if { node['cassandra']['metrics_reporter']['enabled'] } 174 | end 175 | 176 | link "#{node['cassandra']['lib_dir']}/#{node['cassandra']['metrics_reporter']['name']}.jar" do 177 | to "/usr/share/java/#{node['cassandra']['metrics_reporter']['jar_name']}" 178 | owner node['cassandra']['user'] 179 | group node['cassandra']['group'] 180 | notifies :restart, 'service[cassandra]', :delayed if node['cassandra']['notify_restart'] 181 | only_if { node['cassandra']['metrics_reporter']['enabled'] } 182 | end 183 | 184 | template ::File.join(node['cassandra']['conf_dir'], 'cassandra-metrics.yaml') do 185 | cookbook node['cassandra']['templates_cookbook'] 186 | source 'cassandra-metrics.yaml.erb' 187 | owner node['cassandra']['user'] 188 | group node['cassandra']['group'] 189 | mode '0644' 190 | notifies :restart, 'service[cassandra]', :delayed if node['cassandra']['notify_restart'] 191 | variables(yaml_config: hash_to_yaml_string(node['cassandra']['metrics_reporter']['config'])) 192 | only_if { node['cassandra']['metrics_reporter']['enabled'] } 193 | end 194 | 195 | # set up jamm 196 | remote_file "/usr/share/java/#{node['cassandra']['jamm']['jar_name']}" do 197 | source "#{node['cassandra']['jamm']['base_url']}/#{node['cassandra']['jamm']['jar_name']}" 198 | mode '0644' 199 | owner node['cassandra']['user'] 200 | group node['cassandra']['group'] 201 | checksum node['cassandra']['jamm']['sha256sum'] 202 | only_if { node['cassandra']['setup_jamm'] } 203 | end 204 | 205 | link "#{node['cassandra']['lib_dir']}/#{node['cassandra']['jamm']['jar_name']}" do 206 | owner node['cassandra']['user'] 207 | group node['cassandra']['group'] 208 | to "/usr/share/java/#{node['cassandra']['jamm']['jar_name']}" 209 | notifies :restart, 'service[cassandra]', :delayed if node['cassandra']['notify_restart'] 210 | only_if { node['cassandra']['setup_jamm'] } 211 | end 212 | 213 | # set up priam 214 | remote_file "/usr/share/java/#{node['cassandra']['priam']['jar_name']}" do 215 | source "#{node['cassandra']['priam']['base_url']}/#{node['cassandra']['priam']['jar_name']}" 216 | mode '0644' 217 | checksum node['cassandra']['priam']['sha256sum'] 218 | only_if { node['cassandra']['setup_priam'] } 219 | end 220 | 221 | link "#{node['cassandra']['lib_dir']}/#{node['cassandra']['priam']['jar_name']}" do 222 | to "/usr/share/java/#{node['cassandra']['priam']['jar_name']}" 223 | owner node['cassandra']['user'] 224 | group node['cassandra']['group'] 225 | notifies :restart, 'service[cassandra]', :delayed if node['cassandra']['notify_restart'] 226 | only_if { node['cassandra']['setup_priam'] } 227 | end 228 | 229 | # set up jna 230 | remote_file '/usr/share/java/jna.jar' do 231 | source "#{node['cassandra']['jna']['base_url']}/#{node['cassandra']['jna']['jar_name']}" 232 | mode '0644' 233 | checksum node['cassandra']['jna']['sha256sum'] 234 | only_if { node['cassandra']['setup_jna'] } 235 | end 236 | 237 | link "#{node['cassandra']['lib_dir']}/jna.jar" do 238 | to '/usr/share/java/jna.jar' 239 | owner node['cassandra']['user'] 240 | group node['cassandra']['group'] 241 | notifies :restart, 'service[cassandra]', :delayed if node['cassandra']['notify_restart'] 242 | only_if { node['cassandra']['setup_jna'] } 243 | end 244 | 245 | file "#{node['cassandra']['lib_dir']}/jna.jar" do 246 | action :delete 247 | notifies :restart, 'service[cassandra]', :delayed if node['cassandra']['notify_restart'] 248 | only_if { node['cassandra']['skip_jna'] } 249 | end 250 | 251 | # set up JMX authentication 252 | node.default['cassandra']['jmx_access_path'] = \ 253 | ::File.join(node['cassandra']['conf_dir'], 'jmxremote.access') 254 | node.default['cassandra']['jmx_password_path'] = \ 255 | ::File.join(node['cassandra']['conf_dir'], 'jmxremote.password') 256 | 257 | template node['cassandra']['jmx_access_path'] do 258 | cookbook node['cassandra']['templates_cookbook'] 259 | source 'jmxremote.access.erb' 260 | owner node['cassandra']['user'] 261 | group node['cassandra']['group'] 262 | mode '0400' 263 | notifies :restart, 'service[cassandra]', :delayed if node['cassandra']['notify_restart'] 264 | only_if { node['cassandra']['jmx_remote_authenticate'] } 265 | end 266 | 267 | template node['cassandra']['jmx_password_path'] do 268 | cookbook node['cassandra']['templates_cookbook'] 269 | source 'jmxremote.password.erb' 270 | owner node['cassandra']['user'] 271 | group node['cassandra']['group'] 272 | mode '0400' 273 | notifies :restart, 'service[cassandra]', :delayed if node['cassandra']['notify_restart'] 274 | only_if { node['cassandra']['jmx_remote_authenticate'] } 275 | end 276 | 277 | service 'cassandra' do 278 | supports restart: true, status: true 279 | service_name node['cassandra']['service_name'] 280 | action node['cassandra']['service_action'] 281 | only_if { node['cassandra']['use_initd'] || node['cassandra']['use_systemd'] } 282 | end 283 | -------------------------------------------------------------------------------- /recipes/datastax.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: cassandra-dse 3 | # Recipe:: datastax 4 | # 5 | # Copyright 2011-2015, Michael S Klishin & Travis CI Development Team 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | case node['cassandra']['version'] 21 | # Submit an issue if jamm version is not correct for 0.x or 1.x version 22 | when /^0\./, /^1\./, /^2\.0/ 23 | # < 2.1 Versions 24 | node.default['cassandra']['setup_jna'] = true 25 | node.default['cassandra']['cassandra_old_version_20'] = true 26 | else 27 | # >= 2.1 Version 28 | node.default['cassandra']['setup_jna'] = false 29 | node.default['cassandra']['skip_jna'] = false 30 | node.default['cassandra']['setup_jamm'] = true 31 | node.default['cassandra']['cassandra_old_version_20'] = false 32 | end 33 | 34 | node.default['cassandra']['installation_dir'] = '/usr/share/cassandra' 35 | # node['cassandra']['installation_dir subdirs 36 | node.default['cassandra']['bin_dir'] = '/usr/bin' # package default folder for tools 37 | node.default['cassandra']['sbin_dir'] = '/usr/sbin' # package default for daemon startup binary 38 | node.default['cassandra']['lib_dir'] = ::File.join(node['cassandra']['installation_dir'], 'lib') 39 | 40 | # commit log, data directory, saved caches and so on are all stored under the data root. MK. 41 | # node['cassandra']['root_dir sub dirs 42 | # For JBOD functionality use two attributes: node['cassandra']['jbod']['slices'] and node['cassandra']['jbod']['dir_name_prefix'] 43 | # node['cassandra']['jbod']['slices'] defines the number of jbod slices while each represents data directory 44 | # node['cassandra']['jbod']['dir_name_prefix'] defines prefix of the data directory 45 | # For example if you want to connect 4 EBS disks as a JBOD slices the names will be in the following format: data1,data2,data3,data4 46 | # cassandra.yaml.erb will generate automatically entry per data_dir location 47 | 48 | data_dir = [] 49 | if !node['cassandra']['jbod']['slices'].nil? 50 | node['cassandra']['jbod']['slices'].times do |slice_number| 51 | data_dir << ::File.join(node['cassandra']['root_dir'], "#{node['cassandra']['jbod']['dir_name_prefix']}#{slice_number}") 52 | end 53 | else 54 | data_dir << ::File.join(node['cassandra']['root_dir'], 'data') 55 | end 56 | node.default['cassandra']['data_dir'] = data_dir 57 | node.default['cassandra']['commitlog_dir'] = ::File.join(node['cassandra']['root_dir'], 'commitlog') 58 | node.default['cassandra']['saved_caches_dir'] = ::File.join(node['cassandra']['root_dir'], 'saved_caches') 59 | 60 | include_recipe 'cassandra-dse::user' 61 | include_recipe 'cassandra-dse::repositories' 62 | 63 | # setup repository and install datastax C* packages 64 | case node['platform_family'] 65 | when 'debian' 66 | node.default['cassandra']['conf_dir'] = '/etc/cassandra' 67 | 68 | unless node['cassandra']['dse'] 69 | # DataStax Server Community Edition package will not install w/o this 70 | # one installed. MK. 71 | package node['cassandra']['tools_package_name'] if node['platform_version'].to_f < 16.04 72 | 73 | # This is necessary because apt gets very confused by the fact that the 74 | # latest package available for cassandra is 2.x while you're trying to 75 | # install dsc12 which requests 1.2.x. 76 | apt_preference node['cassandra']['package_name'] do 77 | if node['cassandra']['release'].to_s != '' 78 | pin "version #{node['cassandra']['version']}-#{node['cassandra']['release']}" 79 | else 80 | pin "version #{node['cassandra']['version']}" 81 | end 82 | pin_priority '700' 83 | end 84 | 85 | apt_preference 'cassandra' do 86 | pin "version #{node['cassandra']['version']}" 87 | pin_priority '700' 88 | end 89 | 90 | package 'cassandra' do 91 | options '--force-yes -o Dpkg::Options::="--force-confold"' 92 | version node['cassandra']['version'] 93 | end 94 | end 95 | 96 | package node['cassandra']['package_name'] do 97 | options '--force-yes -o Dpkg::Options::="--force-confold"' 98 | if node['cassandra']['release'].to_s != '' 99 | version "#{node['cassandra']['version']}-#{node['cassandra']['release']}" 100 | else 101 | version node['cassandra']['version'] 102 | end 103 | # giving C* some time to start up 104 | notifies :start, 'service[cassandra]', :immediately 105 | notifies :run, 'ruby_block[sleep30s]', :immediately 106 | notifies :run, 'ruby_block[set_fd_limit]', :immediately 107 | notifies :run, 'execute[set_cluster_name]', :immediately 108 | action :install 109 | end 110 | 111 | ruby_block 'sleep30s' do 112 | block do 113 | sleep 30 114 | end 115 | action :nothing 116 | end 117 | 118 | ruby_block 'set_fd_limit' do 119 | block do 120 | file = Chef::Util::FileEdit.new("/etc/init.d/#{node['cassandra']['service_name']}") 121 | file.search_file_replace_line(/^FD_LIMIT=.*$/, "FD_LIMIT=#{node['cassandra']['limits']['nofile']}") 122 | file.write_file 123 | end 124 | retries 15 125 | retry_delay 1 126 | notifies :restart, 'service[cassandra]', :delayed 127 | action :nothing 128 | end 129 | 130 | execute 'set_cluster_name' do 131 | command "/usr/bin/cqlsh -e \"update system.local set cluster_name='#{node['cassandra']['config']['cluster_name']}' where key='local';\"; /usr/bin/nodetool flush system;" 132 | notifies :restart, 'service[cassandra]', :delayed 133 | action :nothing 134 | end 135 | 136 | when 'rhel' 137 | node.default['cassandra']['conf_dir'] = '/etc/cassandra/conf' 138 | 139 | if node['cassandra']['use_systemd'] 140 | node.default['cassandra']['startup_program'] = ::File.join(node['cassandra']['sbin_dir'], 'cassandra') 141 | include_recipe 'cassandra-dse::systemd' 142 | end 143 | 144 | yum_package node['cassandra']['package_name'] do 145 | if node['cassandra']['release'].to_s != '' 146 | version "#{node['cassandra']['version']}-#{node['cassandra']['release']}" 147 | else 148 | version node['cassandra']['version'] 149 | end 150 | allow_downgrade 151 | notifies :run, 'ruby_block[set_jvm_search_dirs_on_java_8]', :immediately 152 | options node['cassandra']['yum']['options'] 153 | end 154 | 155 | if node['cassandra']['use_systemd'] 156 | file '/etc/init.d/' + node['cassandra']['service_name'] do 157 | action :delete 158 | end 159 | end 160 | 161 | # applying fix for java search directories, on java 8 it needs to be update 162 | # including the new directories 163 | ruby_block 'set_jvm_search_dirs_on_java_8' do 164 | block do 165 | init_path = if node['cassandra']['use_systemd'] 166 | ::File.join('/etc/systemd/system/', node['cassandra']['service_name'] + '.service') 167 | else 168 | ::File.join('/etc/init.d/', node['cassandra']['service_name']) 169 | end 170 | f = Chef::Util::FileEdit.new(init_path) 171 | f.search_file_replace_line( 172 | /^JVM_SEARCH_DIRS=.*$/, 173 | 'JVM_SEARCH_DIRS="/usr/lib/jvm/jre /usr/lib/jvm/jre-1.8.* /usr/lib/jvm/java-1.8.*/jre"' 174 | ) 175 | f.write_file 176 | end 177 | only_if { node['java']['jdk_version'] == 8 } 178 | notifies :restart, 'service[cassandra]', :delayed 179 | action :nothing 180 | end 181 | 182 | # Creating symlink from user defined config directory to default 183 | directory ::File.dirname(node['cassandra']['conf_dir']) do 184 | owner node['cassandra']['user'] 185 | group node['cassandra']['group'] 186 | recursive true 187 | mode '0755' 188 | end 189 | 190 | link node['cassandra']['conf_dir'] do 191 | to node.default['cassandra']['conf_dir'] 192 | owner node['cassandra']['user'] 193 | group node['cassandra']['group'] 194 | not_if { node['cassandra']['conf_dir'] == node.default['cassandra']['conf_dir'] || ::File.exist?(node['cassandra']['conf_dir']) } 195 | end 196 | end 197 | 198 | # manage C* directories 199 | directories = [ 200 | node['cassandra']['installation_dir'], 201 | node['cassandra']['conf_dir'], 202 | node['cassandra']['log_dir'], 203 | node['cassandra']['root_dir'], 204 | node['cassandra']['lib_dir'], 205 | node['cassandra']['pid_dir'], 206 | node['cassandra']['data_dir'], 207 | node['cassandra']['commitlog_dir'], 208 | node['cassandra']['saved_caches_dir'] 209 | ] 210 | 211 | # including hints directory, in case is part of configuration 212 | if node['cassandra']['config'].key?('hints_directory') 213 | directories << node['cassandra']['config']['hints_directory'] 214 | end 215 | 216 | directories.flatten.each do |dir| 217 | directory dir do 218 | owner node['cassandra']['user'] 219 | group node['cassandra']['group'] 220 | recursive true 221 | mode '0755' 222 | end 223 | end 224 | -------------------------------------------------------------------------------- /recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: cassandra-dse 3 | # Recipe:: default 4 | # 5 | # Copyright 2011-2015, Michael S Klishin & Travis CI Development Team 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | raise "attribute node['cassandra']['config']['cluster_name'] not defined" unless node['cassandra']['config']['cluster_name'] 21 | 22 | # discover cluster nodes via chef search 23 | node.default['cassandra']['seeds'] = discover_seed_nodes 24 | 25 | # setup java 26 | include_recipe 'java' if node['cassandra']['install_java'] 27 | 28 | # install C* via datastax / tarball 29 | include_recipe "cassandra-dse::#{node['cassandra']['install_method']}" 30 | 31 | # configues C* 32 | include_recipe 'cassandra-dse::config' 33 | -------------------------------------------------------------------------------- /recipes/envvars.rb: -------------------------------------------------------------------------------- 1 | # generate profile file with environment variables necessary to run nodetool 2 | 3 | template ::File.join('/etc/profile.d', node['cassandra']['service_name'] + '.sh') do 4 | source 'cassandra.envvars.erb' 5 | owner 'root' 6 | group 'root' 7 | mode '0644' 8 | end 9 | -------------------------------------------------------------------------------- /recipes/opscenter_agent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: cassandra-dse 3 | # Recipe:: opscenter_agent 4 | # 5 | # Copyright 2011-2015, Michael S Klishin & Travis CI Development Team 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | Chef::Log.warn('cassandra-dse::opscenter_agent is deprecated, please use cassandra-dse::opscenter_agent_tarball or cassandra-dse::opscenter_agent_datastax') 21 | include_recipe 'cassandra-dse::opscenter_agent_tarball' 22 | -------------------------------------------------------------------------------- /recipes/opscenter_agent_datastax.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: cassandra-dse 3 | # Recipe:: opscenter_agent_datastax 4 | # 5 | # Copyright 2011-2015, Michael S Klishin & Travis CI Development Team 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe 'java' if node['cassandra']['install_java'] 21 | include_recipe 'cassandra-dse::repositories' 22 | 23 | server_ip = node['cassandra']['opscenter']['agent']['server_host'] 24 | 25 | unless server_ip && !node['cassandra']['opscenter']['agent']['use_chef_search'] 26 | 27 | unless Chef::Config[:solo] 28 | search_results = search(:node, "chef_environment:#{node.chef_environment} "\ 29 | "AND roles:#{node['cassandra']['opscenter']['agent']['server_role']}") 30 | if !search_results.empty? 31 | server_ip = search_results[0]['ipaddress'] 32 | else 33 | return # Continue until opscenter will come up 34 | end 35 | end 36 | 37 | end 38 | 39 | ops = node['cassandra']['opscenter'] 40 | ops_agent = ops['agent'] 41 | 42 | package ops_agent['package_name'] do 43 | version ops['version'] 44 | options node['cassandra']['yum']['options'] if node['platform_family'] == 'rhel' 45 | end 46 | 47 | service 'datastax-agent' do 48 | supports restart: true, status: true 49 | action %i[enable start] 50 | subscribes :restart, "package[#{ops_agent['package_name']}]" 51 | end 52 | 53 | template ::File.join(node['cassandra']['opscenter']['agent']['conf_dir'], 'address.yaml') do 54 | mode '0644' 55 | owner node['cassandra']['user'] 56 | group node['cassandra']['group'] 57 | source 'opscenter-agent.conf.erb' 58 | variables(server_ip: server_ip) 59 | notifies :restart, 'service[datastax-agent]' 60 | end 61 | -------------------------------------------------------------------------------- /recipes/opscenter_agent_tarball.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: cassandra-dse 3 | # Recipe:: opscenter_agent_tarball 4 | # 5 | # Copyright 2011-2015, Michael S Klishin & Travis CI Development Team 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe 'ark' 21 | 22 | ark node['cassandra']['opscenter']['agent']['install_folder_name'] do 23 | path node['cassandra']['opscenter']['agent']['install_dir'] 24 | url node['cassandra']['opscenter']['agent']['download_url'] 25 | checksum node['cassandra']['opscenter']['agent']['checksum'] if node['cassandra']['opscenter']['agent']['checksum'] 26 | action :put 27 | end 28 | 29 | server_ip = node['cassandra']['opscenter']['agent']['server_host'] 30 | unless server_ip && !node['cassandra']['opscenter']['agent']['use_chef_search'] 31 | 32 | unless Chef::Config[:solo] 33 | search_results = search(:node, "chef_environment:#{node.chef_environment} "\ 34 | "AND roles:#{node['cassandra']['opscenter']['agent']['server_role']}") 35 | if !search_results.empty? 36 | server_ip = search_results[0]['ipaddress'] 37 | else 38 | return # Continue until opscenter will come up 39 | end 40 | end 41 | 42 | end 43 | 44 | agent_dir = ::File.join(node['cassandra']['opscenter']['agent']['install_dir'], node['cassandra']['opscenter']['agent']['install_folder_name']) 45 | 46 | template "#{agent_dir}/conf/address.yaml" do 47 | mode '0644' 48 | source 'opscenter-agent.conf.erb' 49 | variables(server_ip: server_ip) 50 | notifies :restart, 'service[opscenter-agent]' 51 | end 52 | 53 | binary_name = node['cassandra']['opscenter']['agent']['binary_name'] 54 | binary_grep_str = "[#{binary_name[0]}]#{binary_name[1..-1]}" 55 | 56 | service 'opscenter-agent' do 57 | provider Chef::Provider::Service::Simple 58 | supports start: true, status: true, stop: true 59 | start_command "#{agent_dir}/bin/#{binary_name}" 60 | status_command "ps aux | grep -q '#{binary_grep_str}'" 61 | stop_command "kill $(ps aux | grep '#{binary_grep_str}' | awk '{print $2}')" 62 | action :start 63 | end 64 | -------------------------------------------------------------------------------- /recipes/opscenter_server.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: cassandra-dse 3 | # Recipe:: opscenter_server 4 | # 5 | # Copyright 2011-2012, Michael S Klishin & Travis CI Development Team 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe 'java' if node['cassandra']['install_java'] 21 | include_recipe 'cassandra-dse::repositories' 22 | 23 | ops = node['cassandra']['opscenter'] 24 | ops_server = ops['server'] 25 | 26 | package ops_server['package_name'] do 27 | version ops['version'] 28 | options node['cassandra']['yum']['options'] if node['platform_family'] == 'rhel' 29 | end 30 | 31 | service 'opscenterd' do 32 | supports restart: true, status: true 33 | action %i[enable start] 34 | subscribes :restart, "package[#{ops_server['package_name']}]" 35 | end 36 | 37 | template '/etc/opscenter/opscenterd.conf' do 38 | source 'opscenterd.conf.erb' 39 | mode '0644' 40 | notifies :restart, 'service[opscenterd]', :delayed 41 | end 42 | -------------------------------------------------------------------------------- /recipes/repositories.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: cassandra-dse 3 | # Recipe:: repositories 4 | # 5 | # Copyright 2011-2012, Michael S Klishin & Travis CI Development Team 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | if node['cassandra']['dse'] 21 | dse = node['cassandra']['dse'] 22 | dse_credentials = if dse['credentials']['databag'] 23 | Chef::EncryptedDataBagItem.load(dse['credentials']['databag']['name'], dse['credentials']['databag']['item'])[dse['credentials']['databag']['entry']] 24 | else 25 | dse['credentials'] 26 | end 27 | end 28 | 29 | case node['platform_family'] 30 | when 'debian' 31 | package 'apt-transport-https' 32 | 33 | apt_repository node['cassandra']['apt']['repo'] do 34 | if node['cassandra']['dse'] 35 | uri "https://#{dse_credentials['username']}:#{dse_credentials['password']}@#{node['cassandra']['apt']['dse_uri']}" 36 | else 37 | uri node['cassandra']['apt']['uri'] 38 | end 39 | distribution node['cassandra']['apt']['distribution'] 40 | components node['cassandra']['apt']['components'] 41 | key node['cassandra']['apt']['repo_key'] 42 | action node['cassandra']['apt']['action'] 43 | end 44 | when 'rhel' 45 | include_recipe 'yum' 46 | 47 | yum_repository node['cassandra']['yum']['repo'] do 48 | if node['cassandra']['dse'] 49 | baseurl "https://#{dse_credentials['username']}:#{dse_credentials['password']}@#{node['cassandra']['yum']['dse_uri']}" 50 | else 51 | baseurl node['cassandra']['yum']['baseurl'] 52 | end 53 | description node['cassandra']['yum']['description'] 54 | mirrorlist node['cassandra']['yum']['mirrorlist'] unless node['cassandra']['yum']['mirrorlist'].nil? 55 | gpgcheck node['cassandra']['yum']['gpgcheck'] 56 | enabled node['cassandra']['yum']['enabled'] 57 | action node['cassandra']['yum']['action'] 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /recipes/systemd.rb: -------------------------------------------------------------------------------- 1 | # generate systemd service 2 | # 3 | 4 | execute 'daemon-reload' do 5 | command 'systemctl daemon-reload' 6 | action :nothing 7 | end 8 | 9 | template ::File.join(node['systemd']['units_dir'], node['cassandra']['service_name'] + '.service') do 10 | source 'cassandra.service.erb' 11 | owner node['cassandra']['user'] 12 | group node['cassandra']['group'] 13 | mode '0644' 14 | notifies :run, 'execute[daemon-reload]', :immediately 15 | notifies :enable, 'service[cassandra]', :delayed 16 | notifies :restart, 'service[cassandra]', :delayed if node['cassandra']['notify_restart'] 17 | end 18 | -------------------------------------------------------------------------------- /recipes/tarball.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: cassandra-dse 3 | # Recipe:: tarball 4 | # Copyright 2012-2015, Michael S. Klishin and Travis CI Development Team 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | # THE SOFTWARE. 23 | 24 | node.default['cassandra']['source_dir'] = '/usr/local/apache-cassandra-' + node['cassandra']['version'] 25 | 26 | node.default['cassandra']['installation_dir'] = '/usr/local/cassandra' 27 | 28 | # node['cassandra']['installation_dir'] subdirs 29 | node.default['cassandra']['bin_dir'] = ::File.join(node['cassandra']['installation_dir'], 'bin') 30 | node.default['cassandra']['lib_dir'] = ::File.join(node['cassandra']['installation_dir'], 'lib') 31 | node.default['cassandra']['conf_dir'] = ::File.join(node['cassandra']['installation_dir'], 'conf') 32 | 33 | # commit log, data directory, saved caches and so on are all stored under the data root. MK. 34 | # node['cassandra']['root_dir'] sub dirs 35 | node.default['cassandra']['data_dir'] = [::File.join(node['cassandra']['root_dir'], 'data')] 36 | node.default['cassandra']['commitlog_dir'] = ::File.join(node['cassandra']['root_dir'], 'commitlog') 37 | node.default['cassandra']['saved_caches_dir'] = ::File.join(node['cassandra']['root_dir'], 'saved_caches') 38 | 39 | # manage C* service user 40 | include_recipe 'cassandra-dse::user' 41 | 42 | require 'tmpdir' 43 | 44 | td = Dir.tmpdir 45 | tmp = ::File.join(td, "apache-cassandra-#{node['cassandra']['version']}-bin.tar.gz") 46 | tarball_dir = ::File.join(td, "apache-cassandra-#{node['cassandra']['version']}") 47 | 48 | # if tarball url set to 'auto' use default url 49 | # according to node cassandra version 50 | if node['cassandra']['tarball']['url'] == 'auto' 51 | node.default['cassandra']['tarball']['url'] = "http://archive.apache.org/dist/cassandra/#{node['cassandra']['version']}/apache-cassandra-#{node['cassandra']['version']}-bin.tar.gz" 52 | end 53 | 54 | # stop C* service during upgrades 55 | service 'cassandra' do 56 | service_name node['cassandra']['service_name'] 57 | action :stop 58 | only_if { ::File.exist?("/etc/init.d/#{node['cassandra']['service_name']}") && !::File.exist?(node['cassandra']['source_dir']) } 59 | end 60 | 61 | tarball_checksum = node['cassandra']['tarball']['sha256sum'] || tarball_sha256sum(node['cassandra']['version']) 62 | 63 | # download C* tarball to /tmp 64 | remote_file tmp do 65 | source node['cassandra']['tarball']['url'] 66 | checksum tarball_checksum 67 | not_if { ::File.exist?(node['cassandra']['source_dir']) } 68 | end 69 | 70 | # Ensure that node['cassandra']['source_dir'] node['cassandra']['installation_dir'] minus leaf directories both exist 71 | # Since such directories can be predefined system directories (e.g., /usr/local), ownership should not be changed 72 | [ 73 | node['cassandra']['source_dir'].split('/')[0..-2].join('/'), 74 | node['cassandra']['installation_dir'].split('/')[0..-2].join('/') 75 | ].each do |dir| 76 | directory dir do 77 | mode '0755' 78 | action :create 79 | end 80 | end 81 | 82 | # extract archive to node['cassandra']['source_dir'] and update one time ownership permissions 83 | bash 'extract_cassandra_source' do 84 | user 'root' 85 | cwd td 86 | 87 | code <<-SCRIPT 88 | tar xzf #{tmp} 89 | mv --force #{tarball_dir} #{node['cassandra']['source_dir']} 90 | chown -R #{node['cassandra']['user']}:#{node['cassandra']['group']} #{node['cassandra']['source_dir']} 91 | chmod #{node['cassandra']['dir_mode']} #{node['cassandra']['source_dir']} 92 | SCRIPT 93 | 94 | not_if { ::File.exist?(node['cassandra']['source_dir']) } 95 | creates ::File.join(node['cassandra']['source_dir'], 'bin', 'cassandra') 96 | action :run 97 | end 98 | 99 | # link node['cassandra']['source_dir'] to node['cassandra']['installation_dir'] 100 | link node['cassandra']['installation_dir'] do 101 | to node['cassandra']['source_dir'] 102 | owner node['cassandra']['user'] 103 | group node['cassandra']['group'] 104 | end 105 | 106 | # manage C* directories 107 | directories = [ 108 | node['cassandra']['log_dir'], 109 | node['cassandra']['pid_dir'], 110 | node['cassandra']['lib_dir'], 111 | node['cassandra']['root_dir'], 112 | node['cassandra']['conf_dir'], 113 | node['cassandra']['commitlog_dir'], 114 | node['cassandra']['saved_caches_dir'] 115 | ] 116 | 117 | directories << node['cassandra']['heap_dump_dir'] if node['cassandra']['heap_dump_dir'] 118 | directories << node['cassandra']['config']['hints_directory'] if node['cassandra']['config']['hints_directory'] 119 | directories += node['cassandra']['data_dir'] # this is an array now 120 | directories.each do |dir| 121 | directory dir do 122 | owner node['cassandra']['user'] 123 | group node['cassandra']['group'] 124 | recursive true 125 | mode '0755' 126 | end 127 | end 128 | 129 | # setup C* binaries 130 | template ::File.join(node['cassandra']['bin_dir'], 'cassandra-cli') do 131 | source 'cassandra-cli.erb' 132 | owner node['cassandra']['user'] 133 | group node['cassandra']['group'] 134 | mode '0755' 135 | end 136 | 137 | template ::File.join(node['cassandra']['installation_dir'], 'bin', 'cqlsh') do 138 | source 'cqlsh.erb' 139 | owner node['cassandra']['user'] 140 | group node['cassandra']['group'] 141 | mode '0755' 142 | not_if { ::File.exist?(::File.join(node['cassandra']['installation_dir'], 'bin', 'cqlsh')) } 143 | end 144 | 145 | %w[cqlsh cassandra cassandra-shell cassandra-cli nodetool].each do |f| 146 | link "/usr/local/bin/#{f}" do 147 | owner node['cassandra']['user'] 148 | group node['cassandra']['group'] 149 | to ::File.join(node['cassandra']['installation_dir'], 'bin', f) 150 | only_if { ::File.exist?(::File.join(node['cassandra']['installation_dir'], 'bin', f)) } 151 | end 152 | end 153 | 154 | # generate profile file with environment variables necessary to run nodetool 155 | include_recipe 'cassandra-dse::envvars' 156 | 157 | # setup ulimits 158 | # 159 | # Perhaps we can move it to recipe `config` 160 | # ~FC023 (simple guard doesn't seem to have any effect) 161 | if node['cassandra']['setup_user_limits'] 162 | user_ulimit node['cassandra']['user'] do 163 | filehandle_limit node['cassandra']['limits']['nofile'] 164 | process_limit node['cassandra']['limits']['nproc'] 165 | memory_limit node['cassandra']['limits']['memlock'] 166 | notifies :restart, 'service[cassandra]', :delayed if node['cassandra']['notify_restart'] 167 | end 168 | end 169 | 170 | pam_limits = 'session required pam_limits.so' 171 | ruby_block 'require_pam_limits.so' do 172 | block do 173 | fe = Chef::Util::FileEdit.new('/etc/pam.d/su') 174 | fe.search_file_replace_line(/# #{pam_limits}/, pam_limits) 175 | fe.write_file 176 | end 177 | only_if { ::File.readlines('/etc/pam.d/su').grep(/# #{pam_limits}/).any? } 178 | end 179 | 180 | if node['cassandra']['use_initd'] 181 | # sysv service file 182 | template "/etc/init.d/#{node['cassandra']['service_name']}" do 183 | source "#{node['platform_family']}.cassandra.init.erb" 184 | owner 'root' 185 | group 'root' 186 | mode '0755' 187 | notifies :restart, 'service[cassandra]', :delayed if node['cassandra']['notify_restart'] 188 | end 189 | elsif node['cassandra']['use_systemd'] 190 | node.default['cassandra']['startup_program'] = ::File.join(node['cassandra']['bin_dir'], 'cassandra') 191 | include_recipe 'cassandra-dse::systemd' 192 | end 193 | 194 | # 15. Cleanup 195 | remote_file tmp do 196 | action :delete 197 | end 198 | 199 | # purge older versions 200 | ruby_block 'purge-old-tarball' do 201 | block do 202 | require 'fileutils' 203 | installed_versions = Dir.entries('/usr/local').select { |a| a =~ /^apache-cassandra/ }.sort 204 | old_versions = installed_versions - ["apache-cassandra-#{node['cassandra']['version']}"] 205 | 206 | old_versions.each do |v| 207 | v = "/usr/local/#{v}" 208 | FileUtils.rm_rf Dir.glob(v) 209 | Chef::Log.warn("deleted older C* tarball archive #{v}") 210 | end 211 | end 212 | only_if { node['cassandra']['tarball_purge'] } 213 | end 214 | -------------------------------------------------------------------------------- /recipes/user.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: cassandra-dse 3 | # Recipe:: user 4 | # 5 | # Copyright 2014-2015, Virender Khatri 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | group node['cassandra']['group'] do 21 | system node['cassandra']['system_user'] # ~FC048 22 | append true 23 | only_if { node['cassandra']['setup_user'] } 24 | action :create 25 | end 26 | 27 | user node['cassandra']['user'] do 28 | comment 'Cassandra Server user' 29 | gid node['cassandra']['group'] 30 | home node['cassandra']['user_home'] if node['cassandra']['user_home'] 31 | system node['cassandra']['system_user'] # ~FC048 32 | shell '/bin/bash' 33 | only_if { node['cassandra']['setup_user'] } 34 | action :create 35 | end 36 | 37 | group "explicity add #{node['cassandra']['user']} to #{node['cassandra']['group']} group" do 38 | group_name node['cassandra']['group'] 39 | system node['cassandra']['system_user'] # ~FC048 40 | members [node['cassandra']['user']] 41 | append true 42 | only_if { node['cassandra']['setup_user'] } 43 | action :modify 44 | end 45 | -------------------------------------------------------------------------------- /spec/opscenter_agent_datastax_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'cassandra-dse::opscenter_agent_datastax' do 4 | let(:chef_run) do 5 | ChefSpec::SoloRunner.new(platform: 'centos', version: '6.4') do |node| 6 | node.override['cassandra']['cluster_name'] = 'test' 7 | node.override['cassandra']['version'] = '2.1.7' 8 | node.override['cassandra']['yum']['options'] = '--always-have-options' 9 | end.converge(described_recipe) 10 | end 11 | 12 | it 'includes dependent recipes' do 13 | expect(chef_run).to include_recipe 'java' 14 | expect(chef_run).to include_recipe 'cassandra-dse::repositories' 15 | end 16 | 17 | it 'installs the agent package' do 18 | expect(chef_run).to install_package('datastax-agent').with(options: '--always-have-options') 19 | end 20 | 21 | it 'starts & enables the service' do 22 | expect(chef_run).to enable_service('datastax-agent') 23 | expect(chef_run).to start_service('datastax-agent') 24 | end 25 | 26 | it 'renders the agent config file' do 27 | expect(chef_run).to create_template('/var/lib/datastax-agent/conf/address.yaml') 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /spec/opscenter_agent_tarball_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'cassandra-dse::opscenter_agent_tarball' do 4 | cached(:chef_run) do 5 | ChefSpec::SoloRunner.new(platform: 'centos', version: '6.4') do |node| 6 | node.override['cassandra']['opscenter']['agent']['download_url'] = 'test' 7 | end.converge(described_recipe) 8 | end 9 | 10 | it 'includes the ark recipe' do 11 | expect(chef_run).to include_recipe('ark') 12 | end 13 | 14 | it 'adds the opscenter_agent tarball' do 15 | expect(chef_run).to put_ark('opscenter_agent') 16 | end 17 | 18 | it 'adds the address.yaml conf file' do 19 | expect(chef_run).to create_template('/opt/opscenter_agent/conf/address.yaml') 20 | end 21 | 22 | it 'stats the opscenter agent service' do 23 | expect(chef_run).to start_service('opscenter-agent') 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /spec/rendered_templates/cassandra-env.sh: -------------------------------------------------------------------------------- 1 | # 2 | # This file is managed by Chef. 3 | # Do NOT modify this file directly. 4 | # 5 | # Licensed to the Apache Software Foundation (ASF) under one 6 | # or more contributor license agreements. See the NOTICE file 7 | # distributed with this work for additional information 8 | # regarding copyright ownership. The ASF licenses this file 9 | # to you under the Apache License, Version 2.0 (the 10 | # "License"); you may not use this file except in compliance 11 | # with the License. You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | 21 | calculate_heap_sizes() 22 | { 23 | case "`uname`" in 24 | Linux) 25 | system_memory_in_mb=`free -m | awk '/Mem:/ {print $2}'` 26 | system_cpu_cores=`egrep -c 'processor([[:space:]]+):.*' /proc/cpuinfo` 27 | ;; 28 | FreeBSD) 29 | system_memory_in_bytes=`sysctl hw.physmem | awk '{print $2}'` 30 | system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024` 31 | system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'` 32 | ;; 33 | SunOS) 34 | system_memory_in_mb=`prtconf | awk '/Memory size:/ {print $3}'` 35 | system_cpu_cores=`psrinfo | wc -l` 36 | ;; 37 | Darwin) 38 | system_memory_in_bytes=`sysctl hw.memsize | awk '{print $2}'` 39 | system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024` 40 | system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'` 41 | ;; 42 | *) 43 | # assume reasonable defaults for e.g. a modern desktop or 44 | # cheap server 45 | system_memory_in_mb="2048" 46 | system_cpu_cores="2" 47 | ;; 48 | esac 49 | 50 | # some systems like the raspberry pi don't report cores, use at least 1 51 | if [ "$system_cpu_cores" -lt "1" ] 52 | then 53 | system_cpu_cores="1" 54 | fi 55 | 56 | # set max heap size based on the following 57 | # max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB)) 58 | # calculate 1/2 ram and cap to 1024MB 59 | # calculate 1/4 ram and cap to 8192MB 60 | # pick the max 61 | half_system_memory_in_mb=`expr $system_memory_in_mb / 2` 62 | quarter_system_memory_in_mb=`expr $half_system_memory_in_mb / 2` 63 | if [ "$half_system_memory_in_mb" -gt "1024" ] 64 | then 65 | half_system_memory_in_mb="1024" 66 | fi 67 | if [ "$quarter_system_memory_in_mb" -gt "8192" ] 68 | then 69 | quarter_system_memory_in_mb="8192" 70 | fi 71 | if [ "$half_system_memory_in_mb" -gt "$quarter_system_memory_in_mb" ] 72 | then 73 | max_heap_size_in_mb="$half_system_memory_in_mb" 74 | else 75 | max_heap_size_in_mb="$quarter_system_memory_in_mb" 76 | fi 77 | MAX_HEAP_SIZE="${max_heap_size_in_mb}M" 78 | 79 | # Young gen: min(max_sensible_per_modern_cpu_core * num_cores, 1/4 * heap size) 80 | max_sensible_yg_per_core_in_mb="100" 81 | max_sensible_yg_in_mb=`expr $max_sensible_yg_per_core_in_mb "*" $system_cpu_cores` 82 | 83 | desired_yg_in_mb=`expr $max_heap_size_in_mb / 4` 84 | 85 | if [ "$desired_yg_in_mb" -gt "$max_sensible_yg_in_mb" ] 86 | then 87 | HEAP_NEWSIZE="${max_sensible_yg_in_mb}M" 88 | else 89 | HEAP_NEWSIZE="${desired_yg_in_mb}M" 90 | fi 91 | } 92 | 93 | # Determine the sort of JVM we'll be running on. 94 | 95 | java_ver_output=`"${JAVA:-java}" -version 2>&1` 96 | 97 | jvmver=`echo "$java_ver_output" | awk -F'"' 'NR==1 {print $2}'` 98 | JVM_VERSION=${jvmver%_*} 99 | JVM_PATCH_VERSION=${jvmver#*_} 100 | 101 | #if [ "$JVM_VERSION" < "1.6" ] ; then 102 | # echo "Cassandra 2.0 and later require Java 7 or later." 103 | # exit 1; 104 | #fi 105 | 106 | jvm=`echo "$java_ver_output" | awk 'NR==2 {print $1}'` 107 | case "$jvm" in 108 | OpenJDK) 109 | JVM_VENDOR=OpenJDK 110 | # this will be "64-Bit" or "32-Bit" 111 | JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $2}'` 112 | ;; 113 | "Java(TM)") 114 | JVM_VENDOR=Oracle 115 | # this will be "64-Bit" or "32-Bit" 116 | JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $3}'` 117 | ;; 118 | *) 119 | # Help fill in other JVM values 120 | JVM_VENDOR=other 121 | JVM_ARCH=unknown 122 | ;; 123 | esac 124 | 125 | #GC log path has to be defined here because it needs to access CASSANDRA_HOME 126 | JVM_OPTS="$JVM_OPTS -Xloggc:${CASSANDRA_HOME}/logs/gc.log" 127 | 128 | # Here we create the arguments that will get passed to the jvm when 129 | # starting cassandra. 130 | 131 | # Read user-defined JVM options from jvm.options file 132 | JVM_OPTS_FILE=$CASSANDRA_CONF/jvm.options 133 | for opt in `grep "^-" $JVM_OPTS_FILE` 134 | do 135 | JVM_OPTS="$JVM_OPTS $opt" 136 | done 137 | 138 | # Check what parameters were defined on jvm.options file to avoid conflicts 139 | echo $JVM_OPTS | grep -q Xmn 140 | DEFINED_XMN=$? 141 | echo $JVM_OPTS | grep -q Xmx 142 | DEFINED_XMX=$? 143 | echo $JVM_OPTS | grep -q Xms 144 | DEFINED_XMS=$? 145 | echo $JVM_OPTS | grep -q UseConcMarkSweepGC 146 | USING_CMS=$? 147 | echo $JVM_OPTS | grep -q UseG1GC 148 | USING_G1=$? 149 | 150 | # Override these to set the amount of memory to allocate to the JVM at 151 | # start-up. For production use you may wish to adjust this for your 152 | # environment. MAX_HEAP_SIZE is the total amount of memory dedicated 153 | # to the Java heap. HEAP_NEWSIZE refers to the size of the young 154 | # generation. Both MAX_HEAP_SIZE and HEAP_NEWSIZE should be either set 155 | # or not (if you set one, set the other). 156 | # 157 | # The main trade-off for the young generation is that the larger it 158 | # is, the longer GC pause times will be. The shorter it is, the more 159 | # expensive GC will be (usually). 160 | # 161 | # The example HEAP_NEWSIZE assumes a modern 8-core+ machine for decent pause 162 | # times. If in doubt, and if you do not particularly want to tweak, go with 163 | # 100 MB per physical CPU core. 164 | 165 | #MAX_HEAP_SIZE="4G" 166 | #HEAP_NEWSIZE="800M" 167 | 168 | # Set this to control the amount of arenas per-thread in glibc 169 | #MALLOC_ARENA_MAX=4 170 | 171 | # only calculate the size if it's not set manually 172 | if [ "x$MAX_HEAP_SIZE" = "x" ] && [ "x$HEAP_NEWSIZE" = "x" -o $USING_G1 -eq 0 ]; then 173 | calculate_heap_sizes 174 | elif [ "x$MAX_HEAP_SIZE" = "x" ] || [ "x$HEAP_NEWSIZE" = "x" -a $USING_G1 -ne 0 ]; then 175 | echo "please set or unset MAX_HEAP_SIZE and HEAP_NEWSIZE in pairs when using CMS GC (see cassandra-env.sh)" 176 | exit 1 177 | fi 178 | 179 | if [ "x$MALLOC_ARENA_MAX" = "x" ] 180 | then 181 | MALLOC_ARENA_MAX=4 182 | fi 183 | 184 | # We only set -Xms and -Xmx if they were not defined on jvm.options file 185 | # If defined, both Xmx and Xms should be defined together. 186 | if [ $DEFINED_XMX -ne 0 ] && [ $DEFINED_XMS -ne 0 ]; then 187 | JVM_OPTS="$JVM_OPTS -Xms${MAX_HEAP_SIZE}" 188 | JVM_OPTS="$JVM_OPTS -Xmx${MAX_HEAP_SIZE}" 189 | elif [ $DEFINED_XMX -ne 0 ] || [ $DEFINED_XMS -ne 0 ]; then 190 | echo "Please set or unset -Xmx and -Xms flags in pairs on jvm.options file." 191 | exit 1 192 | fi 193 | 194 | # We only set -Xmn flag if it was not defined in jvm.options file 195 | # and if the CMS GC is being used 196 | # If defined, both Xmn and Xmx should be defined together. 197 | if [ $DEFINED_XMN -eq 0 ] && [ $DEFINED_XMX -ne 0 ]; then 198 | echo "Please set or unset -Xmx and -Xmn flags in pairs on jvm.options file." 199 | exit 1 200 | elif [ $DEFINED_XMN -ne 0 ] && [ $USING_CMS -eq 0 ]; then 201 | JVM_OPTS="$JVM_OPTS -Xmn${HEAP_NEWSIZE}" 202 | fi 203 | 204 | if [ "$JVM_ARCH" = "64-Bit" ] && [ $USING_CMS -eq 0 ]; then 205 | JVM_OPTS="$JVM_OPTS -XX:+UseCondCardMark" 206 | fi 207 | 208 | # provides hints to the JIT compiler 209 | JVM_OPTS="$JVM_OPTS -XX:CompileCommandFile=$CASSANDRA_CONF/hotspot_compiler" 210 | 211 | # add the jamm javaagent 212 | if [ "$JVM_VENDOR" != "OpenJDK" -o "$JVM_VERSION" \> "1.6.0" ] \ 213 | || [ "$JVM_VERSION" = "1.6.0" -a "$JVM_PATCH_VERSION" -ge 23 ] 214 | then 215 | JVM_OPTS="$JVM_OPTS -javaagent:$CASSANDRA_HOME/lib/jamm-0.3.1.jar" 216 | fi 217 | 218 | # set jvm HeapDumpPath with CASSANDRA_HEAPDUMP_DIR 219 | if [ "x$CASSANDRA_HEAPDUMP_DIR" != "x" ]; then 220 | JVM_OPTS="$JVM_OPTS -XX:HeapDumpPath=$CASSANDRA_HEAPDUMP_DIR/cassandra-`date +%s`-pid$$.hprof" 221 | fi 222 | 223 | # stop the jvm on OutOfMemoryError as it can result in some data corruption 224 | # uncomment the preferred option 225 | # ExitOnOutOfMemoryError and CrashOnOutOfMemoryError require a JRE greater or equals to 1.7 update 101 or 1.8 update 92 226 | # For OnOutOfMemoryError we cannot use the JVM_OPTS variables because bash commands split words 227 | # on white spaces without taking quotes into account 228 | # JVM_OPTS="$JVM_OPTS -XX:+ExitOnOutOfMemoryError" 229 | # JVM_OPTS="$JVM_OPTS -XX:+CrashOnOutOfMemoryError" 230 | JVM_ON_OUT_OF_MEMORY_ERROR_OPT="-XX:OnOutOfMemoryError=kill -9 %p" 231 | 232 | # 233 | # see 234 | # https://blogs.oracle.com/jmxetc/entry/troubleshooting_connection_problems_in_jconsole 235 | # for more on configuring JMX through firewalls, etc. (Short version: 236 | # get it working with no firewall first.) 237 | # 238 | # Cassandra ships with JMX accessible *only* from localhost. 239 | # To enable remote JMX connections, uncomment lines below 240 | # with authentication and/or ssl enabled. See https://wiki.apache.org/cassandra/JmxSecurity 241 | # 242 | if [ "x$LOCAL_JMX" = "x" ]; then 243 | LOCAL_JMX=yes 244 | fi 245 | 246 | # Specifies the default port over which Cassandra will be available for 247 | # JMX connections. 248 | # For security reasons, you should not expose this port to the internet. Firewall it if needed. 249 | 250 | # Specifies the default port over which Cassandra will be available for 251 | # JMX connections. 252 | # For security reasons, you should not expose this port to the internet. Firewall it if needed. 253 | JMX_PORT="7199" 254 | 255 | if [ "$LOCAL_JMX" = "yes" ]; then 256 | JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.local.port=$JMX_PORT" 257 | JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false" 258 | else 259 | # if ssl is enabled the same port cannot be used for both jmx and rmi so either 260 | # pick another value for this property or comment out to use a random port (though see CASSANDRA-7087 for origins) 261 | JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT" 262 | JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT" 263 | JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false" 264 | JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false" 265 | JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.password.file=$CASSANDRA_CONF/jmxremote.password" 266 | JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.access.file=$CASSANDRA_CONF/jmxremote.access" 267 | 268 | # jmx ssl options 269 | #JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=true" 270 | #JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl.need.client.auth=true" 271 | #JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl.enabled.protocols=" 272 | #JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl.enabled.cipher.suites=" 273 | #JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.keyStore=/path/to/keystore" 274 | #JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.keyStorePassword=" 275 | #JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.trustStore=/path/to/truststore" 276 | #JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.trustStorePassword=" 277 | fi 278 | 279 | # To use mx4j, an HTML interface for JMX, add mx4j-tools.jar to the lib/ 280 | # directory. 281 | # See http://wiki.apache.org/cassandra/Operations#Monitoring_with_MX4J 282 | # By default mx4j listens on 0.0.0.0:8081. Uncomment the following lines 283 | # to control its listen address and port. 284 | #MX4J_ADDRESS="-Dmx4jaddress=127.0.0.1" 285 | #MX4J_PORT="-Dmx4jport=8081" 286 | 287 | # Cassandra uses SIGAR to capture OS metrics CASSANDRA-7838 288 | # for SIGAR we have to set the java.library.path 289 | # to the location of the native libraries. 290 | JVM_OPTS="$JVM_OPTS -Djava.library.path=$CASSANDRA_HOME/lib/sigar-bin" 291 | 292 | 293 | # add the priam cass extensions javaagent 294 | JVM_OPTS="$JVM_OPTS -javaagent:$CASSANDRA_HOME/lib/priam-cass-extensions-2.2.0.jar" 295 | 296 | # jmx: metrics and administration interface 297 | # 298 | # add this if you're having trouble connecting: 299 | # JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=" 300 | 301 | # support for metrics reporter: 302 | JVM_OPTS="$JVM_OPTS -Dcassandra.metricsReporterConfigFile=cassandra-metrics.yaml" 303 | 304 | 305 | # see https://issues.apache.org/jira/browse/CASSANDRA-6541 306 | JVM_OPTS="$JVM_OPTS -XX:+CMSClassUnloadingEnabled" 307 | 308 | 309 | 310 | 311 | 312 | JVM_OPTS="$JVM_OPTS $MX4J_ADDRESS" 313 | JVM_OPTS="$JVM_OPTS $MX4J_PORT" 314 | JVM_OPTS="$JVM_OPTS $JVM_EXTRA_OPTS" 315 | -------------------------------------------------------------------------------- /spec/rendered_templates/cassandra-metrics.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | test1: value1 3 | test2: 4 | - value2 5 | - value3 6 | -------------------------------------------------------------------------------- /spec/rendered_templates/cassandra-rackdc.properties: -------------------------------------------------------------------------------- 1 | # 2 | # This file is managed by Chef. 3 | # Do NOT modify this file directly. 4 | # 5 | # Licensed to the Apache Software Foundation (ASF) under one 6 | # or more contributor license agreements. See the NOTICE file 7 | # distributed with this work for additional information 8 | # regarding copyright ownership. The ASF licenses this file 9 | # to you under the Apache License, Version 2.0 (the 10 | # "License"); you may not use this file except in compliance 11 | # with the License. You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | 21 | # These properties are used with GossipingPropertyFileSnitch and will 22 | # indicate the rack and dc for this node 23 | dc=testdc 24 | rack=testrack 25 | 26 | # Add a suffix to a datacenter name. Used by the Ec2Snitch and Ec2MultiRegionSnitch 27 | # to append a string to the EC2 region name. 28 | #dc_suffix= 29 | 30 | # Uncomment the following line to make this snitch prefer the internal ip when possible, as the Ec2MultiRegionSnitch does. 31 | prefer_local=false 32 | -------------------------------------------------------------------------------- /spec/rendered_templates/cassandra-topology.properties: -------------------------------------------------------------------------------- 1 | # 2 | # This file is managed by Chef. 3 | # Do NOT modify this file directly. 4 | # 5 | # Cassandra Node IP=Data Center:Rack 6 | 7 | default=testdc:testrack 8 | -------------------------------------------------------------------------------- /spec/rendered_templates/cassandra.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # This file is managed by Chef. 3 | # Do NOT modify this file directly. 4 | # 5 | # This commented out line will trigger a node restart when Cassandra version changes. 6 | # It's non-functional otherwise. 7 | # version: 2.2.0 8 | --- 9 | authenticator: org.apache.cassandra.auth.AllowAllAuthenticator 10 | authorizer: org.apache.cassandra.auth.AllowAllAuthorizer 11 | auto_bootstrap: true 12 | auto_snapshot: true 13 | batch_size_warn_threshold_in_kb: 5 14 | batchlog_replay_throttle_in_kb: 1024 15 | broadcast_address: 10.0.0.2 16 | broadcast_rpc_address: 10.0.0.2 17 | cas_contention_timeout_in_ms: 1000 18 | client_encryption_options: 19 | enabled: false 20 | keystore: conf/.keystore 21 | keystore_password: cassandra 22 | require_client_auth: false 23 | cluster_name: chefspec 24 | column_index_size_in_kb: 64 25 | commit_failure_policy: stop 26 | commitlog_directory: "/var/lib/cassandra/commitlog" 27 | commitlog_segment_size_in_mb: 32 28 | commitlog_sync: periodic 29 | commitlog_sync_period_in_ms: 10000 30 | commitlog_total_space_in_mb: 4096 31 | compaction_throughput_mb_per_sec: 16 32 | concurrent_counter_writes: 32 33 | concurrent_reads: 32 34 | concurrent_writes: 32 35 | counter_cache_save_period: 7200 36 | counter_write_request_timeout_in_ms: 5000 37 | cross_node_timeout: false 38 | data_file_directories: 39 | - "/var/lib/cassandra/data" 40 | disk_failure_policy: stop 41 | dynamic_snitch_badness_threshold: 0.1 42 | dynamic_snitch_reset_interval_in_ms: 600000 43 | dynamic_snitch_update_interval_in_ms: 100 44 | endpoint_snitch: SimpleSnitch 45 | hinted_handoff_enabled: true 46 | hinted_handoff_throttle_in_kb: 1024 47 | incremental_backups: false 48 | index_interval: 128 49 | index_summary_resize_interval_in_minutes: 60 50 | inter_dc_tcp_nodelay: false 51 | internode_compression: dc 52 | key_cache_save_period: 14400 53 | listen_address: 10.0.0.2 54 | max_hint_window_in_ms: 10800000 55 | max_hints_delivery_threads: 2 56 | memtable_allocation_type: heap_buffers 57 | native_transport_port: '9042' 58 | num_tokens: 256 59 | partitioner: org.apache.cassandra.dht.Murmur3Partitioner 60 | permissions_validity_in_ms: 2000 61 | phi_convict_threshold: 8 62 | range_request_timeout_in_ms: 10000 63 | read_request_timeout_in_ms: 10000 64 | request_scheduler: org.apache.cassandra.scheduler.NoScheduler 65 | request_timeout_in_ms: 10000 66 | row_cache_save_period: 0 67 | row_cache_size_in_mb: 0 68 | rpc_address: 0.0.0.0 69 | rpc_keepalive: 'true' 70 | rpc_max_threads: 2048 71 | rpc_min_threads: 16 72 | rpc_port: '9160' 73 | rpc_server_type: sync 74 | saved_caches_directory: "/var/lib/cassandra/saved_caches" 75 | seed_provider: 76 | - class_name: org.apache.cassandra.locator.SimpleSeedProvider 77 | parameters: 78 | - seeds: 10.0.0.2 79 | server_encryption_options: 80 | internode_encryption: none 81 | keystore: conf/.keystore 82 | keystore_password: cassandra 83 | truststore: conf/.truststore 84 | truststore_password: cassandra 85 | snapshot_before_compaction: false 86 | ssl_storage_port: 7001 87 | sstable_preemptive_open_interval_in_mb: 50 88 | start_native_transport: true 89 | start_rpc: 'true' 90 | storage_port: 7000 91 | stream_throughput_outbound_megabits_per_sec: 400 92 | streaming_socket_timeout_in_ms: 86400000 93 | thrift_framed_transport_size_in_mb: 15 94 | thrift_max_message_length_in_mb: 16 95 | tombstone_failure_threshold: 100000 96 | tombstone_warn_threshold: 1000 97 | trickle_fsync: false 98 | trickle_fsync_interval_in_kb: 10240 99 | truncate_request_timeout_in_ms: 60000 100 | write_request_timeout_in_ms: 10000 101 | -------------------------------------------------------------------------------- /spec/rendered_templates/jvm.options: -------------------------------------------------------------------------------- 1 | ########################################################################### 2 | # jvm.options # 3 | # # 4 | # - all flags defined here will be used by cassandra to startup the JVM # 5 | # - one flag should be specified per line # 6 | # - lines that do not start with '-' will be ignored # 7 | # - only static flags are accepted (no variables or parameters) # 8 | # - dynamic flags will be appended to these on cassandra-env # 9 | ########################################################################### 10 | 11 | ###################### 12 | # STARTUP PARAMETERS # 13 | ###################### 14 | 15 | # Uncomment any of the following properties to enable specific startup parameters 16 | 17 | # In a multi-instance deployment, multiple Cassandra instances will independently assume that all 18 | # CPU processors are available to it. This setting allows you to specify a smaller set of processors 19 | # and perhaps have affinity. 20 | #-Dcassandra.available_processors=number_of_processors 21 | 22 | # The directory location of the cassandra.yaml file. 23 | #-Dcassandra.config=directory 24 | 25 | # Sets the initial partitioner token for a node the first time the node is started. 26 | #-Dcassandra.initial_token=token 27 | 28 | # Set to false to start Cassandra on a node but not have the node join the cluster. 29 | #-Dcassandra.join_ring=true|false 30 | 31 | # Set to false to clear all gossip state for the node on restart. Use when you have changed node 32 | # information in cassandra.yaml (such as listen_address). 33 | #-Dcassandra.load_ring_state=true|false 34 | 35 | # Enable pluggable metrics reporter. See Pluggable metrics reporting in Cassandra 2.0.2. 36 | #-Dcassandra.metricsReporterConfigFile=file 37 | 38 | # Set the port on which the CQL native transport listens for clients. (Default: 9042) 39 | #-Dcassandra.native_transport_port=port 40 | 41 | # Overrides the partitioner. (Default: org.apache.cassandra.dht.Murmur3Partitioner) 42 | #-Dcassandra.partitioner=partitioner 43 | 44 | # To replace a node that has died, restart a new node in its place specifying the address of the 45 | # dead node. The new node must not have any data in its data directory, that is, it must be in the 46 | # same state as before bootstrapping. 47 | #-Dcassandra.replace_address=listen_address or broadcast_address of dead node 48 | 49 | # Allow restoring specific tables from an archived commit log. 50 | #-Dcassandra.replayList=table 51 | 52 | # Allows overriding of the default RING_DELAY (1000ms), which is the amount of time a node waits 53 | # before joining the ring. 54 | #-Dcassandra.ring_delay_ms=ms 55 | 56 | # Set the port for the Thrift RPC service, which is used for client connections. (Default: 9160) 57 | #-Dcassandra.rpc_port=port 58 | 59 | # Set the SSL port for encrypted communication. (Default: 7001) 60 | #-Dcassandra.ssl_storage_port=port 61 | 62 | # Enable or disable the native transport server. See start_native_transport in cassandra.yaml. 63 | # cassandra.start_native_transport=true|false 64 | 65 | # Enable or disable the Thrift RPC server. (Default: true) 66 | #-Dcassandra.start_rpc=true/false 67 | 68 | # Set the port for inter-node communication. (Default: 7000) 69 | #-Dcassandra.storage_port=port 70 | 71 | # Set the default location for the trigger JARs. (Default: conf/triggers) 72 | #-Dcassandra.triggers_dir=directory 73 | 74 | # For testing new compaction and compression strategies. It allows you to experiment with different 75 | # strategies and benchmark write performance differences without affecting the production workload. 76 | #-Dcassandra.write_survey=true 77 | 78 | # To disable configuration via JMX of auth caches (such as those for credentials, permissions and 79 | # roles). This will mean those config options can only be set (persistently) in cassandra.yaml 80 | # and will require a restart for new values to take effect. 81 | #-Dcassandra.disable_auth_caches_remote_configuration=true 82 | 83 | ######################## 84 | # GENERAL JVM SETTINGS # 85 | ######################## 86 | 87 | # enable assertions. disabling this in production will give a modest 88 | # performance benefit (around 5%). 89 | -ea 90 | 91 | 92 | # enable thread priorities, primarily so we can give periodic tasks 93 | # a lower priority to avoid interfering with client workload 94 | -XX:+UseThreadPriorities 95 | 96 | # allows lowering thread priority without being root on linux - probably 97 | # not necessary on Windows but doesn't harm anything. 98 | # see http://tech.stolsvik.com/2010/01/linux-java-thread-priorities-workar 99 | -XX:ThreadPriorityPolicy=42 100 | 101 | # Enable heap-dump if there's an OOM 102 | -XX:+HeapDumpOnOutOfMemoryError 103 | 104 | # Per-thread stack size. 105 | -Xss256k 106 | 107 | # Larger interned string table, for gossip's benefit (CASSANDRA-6410) 108 | -XX:StringTableSize=1000003 109 | 110 | # Make sure all memory is faulted and zeroed on startup. 111 | # This helps prevent soft faults in containers and makes 112 | # transparent hugepage allocation more effective. 113 | -XX:-AlwaysPreTouch 114 | 115 | # Disable biased locking as it does not benefit Cassandra. 116 | -XX:+UseBiasedLocking 117 | 118 | # Enable thread-local allocation blocks and allow the JVM to automatically 119 | # resize them at runtime. 120 | -XX:+UseTLAB 121 | 122 | -XX:+ResizeTLAB 123 | 124 | -XX:+UseNUMA 125 | 126 | 127 | # http://www.evanjones.ca/jvm-mmap-pause.html 128 | -XX:+PerfDisableSharedMem 129 | 130 | # Prefer binding to IPv4 network intefaces (when net.ipv6.bindv6only=1). See 131 | # http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6342561 (short version: 132 | # comment out this entry to enable IPv6 support). 133 | -Djava.net.preferIPv4Stack=true 134 | 135 | ### Debug options 136 | 137 | # uncomment to enable flight recorder 138 | #-XX:+UnlockCommercialFeatures 139 | #-XX:+FlightRecorder 140 | 141 | # uncomment to have Cassandra JVM listen for remote debuggers/profilers on port 1414 142 | #-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1414 143 | 144 | # uncomment to have Cassandra JVM log internal method compilation (developers only) 145 | #-XX:+UnlockDiagnosticVMOptions 146 | #-XX:+LogCompilation 147 | 148 | ################# 149 | # HEAP SETTINGS # 150 | ################# 151 | 152 | # Heap size is automatically calculated by cassandra-env based on this 153 | # formula: max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB)) 154 | # That is: 155 | # - calculate 1/2 ram and cap to 1024MB 156 | # - calculate 1/4 ram and cap to 8192MB 157 | # - pick the max 158 | # 159 | # For production use you may wish to adjust this for your environment. 160 | # If that's the case, uncomment the -Xmx and Xms options below to override the 161 | # automatic calculation of JVM heap memory. 162 | # 163 | # It is recommended to set min (-Xms) and max (-Xmx) heap sizes to 164 | # the same value to avoid stop-the-world GC pauses during resize, and 165 | # so that we can lock the heap in memory on startup to prevent any 166 | # of it from being swapped out. 167 | #-Xms4G 168 | #-Xmx4G 169 | 170 | # Young generation size is automatically calculated by cassandra-env 171 | # based on this formula: min(100 * num_cores, 1/4 * heap size) 172 | # 173 | # The main trade-off for the young generation is that the larger it 174 | # is, the longer GC pause times will be. The shorter it is, the more 175 | # expensive GC will be (usually). 176 | # 177 | # It is not recommended to set the young generation size if using the 178 | # G1 GC, since that will override the target pause-time goal. 179 | # More info: http://www.oracle.com/technetwork/articles/java/g1gc-1984535.html 180 | # 181 | # The example below assumes a modern 8-core+ machine for decent 182 | # times. If in doubt, and if you do not particularly want to tweak, go 183 | # 100 MB per physical CPU core. 184 | #-Xmn800M 185 | 186 | ################# 187 | # GC SETTINGS # 188 | ################# 189 | 190 | ### CMS Settings 191 | 192 | 193 | -XX:SurvivorRatio=8 194 | -XX:MaxTenuringThreshold=1 195 | 196 | ### G1 Settings (experimental, comment previous section and uncomment section below to enable) 197 | 198 | ## Use the Hotspot garbage-first collector. 199 | #-XX:+UseG1GC 200 | -XX:+UseG1GC 201 | # 202 | ## Have the JVM do less remembered set work during STW, instead 203 | ## preferring concurrent GC. Reduces p99.9 latency. 204 | #-XX:G1RSetUpdatingPauseTimePercent=5 205 | -XX:G1RSetUpdatingPauseTimePercent=5 206 | # 207 | ## Main G1GC tunable: lowering the pause target will lower throughput and vise versa. 208 | ## 200ms is the JVM default and lowest viable setting 209 | ## 1000ms increases throughput. Keep it smaller than the timeouts in cassandra.yaml. 210 | #-XX:MaxGCPauseMillis=500 211 | -XX:MaxGCPauseMillis=200 212 | 213 | 214 | ## Optional G1 Settings 215 | 216 | # Save CPU time on large (>= 16GB) heaps by delaying region scanning 217 | # until the heap is 70% full. The default in Hotspot 8u40 is 40%. 218 | #-XX:InitiatingHeapOccupancyPercent=70 219 | -XX:InitiatingHeapOccupancyPercent=45 220 | 221 | # Sets the size of a G1 region. The value will be a power of two and can range 222 | # from 1MB to 32MB. The goal is to have around 2048 regions based on the minimum 223 | # Java heap size. 224 | -XX:G1HeapRegionSize=0 225 | 226 | # For systems with > 8 cores, the default ParallelGCThreads is 5/8 the number of logical cores. 227 | # Otherwise equal to the number of cores when 8 or less. 228 | # Machines with > 10 cores should try setting these to <= full cores. 229 | #-XX:ParallelGCThreads=16 230 | # By default, ConcGCThreads is 1/4 of ParallelGCThreads. 231 | # Setting both to the same value can reduce STW durations. 232 | #-XX:ConcGCThreads=16 233 | 234 | # Additional options 235 | -XX:-ParallelRefProcEnabled 236 | 237 | ### GC logging options -- uncomment to enable 238 | 239 | -XX:+PrintGCDetails 240 | -XX:+PrintGCDateStamps 241 | -XX:+PrintHeapAtGC 242 | -XX:+PrintTenuringDistribution 243 | -XX:+PrintGCApplicationStoppedTime 244 | -XX:+PrintPromotionFailure 245 | #-XX:PrintFLSStatistics=1 246 | #-Xloggc:/var/log/cassandra/gc.log 247 | -XX:+UseGCLogFileRotation 248 | -XX:NumberOfGCLogFiles=10 249 | -XX:GCLogFileSize=10M 250 | -------------------------------------------------------------------------------- /spec/rendered_templates/logback-tools.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | 28 | %-5level %date{HH:mm:ss,SSS} %msg%n 29 | 30 | 31 | WARN 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /spec/rendered_templates/logback.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | INFO 35 | 36 | /var/log/cassandra/system.log 37 | 38 | /var/log/cassandra/system.log.%i.zip 39 | 1 40 | 20 41 | 42 | 43 | 20MB 44 | 45 | 46 | %-5level [%thread] %date{ISO8601} %F:%L - %msg%n 47 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | INFO 57 | 58 | 59 | %-5level [%thread] %date{ISO8601} %F:%L - %msg%n 60 | 61 | 62 | 63 | 64 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /spec/repositories_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'cassandra-dse::repositories' do 4 | context 'Centos 7.0' do 5 | let(:chef_run) do 6 | ChefSpec::SoloRunner.new(platform: 'centos', version: '7.3.1611') do |node| 7 | node.override['cassandra']['config']['cluster_name'] = 'test' 8 | end.converge(described_recipe) 9 | end 10 | 11 | it 'adds the datastax repository' do 12 | expect(chef_run).to create_yum_repository('datastax').with( 13 | baseurl: 'http://rpm.datastax.com/community', 14 | description: 'DataStax Repo for Apache Cassandra', 15 | gpgcheck: false, 16 | enabled: true 17 | ) 18 | end 19 | end 20 | 21 | context 'Ubuntu 16.04' do 22 | let(:chef_run) do 23 | ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04') do |node| 24 | node.override['cassandra']['config']['cluster_name'] = 'test' 25 | end.converge(described_recipe) 26 | end 27 | 28 | it 'installs the apt-transport-https package' do 29 | expect(chef_run).to install_package('apt-transport-https') 30 | end 31 | 32 | it 'adds the datastax repository' do 33 | expect(chef_run).to add_apt_repository('datastax').with( 34 | uri: 'https://debian.datastax.com/community/', 35 | distribution: 'stable', 36 | components: %w[main], 37 | key: 'https://debian.datastax.com/debian/repo_key' 38 | ) 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /spec/seed_selection_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'cassandra-dse' do 4 | context "seeds assigned as an array to node['cassandra']['seeds']" do 5 | cached(:chef_run) do 6 | ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04') do |node| 7 | node.override['cassandra']['config']['cluster_name'] = 'chefspec' 8 | node.override['cassandra']['seeds'] = %w[seed1 seed2] 9 | end.converge(described_recipe) 10 | end 11 | 12 | it 'renders the /etc/cassandra/cassandra.yaml with seeds: seed1,seed2' do 13 | expect(chef_run).to render_file('/etc/cassandra/cassandra.yaml') 14 | .with_content('- seeds: seed1,seed2') 15 | end 16 | end 17 | 18 | context "seeds assigned as an string to node['cassandra']['seeds']" do 19 | cached(:chef_run) do 20 | ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04') do |node| 21 | node.override['cassandra']['config']['cluster_name'] = 'chefspec' 22 | node.override['cassandra']['seeds'] = 'seed1,seed2' 23 | end.converge(described_recipe) 24 | end 25 | 26 | it 'renders the /etc/cassandra/cassandra.yaml with seeds: seed1,seed2' do 27 | expect(chef_run).to render_file('/etc/cassandra/cassandra.yaml') 28 | .with_content('- seeds: seed1,seed2') 29 | end 30 | end 31 | 32 | # TODO: Why doesn't the stub work? 33 | # context 'seeds selected through a chef search' do 34 | # cached(:chef_run) do 35 | # ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '14.04') do |node, server| 36 | # node.override['cassandra']['config']['cluster_name'] = 'chefspec' 37 | # node.override['cassandra']['seed_discovery']['use_chef_search'] = true 38 | # node.override['chef_environment'] = 'chefspec' 39 | # end.converge(described_recipe) 40 | # end 41 | 42 | # it 'renders the /etc/cassandra/cassandra.yaml with seeds: seed1,seed2' do 43 | # stub_search(:node, 'chef_environment:_default AND role:cassandra-seed AND cassandra_cluster_name:chefspec') 44 | # .and_return([{seed1: {ipaddress: '10.10.10.10'}, seed2: {ipaddress: '10.10.10.11'}}]) 45 | # expect(chef_run).to render_file('/etc/cassandra/cassandra.yaml') 46 | # .with_content('- seeds: 10.10.10.10,10.10.10.11') 47 | # end 48 | # end 49 | end 50 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'chefspec' 2 | require 'chefspec/berkshelf' 3 | 4 | RSpec.configure do |config| 5 | config.expect_with :rspec do |c| 6 | c.syntax = :expect 7 | end 8 | 9 | config.before(:each) do 10 | # stub out the repo_server data bag 11 | server_node = { 12 | 'id' => 'node', 13 | 'ipaddress' => '0.0.0.0' 14 | } 15 | stub_search(:node, 'roles:opscenter_server').and_return([server_node]) 16 | end 17 | end 18 | 19 | at_exit { ChefSpec::Coverage.report! } 20 | -------------------------------------------------------------------------------- /spec/systemd_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'cassandra-dse::systemd' do 4 | context 'Centos 7.0' do 5 | let(:chef_run) do 6 | ChefSpec::SoloRunner.new(platform: 'centos', version: '7.3.1611') do |node| 7 | node.override['cassandra']['config']['cluster_name'] = 'test' 8 | node.override['cassandra']['conf_dir'] = '/etc/cassandra/conf' 9 | node.override['cassandra']['use_systemd'] = true 10 | node.override['cassandra']['notify_restart'] = true 11 | node.set['systemd']['units_dir'] = '/etc/systemd/system' 12 | end.converge('cassandra-dse::config', described_recipe) 13 | end 14 | 15 | it 'declares the daemon-reload resource' do 16 | resource = chef_run.execute('daemon-reload') 17 | expect(resource).to do_nothing 18 | end 19 | 20 | it 'creates the systemd unit file' do 21 | expect(chef_run).to create_template('/etc/systemd/system/cassandra.service').with( 22 | source: 'cassandra.service.erb', 23 | owner: 'cassandra', 24 | group: 'cassandra', 25 | mode: '0644' 26 | ) 27 | template = chef_run.template('/etc/systemd/system/cassandra.service') 28 | expect(template).to notify('execute[daemon-reload]').to(:run).immediately 29 | expect(template).to notify('service[cassandra]').to(:enable).delayed 30 | expect(template).to notify('service[cassandra]').to(:restart).delayed 31 | end 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /templates/default/cassandra-cli.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This file is managed by Chef. 4 | # Do NOT modify this file directly. 5 | # 6 | # Licensed to the Apache Software Foundation (ASF) under one 7 | # or more contributor license agreements. See the NOTICE file 8 | # distributed with this work for additional information 9 | # regarding copyright ownership. The ASF licenses this file 10 | # to you under the Apache License, Version 2.0 (the 11 | # "License"); you may not use this file except in compliance 12 | # with the License. You may obtain a copy of the License at 13 | # 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | # 16 | # Unless required by applicable law or agreed to in writing, software 17 | # distributed under the License is distributed on an "AS IS" BASIS, 18 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | # See the License for the specific language governing permissions and 20 | # limitations under the License. 21 | 22 | for j in <%= node['cassandra']['lib_dir'] %>/*.jar; do 23 | [ "x$CLASSPATH" = "x" ] && CLASSPATH=$j || CLASSPATH=$CLASSPATH:$j 24 | done 25 | for j in /usr/share/$NAME/*.jar; do 26 | [ "x$CLASSPATH" = "x" ] && CLASSPATH=$j || CLASSPATH=$CLASSPATH:$j 27 | done 28 | 29 | # use JNA if installed in standard location 30 | [ -r /usr/share/java/jna.jar ] && cp="$cp:/usr/share/java/jna.jar" 31 | 32 | if [ "x$CASSANDRA_INCLUDE" = "x" ]; then 33 | for include in /usr/share/cassandra/cassandra.in.sh \ 34 | /usr/local/share/cassandra/cassandra.in.sh \ 35 | /opt/cassandra/cassandra.in.sh \ 36 | ~/.cassandra.in.sh \ 37 | `dirname $0`/cassandra.in.sh; do 38 | if [ -r $include ]; then 39 | . $include 40 | break 41 | fi 42 | done 43 | elif [ -r $CASSANDRA_INCLUDE ]; then 44 | . $CASSANDRA_INCLUDE 45 | fi 46 | 47 | # Use JAVA_HOME if set, otherwise look for java in PATH 48 | if [ -x $JAVA_HOME/bin/java ]; then 49 | JAVA=$JAVA_HOME/bin/java 50 | else 51 | JAVA=`which java` 52 | fi 53 | 54 | if [ -z $CLASSPATH ]; then 55 | echo "You must set the CLASSPATH var" >&2 56 | exit 1 57 | fi 58 | 59 | $JAVA -ea -cp $CLASSPATH -Xmx256M \ 60 | -Dlog4j.configuration=log4j-tools.properties \ 61 | org.apache.cassandra.cli.CliMain "$@" 62 | 63 | # vi:ai sw=4 ts=4 tw=0 et 64 | -------------------------------------------------------------------------------- /templates/default/cassandra-env.sh.erb: -------------------------------------------------------------------------------- 1 | # 2 | # This file is managed by Chef. 3 | # Do NOT modify this file directly. 4 | # 5 | # Licensed to the Apache Software Foundation (ASF) under one 6 | # or more contributor license agreements. See the NOTICE file 7 | # distributed with this work for additional information 8 | # regarding copyright ownership. The ASF licenses this file 9 | # to you under the Apache License, Version 2.0 (the 10 | # "License"); you may not use this file except in compliance 11 | # with the License. You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | 21 | calculate_heap_sizes() 22 | { 23 | case "`uname`" in 24 | Linux) 25 | system_memory_in_mb=`free -m | awk '/Mem:/ {print $2}'` 26 | system_cpu_cores=`egrep -c 'processor([[:space:]]+):.*' /proc/cpuinfo` 27 | ;; 28 | FreeBSD) 29 | system_memory_in_bytes=`sysctl hw.physmem | awk '{print $2}'` 30 | system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024` 31 | system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'` 32 | ;; 33 | SunOS) 34 | system_memory_in_mb=`prtconf | awk '/Memory size:/ {print $3}'` 35 | system_cpu_cores=`psrinfo | wc -l` 36 | ;; 37 | Darwin) 38 | system_memory_in_bytes=`sysctl hw.memsize | awk '{print $2}'` 39 | system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024` 40 | system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'` 41 | ;; 42 | *) 43 | # assume reasonable defaults for e.g. a modern desktop or 44 | # cheap server 45 | system_memory_in_mb="2048" 46 | system_cpu_cores="2" 47 | ;; 48 | esac 49 | 50 | # some systems like the raspberry pi don't report cores, use at least 1 51 | if [ "$system_cpu_cores" -lt "1" ] 52 | then 53 | system_cpu_cores="1" 54 | fi 55 | 56 | # set max heap size based on the following 57 | # max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB)) 58 | # calculate 1/2 ram and cap to 1024MB 59 | # calculate 1/4 ram and cap to 8192MB 60 | # pick the max 61 | half_system_memory_in_mb=`expr $system_memory_in_mb / 2` 62 | quarter_system_memory_in_mb=`expr $half_system_memory_in_mb / 2` 63 | if [ "$half_system_memory_in_mb" -gt "1024" ] 64 | then 65 | half_system_memory_in_mb="1024" 66 | fi 67 | if [ "$quarter_system_memory_in_mb" -gt "8192" ] 68 | then 69 | quarter_system_memory_in_mb="8192" 70 | fi 71 | if [ "$half_system_memory_in_mb" -gt "$quarter_system_memory_in_mb" ] 72 | then 73 | max_heap_size_in_mb="$half_system_memory_in_mb" 74 | else 75 | max_heap_size_in_mb="$quarter_system_memory_in_mb" 76 | fi 77 | MAX_HEAP_SIZE="${max_heap_size_in_mb}M" 78 | 79 | # Young gen: min(max_sensible_per_modern_cpu_core * num_cores, 1/4 * heap size) 80 | max_sensible_yg_per_core_in_mb="100" 81 | max_sensible_yg_in_mb=`expr $max_sensible_yg_per_core_in_mb "*" $system_cpu_cores` 82 | 83 | desired_yg_in_mb=`expr $max_heap_size_in_mb / 4` 84 | 85 | if [ "$desired_yg_in_mb" -gt "$max_sensible_yg_in_mb" ] 86 | then 87 | HEAP_NEWSIZE="${max_sensible_yg_in_mb}M" 88 | else 89 | HEAP_NEWSIZE="${desired_yg_in_mb}M" 90 | fi 91 | } 92 | 93 | # Determine the sort of JVM we'll be running on. 94 | 95 | java_ver_output=`"${JAVA:-java}" -version 2>&1` 96 | 97 | jvmver=`echo "$java_ver_output" | awk -F'"' 'NR==1 {print $2}'` 98 | JVM_VERSION=${jvmver%_*} 99 | JVM_PATCH_VERSION=${jvmver#*_} 100 | 101 | #if [ "$JVM_VERSION" < "1.6" ] ; then 102 | # echo "Cassandra 2.0 and later require Java 7 or later." 103 | # exit 1; 104 | #fi 105 | 106 | jvm=`echo "$java_ver_output" | awk 'NR==2 {print $1}'` 107 | case "$jvm" in 108 | OpenJDK) 109 | JVM_VENDOR=OpenJDK 110 | # this will be "64-Bit" or "32-Bit" 111 | JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $2}'` 112 | ;; 113 | "Java(TM)") 114 | JVM_VENDOR=Oracle 115 | # this will be "64-Bit" or "32-Bit" 116 | JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $3}'` 117 | ;; 118 | *) 119 | # Help fill in other JVM values 120 | JVM_VENDOR=other 121 | JVM_ARCH=unknown 122 | ;; 123 | esac 124 | 125 | #GC log path has to be defined here because it needs to access CASSANDRA_HOME 126 | JVM_OPTS="$JVM_OPTS -Xloggc:<%= node['cassandra']['log_gc'] %>" 127 | 128 | # Here we create the arguments that will get passed to the jvm when 129 | # starting cassandra. 130 | 131 | # Read user-defined JVM options from jvm.options file 132 | JVM_OPTS_FILE=$CASSANDRA_CONF/jvm.options 133 | for opt in `grep "^-" $JVM_OPTS_FILE` 134 | do 135 | JVM_OPTS="$JVM_OPTS $opt" 136 | done 137 | 138 | # Check what parameters were defined on jvm.options file to avoid conflicts 139 | echo $JVM_OPTS | grep -q Xmn 140 | DEFINED_XMN=$? 141 | echo $JVM_OPTS | grep -q Xmx 142 | DEFINED_XMX=$? 143 | echo $JVM_OPTS | grep -q Xms 144 | DEFINED_XMS=$? 145 | echo $JVM_OPTS | grep -q UseConcMarkSweepGC 146 | USING_CMS=$? 147 | echo $JVM_OPTS | grep -q UseG1GC 148 | USING_G1=$? 149 | 150 | # Override these to set the amount of memory to allocate to the JVM at 151 | # start-up. For production use you may wish to adjust this for your 152 | # environment. MAX_HEAP_SIZE is the total amount of memory dedicated 153 | # to the Java heap. HEAP_NEWSIZE refers to the size of the young 154 | # generation. Both MAX_HEAP_SIZE and HEAP_NEWSIZE should be either set 155 | # or not (if you set one, set the other). 156 | # 157 | # The main trade-off for the young generation is that the larger it 158 | # is, the longer GC pause times will be. The shorter it is, the more 159 | # expensive GC will be (usually). 160 | # 161 | # The example HEAP_NEWSIZE assumes a modern 8-core+ machine for decent pause 162 | # times. If in doubt, and if you do not particularly want to tweak, go with 163 | # 100 MB per physical CPU core. 164 | 165 | <% if node['cassandra']['max_heap_size'] && node['cassandra']['heap_new_size'] %> 166 | MAX_HEAP_SIZE="<%= node['cassandra']['max_heap_size'] %>" 167 | HEAP_NEWSIZE="<%= node['cassandra']['heap_new_size'] %>" 168 | <% else %> 169 | #MAX_HEAP_SIZE="4G" 170 | #HEAP_NEWSIZE="800M" 171 | <% end %> 172 | 173 | # Set this to control the amount of arenas per-thread in glibc 174 | #MALLOC_ARENA_MAX=4 175 | 176 | # only calculate the size if it's not set manually 177 | if [ "x$MAX_HEAP_SIZE" = "x" ] && [ "x$HEAP_NEWSIZE" = "x" -o $USING_G1 -eq 0 ]; then 178 | calculate_heap_sizes 179 | elif [ "x$MAX_HEAP_SIZE" = "x" ] || [ "x$HEAP_NEWSIZE" = "x" -a $USING_G1 -ne 0 ]; then 180 | echo "please set or unset MAX_HEAP_SIZE and HEAP_NEWSIZE in pairs when using CMS GC (see cassandra-env.sh)" 181 | exit 1 182 | fi 183 | 184 | if [ "x$MALLOC_ARENA_MAX" = "x" ] 185 | then 186 | MALLOC_ARENA_MAX=4 187 | fi 188 | 189 | # We only set -Xms and -Xmx if they were not defined on jvm.options file 190 | # If defined, both Xmx and Xms should be defined together. 191 | if [ $DEFINED_XMX -ne 0 ] && [ $DEFINED_XMS -ne 0 ]; then 192 | JVM_OPTS="$JVM_OPTS -Xms${MAX_HEAP_SIZE}" 193 | JVM_OPTS="$JVM_OPTS -Xmx${MAX_HEAP_SIZE}" 194 | elif [ $DEFINED_XMX -ne 0 ] || [ $DEFINED_XMS -ne 0 ]; then 195 | echo "Please set or unset -Xmx and -Xms flags in pairs on jvm.options file." 196 | exit 1 197 | fi 198 | 199 | # We only set -Xmn flag if it was not defined in jvm.options file 200 | # and if the CMS GC is being used 201 | # If defined, both Xmn and Xmx should be defined together. 202 | if [ $DEFINED_XMN -eq 0 ] && [ $DEFINED_XMX -ne 0 ]; then 203 | echo "Please set or unset -Xmx and -Xmn flags in pairs on jvm.options file." 204 | exit 1 205 | elif [ $DEFINED_XMN -ne 0 ] && [ $USING_CMS -eq 0 ]; then 206 | JVM_OPTS="$JVM_OPTS -Xmn${HEAP_NEWSIZE}" 207 | fi 208 | 209 | if [ "$JVM_ARCH" = "64-Bit" ] && [ $USING_CMS -eq 0 ]; then 210 | JVM_OPTS="$JVM_OPTS -XX:+UseCondCardMark" 211 | fi 212 | 213 | # provides hints to the JIT compiler 214 | JVM_OPTS="$JVM_OPTS -XX:CompileCommandFile=$CASSANDRA_CONF/hotspot_compiler" 215 | 216 | <% if node['cassandra']['setup_jamm'] -%> 217 | # add the jamm javaagent 218 | if [ "$JVM_VENDOR" != "OpenJDK" -o "$JVM_VERSION" \> "1.6.0" ] \ 219 | || [ "$JVM_VERSION" = "1.6.0" -a "$JVM_PATCH_VERSION" -ge 23 ] 220 | then 221 | JVM_OPTS="$JVM_OPTS -javaagent:$CASSANDRA_HOME/lib/jamm-<%= node['cassandra']['jamm']['version'] -%>.jar" 222 | fi 223 | <% end -%> 224 | 225 | # set jvm HeapDumpPath with CASSANDRA_HEAPDUMP_DIR 226 | <% if node['cassandra']['heap_dump_dir'] -%> 227 | CASSANDRA_HEAPDUMP_DIR=<%= node['cassandra']['heap_dump_dir'] %> 228 | <% end -%> 229 | if [ "x$CASSANDRA_HEAPDUMP_DIR" != "x" ]; then 230 | JVM_OPTS="$JVM_OPTS -XX:HeapDumpPath=$CASSANDRA_HEAPDUMP_DIR/cassandra-`date +%s`-pid$$.hprof" 231 | fi 232 | 233 | # stop the jvm on OutOfMemoryError as it can result in some data corruption 234 | # uncomment the preferred option 235 | # ExitOnOutOfMemoryError and CrashOnOutOfMemoryError require a JRE greater or equals to 1.7 update 101 or 1.8 update 92 236 | # For OnOutOfMemoryError we cannot use the JVM_OPTS variables because bash commands split words 237 | # on white spaces without taking quotes into account 238 | # JVM_OPTS="$JVM_OPTS -XX:+ExitOnOutOfMemoryError" 239 | # JVM_OPTS="$JVM_OPTS -XX:+CrashOnOutOfMemoryError" 240 | JVM_ON_OUT_OF_MEMORY_ERROR_OPT="-XX:OnOutOfMemoryError=<%= node['cassandra']['on_oom'] %>" 241 | 242 | # 243 | # see 244 | # https://blogs.oracle.com/jmxetc/entry/troubleshooting_connection_problems_in_jconsole 245 | # for more on configuring JMX through firewalls, etc. (Short version: 246 | # get it working with no firewall first.) 247 | # 248 | # Cassandra ships with JMX accessible *only* from localhost. 249 | # To enable remote JMX connections, uncomment lines below 250 | # with authentication and/or ssl enabled. See https://wiki.apache.org/cassandra/JmxSecurity 251 | # 252 | <% if node['cassandra']['local_jmx'] %> 253 | if [ "x$LOCAL_JMX" = "x" ]; then 254 | LOCAL_JMX=yes 255 | fi 256 | <% end %> 257 | 258 | # Specifies the default port over which Cassandra will be available for 259 | # JMX connections. 260 | # For security reasons, you should not expose this port to the internet. Firewall it if needed. 261 | 262 | # Specifies the default port over which Cassandra will be available for 263 | # JMX connections. 264 | # For security reasons, you should not expose this port to the internet. Firewall it if needed. 265 | JMX_PORT="<%= node['cassandra']['jmx_port'] %>" 266 | 267 | if [ "$LOCAL_JMX" = "yes" ]; then 268 | JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.local.port=$JMX_PORT" 269 | JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false" 270 | else 271 | # if ssl is enabled the same port cannot be used for both jmx and rmi so either 272 | # pick another value for this property or comment out to use a random port (though see CASSANDRA-7087 for origins) 273 | JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT" 274 | JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.rmi.port=<%= node['cassandra']['jmx_remote_rmi_port'] %>" 275 | JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false" 276 | JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=<%= node['cassandra']['jmx_remote_authenticate'] %>" 277 | JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.password.file=$CASSANDRA_CONF/jmxremote.password" 278 | JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.access.file=$CASSANDRA_CONF/jmxremote.access" 279 | 280 | # jmx ssl options 281 | #JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=true" 282 | #JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl.need.client.auth=true" 283 | #JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl.enabled.protocols=" 284 | #JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl.enabled.cipher.suites=" 285 | #JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.keyStore=/path/to/keystore" 286 | #JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.keyStorePassword=" 287 | #JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.trustStore=/path/to/truststore" 288 | #JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.trustStorePassword=" 289 | fi 290 | 291 | # To use mx4j, an HTML interface for JMX, add mx4j-tools.jar to the lib/ 292 | # directory. 293 | # See http://wiki.apache.org/cassandra/Operations#Monitoring_with_MX4J 294 | # By default mx4j listens on 0.0.0.0:8081. Uncomment the following lines 295 | # to control its listen address and port. 296 | #MX4J_ADDRESS="-Dmx4jaddress=127.0.0.1" 297 | #MX4J_PORT="-Dmx4jport=8081" 298 | 299 | # Cassandra uses SIGAR to capture OS metrics CASSANDRA-7838 300 | # for SIGAR we have to set the java.library.path 301 | # to the location of the native libraries. 302 | JVM_OPTS="$JVM_OPTS -Djava.library.path=$CASSANDRA_HOME/lib/sigar-bin" 303 | 304 | 305 | <% if node['cassandra']['setup_priam'] -%> 306 | # add the priam cass extensions javaagent 307 | JVM_OPTS="$JVM_OPTS -javaagent:$CASSANDRA_HOME/lib/<%= node['cassandra']['priam']['jar_name'] -%>" 308 | <% end -%> 309 | 310 | # jmx: metrics and administration interface 311 | # 312 | # add this if you're having trouble connecting: 313 | <% if node['cassandra']['jmx_server_hostname'] %> 314 | JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<%= node['cassandra']['jmx_server_hostname'] %>" 315 | <% else %> 316 | # JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=" 317 | <% end %> 318 | 319 | # support for metrics reporter: 320 | <% if node['cassandra']['metrics_reporter']['enabled'] %> 321 | JVM_OPTS="$JVM_OPTS -Dcassandra.metricsReporterConfigFile=cassandra-metrics.yaml" 322 | <% end %> 323 | 324 | <% if node['cassandra']['skip_jna'] %> 325 | JVM_OPTS="$JVM_OPTS -Dcassandra.boot_without_jna=true" 326 | <% end %> 327 | 328 | # see https://issues.apache.org/jira/browse/CASSANDRA-6541 329 | JVM_OPTS="$JVM_OPTS -XX:+CMSClassUnloadingEnabled" 330 | 331 | <%if node['cassandra']['tmp_dir'] %> 332 | JVM_OPTS="$JVM_OPTS -Djna.tmpdir=<%= node['cassandra']['tmp_dir'] %>" 333 | JVM_OPTS="$JVM_OPTS -Djava.io.tmpdir=<%= node['cassandra']['tmp_dir'] %>" 334 | <% end %> 335 | 336 | <% if node['cassandra']['jvm']['agentpath'] %> 337 | JVM_OPTS="$JVM_OPTS -agentpath:<%= node['cassandra']['jvm']['agentpath'] %>" 338 | <% end %> 339 | 340 | <% if node['cassandra']['jvm']['misc_java_agents'] %> 341 | <% node['cassandra']['jvm']['misc_java_agents'].each do |agent| %> 342 | JVM_OPTS="$JVM_OPTS -javaagent:<%= agent.to_s -%>" 343 | <% end %> 344 | <% end %> 345 | 346 | <% if node['cassandra']['jvm']['misc_jvm_options'] %> 347 | <% node['cassandra']['jvm']['misc_jvm_options'].each do |option| %> 348 | JVM_OPTS="$JVM_OPTS -D<%= option.to_s -%>" 349 | <% end %> 350 | <% end %> 351 | 352 | JVM_OPTS="$JVM_OPTS $MX4J_ADDRESS" 353 | JVM_OPTS="$JVM_OPTS $MX4J_PORT" 354 | JVM_OPTS="$JVM_OPTS $JVM_EXTRA_OPTS" 355 | -------------------------------------------------------------------------------- /templates/default/cassandra-metrics.yaml.erb: -------------------------------------------------------------------------------- 1 | <%= @yaml_config %> 2 | -------------------------------------------------------------------------------- /templates/default/cassandra-rackdc.properties.erb: -------------------------------------------------------------------------------- 1 | # 2 | # This file is managed by Chef. 3 | # Do NOT modify this file directly. 4 | # 5 | # Licensed to the Apache Software Foundation (ASF) under one 6 | # or more contributor license agreements. See the NOTICE file 7 | # distributed with this work for additional information 8 | # regarding copyright ownership. The ASF licenses this file 9 | # to you under the Apache License, Version 2.0 (the 10 | # "License"); you may not use this file except in compliance 11 | # with the License. You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | 21 | # These properties are used with GossipingPropertyFileSnitch and will 22 | # indicate the rack and dc for this node 23 | dc=<%= @rackdc['dc'] %> 24 | rack=<%= @rackdc['rack'] %> 25 | 26 | # Add a suffix to a datacenter name. Used by the Ec2Snitch and Ec2MultiRegionSnitch 27 | # to append a string to the EC2 region name. 28 | #dc_suffix= 29 | 30 | # Uncomment the following line to make this snitch prefer the internal ip when possible, as the Ec2MultiRegionSnitch does. 31 | prefer_local=<%= @rackdc['prefer_local'] or false %> 32 | -------------------------------------------------------------------------------- /templates/default/cassandra-topology.properties.erb: -------------------------------------------------------------------------------- 1 | # 2 | # This file is managed by Chef. 3 | # Do NOT modify this file directly. 4 | # 5 | # Cassandra Node IP=Data Center:Rack 6 | 7 | default=<%= @snitch['dc'] %>:<%= @snitch['rack'] %> 8 | -------------------------------------------------------------------------------- /templates/default/cassandra.envvars.erb: -------------------------------------------------------------------------------- 1 | # environment variables necessary to run nodetool 2 | 3 | CASSANDRA_CONF=<%= node['cassandra']['conf_dir'] %> 4 | CLASSPATH=$CASSANDRA_CONF:<%= node['cassandra']['bin_dir'] %> 5 | 6 | for jar in <%= node['cassandra']['lib_dir'] %>/*.jar; do 7 | CLASSPATH="$CLASSPATH:$jar" 8 | done 9 | 10 | export CASSANDRA_CONF 11 | export CLASSPATH 12 | -------------------------------------------------------------------------------- /templates/default/cassandra.service.erb: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=cassandra daemon 3 | Wants=network-online.target 4 | After=network-online.target 5 | 6 | [Install] 7 | WantedBy=multi-user.target 8 | 9 | [Service] 10 | ExecStart=<%= node['cassandra']['startup_program'] %> -f -p <%= node['cassandra']['pid_dir'] %>/cassandra.pid 11 | Type=simple 12 | User=<%= node['cassandra']['user'] %> 13 | Group=<%= node['cassandra']['group'] %> 14 | StandardOutput=journal 15 | StandardError=inherit 16 | Environment="CASSANDRA_HOME=<%= node['cassandra']['installation_dir'] %>" "CASSANDRA_CONF=<%= node['cassandra']['conf_dir'] %>" 17 | LimitNOFILE=infinity 18 | TimeoutStopSec=10min 19 | Restart=<%= node['cassandra']['systemd']['restart_condition'] %> 20 | PIDFile=<%= node['cassandra']['pid_dir'] %>/cassandra.pid 21 | ExecStop=<%= node['cassandra']['bin_dir'] %>/nodetool disablegossip 22 | ExecStop=<%= node['cassandra']['bin_dir'] %>/nodetool disablethrift 23 | ExecStop=<%= node['cassandra']['bin_dir'] %>/nodetool drain 24 | ExecStop=-<%= node['cassandra']['bin_dir'] %>/nodetool stopdaemon 25 | -------------------------------------------------------------------------------- /templates/default/cassandra.yaml.erb: -------------------------------------------------------------------------------- 1 | # 2 | # This file is managed by Chef. 3 | # Do NOT modify this file directly. 4 | # 5 | # This commented out line will trigger a node restart when Cassandra version changes. 6 | # It's non-functional otherwise. 7 | # version: <%= node['cassandra']['version'] %> 8 | <%= cassandra_yaml_config(node['cassandra']['config']) %> 9 | -------------------------------------------------------------------------------- /templates/default/cqlsh.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This file is managed by Chef. 4 | # Do NOT modify this file directly. 5 | # 6 | exec <%= node['cassandra']['bin_dir'] %>/cqlsh "$@" 7 | -------------------------------------------------------------------------------- /templates/default/debian.cassandra.init.erb: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # This file is managed by Chef. 4 | # Do NOT modify this file directly. 5 | # 6 | ### BEGIN INIT INFO 7 | # Provides: cassandra 8 | # Required-Start: $remote_fs $network $named $time 9 | # Required-Stop: $remote_fs $network $named $time 10 | # Should-Start: ntp mdadm 11 | # Should-Stop: ntp mdadm 12 | # Default-Start: 2 3 4 5 13 | # Default-Stop: 0 1 6 14 | # Short-Description: distributed storage system for structured data 15 | # Description: Cassandra is a distributed (peer-to-peer) system for 16 | # the management and storage of structured data. 17 | ### END INIT INFO 18 | 19 | DESC="Cassandra" 20 | NAME=cassandra 21 | PIDFILE=/var/run/$NAME.pid 22 | SCRIPTNAME=/etc/init.d/$NAME 23 | export CASSANDRA_HOME=<%= node['cassandra']['installation_dir'] %> 24 | export CASSANDRA_CONF=<%= node['cassandra']['conf_dir'] %> 25 | USER=<%= node['cassandra']['user'] %> 26 | GROUP=<%= node['cassandra']['group'] %> 27 | WAIT_FOR_START=10 28 | FD_LIMIT=<%= node['cassandra']['limits']['nofile'] %> 29 | NODETOOL=$CASSANDRA_HOME/bin/nodetool 30 | 31 | [ -e $CASSANDRA_HOME/lib/apache-cassandra-<%= node['cassandra']['version'] %>.jar ] || exit 0 32 | [ -e $CASSANDRA_CONF/cassandra.yaml ] || exit 0 33 | [ -e $CASSANDRA_CONF/cassandra-env.sh ] || exit 0 34 | [ -e $CASSANDRA_HOME/bin/cassandra ] || exit 0 35 | [ -e $NODETOOL ] || exit 0 36 | 37 | 38 | # Read configuration variable file if it is present 39 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME 40 | 41 | # Load the VERBOSE setting and other rcS variables 42 | . /lib/init/vars.sh 43 | 44 | # Define LSB log_* functions. 45 | # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. 46 | . /lib/lsb/init-functions 47 | 48 | # Return 49 | # 0 if daemon is running 50 | # 1 if daemon is not running 51 | is_running() 52 | { 53 | [ -f $PIDFILE -a -d /proc/$(cat $PIDFILE) ] && return 0 54 | return 1 55 | } 56 | 57 | # Return 58 | # 0 if daemon has been started 59 | # 1 if daemon was already running 60 | # 2 if daemon could not be started 61 | do_start() 62 | { 63 | is_running && return 1 64 | 65 | ulimit -l unlimited 66 | ulimit -n "$FD_LIMIT" 67 | 68 | touch $PIDFILE 69 | chown $USER:$GROUP $PIDFILE 70 | 71 | start-stop-daemon --start \ 72 | --quiet \ 73 | --background \ 74 | --chdir / \ 75 | --oknodo \ 76 | --chuid $USER:$GROUP \ 77 | --exec /bin/bash \ 78 | --pidfile $PIDFILE \ 79 | -- -c "$CASSANDRA_HOME/bin/cassandra -p $PIDFILE > <%= node['cassandra']['log_dir'] %>/boot.log 2>&1" 80 | 81 | is_running && return 0 82 | 83 | for tries in `seq $WAIT_FOR_START`; do 84 | sleep 1 85 | is_running && return 0 86 | done 87 | 88 | return 2 89 | } 90 | 91 | # Returns 92 | # 0 if daemon has been stopped 93 | # 1 if daemon was already stopped 94 | # 2 if daemon could not be stopped 95 | # other if a failure occurred 96 | do_stop() 97 | { 98 | is_running || return 1 99 | 100 | # Disable Thrift, Mark node down for client 101 | echo "executing nodetool disablethrift .." 102 | $NODETOOL -h <%=node['ipaddress']%> disablethrift 103 | [ $? -eq 0 ] || { 104 | echo "failed to execute disablethrift .." 105 | } 106 | sleep 2 107 | 108 | # Disabling Gossip, Mark node down for cluster 109 | echo "executing nodetool disablegossip .." 110 | $NODETOOL -h <%=node['ipaddress']%> disablegossip 111 | [ $? -eq 0 ] || { 112 | echo "failed to execute disablegossip .." 113 | } 114 | sleep 2 115 | 116 | # Drain node for existing connections, Always safe even takes long time 117 | echo "executing nodetool drain .." 118 | $NODETOOL -h <%=node['ipaddress']%> drain 119 | [ $? -eq 0 ] || { 120 | echo "failed to execute drain .." 121 | } 122 | sleep 2 123 | 124 | start-stop-daemon --stop \ 125 | --pidfile $PIDFILE \ 126 | --user $USER \ 127 | --retry TERM/30/KILL/5 128 | 129 | is_running && return 2 130 | 131 | return 0 132 | } 133 | 134 | case "$1" in 135 | start) 136 | echo "Starting $DESC" 137 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" 138 | do_start 139 | case "$?" in 140 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 141 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 142 | esac 143 | ;; 144 | stop) 145 | echo "Stopping $DESC" 146 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" 147 | do_stop 148 | case "$?" in 149 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 150 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 151 | esac 152 | ;; 153 | restart|force-reload) 154 | echo "Restarting $DESC" 155 | log_daemon_msg "Restarting $DESC" "$NAME" 156 | do_stop 157 | case "$?" in 158 | 0|1) 159 | do_start 160 | case "$?" in 161 | 0) log_end_msg 0 ;; 162 | 1) log_end_msg 1 ;; # Old process is still running 163 | *) log_end_msg 1 ;; # Failed to start 164 | esac 165 | ;; 166 | *) 167 | # Failed to stop 168 | log_end_msg 1 169 | ;; 170 | esac 171 | ;; 172 | status) 173 | is_running 174 | stat=$? 175 | case "$stat" in 176 | 0) log_success_msg "$DESC is running" ;; 177 | *) log_success_msg "$DESC is not running" ;; 178 | esac 179 | exit "$stat" 180 | ;; 181 | *) 182 | echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2 183 | exit 3 184 | ;; 185 | esac 186 | 187 | : 188 | 189 | # vi:ai sw=4 ts=4 tw=0 et 190 | -------------------------------------------------------------------------------- /templates/default/jmxremote.access.erb: -------------------------------------------------------------------------------- 1 | <%= node['cassandra']['jmx']['user'] %> readwrite 2 | -------------------------------------------------------------------------------- /templates/default/jmxremote.password.erb: -------------------------------------------------------------------------------- 1 | <%= node['cassandra']['jmx']['user'] %> <%= node['cassandra']['jmx']['password'] %> 2 | -------------------------------------------------------------------------------- /templates/default/jvm.options.erb: -------------------------------------------------------------------------------- 1 | ########################################################################### 2 | # jvm.options # 3 | # # 4 | # - all flags defined here will be used by cassandra to startup the JVM # 5 | # - one flag should be specified per line # 6 | # - lines that do not start with '-' will be ignored # 7 | # - only static flags are accepted (no variables or parameters) # 8 | # - dynamic flags will be appended to these on cassandra-env # 9 | ########################################################################### 10 | 11 | ###################### 12 | # STARTUP PARAMETERS # 13 | ###################### 14 | 15 | # Uncomment any of the following properties to enable specific startup parameters 16 | 17 | # In a multi-instance deployment, multiple Cassandra instances will independently assume that all 18 | # CPU processors are available to it. This setting allows you to specify a smaller set of processors 19 | # and perhaps have affinity. 20 | #-Dcassandra.available_processors=number_of_processors 21 | 22 | # The directory location of the cassandra.yaml file. 23 | #-Dcassandra.config=directory 24 | 25 | # Sets the initial partitioner token for a node the first time the node is started. 26 | #-Dcassandra.initial_token=token 27 | 28 | # Set to false to start Cassandra on a node but not have the node join the cluster. 29 | #-Dcassandra.join_ring=true|false 30 | 31 | # Set to false to clear all gossip state for the node on restart. Use when you have changed node 32 | # information in cassandra.yaml (such as listen_address). 33 | #-Dcassandra.load_ring_state=true|false 34 | 35 | # Enable pluggable metrics reporter. See Pluggable metrics reporting in Cassandra 2.0.2. 36 | #-Dcassandra.metricsReporterConfigFile=file 37 | 38 | # Set the port on which the CQL native transport listens for clients. (Default: 9042) 39 | #-Dcassandra.native_transport_port=port 40 | 41 | # Overrides the partitioner. (Default: org.apache.cassandra.dht.Murmur3Partitioner) 42 | #-Dcassandra.partitioner=partitioner 43 | 44 | # To replace a node that has died, restart a new node in its place specifying the address of the 45 | # dead node. The new node must not have any data in its data directory, that is, it must be in the 46 | # same state as before bootstrapping. 47 | #-Dcassandra.replace_address=listen_address or broadcast_address of dead node 48 | 49 | # Allow restoring specific tables from an archived commit log. 50 | #-Dcassandra.replayList=table 51 | 52 | # Allows overriding of the default RING_DELAY (1000ms), which is the amount of time a node waits 53 | # before joining the ring. 54 | #-Dcassandra.ring_delay_ms=ms 55 | 56 | # Set the port for the Thrift RPC service, which is used for client connections. (Default: 9160) 57 | #-Dcassandra.rpc_port=port 58 | 59 | # Set the SSL port for encrypted communication. (Default: 7001) 60 | #-Dcassandra.ssl_storage_port=port 61 | 62 | # Enable or disable the native transport server. See start_native_transport in cassandra.yaml. 63 | # cassandra.start_native_transport=true|false 64 | 65 | # Enable or disable the Thrift RPC server. (Default: true) 66 | #-Dcassandra.start_rpc=true/false 67 | 68 | # Set the port for inter-node communication. (Default: 7000) 69 | #-Dcassandra.storage_port=port 70 | 71 | # Set the default location for the trigger JARs. (Default: conf/triggers) 72 | #-Dcassandra.triggers_dir=directory 73 | 74 | # For testing new compaction and compression strategies. It allows you to experiment with different 75 | # strategies and benchmark write performance differences without affecting the production workload. 76 | #-Dcassandra.write_survey=true 77 | 78 | # To disable configuration via JMX of auth caches (such as those for credentials, permissions and 79 | # roles). This will mean those config options can only be set (persistently) in cassandra.yaml 80 | # and will require a restart for new values to take effect. 81 | #-Dcassandra.disable_auth_caches_remote_configuration=true 82 | 83 | ######################## 84 | # GENERAL JVM SETTINGS # 85 | ######################## 86 | 87 | # enable assertions. disabling this in production will give a modest 88 | # performance benefit (around 5%). 89 | <% if node['cassandra']['enable_assertions'] %> 90 | -ea 91 | <% end %> 92 | 93 | 94 | # enable thread priorities, primarily so we can give periodic tasks 95 | # a lower priority to avoid interfering with client workload 96 | -XX:+UseThreadPriorities 97 | 98 | # allows lowering thread priority without being root on linux - probably 99 | # not necessary on Windows but doesn't harm anything. 100 | # see http://tech.stolsvik.com/2010/01/linux-java-thread-priorities-workar 101 | -XX:ThreadPriorityPolicy=42 102 | 103 | # Enable heap-dump if there's an OOM 104 | <% if node['cassandra']['heap_dump'] -%> 105 | -XX:+HeapDumpOnOutOfMemoryError 106 | <% end -%> 107 | 108 | # Per-thread stack size. 109 | -Xss<%= node['cassandra']['xss'] %> 110 | 111 | # Larger interned string table, for gossip's benefit (CASSANDRA-6410) 112 | -XX:StringTableSize=1000003 113 | 114 | # Make sure all memory is faulted and zeroed on startup. 115 | # This helps prevent soft faults in containers and makes 116 | # transparent hugepage allocation more effective. 117 | <% if node['cassandra']['jvm']['always_pre_touch'] -%> 118 | -XX:+AlwaysPreTouch 119 | <% else %> 120 | -XX:-AlwaysPreTouch 121 | <% end -%> 122 | 123 | # Disable biased locking as it does not benefit Cassandra. 124 | <% if node['cassandra']['jvm']['use_biased_locking'] -%> 125 | -XX:+UseBiasedLocking 126 | <% else %> 127 | -XX:-UseBiasedLocking 128 | <% end -%> 129 | 130 | # Enable thread-local allocation blocks and allow the JVM to automatically 131 | # resize them at runtime. 132 | <% if node['cassandra']['jvm']['use_tlab'] -%> 133 | -XX:+UseTLAB 134 | <% else %> 135 | -XX:-UseTLAB 136 | <% end -%> 137 | 138 | <% if node['cassandra']['jvm']['resize_tlab'] -%> 139 | -XX:+ResizeTLAB 140 | <% else %> 141 | -XX:-ResizeTLAB 142 | <% end -%> 143 | 144 | -XX:+UseNUMA 145 | 146 | 147 | # http://www.evanjones.ca/jvm-mmap-pause.html 148 | -XX:+PerfDisableSharedMem 149 | 150 | # Prefer binding to IPv4 network intefaces (when net.ipv6.bindv6only=1). See 151 | # http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6342561 (short version: 152 | # comment out this entry to enable IPv6 support). 153 | -Djava.net.preferIPv4Stack=true 154 | 155 | ### Debug options 156 | 157 | # uncomment to enable flight recorder 158 | #-XX:+UnlockCommercialFeatures 159 | #-XX:+FlightRecorder 160 | 161 | # uncomment to have Cassandra JVM listen for remote debuggers/profilers on port 1414 162 | #-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1414 163 | 164 | # uncomment to have Cassandra JVM log internal method compilation (developers only) 165 | #-XX:+UnlockDiagnosticVMOptions 166 | #-XX:+LogCompilation 167 | 168 | ################# 169 | # HEAP SETTINGS # 170 | ################# 171 | 172 | # Heap size is automatically calculated by cassandra-env based on this 173 | # formula: max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB)) 174 | # That is: 175 | # - calculate 1/2 ram and cap to 1024MB 176 | # - calculate 1/4 ram and cap to 8192MB 177 | # - pick the max 178 | # 179 | # For production use you may wish to adjust this for your environment. 180 | # If that's the case, uncomment the -Xmx and Xms options below to override the 181 | # automatic calculation of JVM heap memory. 182 | # 183 | # It is recommended to set min (-Xms) and max (-Xmx) heap sizes to 184 | # the same value to avoid stop-the-world GC pauses during resize, and 185 | # so that we can lock the heap in memory on startup to prevent any 186 | # of it from being swapped out. 187 | #-Xms4G 188 | #-Xmx4G 189 | <% if node['cassandra']['jvm'] && node['cassandra']['jvm']['xms'] -%> 190 | # (set via node['cassandra']['jvm']['xms']) 191 | -Xms<%= node['cassandra']['jvm']['xms'] %> 192 | <% end -%> 193 | <% if node['cassandra']['jvm'] && node['cassandra']['jvm']['xmx'] -%> 194 | # (set via node['cassandra']['jvm']['xmx']) 195 | -Xmx<%= node['cassandra']['jvm']['xmx'] %> 196 | <% end -%> 197 | 198 | # Young generation size is automatically calculated by cassandra-env 199 | # based on this formula: min(100 * num_cores, 1/4 * heap size) 200 | # 201 | # The main trade-off for the young generation is that the larger it 202 | # is, the longer GC pause times will be. The shorter it is, the more 203 | # expensive GC will be (usually). 204 | # 205 | # It is not recommended to set the young generation size if using the 206 | # G1 GC, since that will override the target pause-time goal. 207 | # More info: http://www.oracle.com/technetwork/articles/java/g1gc-1984535.html 208 | # 209 | # The example below assumes a modern 8-core+ machine for decent 210 | # times. If in doubt, and if you do not particularly want to tweak, go 211 | # 100 MB per physical CPU core. 212 | #-Xmn800M 213 | <% if node['cassandra']['jvm'] && node['cassandra']['jvm']['xmn'] -%> 214 | # (set via node['cassandra']['jvm']['xmn']) 215 | -Xmn<%= node['cassandra']['jvm']['xmn'] %> 216 | <% end -%> 217 | 218 | ################# 219 | # GC SETTINGS # 220 | ################# 221 | 222 | ### CMS Settings 223 | 224 | <% if !node['cassandra']['jvm']['g1'] -%> 225 | -XX:+UseParNewGC 226 | -XX:+UseConcMarkSweepGC 227 | -XX:+CMSParallelRemarkEnabled 228 | -XX:CMSInitiatingOccupancyFraction=<%= node['cassandra']['gc_cms_initiating_occupancy_fraction'] %> 229 | -XX:+UseCMSInitiatingOccupancyOnly 230 | -XX:CMSWaitDuration=10000 231 | -XX:+CMSParallelInitialMarkEnabled 232 | -XX:+CMSEdenChunksRecordAlways 233 | # some JVMs will fill up their heap when accessed via JMX, see CASSANDRA-6541 234 | -XX:+CMSClassUnloadingEnabled 235 | <% end -%> 236 | 237 | -XX:SurvivorRatio=<%= node['cassandra']['gc_survivor_ratio'] %> 238 | -XX:MaxTenuringThreshold=<%= node['cassandra']['gc_max_tenuring_threshold'] %> 239 | 240 | ### G1 Settings (experimental, comment previous section and uncomment section below to enable) 241 | 242 | ## Use the Hotspot garbage-first collector. 243 | #-XX:+UseG1GC 244 | <% if node['cassandra']['jvm']['g1'] -%> 245 | -XX:+UseG1GC 246 | <% end -%> 247 | # 248 | ## Have the JVM do less remembered set work during STW, instead 249 | ## preferring concurrent GC. Reduces p99.9 latency. 250 | #-XX:G1RSetUpdatingPauseTimePercent=5 251 | <% if node['cassandra']['jvm']['g1_rset_updating_pause_time_percent'] -%> 252 | -XX:G1RSetUpdatingPauseTimePercent=<%= node['cassandra']['jvm']['g1_rset_updating_pause_time_percent'] %> 253 | <% end -%> 254 | # 255 | ## Main G1GC tunable: lowering the pause target will lower throughput and vise versa. 256 | ## 200ms is the JVM default and lowest viable setting 257 | ## 1000ms increases throughput. Keep it smaller than the timeouts in cassandra.yaml. 258 | #-XX:MaxGCPauseMillis=500 259 | <% if node['cassandra']['jvm']['max_gc_pause_millis'] -%> 260 | -XX:MaxGCPauseMillis=<%= node['cassandra']['jvm']['max_gc_pause_millis'] %> 261 | <% end -%> 262 | 263 | 264 | ## Optional G1 Settings 265 | 266 | # Save CPU time on large (>= 16GB) heaps by delaying region scanning 267 | # until the heap is 70% full. The default in Hotspot 8u40 is 40%. 268 | #-XX:InitiatingHeapOccupancyPercent=70 269 | <% if node['cassandra']['jvm']['heap_occupancy_threshold'] -%> 270 | -XX:InitiatingHeapOccupancyPercent=<%= node['cassandra']['jvm']['heap_occupancy_threshold'] %> 271 | <% end -%> 272 | 273 | # Sets the size of a G1 region. The value will be a power of two and can range 274 | # from 1MB to 32MB. The goal is to have around 2048 regions based on the minimum 275 | # Java heap size. 276 | <% if node['cassandra']['jvm']['g1_heap_region_size'] -%> 277 | -XX:G1HeapRegionSize=<%= node['cassandra']['jvm']['g1_heap_region_size'] %> 278 | <% end -%> 279 | 280 | # For systems with > 8 cores, the default ParallelGCThreads is 5/8 the number of logical cores. 281 | # Otherwise equal to the number of cores when 8 or less. 282 | # Machines with > 10 cores should try setting these to <= full cores. 283 | #-XX:ParallelGCThreads=16 284 | <% if node['cassandra']['jvm']['max_parallel_gc_threads'] -%> 285 | -XX:ParallelGCThreads=<%= node['cassandra']['jvm']['max_parallel_gc_threads'] %> 286 | <% end -%> 287 | # By default, ConcGCThreads is 1/4 of ParallelGCThreads. 288 | # Setting both to the same value can reduce STW durations. 289 | #-XX:ConcGCThreads=16 290 | <% if node['cassandra']['jvm']['max_conc_gc_threads'] -%> 291 | -XX:ConcGCThreads=<%= node['cassandra']['jvm']['max_conc_gc_threads'] %> 292 | <% end -%> 293 | 294 | # Additional options 295 | <% if node['cassandra']['jvm']['parallel_ref_proc'] -%> 296 | -XX:+ParallelRefProcEnabled 297 | <% else %> 298 | -XX:-ParallelRefProcEnabled 299 | <% end -%> 300 | 301 | ### GC logging options -- uncomment to enable 302 | 303 | <% if node['cassandra']['jvm']['gcdetail'] -%> 304 | -XX:+PrintGCDetails 305 | -XX:+PrintGCDateStamps 306 | -XX:+PrintHeapAtGC 307 | -XX:+PrintTenuringDistribution 308 | -XX:+PrintGCApplicationStoppedTime 309 | -XX:+PrintPromotionFailure 310 | #-XX:PrintFLSStatistics=1 311 | #-Xloggc:/var/log/cassandra/gc.log 312 | -XX:+UseGCLogFileRotation 313 | -XX:NumberOfGCLogFiles=10 314 | -XX:GCLogFileSize=10M 315 | <% else -%> 316 | #-XX:+PrintGCDetails 317 | #-XX:+PrintGCDateStamps 318 | #-XX:+PrintHeapAtGC 319 | #-XX:+PrintTenuringDistribution 320 | #-XX:+PrintGCApplicationStoppedTime 321 | #-XX:+PrintPromotionFailure 322 | #-XX:PrintFLSStatistics=1 323 | #-Xloggc:/var/log/cassandra/gc.log 324 | #-XX:+UseGCLogFileRotation 325 | #-XX:NumberOfGCLogFiles=10 326 | #-XX:GCLogFileSize=10M 327 | <% end -%> 328 | -------------------------------------------------------------------------------- /templates/default/log4j-server.properties.erb: -------------------------------------------------------------------------------- 1 | # 2 | # This file is managed by Chef. 3 | # Do NOT modify this file directly. 4 | # 5 | # Licensed to the Apache Software Foundation (ASF) under one 6 | # or more contributor license agreements. See the NOTICE file 7 | # distributed with this work for additional information 8 | # regarding copyright ownership. The ASF licenses this file 9 | # to you under the Apache License, Version 2.0 (the 10 | # "License"); you may not use this file except in compliance 11 | # with the License. You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | 21 | # for production, you should probably set pattern to %c instead of %l. 22 | # (%l is slower.) 23 | 24 | # output messages into a rolling log file as well as stdout 25 | log4j.rootLogger=<%= node['cassandra']['rootlogger'] %> 26 | 27 | # stdout 28 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 29 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 30 | log4j.appender.stdout.layout.ConversionPattern=%5p %d{HH:mm:ss,SSS} %m%n 31 | 32 | # rolling log file 33 | log4j.appender.R=org.apache.log4j.RollingFileAppender 34 | log4j.appender.R.maxFileSize=20MB 35 | log4j.appender.R.maxBackupIndex=50 36 | log4j.appender.R.layout=org.apache.log4j.PatternLayout 37 | log4j.appender.R.layout.ConversionPattern=%5p [%t] %d{ISO8601} %F (line %L) %m%n 38 | # Edit the next line to point to your logs directory 39 | log4j.appender.R.File=<%= node['cassandra']['log_dir'] %>/system.log 40 | 41 | # Application logging options 42 | #log4j.logger.org.apache.cassandra=DEBUG 43 | #log4j.logger.org.apache.cassandra.db=DEBUG 44 | #log4j.logger.org.apache.cassandra.service.StorageProxy=DEBUG 45 | 46 | # Adding this to avoid thrift logging disconnect errors. 47 | log4j.logger.org.apache.thrift.server.TNonblockingServer=ERROR 48 | 49 | <% node['cassandra']['log4j'].each do |key, value| %> 50 | <%= key %>=<%= value %> 51 | <% end %> 52 | 53 | -------------------------------------------------------------------------------- /templates/default/logback-tools.xml.erb: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | 28 | %-5level %date{HH:mm:ss,SSS} %msg%n 29 | 30 | 31 | WARN 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /templates/default/logback.xml.erb: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | INFO 35 | 36 | <%= node['cassandra']['log_dir'] %>/system.log 37 | 38 | <%= node['cassandra']['log_dir'] %>/system.log.%i.zip 39 | <%= node['cassandra']['logback']['file']['min_index'] %> 40 | <%= node['cassandra']['logback']['file']['max_index'] %> 41 | 42 | 43 | <%= node['cassandra']['logback']['file']['max_file_size'] %> 44 | 45 | 46 | <%= node['cassandra']['logback']['file']['pattern'] %> 47 | 50 | 51 | 52 | 53 | <% if node['cassandra']['logback']['debug']['enable'] -%> 54 | 55 | 56 | 57 | <%= node['cassandra']['log_dir'] %>/debug.log 58 | 59 | <%= node['cassandra']['log_dir'] %>/debug.log.%i.zip 60 | <%= node['cassandra']['logback']['debug']['min_index'] %> 61 | <%= node['cassandra']['logback']['debug']['max_index'] %> 62 | 63 | 64 | <%= node['cassandra']['logback']['debug']['max_file_size'] %> 65 | 66 | 67 | <%= node['cassandra']['logback']['debug']['pattern'] %> 68 | 69 | 70 | 71 | 72 | 73 | 74 | 1024 75 | 0 76 | true 77 | 78 | 79 | <% end -%> 80 | 81 | <% if node['cassandra']['logback']['stdout']['enable'] -%> 82 | 83 | 84 | INFO 85 | 86 | 87 | <%= node['cassandra']['logback']['stdout']['pattern'] %> 88 | 89 | 90 | <% end -%> 91 | 92 | <% if node['cassandra']['logback']['syslog']['enable'] -%> 93 | 94 | <%= node['cassandra']['logback']['syslog']['host'] %> 95 | <%= node['cassandra']['logback']['syslog']['facility'] %> 96 | <%= node['cassandra']['logback']['syslog']['pattern'] %> 97 | 98 | <% end -%> 99 | 100 | 103 | 104 | 105 | 106 | <% if node['cassandra']['logback']['debug']['enable'] -%> 107 | 108 | <% end -%> 109 | <% if node['cassandra']['logback']['stdout']['enable'] -%> 110 | 111 | <% end -%> 112 | <% if node['cassandra']['logback']['syslog']['enable'] -%> 113 | 114 | <% end -%> 115 | 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /templates/default/opscenter-agent.conf.erb: -------------------------------------------------------------------------------- 1 | # 2 | # This file is managed by Chef. 3 | # Do NOT modify this file directly. 4 | # 5 | stomp_interface: "<%= @server_ip %>" 6 | 7 | use_ssl: <%= node['cassandra']['opscenter']['agent']['use_ssl'] ? "1" : "0" %> 8 | -------------------------------------------------------------------------------- /templates/default/opscenterd.conf.erb: -------------------------------------------------------------------------------- 1 | # 2 | # This file is managed by Chef. 3 | # Do NOT modify this file directly. 4 | # 5 | [jmx] 6 | # The default jmx port for Cassandra >= 0.8.0 is 7199. If you are using 7 | # Cassandra 0.7.*, the default is 8080, and you should change this to 8 | # reflect that. 9 | port = 7199 10 | 11 | [webserver] 12 | port = <%= node['cassandra']['opscenter']['server']['port'] %> 13 | interface = <%= node['cassandra']['opscenter']['server']['interface'] %> 14 | 15 | [agents] 16 | use_ssl = <%= node['cassandra']['opscenter']['agent']['use_ssl'] ? "1" : "0" %> 17 | 18 | [logging] 19 | # level may be TRACE, DEBUG, INFO, WARN, or ERROR 20 | #level = INFO 21 | 22 | [cassandra] 23 | # a comma-separated list of places to try for a connection to your Cassandra 24 | # cluster: 25 | seed_hosts = <%= if node['cassandra']['seeds'].kind_of?(Array) then node['cassandra']['seeds'].join(",") else node['cassandra']['seeds'] end %> 26 | 27 | # the API (Thrift) port on your Cassandra cluster 28 | #api_port = 9160 29 | 30 | [authentication] 31 | # if this file does not exist, there will be no password protection. Use the 32 | # set_passwd.py tool (included with OpsCenter) to set passwords. 33 | <% if node['cassandra']['opscenter']['server']['authentication'] %> 34 | enabled = True 35 | <% end %> 36 | passwd_file = /etc/opscenter/.passwd 37 | 38 | [cassandra_metrics] 39 | # A list of keyspaces to *not* collect metrics for, separated by commas 40 | ignored_keyspaces = <%= node['cassandra']['opscenter']['cassandra_metrics']['ignored_keyspaces'].join(", ") %> 41 | 42 | # A list of column families to *not* collect metrics for, separated 43 | # by commas. Each entry should be of the form "ks.cf". For example: 44 | # metrics_ignored_column_families = system.NodeInfo, system.Schema, Keyspace1.Standard1 45 | <% if node['cassandra']['opscenter']['cassandra_metrics']['ignored_column_families'].length > 0 %> 46 | ignored_column_families = <%= node['cassandra']['opscenter']['cassandra_metrics']['ignored_column_families'].join(", ") %> 47 | <% else %> 48 | #ignored_column_families = 49 | <% end %> 50 | 51 | # OpsCenter stores performance data for your cluster at multiple granularities. 52 | # These values determine the expiration of each level of granularity. A value of 53 | # -1 indicates to never expire data for that level. Newly set expiration times 54 | # apply to data inserted after the value was changed and OpsCenter was restarted. 55 | # Data inserted prior to that point will expire at the previously specified rate. 56 | # Expire 1 minute data points after 7 days 57 | 1min_ttl = <%= node['cassandra']['opscenter']['cassandra_metrics']['1min_ttl'] %> 58 | # Expire 5 minute data points after 4 weeks (28 days) 59 | 5min_ttl = <%= node['cassandra']['opscenter']['cassandra_metrics']['5min_ttl'] %> 60 | # Expire 2 hour data points after 365 days 61 | 2hr_ttl = <%= node['cassandra']['opscenter']['cassandra_metrics']['2hr_ttl'] %> 62 | 63 | <% node['cassandra']['opscenter']['custom_configuration'].each do |section, config| %> 64 | <% if %w(http_proxy_settings security definitions ldap stat_reporter hadoop spark cloud repair_service ui request_tracker clusters failover lifecycle_manager agents).include? section %> 65 | [<%= section %>] 66 | <% config.each do |key,value| %> 67 | <%= key %> = <%= value %> 68 | <% end %> 69 | 70 | <% end %> 71 | <% end %> 72 | 73 | -------------------------------------------------------------------------------- /templates/default/rhel.cassandra.init.erb: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This file is managed by Chef. 4 | # Do NOT modify this file directly. 5 | # 6 | # chkconfig: 345 20 80 7 | # description: <%=node['cassandra']['service_name']%> daemon 8 | # processname: <%=node['cassandra']['service_name']%> 9 | 10 | export CASSANDRA_HOME=<%=node['cassandra']['installation_dir']%> 11 | export CASSANDRA_CONF=<%=node['cassandra']['conf_dir']%> 12 | NODETOOL=$CASSANDRA_HOME/bin/nodetool 13 | 14 | SERVICE_USER=<%=node['cassandra']['user']%> 15 | SERVICE_GROUP=<%=node['cassandra']['group']%> 16 | 17 | PROGRAM=<%=node['cassandra']['service_name']%> 18 | SERVICE_PID_FILE=<%=node['cassandra']['pid_dir']%>/$PROGRAM.pid 19 | 20 | SERVICE_EXEC=$CASSANDRA_HOME/bin/cassandra 21 | 22 | SERVICE_LOG_FILE=<%=node['cassandra']['log_dir']%>/boot.log 23 | SERVICE_LOCK=/var/lock/subsys/$PROGRAM 24 | 25 | WAIT_FOR_START=10 26 | 27 | # Instead set ulimit for the user 28 | # FD_LIMIT=100000 29 | # ulimit -l unlimited 30 | # ulimit -n "$FD_LIMIT" 31 | 32 | [ -e $SERVICE_EXEC ] || { 33 | echo "$PROGRAM missing $SERVICE_EXEC [failed]" 34 | exit 1 35 | } 36 | 37 | [ -e $CASSANDRA_HOME/lib/apache-cassandra-<%=node['cassandra']['version']%>.jar ] || { 38 | echo "$PROGRAM missing $CASSANDRA_HOME/lib/apache-cassandra-<%=node['cassandra']['version']%>.jar [failed]" 39 | exit 1 40 | } 41 | 42 | [ -e $CASSANDRA_CONF/cassandra.yaml ] || { 43 | echo "$PROGRAM missing $CASSANDRA_CONF/cassandra.yaml [failed]" 44 | exit 1 45 | } 46 | 47 | [ -e $CASSANDRA_CONF/cassandra-env.sh ] || { 48 | echo "$PROGRAM missing $CASSANDRA_CONF/cassandra-env.sh [failed]" 49 | exit 0 50 | } 51 | 52 | . /etc/init.d/functions 53 | 54 | RETVAL=0 55 | 56 | # Common 57 | service_start_pre_check() { 58 | if [ -s $SERVICE_PID_FILE ]; then 59 | process_pid=$(cat $SERVICE_PID_FILE) 60 | ps -p $process_pid > /dev/null 61 | if [ $? == 0 ]; then 62 | echo -n "$PROGRAM is already running (pid $process_pid) .." 63 | echo 64 | exit 0 65 | else 66 | echo -n "$PROGRAM is dead and pid file exists ($SERVICE_PID_FILE) .." 67 | echo 68 | exit 1 69 | fi 70 | fi 71 | } 72 | 73 | service_stop_pre_check() { 74 | if [ ! -f $SERVICE_PID_FILE ]; then 75 | echo "$PROGRAM is already stopped " 76 | # echo_success 77 | exit 0 78 | else 79 | process_pid=$(cat $SERVICE_PID_FILE) 80 | ps -p $process_pid > /dev/null 81 | if [ $? != 0 ]; then 82 | rm -fr $SERVICE_PID_FILE 83 | echo "$PROGRAM is dead and pid file exists ($SERVICE_PID_FILE). pid file removed " 84 | # echo_success 85 | exit 0 86 | fi 87 | fi 88 | echo 89 | } 90 | 91 | service_start() { 92 | service_start_pre_check 93 | echo -n "Starting $PROGRAM .." 94 | daemon --user $SERVICE_USER $SERVICE_EXEC -p $SERVICE_PID_FILE >> $SERVICE_LOG_FILE 2>&1 95 | RETVAL=$? 96 | if [ $RETVAL = 0 ]; then 97 | echo_success 98 | else 99 | echo_failure 100 | fi 101 | echo 102 | return $RETVAL 103 | } 104 | 105 | service_stop() { 106 | service_stop_pre_check 107 | 108 | echo "executing nodetool disablethrift .." 109 | $NODETOOL -h <%=node['ipaddress']%> disablethrift 110 | [ $? -eq 0 ] || { 111 | echo "failed to execute disablethrift .." 112 | } 113 | sleep 3 114 | 115 | echo "executing nodetool disablegossip .." 116 | $NODETOOL -h <%=node['ipaddress']%> disablegossip 117 | [ $? -eq 0 ] || { 118 | echo "failed to execute disablegossip .." 119 | } 120 | sleep 3 121 | 122 | echo "executing nodetool drain .." 123 | $NODETOOL -h <%=node['ipaddress']%> drain 124 | [ $? -eq 0 ] || { 125 | echo "failed to execute drain .." 126 | } 127 | sleep 3 128 | 129 | echo -n "Shutting down $PROGRAM .. " 130 | killproc -p $SERVICE_PID_FILE $PROGRAM 131 | RETVAL=$? 132 | echo 133 | 134 | } 135 | 136 | service_status() { 137 | status -p $SERVICE_PID_FILE $PROGRAM 138 | RETVAL=$? 139 | } 140 | 141 | case "$1" in 142 | start) 143 | service_start 144 | ;; 145 | stop) 146 | service_stop 147 | ;; 148 | status) 149 | service_status 150 | ;; 151 | restart) 152 | service_stop 153 | sleep 5 154 | service_start 155 | ;; 156 | *) 157 | echo "Usage: $0 {start|stop|status|restart}" 158 | RETVAL=1 159 | esac 160 | 161 | exit $RETVAL 162 | -------------------------------------------------------------------------------- /test/integration/default/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'cassandra' do 4 | describe service('cassandra') do 5 | it { should be_enabled } 6 | end 7 | end 8 | 9 | describe 'cassandra configuration' do 10 | case os[:family] 11 | when 'ubuntu' 12 | cassandra_config = '/etc/cassandra/cassandra.yaml' 13 | when 'redhat' 14 | cassandra_config = '/etc/cassandra/conf/cassandra.yaml' 15 | end 16 | 17 | describe file(cassandra_config) do 18 | it { should be_file } 19 | end 20 | end 21 | 22 | describe 'cassandra user' do 23 | describe user('cassandra') do 24 | it { should exist } 25 | it { should belong_to_group 'cassandra' } 26 | it { should have_login_shell '/bin/bash' } 27 | it { should have_home_directory '/home/cassandra' } 28 | end 29 | end 30 | 31 | describe 'jmx port' do 32 | describe port(7199) do 33 | it { should be_listening.on('127.0.0.1').with('tcp') } 34 | it { should_not be_listening.on('0.0.0.0') } 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /test/integration/dsc21/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'cassandra' do 4 | describe package('dsc21') do 5 | it { should be_installed } 6 | end 7 | 8 | describe service('cassandra') do 9 | it { should be_enabled } 10 | end 11 | 12 | describe service('cassandra') do 13 | it { should be_running } 14 | end 15 | end 16 | 17 | describe 'jmx port' do 18 | describe port(7199) do 19 | it { should be_listening.on('127.0.0.1').with('tcp') } 20 | it { should not_be_listening.on('0.0.0.0') } 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /test/integration/dse/serverspec/dse_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'cassandra' do 4 | describe package('dsc20') do 5 | it { should be_installed } 6 | end 7 | 8 | describe service('cassandra') do 9 | it { should be_enabled } 10 | end 11 | 12 | describe service('cassandra') do 13 | it { should be_running } 14 | end 15 | end 16 | 17 | describe 'jmx port' do 18 | describe port(7199) do 19 | it { should be_listening.on('127.0.0.1').with('tcp') } 20 | it { should not_be_listening.on('0.0.0.0') } 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /test/integration/helpers/serverspec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | set :backend, :exec 4 | 5 | RSpec.configure do |config| 6 | config.expect_with :rspec do |c| 7 | c.syntax = :expect 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /test/integration/opscenter-agent-datastax/serverspec/opscenter_datastax_agent_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'opscenter-datastax-agent' do 4 | context 'installs, enables & runs the agent' do 5 | describe package('datastax-agent') do 6 | it { should be_installed } 7 | end 8 | 9 | describe service('datastax-agent') do 10 | it { should be_enabled } 11 | it { should be_running } 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /test/integration/opscenter-server-datastax/serverspec/opscenter_datastax_agent_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'opscenter-datastax-agent' do 4 | it 'installs, enables & runs the agent' do 5 | describe package('opscenter') do 6 | it { should be_installed } 7 | end 8 | 9 | describe service('opscenterd') do 10 | it { should be_enabled } 11 | end 12 | 13 | describe service('opscenterd') do 14 | it { should be_running } 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /test/integration/tarball/serverspec/tarball_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'cassandra' do 4 | describe package('dsc20') do 5 | it { should be_installed } 6 | end 7 | 8 | describe service('cassandra') do 9 | it { should be_enabled } 10 | end 11 | 12 | describe service('cassandra') do 13 | it { should be_running } 14 | end 15 | end 16 | 17 | describe 'jmx port' do 18 | describe port(7199) do 19 | it { should be_listening.on('127.0.0.1').with('tcp') } 20 | it { should not_be_listening.on('0.0.0.0') } 21 | end 22 | end 23 | --------------------------------------------------------------------------------