环境准备
Python2.7* https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz
Cassandra 2.1.* http://archive.apache.org/dist/cassandra/2.1.20/apache-cassandra-2.1.20-bin.tar.gz
Host Name | IP Address | OS | |
sht-sgmhadoopcm-01 | 172.16.101.54 | CentOS7.1 | |
sht-sgmhadoopnn-01 | 172.16.101.55 |
CentOS7.1 |
|
sht-sgmhadoopnn-02 | 172.16.101.56 |
|
1. 各节点做准备工作
安装python和java
[root@sht-sgmhadoopcm-01 ~]# tar -zxf Python-2.7.15.tgz [root@sht-sgmhadoopcm-01 ~]# cd Python-2.7.15 [root@sht-sgmhadoopcm-01 Python-2.7.15]# ./configure --prefix=/usr/local/python-2.7.15 --enable-optimizations [root@sht-sgmhadoopcm-01 Python-2.7.15]# make && make install [root@sht-sgmhadoopcm-01 ~]# /usr/local/python-2.7.15/bin/python --version Python 2.7.15 [root@sht-sgmhadoopcm-01 ~]# tar -zxf jdk-8u111-linux-x64.tar.gz -C /usr/java/ [root@sht-sgmhadoopcm-01 ~]# /usr/java/jdk1.8.0_111/bin/java -version java version "1.8.0_111" Java(TM) SE Runtime Environment (build 1.8.0_111-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
配置系统用户
[root@sht-sgmhadoopcm-01 ~]# groupadd -r -g 601 dba [root@sht-sgmhadoopcm-01 ~]# useradd -r -u 601 -d /home/cassandra -g dba -G root cassandra [root@sht-sgmhadoopcm-01 ~]# cat /home/cassandra/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs export CASSANDRA_HOME=/usr/local/cassandra export JAVA_HOME=/usr/java/jdk1.8.0_171 export PYTHON_HOME=/usr/local/python-2.7.15 export PATH=$PYTHON_HOME/bin:$JAVA_HOME/bin:$CASSANDRA_HOME/bin:$CASSANDRA_HOME/tools/bin:$PATH:$HOME/bin:/usr/local/bin
安装Cassandra
[root@sht-sgmhadoopcm-01 ~]# tar -zxf apache-cassandra-2.1.20-bin.tar.gz -C /usr/local/ [root@sht-sgmhadoopcm-01 ~]# ln -s /usr/local/apache-cassandra-2.1.20 /usr/local/cassandra [root@sht-sgmhadoopcm-01 ~]# chown -R cassandra.dba /usr/local/apache-cassandra-2.1.20/
2. 配置cassandra
cassandra-topology.properties文件各节点一致
[cassandra@sht-sgmhadoopcm-01 conf]$ cat cassandra-topology.properties
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Cassandra Node IP=Data Center:Rack
#192.168.1.100=DC1:RAC1
#192.168.2.200=DC2:RAC2
#10.0.0.10=DC1:RAC1
#10.0.0.11=DC1:RAC1
#10.0.0.12=DC1:RAC2
#10.20.114.10=DC2:RAC1
#10.20.114.11=DC2:RAC1
#10.21.119.13=DC3:RAC1
#10.21.119.10=DC3:RAC1
#10.0.0.13=DC1:RAC2
#10.21.119.14=DC3:RAC2
#10.20.114.15=DC2:RAC2
172.16.101.54=EAST:RAC1
172.16.101.55=EAST:RAC1
172.16.101.56=EAST:RAC1
# default for unknown nodes
default=DC1:r1
# Native IPv6 is supported, however you must escape the colon in the IPv6 Address
# Also be sure to comment out JVM_OPTS="$JVM_OPTS -Djava.net.preferIPv4Stack=true"
# in cassandra-env.sh
fe80\:0\:0\:0\:202\:b3ff\:fe1e\:8329=DC1:RAC3
cassandra.yaml
cluster_name: 'NavigationData' data_file_directories: - /usr/local/cassandra/data commitlog_directory: /usr/local/cassandra/commitlog saved_caches_directory: /usr/local/cassandra/saved_caches seed_provider: # Addresses of hosts that are deemed contact points. # Cassandra nodes use this list of hosts to find each other and learn # the topology of the ring. You must change this if you are running # multiple nodes! - class_name: org.apache.cassandra.locator.SimpleSeedProvider parameters: # seeds is actually a comma-delimited list of addresses. # Ex: "<ip1>,<ip2>,<ip3>" - seeds: "172.16.101.54,172.16.101.55" listen_address: 172.16.101.54 #修改为各节点的IP地址 rpc_address: 172.16.101.54 #修改为各节点的IP地址 endpoint_snitch: PropertyFileSnitch
cassandra-env.sh注释如下
#if [ "x$LOCAL_JMX" = "x" ]; then
# LOCAL_JMX=yes
#fi
3.启动并查看cassandra
[cassandra@sht-sgmhadoopcm-01 ~]$ /usr/local/cassandra/bin/cassandra & [cassandra@sht-sgmhadoopnn-01 ~]$ /usr/local/cassandra/bin/cassandra & [cassandra@sht-sgmhadoopnn-02 ~]$ /usr/local/cassandra/bin/cassandra & [cassandra@sht-sgmhadoopcm-01 ~]$ nodetool status Datacenter: EAST ================ Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns (effective) Host ID Rack UN 172.16.101.54 51.75 KB 256 64.5% 0ec471a6-1730-4c53-9b70-78b03b40d13b RAC1 UN 172.16.101.55 118.25 KB 256 69.2% d4c873d0-e3b8-4e73-a9eb-1e238a399183 RAC1 UN 172.16.101.56 162.38 KB 256 66.4% 6f7b0f6e-f4bc-4724-b431-dddbeb16dcc1 RAC1
===================来自一泽涟漪的博客,转载请标明出处 www.cnblogs.com/ilifeilong===================