Cassandra升级

Cassandra升级

http://zhaoyanblog.com/archives/815.html
https://docs.datastax.com/en/upgrade/doc/upgrade/cassandra/upgradeCassandraDetails.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
第一步:更改配置文件
把Cassandra 2.0的配置通过比对, 把你原来cassandra.yaml配置文件里的参数移植到新版本的cassandra.yaml配置文件中。
因为cassandra2.1增加了一些配置,也减少了一些配置。所以你不能直接复制过来。你只要把新版的配置文件中有的配置项,从老的配置文件中挪过来就可以了。

第二步:创建快照,防止升级失败
nodetool snapshot keyspace -t snapshot_20150828 创建快照。如果你使用了JNA,快照是通过硬链接实现的,并不会增加磁盘空间,创建快照时间很短。

apache-cassandra-2.0.16/bin/nodetool snapshot forseti -t snapshot_20160420

第三步:停节点
先执行apache-cassandra-2.0.16/bin/nodetool drain关闭写入,同时把数据写入文件。
执行bin/nodetool stopdaemon停掉本节点。 --> sudo kill xxx

第四步: 启动新节点
sudo apache-cassandra-2.1.13/bin/cassandra

第五步:重复一到四步把集群所有机器都升级为新版本。这时候如果查询forseti的表应该是能查到数据的。 如果没有,说明有问题!

第六步:在所有节点执行升级sstable文件操作
apache-cassandra-2.1.13/bin/nodetool upgradesstables

具体测试步骤如下:

2.0版本: Soft/apache-cassandra-2.0.16
2.1版本: Soft/apache-cassandra-2.1.13

1
2
3
4
5
6
7
8
9
10
[可选]清空并重建数据目录(data_file_directories): sudo rm -rf /Users/zhengqh/data/cassandra && sudo mkdir /Users/zhengqh/data/cassandra
启动2.0的Cassandra: sudo Soft/apache-cassandra-2.0.16/bin/cassandra
生成数据:
关闭Cassandra: Soft/apache-cassandra-2.0.16/bin/nodetool drain
停止Cassandra: sudo kill -9 `sudo jps | grep CassandraDaemon |awk '{print $1}'`
☆☆☆☆☆更改2.1的配置文件:
启动2.1的Cassandra: sudo Soft/apache-cassandra-2.1.13/bin/cassandra
☆☆☆☆☆升级sstable文件:Soft/apache-cassandra-2.1.13/bin/nodetool upgradesstables
验证可以查询到数据:
重新写入新版本数据:

本机单节点测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#先确保环境变量中不存在CASSANDRA_HOME,如果存在,先去掉
echo $CASSANDRA_HOME

#如果是要一个干净的环境,或者说重复测试,需要清理旧数据,否则不要这么做
sudo kill -9 `sudo jps | grep CassandraDaemon |awk '{print $1}'`
sudo rm -rf /Users/zhengqh/data/cassandra && sudo mkdir /Users/zhengqh/data/cassandra
sudo Soft/apache-cassandra-2.0.16/bin/cassandra
#因为删除了全部数据库,所以要重新建库表结构
Soft/apache-cassandra-2.0.16/bin/cqlsh -f /Users/zhengqh/IdeaProjects/tongdun/vulcan/spark-cassandra/src/test/resources/forseti_velocity.sql

#插入测试数据(mac下批量插入用zsh解析不了括号,暂作罢,插一条试试)
Soft/apache-cassandra-2.0.16/bin/cqlsh -e "insert into forseti.velocity_global(attribute,partner_code,app_name,type,timestamp,sequence_id,event)values('migration_test','migration_test','migration_test','migration_test',111111111,'111111111','{accountLogin:1111111}')"
Soft/apache-cassandra-2.0.16/bin/cqlsh -e "select count(*) from forseti.velocity_global where attribute='migration_test' and type='migration_test';"

#停掉节点
Soft/apache-cassandra-2.0.16/bin/nodetool drain
sudo kill -9 `sudo jps | grep CassandraDaemon |awk '{print $1}'`

#备份配置文件
cp /Users/zhengqh/Soft/apache-cassandra-2.1.13/conf/cassandra.yaml /Users/zhengqh/Soft/apache-cassandra-2.1.13/conf/cassandra_2.1.yaml
#迁移配置文件,一个个对比太麻烦了,用代码实现
java -cp spark-cassandra-1.0.1-SNAPSHOT-jar-with-dependencies.jar cn.fraudmetrix.vulcan.velocity.upgrade.CassandraUpgradeLocal /Users/zhengqh/Soft/apache-cassandra-2.0.16/conf/ /Users/zhengqh/Soft/apache-cassandra-2.1.13/conf/

#启动新版本的Cassandra,确保可以正常启动,如果启动不了,会有错误提示信息的
sudo Soft/apache-cassandra-2.1.13/bin/cassandra

#升级sstables
Soft/apache-cassandra-2.1.13/bin/cqlsh -e "select count(*) from forseti.velocity_global where attribute='migration_test' and type='migration_test';"
Soft/apache-cassandra-2.1.13/bin/nodetool upgradesstables
Soft/apache-cassandra-2.1.13/bin/cqlsh -e "select count(*) from forseti.velocity_global where attribute='migration_test' and type='migration_test';"
Soft/apache-cassandra-2.1.13/bin/cqlsh -e "insert into forseti.velocity_global(attribute,partner_code,app_name,type,timestamp,sequence_id,event)values('migration_test','migration_test','migration_test','migration_test',111111111,'111111111','{accountLogin:1111111}')"
Soft/apache-cassandra-2.1.13/bin/cqlsh -e "select count(*) from forseti.velocity_global where attribute='migration_test' and type='migration_test';"

测试环境两个节点测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
scp apache-cassandra-2.1.13.tar.gz qihuang.zheng@192.168.6.53:~/
scp spark-cassandra-1.0.1-SNAPSHOT-jar-with-dependencies.jar qihuang.zheng@192.168.6.53:~/

#先确保环境变量中不存在CASSANDRA_HOME,如果存在,先去掉
sed -i -e "s/export CASSANDRA_HOME/#export CASSANDRA_HOME/g" .bashrc
source .bashrc
echo $CASSANDRA_HOME #如果还有值,退出重新登录
cat .bashrc |grep CASSANDRA_HOME

host=192.168.6.70
tar zxf apache-cassandra-2.1.13-bin.tar.gz && sudo mv apache-cassandra-2.1.13 /usr/install/
#测试环境无法直接用admin登,所以只好把权限改回来,否则后面java -cp无法用admin执行
sudo chown qihuang.zheng:users -R /usr/install/apache-cassandra-2.0.15
sudo chown qihuang.zheng:users -R /usr/install/apache-cassandra-2.1.13

#插入测试数据
for((i=1;i<=10;i++));do /usr/install/apache-cassandra-2.0.15/bin/cqlsh $host -e "insert into forseti.velocity_global(attribute,partner_code,app_name,type,timestamp,sequence_id,event)values('migration_test','migration_test','migration_test','migration_test',111111111,'111111111_$i','{accountLogin:1111111}')";done
/usr/install/apache-cassandra-2.0.15/bin/cqlsh $host -e "select count(*) from forseti.velocity_global where attribute='migration_test' and type='migration_test';"

#停掉节点
/usr/install/apache-cassandra-2.0.15/bin/nodetool drain -h $host
sudo kill -9 `sudo -u admin jps | grep CassandraDaemon |awk '{print $1}'`
ps -ef|grep cassandra

#################
#备份配置文件和修改配置文件
cp /usr/install/apache-cassandra-2.1.13/conf/cassandra.yaml /usr/install/apache-cassandra-2.1.13/conf/cassandra_2.1.yaml
java -cp spark-cassandra-1.0.1-SNAPSHOT-jar-with-dependencies.jar cn.fraudmetrix.vulcan.velocity.upgrade.CassandraUpgradeLocal /usr/install/apache-cassandra-2.0.15/conf/ /usr/install/apache-cassandra-2.1.13/conf/

#权限改回来
sudo chown admin:admin -R /usr/install/apache-cassandra-2.0.15
sudo chown admin:admin -R /usr/install/apache-cassandra-2.1.13

#还有seeds也要移植
cat /usr/install/apache-cassandra-2.0.15/conf/cassandra.yaml | grep cluster_name
cat /usr/install/apache-cassandra-2.1.13/conf/cassandra.yaml | grep cluster_name
seed1=`cat /usr/install/apache-cassandra-2.0.15/conf/cassandra.yaml | grep seeds`
seed2=`cat /usr/install/apache-cassandra-2.1.13/conf/cassandra.yaml | grep seeds`
sudo -u admin sed -i -e "s/$seed2/$seed1/g" /usr/install/apache-cassandra-2.1.13/conf/cassandra.yaml
#注意要检查有没有空格!

#DC也要一致
cat /usr/install/apache-cassandra-2.1.13/conf/cassandra.yaml | grep 192.168
cat /usr/install/apache-cassandra-2.0.15/conf/cassandra-rackdc.properties | grep DC
cat /usr/install/apache-cassandra-2.1.13/conf/cassandra-rackdc.properties | grep DC
#################

#启动新版本并升级sstables(如果启动失败,一般是因为配置文件没有迁移完全)
sudo -u admin /usr/install/apache-cassandra-2.1.13/bin/cassandra

/usr/install/apache-cassandra-2.1.13/bin/nodetool status
/usr/install/apache-cassandra-2.1.13/bin/cqlsh $host -e "select count(*) from forseti.velocity_global where attribute='migration_test' and type='migration_test';"
/usr/install/apache-cassandra-2.1.13/bin/nodetool upgradesstables
/usr/install/apache-cassandra-2.1.13/bin/cqlsh $host -e "select count(*) from forseti.velocity_global where attribute='migration_test' and type='migration_test';"
for((i=11;i<=20;i++));do /usr/install/apache-cassandra-2.1.13/bin/cqlsh $host -e "insert into forseti.velocity_global(attribute,partner_code,app_name,type,timestamp,sequence_id,event)values('migration_test','migration_test','migration_test','migration_test',111111111,'111111111_$i','{accountLogin:1111111}')";done
/usr/install/apache-cassandra-2.1.13/bin/cqlsh $host -e "select count(*) from forseti.velocity_global where attribute='migration_test' and type='migration_test';"

#更改软连接
sudo -u admin rm /usr/install/cassandra
sudo -u admin ln -s /usr/install/apache-cassandra-2.1.13 /usr/install/cassandra
ll /usr/install/cassandra

生产环境

211: sh cassandra-scp.sh 192.168.47.12

1
2
3
host=192.168.47.12
scp apache-cassandra-2.1.13.tar.gz $host:~/
scp spark-cassandra-1.0.1-SNAPSHOT-jar-with-dependencies.jar $host:~/

或者一个比较hack的方式:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[qihuang.zheng@spark047211 ~]$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
192.168.47.12 - - [25/Apr/2016 10:35:34] "GET / HTTP/1.1" 200 -
192.168.47.12 - - [25/Apr/2016 10:35:49] "GET /apache-cassandra-2.1.13-bin.tar.gz HTTP/1.0" 200 -
192.168.47.12 - - [25/Apr/2016 10:36:01] "GET /spark-cassandra-1.0.1-SNAPSHOT-jar-with-dependencies.jar HTTP/1.0" 200 -

[qihuang.zheng@mysql047012 ~]$ wget http://192.168.47.211:8000/apache-cassandra-2.1.13-bin.tar.gz
--2016-04-25 10:35:49-- http://192.168.47.211:8000/apache-cassandra-2.1.13-bin.tar.gz
正在连接 192.168.47.211:8000... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:24727850 (24M) [application/x-gzip]
正在保存至: “apache-cassandra-2.1.13-bin.tar.gz”
100%[==========================================>] 24,727,850 111M/s in 0.2s
2016-04-25 10:35:50 (111 MB/s) - 已保存 “apache-cassandra-2.1.13-bin.tar.gz” [24727850/24727850])

可以直接在211上生成新的配置文件,其他节点就不需要重新生成了只需要改下地址:

1
2
3
4
5
6
7
8
9
cp apache-cassandra-2.1.13/conf/cassandra.yaml apache-cassandra-2.1.13/conf/cassandra_2.1.yaml
java -cp spark-cassandra-1.0.1-SNAPSHOT-jar-with-dependencies.jar cn.fraudmetrix.vulcan.velocity.upgrade.CassandraUpgradeLocal apache-cassandra-2.0.15/conf/ apache-cassandra-2.1.13/conf/

[qihuang.zheng@spark047211 ~]$ cat apache-cassandra-2.1.13/conf/cassandra.yaml |grep 192.168
- seeds: "192.168.48.162,192.168.48.163"
listen_address: 192.168.47.211
rpc_address: 192.168.47.211
[qihuang.zheng@spark047211 ~]$ cat apache-cassandra-2.1.13/conf/cassandra-env.sh |grep 192.168
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=192.168.47.211"

在211上把cassandra-env.sh等共同的配置都整理好,只留下IP地址相关的在各个节点上自行更改,再打包

1
2
3
4
tar zxf apache-cassandra-2.1.13-bin.tar.gz
vi apache-cassandra-2.1.13/conf/cassandra-env.sh
...
tar zcvf apache-cassandra-2.1.13.tar.gz apache-cassandra-2.1.13

cassandra-env.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
export MALLOC_ARENA_MAX=4

#JVM_OPTS="$JVM_OPTS -ea"
JVM_OPTS="$JVM_OPTS -XX:PrintFLSStatistics=1"
JVM_OPTS="$JVM_OPTS -XX:+PrintSafepointStatistics"
JVM_OPTS="$JVM_OPTS -XX:+PrintClassHistogramBeforeFullGC"
JVM_OPTS="$JVM_OPTS -XX:+PrintClassHistogramAfterFullGC"

#JVM_OPTS="$JVM_OPTS -Xms${MAX_HEAP_SIZE}"
#JVM_OPTS="$JVM_OPTS -Xmx${MAX_HEAP_SIZE}"
#JVM_OPTS="$JVM_OPTS -Xmn${HEAP_NEWSIZE}"
JVM_OPTS="$JVM_OPTS -Xms16G"
JVM_OPTS="$JVM_OPTS -Xmx16G"
JVM_OPTS="$JVM_OPTS -Xmn4G"
JVM_OPTS="$JVM_OPTS -XX:MaxDirectMemorySize=6G"

# GC logging options -- uncomment to enable
JVM_OPTS="$JVM_OPTS -XX:+PrintGCDetails"
JVM_OPTS="$JVM_OPTS -XX:+PrintGCDateStamps"
JVM_OPTS="$JVM_OPTS -XX:+PrintGCApplicationStoppedTime"
JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/cassandra/gc-`date +%s`.log"

# JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>"
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=192.168.47.202"

if [ "x$LOCAL_JMX" = "x" ]; then
LOCAL_JMX=yes
fi

if [ "$LOCAL_JMX" = "yes" ]; then
JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.local.port=$JMX_PORT -XX:+DisableExplicitGC"
else

JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false"

cassandra_upgrade1.sh:更新配置文件,并重启

1
2
3
4
5
6
7
8
9
10
11
12
13
14
host=`ifconfig | grep "192.168.4" | awk '/inet addr/{sub("addr:",""); print $2}'`
cluster=$1
seeds=$2

tar zxf apache-cassandra-2.1.13.tar.gz
sed -i -e "s#forseti_cluster#$cluster#g" apache-cassandra-2.1.13/conf/cassandra.yaml
sed -i -e "s#192.168.47.211#$host#g" apache-cassandra-2.1.13/conf/cassandra.yaml
sed -i -e "s/192.168.48.162,192.168.48.163/$seeds/g" apache-cassandra-2.1.13/conf/cassandra.yaml
sed -i -e "s#192.168.47.211#$host#g" apache-cassandra-2.1.13/conf/cassandra-env.sh
mv apache-cassandra-2.1.13 /usr/install

#fp的DC名称也要迁移
#sed -i -e "s#dc=DC1#dc=DC3#g" /usr/install/apache-cassandra-2.1.13/conf/cassandra-rackdc.properties
#sed -i -e "s#/home/admin/cassandra/commitlog#/data/cassandra/commitlog#g" apache-cassandra-2.1.13/conf/cassandra.yaml

服务端升级步骤:

forseti_velocity

wget http://192.168.47.211:8000/apache-cassandra-2.1.13.tar.gz && wget http://192.168.47.211:8000/cassandra_upgrade1.sh && wget http://192.168.47.211:8000/cassandra_upgrade2.sh && wget http://192.168.47.211:8000/cassandra_upgrade3.sh
sh cassandra_upgrade1.sh forseti_velocity 192.168.48.162,192.168.48.163

sh cassandra_upgrade2.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
host=`ifconfig | grep "192.168.4" | awk '/inet addr/{sub("addr:",""); print $2}'`

#插入测试数据
for((i=1;i<=10;i++));do /usr/install/apache-cassandra-2.0.15/bin/cqlsh $host -e "insert into forseti.velocity_global(attribute,partner_code,app_name,type,timestamp,sequence_id,event)values('migration_test','migration_test','migration_test','migration_test',111111111,'111111111_$i','{accountLogin:1111111}')";done
/usr/install/apache-cassandra-2.0.15/bin/cqlsh $host -e "select count(*) from forseti.velocity_global where attribute='migration_test' and type='migration_test';"

#停掉节点
/usr/install/apache-cassandra-2.0.15/bin/nodetool drain -h $host
sudo kill -9 `sudo -u admin jps | grep CassandraDaemon |awk '{print $1}'`
ps -ef|grep cassandra
sleep 15s

#启动新版本并升级sstables(如果启动失败,一般是因为配置文件没有迁移完全)
sudo -u admin /usr/install/apache-cassandra-2.1.13/bin/cassandra

sh cassandra_upgrade3.sh

1
2
3
4
5
6
7
8
9
10
host=`ifconfig | grep "192.168.4" | awk '/inet addr/{sub("addr:",""); print $2}'`
/usr/install/apache-cassandra-2.1.13/bin/nodetool status
/usr/install/apache-cassandra-2.1.13/bin/cqlsh $host -e "select count(*) from forseti.velocity_global where attribute='migration_test' and type='migration_test';"
/usr/install/apache-cassandra-2.1.13/bin/nodetool upgradesstables
/usr/install/apache-cassandra-2.1.13/bin/cqlsh $host -e "select count(*) from forseti.velocity_global where attribute='migration_test' and type='migration_test';"
for((i=11;i<=20;i++));do /usr/install/apache-cassandra-2.1.13/bin/cqlsh $host -e "insert into forseti.velocity_global(attribute,partner_code,app_name,type,timestamp,sequence_id,event)values('migration_test','migration_test','migration_test','migration_test',111111111,'111111111_$i','{accountLogin:1111111}')";done
/usr/install/apache-cassandra-2.1.13/bin/cqlsh $host -e "select count(*) from forseti.velocity_global where attribute='migration_test' and type='migration_test';"

#更改软连接
sudo -u admin rm /usr/install/cassandra && sudo -u admin ln -s /usr/install/apache-cassandra-2.1.13 /usr/install/cassandra && ll /usr/install/cassandra && nodetool version

forseti_galaxy

wget http://192.168.47.211:8000/apache-cassandra-2.1.13.tar.gz && wget http://192.168.47.211:8000/cassandra_upgrade1_admin.sh
sh cassandra_upgrade1_admin.sh forseti_galaxy 192.168.49.56,192.168.49.57

admin用户执行:

1
2
3
4
5
6
7
8
9
10
host=`ifconfig | grep "192.168.4" | awk '/inet addr/{sub("addr:",""); print $2}'`
/usr/install/apache-cassandra-2.0.15/bin/nodetool flush
/usr/install/apache-cassandra-2.0.15/bin/nodetool drain -h $host
kill -9 `jps | grep CassandraDaemon |awk '{print $1}'`
sleep 5s
/usr/install/apache-cassandra-2.1.13/bin/cassandra

/usr/install/apache-cassandra-2.1.13/bin/nodetool status
rm /usr/install/cassandra && ln -s /usr/install/apache-cassandra-2.1.13 /usr/install/cassandra && ll /usr/install/cassandra
/usr/install/apache-cassandra-2.1.13/bin/nodetool upgradesstables

问题

在实践中遇到下面几个问题:

  1. 升级命令不能正常执行 –> 去掉CASSANDRA_HOME
  2. 找不到sstables –> 数据文件的目录要一致
  3. 还没升级sstable前,无法看到keyspace –> 种子节点要一样
  4. 可以看到keyspace,但是查询不到数据 -> 数据文件的目录要一致
  5. cassandra-rackdc.properties的RAC名称要一致,否则可能启动不起来

设置了CASSANDRA_HOME有问题,应该去掉

1
2
3
4
5
➜  apache-cassandra-2.1.13 bin/nodetool upgradesstables
objc[48843]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
Error opening zip file or JAR manifest missing : /Users/zhengqh/Soft/apache-cassandra-2.0.16/lib/jamm-0.3.0.jar
Error occurred during initialization of VM
agent library failed to init: instrument

执行bin/nodetool upgradesstables时,后台日志没有找到sstables.
实际上这只是说有些表没有sstable文件而已。因为这是在本地,没有其他节点,所以hints,peer_events是没有sstable文件的。

1
2
3
4
5
6
7
8
9
INFO  [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 14:43:13,958 CompactionManager.java:283 - No sstables for system.batchlog
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 14:43:13,959 CompactionManager.java:283 - No sstables for system.peer_events
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 14:43:13,959 CompactionManager.java:283 - No sstables for system.range_xfers
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 14:43:13,960 CompactionManager.java:283 - No sstables for system.paxos
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 14:43:13,962 CompactionManager.java:283 - No sstables for system.compactions_in_progress
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 14:43:13,962 CompactionManager.java:283 - No sstables for system.hints
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 14:43:13,963 CompactionManager.java:283 - No sstables for system.IndexInfo
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 14:43:13,968 CompactionManager.java:283 - No sstables for system_traces.sessions
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 14:43:13,968 CompactionManager.java:283 - No sstables for system_traces.events

那么如果只升级某些数据库呢,因为keyspace都还没有生成,也不能手工创建!

1
2
3
4
➜  apache-cassandra-2.1.13 bin/nodetool upgradesstables forseti velocity_global
objc[49473]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
nodetool: Keyspace [forseti] does not exist.
See 'nodetool help' or 'nodetool help <command>'.

使用cqlsh查看,连库都还没有生成:

1
2
3
4
5
6
7
➜  apache-cassandra-2.1.13 bin/cqlsh
Connected to forseti_cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 2.1.13 | CQL spec 3.2.1 | Native protocol v3]
Use HELP for help.
cqlsh> desc keyspaces;

system_traces system

原来是因为cluster_name不一致。 不过没有升级sstables之前,虽然可以看到表,但是查询不了.而且连system_traces也访问不了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
➜  apache-cassandra-2.1.13 bin/cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 2.1.13 | CQL spec 3.2.1 | Native protocol v3]
Use HELP for help.
cqlsh> desc keyspaces;

system_traces forseti system

cqlsh> use system;
cqlsh:system> use system_traces;
InvalidRequest: code=2200 [Invalid query] message="Keyspace 'system_traces' does not exist"
cqlsh:system> use forseti;
InvalidRequest: code=2200 [Invalid query] message="Keyspace 'forseti' does not exist"
cqlsh:system> use system;
cqlsh:system>

这就导致了nodetool status都不可以使用了。

1
2
➜  Soft apache-cassandra-2.1.13/bin/nodetool status
Error: The node does not have system_traces yet, probably still bootstrapping

问题原因:seeds不一样导致的! 更改成一样的,可以使用了!不过由于还没有升级sstable,还查不到数据

1
2
3
4
5
6
7
8
9
10
11
cqlsh> use forseti;
cqlsh:forseti> desc tables;

velocity_partner velocity_global

cqlsh:forseti> select * from velocity_partner limit 1;

attribute | partner_code | type | sequence_id | app_name | event | timestamp
-----------+--------------+------+-------------+----------+-------+-----------

(0 rows)

而且status也没有报错了:

1
2
3
4
5
6
7
➜  Soft apache-cassandra-2.1.13/bin/nodetool status
Datacenter: DC1
===============
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns Host ID Rack
UN 127.0.0.1 131.39 KB 256 ? b425e141-a2f8-44d5-b18f-6d6c4572491c RAC1

不过为什么查询不到数据呢。 原来是两个配置文件的data_file_directory不一致!
数据文件目录不一样,怎么可能会有数据呢! 所以修改成一样后,
重启的时候,却启动不来了,但是RAC1在上面明明就是RAC1啊,哪里来的RAC_1

1
2
3
4
5
6
ERROR 08:06:30 Fatal exception during initialization
org.apache.cassandra.exceptions.ConfigurationException: Cannot start node if snitch's rack (RAC1) differs from previous rack (RAC_1). Please fix the snitch or decommission and rebootstrap this node.
at org.apache.cassandra.db.SystemKeyspace.checkHealth(SystemKeyspace.java:644) ~[apache-cassandra-2.1.13.jar:2.1.13]
at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:290) [apache-cassandra-2.1.13.jar:2.1.13]
at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:564) [apache-cassandra-2.1.13.jar:2.1.13]
at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:653) [apache-cassandra-2.1.13.jar:2.1.13]

cassandra-rackdc.properties的2.0版本确实是RAC_1

1
2
3
4
5
6
7
8
9
➜  apache-cassandra-2.0.16 bin/nodetool status
objc[51578]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
Note: Ownership information does not include topology; for complete information, specify a keyspace
Datacenter: DC1
===============
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns Host ID Rack
UN 127.0.0.1 69.2 KB 256 100.0% 01fce417-2d6c-42c4-b6ee-056da7a62eae RAC_1
1
2
3
4
5
6
ERROR 00:37:35 Fatal exception during initialization
org.apache.cassandra.exceptions.ConfigurationException: Cannot start node if snitch's rack (r1) differs from previous rack (RAC1). Please fix the snitch or decommission and rebootstrap this node.
at org.apache.cassandra.db.SystemKeyspace.checkHealth(SystemKeyspace.java:644) ~[apache-cassandra-2.1.13.jar:2.1.13]
at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:290) [apache-cassandra-2.1.13.jar:2.1.13]
at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:564) [apache-cassandra-2.1.13.jar:2.1.13]
at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:653) [apache-cassandra-2.1.13.jar:2.1.13]

DC也必须是一样的:

1
2
3
4
5
6
ERROR 03:08:39 Fatal exception during initialization
org.apache.cassandra.exceptions.ConfigurationException: Cannot start node if snitch's data center (DC1) differs from previous data center (DC3). Please fix the snitch configuration, decommission and rebootstrap this node or use the flag -Dcassandra.ignore_dc=true.
at org.apache.cassandra.db.SystemKeyspace.checkHealth(SystemKeyspace.java:629) ~[apache-cassandra-2.1.13.jar:2.1.13]
at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:290) [apache-cassandra-2.1.13.jar:2.1.13]
at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:564) [apache-cassandra-2.1.13.jar:2.1.13]
at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:653) [apache-cassandra-2.1.13.jar:2.1.13]

YAML中seeds格式必须正确(空格缩进不对也是不行的):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
ERROR 03:07:23 Fatal configuration error
org.apache.cassandra.exceptions.ConfigurationException: Invalid yaml
at org.apache.cassandra.config.YamlConfigurationLoader.loadConfig(YamlConfigurationLoader.java:120) ~[apache-cassandra-2.1.13.jar:2.1.13]
at org.apache.cassandra.config.YamlConfigurationLoader.loadConfig(YamlConfigurationLoader.java:84) ~[apache-cassandra-2.1.13.jar:2.1.13]
at org.apache.cassandra.config.DatabaseDescriptor.loadConfig(DatabaseDescriptor.java:161) ~[apache-cassandra-2.1.13.jar:2.1.13]
at org.apache.cassandra.config.DatabaseDescriptor.<clinit>(DatabaseDescriptor.java:136) ~[apache-cassandra-2.1.13.jar:2.1.13]
at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:168) [apache-cassandra-2.1.13.jar:2.1.13]
at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:564) [apache-cassandra-2.1.13.jar:2.1.13]
at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:653) [apache-cassandra-2.1.13.jar:2.1.13]
Caused by: org.yaml.snakeyaml.constructor.ConstructorException: null; Can't construct a java object for tag:yaml.org,2002:org.apache.cassandra.config.Config; exception=Cannot create property=seed_provider for JavaBean=org.apache.cassandra.config.Config@4bf58247; No suitable constructor with 2 arguments found for class org.apache.cassandra.config.SeedProviderDef; in 'reader', line 1, column 1:
cluster_name: forseti_cluster
^
at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:333) ~[snakeyaml-1.11.jar:na]
at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:182) ~[snakeyaml-1.11.jar:na]
at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:141) ~[snakeyaml-1.11.jar:na]
at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:127) ~[snakeyaml-1.11.jar:na]
at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:481) ~[snakeyaml-1.11.jar:na]
at org.yaml.snakeyaml.Yaml.loadAs(Yaml.java:475) ~[snakeyaml-1.11.jar:na]
at org.apache.cassandra.config.YamlConfigurationLoader.loadConfig(YamlConfigurationLoader.java:113) ~[apache-cassandra-2.1.13.jar:2.1.13]
... 6 common frames omitted
Caused by: org.yaml.snakeyaml.error.YAMLException: Cannot create property=seed_provider for JavaBean=org.apache.cassandra.config.Config@4bf58247; No suitable constructor with 2 arguments found for class org.apache.cassandra.config.SeedProviderDef
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:299) ~[snakeyaml-1.11.jar:na]
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.construct(Constructor.java:189) ~[snakeyaml-1.11.jar:na]
at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:331) ~[snakeyaml-1.11.jar:na]
... 12 common frames omitted
Caused by: org.yaml.snakeyaml.error.YAMLException: No suitable constructor with 2 arguments found for class org.apache.cassandra.config.SeedProviderDef
at org.yaml.snakeyaml.constructor.Constructor$ConstructSequence.construct(Constructor.java:573) ~[snakeyaml-1.11.jar:na]
at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:182) ~[snakeyaml-1.11.jar:na]
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:296) ~[snakeyaml-1.11.jar:na]
... 14 common frames omitted
Invalid yaml
Fatal configuration error; unable to start. See log for stacktrace.

确保两个版本的下面都是一致的:

  1. cluster_name
  2. seeds
  3. RAC
  4. data directory

如果一致的话,在还没有执行upgradesstables之前,实际上就可以查询数据了!

正常完成升级,如果还没有往新版本中插入数据,日志如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
INFO  [CompactionExecutor:1] 2016-04-21 08:47:30,069 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/schema_columnfamilies/system-schema_columnfamilies-jb-5-Data.db')]
INFO [CompactionExecutor:1] 2016-04-21 08:47:30,105 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/schema_columnfamilies/system-schema_columnfamilies-ka-6,]. 6,900 bytes to 6,900 (~100% of original) in 33ms = 0.199405MB/s. 3 total partitions merged to 3. Partition merge counts were {1:3, }
INFO [CompactionExecutor:2] 2016-04-21 08:47:30,106 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/schema_columns/system-schema_columns-jb-5-Data.db')]

INFO [CompactionExecutor:2] 2016-04-21 08:47:30,161 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/schema_columns/system-schema_columns-ka-6,]. 11,933 bytes to 11,933 (~100% of original) in 52ms = 0.218850MB/s. 3 total partitions merged to 3. Partition merge counts were {1:3, }
INFO [CompactionExecutor:2] 2016-04-21 08:47:30,162 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/schema_triggers/system-schema_triggers-jb-1-Data.db')]
INFO [CompactionExecutor:1] 2016-04-21 08:47:30,162 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/schema_triggers/system-schema_triggers-jb-2-Data.db')]
INFO [CompactionExecutor:1] 2016-04-21 08:47:30,190 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/schema_triggers/system-schema_triggers-ka-3,]. 32 bytes to 32 (~100% of original) in 25ms = 0.001221MB/s. 1 total partitions merged to 1. Partition merge counts were {1:1, }
INFO [CompactionExecutor:2] 2016-04-21 08:47:30,195 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/schema_triggers/system-schema_triggers-ka-4,]. 32 bytes to 32 (~100% of original) in 31ms = 0.000984MB/s. 1 total partitions merged to 1. Partition merge counts were {1:1, }
INFO [CompactionExecutor:2] 2016-04-21 08:47:30,196 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/schema_keyspaces/system-schema_keyspaces-jb-5-Data.db')]
INFO [CompactionExecutor:1] 2016-04-21 08:47:30,196 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/schema_keyspaces/system-schema_keyspaces-jb-6-Data.db')]
INFO [CompactionExecutor:1] 2016-04-21 08:47:30,225 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/schema_keyspaces/system-schema_keyspaces-ka-8,]. 135 bytes to 135 (~100% of original) in 26ms = 0.004952MB/s. 1 total partitions merged to 1. Partition merge counts were {1:1, }
INFO [CompactionExecutor:2] 2016-04-21 08:47:30,239 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/schema_keyspaces/system-schema_keyspaces-ka-7,]. 294 bytes to 294 (~100% of original) in 40ms = 0.007010MB/s. 3 total partitions merged to 3. Partition merge counts were {1:3, }
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-21 08:47:30,240 CompactionManager.java:283 - No sstables for system.range_xfers
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-21 08:47:30,241 CompactionManager.java:283 - No sstables for system.paxos
INFO [CompactionExecutor:1] 2016-04-21 08:47:30,242 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/peers/system-peers-jb-2-Data.db')]
INFO [CompactionExecutor:2] 2016-04-21 08:47:30,242 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/peers/system-peers-jb-1-Data.db')]
INFO [CompactionExecutor:2] 2016-04-21 08:47:30,275 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/peers/system-peers-ka-3,]. 30 bytes to 30 (~100% of original) in 31ms = 0.000923MB/s. 1 total partitions merged to 1. Partition merge counts were {1:1, }
INFO [CompactionExecutor:1] 2016-04-21 08:47:30,279 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/peers/system-peers-ka-4,]. 30 bytes to 30 (~100% of original) in 35ms = 0.000817MB/s. 1 total partitions merged to 1. Partition merge counts were {1:1, }
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-21 08:47:30,279 CompactionManager.java:283 - No sstables for system.batchlog
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-21 08:47:30,280 CompactionManager.java:283 - No sstables for system.schema_usertypes
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-21 08:47:30,280 CompactionManager.java:283 - No sstables for system.hints
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-21 08:47:30,281 CompactionManager.java:283 - No sstables for system.peer_events
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-21 08:47:30,281 CompactionManager.java:283 - No sstables for system.IndexInfo
INFO [CompactionExecutor:2] 2016-04-21 08:47:30,282 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/compaction_history/system-compaction_history-jb-1-Data.db')]
INFO [CompactionExecutor:1] 2016-04-21 08:47:30,283 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/compaction_history/system-compaction_history-jb-2-Data.db')]

INFO [CompactionExecutor:1] 2016-04-21 08:47:30,318 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/compaction_history/system-compaction_history-ka-4,]. 238 bytes to 238 (~100% of original) in 34ms = 0.006676MB/s. 1 total partitions merged to 1. Partition merge counts were {1:1, }
INFO [CompactionExecutor:2] 2016-04-21 08:47:30,319 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/compaction_history/system-compaction_history-ka-5,]. 361 bytes to 361 (~100% of original) in 36ms = 0.009563MB/s. 2 total partitions merged to 2. Partition merge counts were {1:2, }
INFO [CompactionExecutor:1] 2016-04-21 08:47:30,320 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/sstable_activity/system-sstable_activity-jb-1-Data.db')]
INFO [CompactionExecutor:1] 2016-04-21 08:47:30,350 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/sstable_activity/system-sstable_activity-ka-3,]. 165 bytes to 165 (~100% of original) in 28ms = 0.005620MB/s. 2 total partitions merged to 2. Partition merge counts were {1:2, }
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-21 08:47:30,351 CompactionManager.java:283 - No sstables for system.size_estimates
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-21 08:47:30,364 CompactionManager.java:283 - No sstables for system_traces.events
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-21 08:47:30,365 CompactionManager.java:283 - No sstables for system_traces.sessions

插入数据后(确保不同版本可以成功插入数据),再升级sstable,日志如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
INFO  [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 16:20:04,170 CompactionManager.java:283 - No sstables for system.batchlog
INFO [CompactionExecutor:9] 2016-04-20 16:20:04,173 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/schema_triggers/system-schema_triggers-jb-2-Data.db')]
INFO [CompactionExecutor:10] 2016-04-20 16:20:04,173 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/schema_triggers/system-schema_triggers-jb-1-Data.db')]
INFO [CompactionExecutor:9] 2016-04-20 16:20:04,189 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/schema_triggers/system-schema_triggers-ka-3,]. 32 bytes to 32 (~100% of original) in 13ms = 0.002348MB/s. 1 total partitions merged to 1. Partition merge counts were {1:1, }
INFO [CompactionExecutor:10] 2016-04-20 16:20:04,191 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/schema_triggers/system-schema_triggers-ka-4,]. 32 bytes to 32 (~100% of original) in 15ms = 0.002035MB/s. 1 total partitions merged to 1. Partition merge counts were {1:1, }
INFO [CompactionExecutor:11] 2016-04-20 16:20:04,192 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/sstable_activity/system-sstable_activity-jb-1-Data.db')]
INFO [CompactionExecutor:12] 2016-04-20 16:20:04,192 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/sstable_activity/system-sstable_activity-jb-2-Data.db')]
INFO [CompactionExecutor:12] 2016-04-20 16:20:04,211 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/sstable_activity/system-sstable_activity-ka-4,]. 206 bytes to 206 (~100% of original) in 16ms = 0.012279MB/s. 6 total partitions merged to 6. Partition merge counts were {1:6, }
INFO [CompactionExecutor:11] 2016-04-20 16:20:04,211 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/sstable_activity/system-sstable_activity-ka-5,]. 164 bytes to 164 (~100% of original) in 17ms = 0.009200MB/s. 2 total partitions merged to 2. Partition merge counts were {1:2, }
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 16:20:04,212 CompactionManager.java:283 - No sstables for system.size_estimates
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 16:20:04,213 CompactionManager.java:283 - No sstables for system.peer_events
INFO [CompactionExecutor:13] 2016-04-20 16:20:04,214 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/schema_keyspaces/system-schema_keyspaces-jb-6-Data.db')]
INFO [CompactionExecutor:14] 2016-04-20 16:20:04,214 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/schema_keyspaces/system-schema_keyspaces-jb-5-Data.db')]
INFO [CompactionExecutor:14] 2016-04-20 16:20:04,242 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/schema_keyspaces/system-schema_keyspaces-ka-7,]. 292 bytes to 292 (~100% of original) in 25ms = 0.011139MB/s. 3 total partitions merged to 3. Partition merge counts were {1:3, }
INFO [CompactionExecutor:13] 2016-04-20 16:20:04,242 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/schema_keyspaces/system-schema_keyspaces-ka-8,]. 135 bytes to 135 (~100% of original) in 26ms = 0.004952MB/s. 1 total partitions merged to 1. Partition merge counts were {1:1, }
INFO [CompactionExecutor:15] 2016-04-20 16:20:04,244 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/compaction_history/system-compaction_history-jb-1-Data.db')]
INFO [CompactionExecutor:16] 2016-04-20 16:20:04,245 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/compaction_history/system-compaction_history-jb-2-Data.db')]
INFO [CompactionExecutor:16] 2016-04-20 16:20:04,263 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/compaction_history/system-compaction_history-ka-4,]. 477 bytes to 477 (~100% of original) in 16ms = 0.028431MB/s. 3 total partitions merged to 3. Partition merge counts were {1:3, }
INFO [CompactionExecutor:15] 2016-04-20 16:20:04,263 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/compaction_history/system-compaction_history-ka-5,]. 357 bytes to 357 (~100% of original) in 18ms = 0.018915MB/s. 2 total partitions merged to 2. Partition merge counts were {1:2, }
INFO [CompactionExecutor:9] 2016-04-20 16:20:04,264 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/schema_columnfamilies/system-schema_columnfamilies-jb-5-Data.db')]
INFO [CompactionExecutor:9] 2016-04-20 16:20:04,331 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/schema_columnfamilies/system-schema_columnfamilies-ka-6,]. 6,902 bytes to 6,902 (~100% of original) in 65ms = 0.101266MB/s. 3 total partitions merged to 3. Partition merge counts were {1:3, }
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 16:20:04,332 CompactionManager.java:283 - No sstables for system.range_xfers
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 16:20:04,333 CompactionManager.java:283 - No sstables for system.hints
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 16:20:04,333 CompactionManager.java:283 - No sstables for system.schema_usertypes
INFO [CompactionExecutor:10] 2016-04-20 16:20:04,334 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/peers/system-peers-jb-2-Data.db')]
INFO [CompactionExecutor:12] 2016-04-20 16:20:04,334 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/peers/system-peers-jb-1-Data.db')]
INFO [CompactionExecutor:10] 2016-04-20 16:20:04,355 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/peers/system-peers-ka-4,]. 30 bytes to 30 (~100% of original) in 19ms = 0.001506MB/s. 1 total partitions merged to 1. Partition merge counts were {1:1, }
INFO [CompactionExecutor:12] 2016-04-20 16:20:04,356 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/peers/system-peers-ka-3,]. 30 bytes to 30 (~100% of original) in 19ms = 0.001506MB/s. 1 total partitions merged to 1. Partition merge counts were {1:1, }
INFO [CompactionExecutor:11] 2016-04-20 16:20:04,357 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/schema_columns/system-schema_columns-jb-5-Data.db')]
INFO [CompactionExecutor:11] 2016-04-20 16:20:04,427 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/system/schema_columns/system-schema_columns-ka-6,]. 11,914 bytes to 11,914 (~100% of original) in 67ms = 0.169583MB/s. 3 total partitions merged to 3. Partition merge counts were {1:3, }
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 16:20:04,427 CompactionManager.java:283 - No sstables for system.compactions_in_progress
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 16:20:04,428 CompactionManager.java:283 - No sstables for system.paxos
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 16:20:04,429 CompactionManager.java:283 - No sstables for system.IndexInfo
INFO [CompactionExecutor:14] 2016-04-20 16:20:04,440 ColumnFamilyStore.java:905 - Enqueuing flush of compactions_in_progress: 768 (0%) on-heap, 0 (0%) off-heap
INFO [MemtableFlushWriter:3] 2016-04-20 16:20:04,441 Memtable.java:347 - Writing Memtable-compactions_in_progress@565484753(0.101KiB serialized bytes, 6 ops, 0%/0% of on/off-heap limit)
INFO [MemtableFlushWriter:3] 2016-04-20 16:20:04,443 Memtable.java:382 - Completed flushing /Users/zhengqh/data/cassandra/system/compactions_in_progress/system-compactions_in_progress-tmp-ka-4-Data.db (0.000KiB) for commitlog position ReplayPosition(segmentId=1461140332109, position=507508)
INFO [CompactionExecutor:14] 2016-04-20 16:20:04,449 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/forseti/velocity_partner/forseti-velocity_partner-jb-3-Data.db')]
INFO [CompactionExecutor:14] 2016-04-20 16:20:06,975 ColumnFamilyStore.java:905 - Enqueuing flush of compactions_in_progress: 165 (0%) on-heap, 0 (0%) off-heap
INFO [MemtableFlushWriter:4] 2016-04-20 16:20:06,977 Memtable.java:347 - Writing Memtable-compactions_in_progress@1820406546(0.008KiB serialized bytes, 1 ops, 0%/0% of on/off-heap limit)
INFO [MemtableFlushWriter:4] 2016-04-20 16:20:06,979 Memtable.java:382 - Completed flushing /Users/zhengqh/data/cassandra/system/compactions_in_progress/system-compactions_in_progress-tmp-ka-5-Data.db (0.000KiB) for commitlog position ReplayPosition(segmentId=1461140332109, position=507579)
INFO [CompactionExecutor:14] 2016-04-20 16:20:06,992 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/forseti/velocity_partner/forseti-velocity_partner-ka-4,]. 5,509,972 bytes to 5,509,972 (~100% of original) in 2,541ms = 2.067973MB/s. 19,465 total partitions merged to 19,465. Partition merge counts were {1:19465, }
INFO [CompactionExecutor:16] 2016-04-20 16:20:06,995 ColumnFamilyStore.java:905 - Enqueuing flush of compactions_in_progress: 767 (0%) on-heap, 0 (0%) off-heap
INFO [MemtableFlushWriter:3] 2016-04-20 16:20:06,996 Memtable.java:347 - Writing Memtable-compactions_in_progress@1207113147(0.100KiB serialized bytes, 6 ops, 0%/0% of on/off-heap limit)
INFO [MemtableFlushWriter:3] 2016-04-20 16:20:06,998 Memtable.java:382 - Completed flushing /Users/zhengqh/data/cassandra/system/compactions_in_progress/system-compactions_in_progress-tmp-ka-6-Data.db (0.000KiB) for commitlog position ReplayPosition(segmentId=1461140332109, position=508341)
INFO [CompactionExecutor:16] 2016-04-20 16:20:07,018 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/forseti/velocity_global/forseti-velocity_global-jb-3-Data.db')]
INFO [CompactionExecutor:16] 2016-04-20 16:20:07,698 ColumnFamilyStore.java:905 - Enqueuing flush of compactions_in_progress: 165 (0%) on-heap, 0 (0%) off-heap
INFO [MemtableFlushWriter:4] 2016-04-20 16:20:07,699 Memtable.java:347 - Writing Memtable-compactions_in_progress@1174187682(0.008KiB serialized bytes, 1 ops, 0%/0% of on/off-heap limit)
INFO [MemtableFlushWriter:4] 2016-04-20 16:20:07,701 Memtable.java:382 - Completed flushing /Users/zhengqh/data/cassandra/system/compactions_in_progress/system-compactions_in_progress-tmp-ka-7-Data.db (0.000KiB) for commitlog position ReplayPosition(segmentId=1461140332109, position=508412)
INFO [CompactionExecutor:10] 2016-04-20 16:20:07,712 CompactionTask.java:141 - Compacting [SSTableReader(path='/Users/zhengqh/data/cassandra/system/compactions_in_progress/system-compactions_in_progress-ka-5-Data.db'), SSTableReader(path='/Users/zhengqh/data/cassandra/system/compactions_in_progress/system-compactions_in_progress-ka-7-Data.db'), SSTableReader(path='/Users/zhengqh/data/cassandra/system/compactions_in_progress/system-compactions_in_progress-ka-4-Data.db'), SSTableReader(path='/Users/zhengqh/data/cassandra/system/compactions_in_progress/system-compactions_in_progress-ka-6-Data.db')]
INFO [CompactionExecutor:16] 2016-04-20 16:20:07,715 CompactionTask.java:274 - Compacted 1 sstables to [/Users/zhengqh/data/cassandra/forseti/velocity_global/forseti-velocity_global-ka-4,]. 5,770,633 bytes to 5,770,633 (~100% of original) in 694ms = 7.929834MB/s. 18,947 total partitions merged to 18,947. Partition merge counts were {1:18947, }
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 16:20:07,719 CompactionManager.java:283 - No sstables for system_traces.events
INFO [RMI TCP Connection(4)-127.0.0.1] 2016-04-20 16:20:07,720 CompactionManager.java:283 - No sstables for system_traces.sessions
INFO [CompactionExecutor:10] 2016-04-20 16:20:07,736 CompactionTask.java:274 - Compacted 4 sstables to [/Users/zhengqh/data/cassandra/system/compactions_in_progress/system-compactions_in_progress-ka-8,]. 399 bytes to 42 (~10% of original) in 22ms = 0.001821MB/s. 4 total partitions merged to 1. Partition merge counts were {2:2, }

配置文件迁移

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//2.1的配置文件,如果配置项在2.0中,应当以2.0为准覆盖
val printWriter = new PrintWriter(conf21New)
for(line <- Source.fromFile(conf21Old).getLines()){
if(!line.equals("\n") && !line.equals("") && line.indexOf("#")<0){
//没有嵌套结构的,比较简单的,要覆盖
if(!line.startsWith(" ") && line.split(":").size==2) {
val k = line.split(":")(0)
val v = line.split(":")(1)

val newValue = map20.get(k) match {
case Some(v20) => v20
case None => v
}
if(k.equals("cluster_name")){
printWriter.append(k + ": '" + newValue.toString.trim + "'\n")
}else{
printWriter.append(k + ": " + newValue.toString.trim + "\n")
}
}else{
//有嵌套的,暂时不管
printWriter.append(line + "\n")
}
}
}

//2.1中可能有些注释掉了,但是2.0中没有注释的话,则要加上去
//比如通常在2.0中会设置数据文件的存储目录,在2.1中也有,不过默认的安装包是不打开注释的
//还要注意,并不一定2.0中有些配置不能直接移植过去,可以先全部移过去,启动不起来的时候会提示哪些需要移除
val oldKeys = map20.keySet -- map21.keySet
map20.filter(kv => oldKeys.contains(kv._1) && !removenKeys.contains(kv._1)).foreach(kv => {
println(kv._1 + ": " + kv._2)
printWriter.append(kv._1 + ": " + kv._2 + "\n")
})
printWriter.flush()
printWriter.close

2.1 to 3.0


文章目录
  1. 1. 本机单节点测试
  2. 2. 测试环境两个节点测试
  3. 3. 生产环境
  4. 4. 问题
  5. 5. 配置文件迁移
  6. 6. 2.1 to 3.0