Use $CASSANDRA_HOME for default paths instead of /var

Patch by Tyler Hobbs; reviewed by Brandon Williams and Joshua McKenzie
for CASSANDRA-7136
This commit is contained in:
Tyler Hobbs 2014-06-05 15:38:41 -05:00
parent 4722fe70aa
commit 60be74230e
12 changed files with 104 additions and 33 deletions

View File

@ -6,6 +6,7 @@
* Reduce run time for CQL tests (CASSANDRA-7327)
* Fix heap size calculation on Windows (CASSANDRA-7352)
* RefCount native frames from netty (CASSANDRA-7245)
* Use tarball dir instead of /var for default paths (CASSANDRA-7136)
Merged from 2.0:
* Add per-CF range read request latency metrics (CASSANDRA-7338)
* Fix NPE in StreamTransferTask.createMessageForRetry() (CASSANDRA-7323)

View File

@ -18,6 +18,16 @@ using the provided 'sstableupgrade' tool.
New features
------------
- Default data and log locations have changed. If not set in
cassandra.yaml, the data file directory, commitlog directory,
and saved caches directory will default to $CASSANDRA_HOME/data/data,
$CASSANDRA_HOME/data/commitlog, and $CASSANDRA_HOME/data/saved_caches,
respectively. The log directory now defaults to $CASSANDRA_HOME/logs.
If not set, $CASSANDRA_HOME, defaults to the top-level directory of
the installation.
Note that this should only affect source checkouts and tarballs.
Deb and RPM packages will continue to use /var/lib/cassandra and
/var/log/cassandra in cassandra.yaml.
- SSTable data directory name is slightly changed. Each directory will
have hex string appended after CF name, e.g.
ks/cf-5be396077b811e3a3ab9dc4b9ac088d/

View File

@ -134,6 +134,7 @@ launch_service()
props="$3"
class="$4"
cassandra_parms="-Dlogback.configurationFile=logback.xml"
cassandra_parms="$cassandra_parms -Dcassandra.logdir=$CASSANDRA_HOME/logs -Dcassandra.storagedir=$CASSANDRA_HOME/data"
if [ "x$pidpath" != "x" ]; then
cassandra_parms="$cassandra_parms -Dcassandra-pidfile=$pidpath"

View File

@ -86,6 +86,7 @@ goto :eof
REM Include the build\classes\main directory so it works in development
set CASSANDRA_CLASSPATH=%CLASSPATH%;"%CASSANDRA_HOME%\build\classes\main";"%CASSANDRA_HOME%\build\classes\thrift"
set CASSANDRA_PARAMS=-Dcassandra -Dcassandra-foreground=yes
set CASSANDRA_PARAMS=%CASSANDRA_PARAMS% "-Dcassandra.logdir=%CASSANDRA_HOME%\logs" "-Dcassandra.storagedir=%CASSANDRA_HOME%\data"
if /i "%ARG%" == "INSTALL" goto doInstallOperation
if /i "%ARG%" == "UNINSTALL" goto doInstallOperation
goto runDaemon

View File

@ -77,6 +77,10 @@ Function Main
SetCassandraEnvironment
$pidfile = "$env:CASSANDRA_HOME/$pidfile"
$logdir = "$env:CASSANDRA_HOME/logs"
$storagedir = "$env:CASSANDRA_HOME/data"
$env:CASSANDRA_PARAMS = $env:CASSANDRA_PARAMS + " -Dcassandra.logdir=$logdir -Dcassandra.storagedir=$storagedir"
# Other command line params
if ($H)
{

View File

@ -93,12 +93,14 @@ partitioner: org.apache.cassandra.dht.Murmur3Partitioner
# Directories where Cassandra should store data on disk. Cassandra
# will spread data evenly across them, subject to the granularity of
# the configured compaction strategy.
data_file_directories:
- /var/lib/cassandra/data
# If not set, the default directory is $CASSANDRA_HOME/data/data.
# data_file_directories:
# - /var/lib/cassandra/data
# commit log. when running on magnetic HDD, this should be a
# separate spindle than the data directories.
commitlog_directory: /var/lib/cassandra/commitlog
# If not set, the default directory is $CASSANDRA_HOME/data/commitlog.
# commitlog_directory: /var/lib/cassandra/commitlog
# policy for data disk failures:
# stop_paranoid: shut down gossip and Thrift even for single-sstable errors.
@ -200,7 +202,8 @@ counter_cache_save_period: 7200
# memory_allocator: NativeAllocator
# saved caches
saved_caches_directory: /var/lib/cassandra/saved_caches
# If not set, the default directory is $CASSANDRA_HOME/data/saved_caches.
# saved_caches_directory: /var/lib/cassandra/saved_caches
# commitlog_sync may be either "periodic" or "batch."
# When in batch mode, Cassandra won't ack writes until the commit log

View File

@ -20,9 +20,9 @@
<configuration scan="true">
<jmxConfigurator />
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/var/log/cassandra/system.log</file>
<file>${cassandra.logdir}/system.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>/var/log/cassandra/system.log.%i.zip</fileNamePattern>
<fileNamePattern>${cassandra.logdir}/system.log.%i.zip</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>20</maxIndex>
</rollingPolicy>

2
debian/control vendored
View File

@ -3,7 +3,7 @@ Section: misc
Priority: extra
Maintainer: Eric Evans <eevans@apache.org>
Uploaders: Sylvain Lebresne <slebresne@apache.org>
Build-Depends: debhelper (>= 5), openjdk-7-jdk | java7-jdk, ant (>= 1.7), ant-optional (>= 1.7), python-support
Build-Depends: debhelper (>= 5), openjdk-7-jdk | java7-jdk, ant (>= 1.7), ant-optional (>= 1.7), python-support, dpatch
Homepage: http://cassandra.apache.org
Vcs-Git: http://git-wip-us.apache.org/repos/asf/cassandra.git
Vcs-Browser: https://git-wip-us.apache.org/repos/asf?p=cassandra.git

View File

@ -0,0 +1,36 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 001cassandra_yaml_dirs.dpatch by Tyler Hobbs <tyler@datastax.com>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.
@DPATCH@
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' cassandra~/conf/cassandra.yaml cassandra/conf/cassandra.yaml
--- cassandra~/conf/cassandra.yaml 2014-06-05 13:36:22.000000000 -0500
+++ cassandra/conf/cassandra.yaml 2014-06-05 13:39:20.569034040 -0500
@@ -94,13 +94,13 @@
# will spread data evenly across them, subject to the granularity of
# the configured compaction strategy.
# If not set, the default directory is $CASSANDRA_HOME/data/data.
-# data_file_directories:
-# - /var/lib/cassandra/data
+data_file_directories:
+ - /var/lib/cassandra/data
# commit log. when running on magnetic HDD, this should be a
# separate spindle than the data directories.
# If not set, the default directory is $CASSANDRA_HOME/data/commitlog.
-# commitlog_directory: /var/lib/cassandra/commitlog
+commitlog_directory: /var/lib/cassandra/commitlog
# policy for data disk failures:
# stop_paranoid: shut down gossip and Thrift even for single-sstable errors.
@@ -203,7 +203,7 @@
# saved caches
# If not set, the default directory is $CASSANDRA_HOME/data/saved_caches.
-# saved_caches_directory: /var/lib/cassandra/saved_caches
+saved_caches_directory: /var/lib/cassandra/saved_caches
# commitlog_sync may be either "periodic" or "batch."
# When in batch mode, Cassandra won't ack writes until the commit log

1
debian/patches/00list vendored Normal file
View File

@ -0,0 +1 @@
001cassandra_yaml_dirs.dpatch

6
debian/rules vendored
View File

@ -3,6 +3,8 @@
# Uncomment to enable verbose mode.
#export DH_VERBOSE=1
include /usr/share/dpatch/dpatch.make
ANT = /usr/bin/ant
VERSION = $(shell dpkg-parsechangelog | sed -ne 's/^Version: \(.*\)/\1/p')
@ -10,7 +12,7 @@ test:
dh_testdir
$(ANT) test
clean:
clean: unpatch
dh_testdir
dh_testroot
$(ANT) realclean
@ -22,7 +24,7 @@ clean:
dh_clean
build: build-stamp
build-stamp:
build-stamp: patch-stamp
dh_testdir
printf "version=%s" $(VERSION) > build.properties

View File

@ -452,36 +452,48 @@ public class DatabaseDescriptor
throw new ConfigurationException("in_memory_compaction_limit_in_mb must be a positive integer");
}
// if data dirs, commitlog dir, or saved caches dir are set in cassandra.yaml, use that. Otherwise,
// use -Dcassandra.storagedir (set in cassandra-env.sh) as the parent dir for data/, commitlog/, and saved_caches/
if (conf.commitlog_directory == null)
{
conf.commitlog_directory = System.getProperty("cassandra.storagedir", null);
if (conf.commitlog_directory == null)
throw new ConfigurationException("commitlog_directory is missing and -Dcassandra.storagedir is not set");
conf.commitlog_directory += File.separator + "commitlog";
}
if (conf.saved_caches_directory == null)
{
conf.saved_caches_directory = System.getProperty("cassandra.storagedir", null);
if (conf.saved_caches_directory == null)
throw new ConfigurationException("saved_caches_directory is missing and -Dcassandra.storagedir is not set");
conf.saved_caches_directory += File.separator + "saved_caches";
}
if (conf.data_file_directories == null)
{
String defaultDataDir = System.getProperty("cassandra.storagedir", null);
if (defaultDataDir == null)
throw new ConfigurationException("data_file_directories is not missing and -Dcassandra.storagedir is not set");
conf.data_file_directories = new String[]{ defaultDataDir + File.separator + "data" };
}
/* data file and commit log directories. they get created later, when they're needed. */
for (String datadir : conf.data_file_directories)
{
if (datadir.equals(conf.commitlog_directory))
throw new ConfigurationException("commitlog_directory must not be the same as any data_file_directories");
if (datadir.equals(conf.saved_caches_directory))
throw new ConfigurationException("saved_caches_directory must not be the same as any data_file_directories");
}
if (conf.commitlog_directory.equals(conf.saved_caches_directory))
throw new ConfigurationException("saved_caches_directory must not be the same as the commitlog_directory");
if (conf.concurrent_compactors == null)
conf.concurrent_compactors = Math.min(8, Math.max(2, Math.min(FBUtilities.getAvailableProcessors(), conf.data_file_directories.length)));
if (conf.concurrent_compactors <= 0)
throw new ConfigurationException("concurrent_compactors should be strictly greater than 0");
/* data file and commit log directories. they get created later, when they're needed. */
if (conf.commitlog_directory != null && conf.data_file_directories != null && conf.saved_caches_directory != null)
{
for (String datadir : conf.data_file_directories)
{
if (datadir.equals(conf.commitlog_directory))
throw new ConfigurationException("commitlog_directory must not be the same as any data_file_directories");
if (datadir.equals(conf.saved_caches_directory))
throw new ConfigurationException("saved_caches_directory must not be the same as any data_file_directories");
}
if (conf.commitlog_directory.equals(conf.saved_caches_directory))
throw new ConfigurationException("saved_caches_directory must not be the same as the commitlog_directory");
}
else
{
if (conf.commitlog_directory == null)
throw new ConfigurationException("commitlog_directory missing");
if (conf.data_file_directories == null)
throw new ConfigurationException("data_file_directories missing; at least one data directory must be specified");
if (conf.saved_caches_directory == null)
throw new ConfigurationException("saved_caches_directory missing");
}
if (conf.initial_token != null)
for (String token : tokensFromString(conf.initial_token))
partitioner.getTokenFactory().validate(token);