本文记录一下在CentOS 6.7上,安装Cassandra,本文安装的版本为apache-cassandra-2.2.8-bin.tar.gz。
下载Cassandra
使用wget来下载Cassandra安装包,如
[root@dev18 srv]# wget http://archive.apache.org/dist/cassandra/2.2.8/apache-cassandra-2.2.8-bin.tar.gz --2017-03-16 16:16:39-- http://archive.apache.org/dist/cassandra/2.2.8/apache-cassandra-2.2.8-bin.tar.gz Resolving archive.apache.org... 163.172.17.199 Connecting to archive.apache.org|163.172.17.199|:80... connected. HTTP request sent,awaiting response... 200 OK Length: 29685870 (28M) [application/x-gzip] Saving to: “apache-cassandra-2.2.8-bin.tar.gz” 100%[====================================================================================================================================================================================================================================>] 29,685,870 1.87M/s in 54s 2017-03-16 16:17:33 (541 KB/s) - “apache-cassandra-2.2.8-bin.tar.gz” saved [29685870/29685870] [root@dev18 srv]#
解压缩Cassandra安装包
使用 tar -zvxf apache-cassandra-2.2.8-bin.tar.gz解压缩Cassandra安装包~
[root@dev18 srv]# tar -zvxf apache-cassandra-2.2.8-bin.tar.gz ... ... apache-cassandra-2.2.8/bin/stop-server apache-cassandra-2.2.8/bin/stop-server.bat apache-cassandra-2.2.8/bin/stop-server.ps1 apache-cassandra-2.2.8/tools/bin/cassandra-stress apache-cassandra-2.2.8/tools/bin/cassandra-stress.bat apache-cassandra-2.2.8/tools/bin/cassandra-stressd apache-cassandra-2.2.8/tools/bin/cassandra.in.bat apache-cassandra-2.2.8/tools/bin/cassandra.in.sh apache-cassandra-2.2.8/tools/bin/json2sstable apache-cassandra-2.2.8/tools/bin/json2sstable.bat apache-cassandra-2.2.8/tools/bin/sstable2json apache-cassandra-2.2.8/tools/bin/sstable2json.bat apache-cassandra-2.2.8/tools/bin/sstableexpiredblockers apache-cassandra-2.2.8/tools/bin/sstableexpiredblockers.bat apache-cassandra-2.2.8/tools/bin/sstablelevelreset apache-cassandra-2.2.8/tools/bin/sstablelevelreset.bat apache-cassandra-2.2.8/tools/bin/sstableMetadata apache-cassandra-2.2.8/tools/bin/sstableMetadata.bat apache-cassandra-2.2.8/tools/bin/sstableofflinerelevel apache-cassandra-2.2.8/tools/bin/sstableofflinerelevel.bat apache-cassandra-2.2.8/tools/bin/sstablerepairedset apache-cassandra-2.2.8/tools/bin/sstablerepairedset.bat apache-cassandra-2.2.8/tools/bin/sstablesplit apache-cassandra-2.2.8/tools/bin/sstablesplit.bat apache-cassandra-2.2.8/tools/bin/token-generator apache-cassandra-2.2.8/tools/bin/token-generator.bat [root@dev18 srv]#
修改解压缩后的Cassadra目录名,从apache-cassandra-2.2.8改成cassandra~
[root@dev18 srv]# mv apache-cassandra-2.2.8 cassandra [root@dev18 srv]#
进入cassandra目录,看看有哪些东西~
[root@dev18 srv]# cd cassandra/ [root@dev18 cassandra]# ll total 416 drwxr-xr-x 2 root root 4096 Mar 16 16:29 bin -rw-r--r-- 1 root root 291221 Sep 24 06:06 CHANGES.txt drwxr-xr-x 3 root root 4096 Mar 16 16:29 conf drwxr-xr-x 3 root root 4096 Mar 16 16:29 doc drwxr-xr-x 2 root root 4096 Mar 16 16:29 interface drwxr-xr-x 3 root root 4096 Mar 16 16:29 javadoc drwxr-xr-x 5 root root 4096 Mar 16 16:29 lib -rw-r--r-- 1 root root 11609 Sep 24 06:06 LICENSE.txt -rw-r--r-- 1 root root 81082 Sep 24 06:06 NEWS.txt -rw-r--r-- 1 root root 2509 Sep 24 06:06 NOTICE.txt drwxr-xr-x 3 root root 4096 Mar 16 16:29 pylib drwxr-xr-x 4 root root 4096 Mar 16 16:29 tools [root@dev18 cassandra]#
启动cassandra
进入<Cassandra_HOME>/bin下,使用./cassandra启动即可。
[root@dev18 bin]# ./cassandra [root@dev18 bin]# CompilerOracle: inline org/apache/cassandra/db/AbstractNativeCell.compareTo (Lorg/apache/cassandra/db/composites/Composite;)I CompilerOracle: inline org/apache/cassandra/db/composites/AbstractSimpleCellNameType.compareUnsigned (Lorg/apache/cassandra/db/composites/Composite;Lorg/apache/cassandra/db/composites/Composite;)I CompilerOracle: inline org/apache/cassandra/io/util/Memory.checkBounds (JJ)V CompilerOracle: inline org/apache/cassandra/io/util/SafeMemory.checkBounds (JJ)V CompilerOracle: inline org/apache/cassandra/utils/AsymmetricOrdering.selectBoundary (Lorg/apache/cassandra/utils/AsymmetricOrdering/Op;II)I CompilerOracle: inline org/apache/cassandra/utils/AsymmetricOrdering.strictnessOfLessThan (Lorg/apache/cassandra/utils/AsymmetricOrdering/Op;)I CompilerOracle: inline org/apache/cassandra/utils/ByteBufferUtil.compare (Ljava/nio/ByteBuffer;[B)I CompilerOracle: inline org/apache/cassandra/utils/ByteBufferUtil.compare ([BLjava/nio/ByteBuffer;)I CompilerOracle: inline org/apache/cassandra/utils/ByteBufferUtil.compareUnsigned (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)I CompilerOracle: inline org/apache/cassandra/utils/FastByteOperations$UnsafeOperations.compareTo (Ljava/lang/Object;JILjava/lang/Object;JI)I CompilerOracle: inline org/apache/cassandra/utils/FastByteOperations$UnsafeOperations.compareTo (Ljava/lang/Object;JILjava/nio/ByteBuffer;)I CompilerOracle: inline org/apache/cassandra/utils/FastByteOperations$UnsafeOperations.compareTo (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)I INFO 08:33:09 Node configuration:[authenticator=AllowAllAuthenticator; authorizer=AllowAllAuthorizer; auto_bootstrap=true; auto_snapshot=true; batch_size_fail_threshold_in_kb=50; batch_size_warn_threshold_in_kb=5; batchlog_replay_throttle_in_kb=1024; broadcast_address=null; broadcast_rpc_address=null; cas_contention_timeout_in_ms=1000; client_encryption_options=<REDACTED>; cluster_name=Test Cluster; column_index_size_in_kb=64; commit_failure_policy=stop; commitlog_compression=null; commitlog_directory=null; commitlog_max_compression_buffers_in_pool=3; commitlog_periodic_queue_size=-1; commitlog_segment_size_in_mb=32; commitlog_sync=periodic; commitlog_sync_batch_window_in_ms=null; commitlog_sync_period_in_ms=10000; commitlog_total_space_in_mb=null; compaction_large_partition_warning_threshold_mb=100; compaction_throughput_mb_per_sec=16; concurrent_compactors=null; concurrent_counter_writes=32; concurrent_reads=32; concurrent_replicates=null; concurrent_writes=32; counter_cache_keys_to_save=2147483647; counter_cache_save_period=7200; counter_cache_size_in_mb=null; counter_write_request_timeout_in_ms=5000; cross_node_timeout=false; data_file_directories=null; disk_access_mode=auto; disk_failure_policy=stop; dynamic_snitch=true; dynamic_snitch_badness_threshold=0.1; dynamic_snitch_reset_interval_in_ms=600000; dynamic_snitch_update_interval_in_ms=100; enable_user_defined_functions=false; encryption_options=null; endpoint_snitch=SimpleSnitch; file_cache_size_in_mb=null; gc_log_threshold_in_ms=200; gc_warn_threshold_in_ms=0; hinted_handoff_enabled=true; hinted_handoff_enabled_by_dc=[]; hinted_handoff_enabled_global=true; hinted_handoff_throttle_in_kb=1024; incremental_backups=false; index_interval=null; index_summary_capacity_in_mb=null; index_summary_resize_interval_in_minutes=60; initial_token=null; inter_dc_stream_throughput_outbound_megabits_per_sec=200; inter_dc_tcp_nodelay=false; internode_authenticator=null; internode_compression=all; internode_recv_buff_size_in_bytes=null; internode_send_buff_size_in_bytes=null; key_cache_keys_to_save=2147483647; key_cache_save_period=14400; key_cache_size_in_mb=null; listen_address=localhost; listen_interface=null; listen_interface_prefer_ipv6=false; listen_on_broadcast_address=false; max_hint_window_in_ms=10800000; max_hints_delivery_threads=2; max_streaming_retries=3; memory_allocator=null; memtable_allocation_type=heap_buffers; memtable_cleanup_threshold=null; memtable_flush_writers=null; memtable_heap_space_in_mb=null; memtable_offheap_space_in_mb=null; native_transport_max_concurrent_connections=-1; native_transport_max_concurrent_connections_per_ip=-1; native_transport_max_frame_size_in_mb=256; native_transport_max_threads=128; native_transport_port=9042; num_tokens=256; otc_coalescing_strategy=TIMEHORIZON; otc_coalescing_window_us=200; partitioner=org.apache.cassandra.dht.Murmur3Partitioner; permissions_cache_max_entries=1000; permissions_update_interval_in_ms=-1; permissions_validity_in_ms=2000; phi_convict_threshold=8.0; range_request_timeout_in_ms=10000; read_request_timeout_in_ms=5000; request_scheduler=org.apache.cassandra.scheduler.NoScheduler; request_scheduler_id=null; request_scheduler_options=null; request_timeout_in_ms=10000; role_manager=CassandraRoleManager; roles_cache_max_entries=1000; roles_update_interval_in_ms=-1; roles_validity_in_ms=2000; row_cache_class_name=org.apache.cassandra.cache.OHCProvider; row_cache_keys_to_save=2147483647; row_cache_save_period=0; row_cache_size_in_mb=0; rpc_address=localhost; rpc_interface=null; rpc_interface_prefer_ipv6=false; rpc_keepalive=true; rpc_listen_backlog=50; rpc_max_threads=2147483647; rpc_min_threads=16; rpc_port=9160; rpc_recv_buff_size_in_bytes=null; rpc_send_buff_size_in_bytes=null; rpc_server_type=sync; saved_caches_directory=null; seed_provider=org.apache.cassandra.locator.SimpleSeedProvider{seeds=127.0.0.1}; server_encryption_options=<REDACTED>; snapshot_before_compaction=false; ssl_storage_port=7001; sstable_preemptive_open_interval_in_mb=50; start_native_transport=true; start_rpc=false; storage_port=7000; stream_throughput_outbound_megabits_per_sec=200; streaming_socket_timeout_in_ms=86400000; thrift_framed_transport_size_in_mb=15; thrift_max_message_length_in_mb=16; tombstone_failure_threshold=100000; tombstone_warn_threshold=1000; tracetype_query_ttl=86400; tracetype_repair_ttl=604800; trickle_fsync=false; trickle_fsync_interval_in_kb=10240; truncate_request_timeout_in_ms=60000; unlogged_batch_across_partitions_warn_threshold=10; windows_timer_interval=1; write_request_timeout_in_ms=2000] INFO 08:33:09 DiskAccessMode 'auto' determined to be mmap,indexAccessMode is mmap INFO 08:33:10 Global memtable on-heap threshold is enabled at 251MB INFO 08:33:10 Global memtable off-heap threshold is enabled at 251MB WARN 08:33:10 Small commitlog volume detected at ./../data/commitlog; setting commitlog_total_space_in_mb to 6392. You can override this in cassandra.yaml WARN 08:33:10 Only 10675 MB free across all data volumes. Consider adding more capacity to your cluster or removing obsolete snapshots INFO 08:33:10 Hostname: dev18.gzhl.zhhl INFO 08:33:10 JVM vendor/version: Java HotSpot(TM) 64-Bit Server VM/1.7.0_71 INFO 08:33:10 Heap size: 1052770304/1052770304 ... ... 省略其它
验证Cassandra是否启动
可以使用ps -ef|grep cassandra查看,Cassandra是否启动~
[root@dev18 ~]# ps -ef|grep cassandra root 20437 1 1 16:33 ? 00:00:20 /usr/java/jdk1.7.0_71/bin/java -ea -javaagent:./../lib/jamm-0.3.0.jar -XX:+CMSClassUnloadingEnabled -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms1024M -Xmx1024M -Xmn200M -XX:+HeapDumpOnOutOfMemoryError -Xss256k -XX:StringTableSize=1000003 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=1 -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+UseTLAB -XX:+PerfDisableSharedMem -XX:CompileCommandFile=./../conf/hotspot_compiler -XX:CMSWaitDuration=10000 -XX:+CMSParallelInitialMarkEnabled -XX:+CMSEdenChunksRecordAlways -XX:CMSWaitDuration=10000 -XX:+UseCondCardMark -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -XX:+PrintPromotionFailure -Xloggc:./../logs/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=10M -Djava.net.preferIPv4Stack=true -Dcassandra.jmx.local.port=7199 -XX:+DisableExplicitGC -Djava.library.path=./../lib/sigar-bin -Dlogback.configurationFile=logback.xml -Dcassandra.logdir=./../logs -Dcassandra.storagedir=./../data -cp ./../conf:./../build/classes/main:./../build/classes/thrift:./../lib/airline-0.6.jar:./../lib/antlr-runtime-3.5.2.jar:./../lib/apache-cassandra-2.2.8.jar:./../lib/apache-cassandra-clientutil-2.2.8.jar:./../lib/apache-cassandra-thrift-2.2.8.jar:./../lib/cassandra-driver-core-2.2.0-rc2-SNAPSHOT-20150617-shaded.jar:./../lib/commons-cli-1.1.jar:./../lib/commons-codec-1.2.jar:./../lib/commons-lang3-3.1.jar:./../lib/commons-math3-3.2.jar:./../lib/compress-lzf-0.8.4.jar:./../lib/concurrentlinkedhashmap-lru-1.4.jar:./../lib/crc32ex-0.1.1.jar:./../lib/disruptor-3.0.1.jar:./../lib/ecj-4.4.2.jar:./../lib/guava-16.0.jar:./../lib/high-scale-lib-1.0.6.jar:./../lib/jackson-core-asl-1.9.2.jar:./../lib/jackson-mapper-asl-1.9.2.jar:./../lib/jamm-0.3.0.jar:./../lib/javax.inject.jar:./../lib/jbcrypt-0.3m.jar:./../lib/jcl-over-slf4j-1.7.7.jar:./../lib/jna-4.0.0.jar:./../lib/joda-time-2.4.jar:./../lib/json-simple-1.1.jar:./../lib/libthrift-0.9.2.jar:./../lib/log4j-over-slf4j-1.7.7.jar:./../lib/logback-classic-1.1.3.jar:./../lib/logback-core-1.1.3.jar:./../lib/lz4-1.3.0.jar:./../lib/metrics-core-3.1.0.jar:./../lib/metrics-jvm-3.1.0.jar:./../lib/metrics-logback-3.1.0.jar:./../lib/netty-all-4.0.23.Final.jar:./../lib/ohc-core-0.3.4.jar:./../lib/ohc-core-j8-0.3.4.jar:./../lib/reporter-config3-3.0.0.jar:./../lib/reporter-config-base-3.0.0.jar:./../lib/sigar-1.6.4.jar:./../lib/slf4j-api-1.7.7.jar:./../lib/snakeyaml-1.11.jar:./../lib/snappy-java-1.1.1.7.jar:./../lib/ST4-4.0.8.jar:./../lib/stream-2.5.2.jar:./../lib/super-csv-2.1.0.jar:./../lib/thrift-server-0.3.7.jar:./../lib/jsr223/*/*.jar org.apache.cassandra.service.CassandraDaemon root 20700 20680 0 16:52 pts/0 00:00:00 grep cassandra [root@dev18 ~]#
上面的示例中,Cassandra的配置信息采用的是默认的方式~如需要修改相关的配置信息,则可以进入<Cassandra_HOME>/conf目录,修改cassandra的配置文件cassandra.yaml~
[root@dev18 conf]# ll total 120 -rw-r--r-- 1 root root 18734 Sep 24 06:06 cassandra-env.ps1 -rw-r--r-- 1 root root 12216 Sep 24 06:06 cassandra-env.sh -rw-r--r-- 1 root root 1200 Sep 24 06:06 cassandra-rackdc.properties -rw-r--r-- 1 root root 1358 Sep 24 06:06 cassandra-topology.properties -rw-r--r-- 1 root root 42438 Mar 16 16:44 cassandra.yaml -rw-r--r-- 1 root root 2082 Sep 24 06:06 commitlog_archiving.properties -rw-r--r-- 1 root root 6235 Sep 24 06:06 cqlshrc.sample -rw-r--r-- 1 root root 1335 Sep 24 06:06 hotspot_compiler -rw-r--r-- 1 root root 1193 Sep 24 06:06 logback-tools.xml -rw-r--r-- 1 root root 3785 Sep 24 06:06 logback.xml -rw-r--r-- 1 root root 1603 Sep 24 06:06 metrics-reporter-config-sample.yaml -rw-r--r-- 1 root root 291 Sep 24 06:06 README.txt drwxr-xr-x 2 root root 4096 Mar 16 16:29 triggers [root@dev18 conf]#原文链接:https://www.f2er.com/centos/378351.html