ScyllaDB 学习 - 基础部署

ScyllaDB 使用 1.5 版本,以 admin 用户身份安装。

Scylla 只支持 CentOS 7.2 以上版本。

基础环境

操作系统: CentOS 7.2;

集群节点(虚拟机):172.16.134.15 ~ 17;

基础准备

安装依赖和卸载 abrt ( abrt 和 coredump 配置冲突 ):

sudo yum install -y qt-settings epel-release wget
sudo yum remove -y abrt

准备工作目录:

mkdir -p ops/admin/20170316_build_scylladb
cd ops/admin/20170316_build_scylladb

准备机器列表文件 list_all

172.16.134.15
172.16.134.16
172.16.134.17

准备机器列表文件 list_all_hostname

v134015.dc1.domain.com
v134016.dc1.domain.com
v134017.dc1.domain.com

本地 REPO 制作

因为生产环境更多的是离线安装,所以我们需要制作本地 REPO。要使用 --downloadonly,需要安装:

sudo yum install -y yum-plugin-downloadonly

选择一台可以连接互联网的机器,下载中国源:

sudo wget -O /etc/yum.repos.d/scylla.repo http://downloads.scylladb.cn/1.5/scylla.cn.repo

下载所有 RPM 包至 YUM 缓存:

sudo yum install -y scylla --downloadonly

得到下载的 RPM 列表 rpm_list 如下:

 PyYAML-3.10-11.el7.x86_64.rpm
 gnutls-c++-3.3.8-12.el7_1.1.x86_64.rpm
 hwloc-1.7-5.el7.x86_64.rpm
 collectd-5.6.0-1.el7.x86_64.rpm
 cryptopp-5.6.2-10.el7.x86_64.rpm
 hwloc-libs-1.7-5.el7.x86_64.rpm
 javapackages-tools-3.4.1-11.el7.noarch.rpm
 libjpeg-turbo-1.2.90-5.el7.x86_64.rpm
 libtool-ltdl-2.4.2-20.el7.x86_64.rpm
 libunwind-1.1-5.el7.x86_64.rpm
 libyaml-0.1.4-11.el7_0.x86_64.rpm
 lksctp-tools-1.0.13-3.el7.x86_64.rpm
 jsoncpp-0.10.5-2.el7.x86_64.rpm
 protobuf-2.5.0-8.el7.x86_64.rpm
 python-javapackages-3.4.1-11.el7.noarch.rpm
 lz4-r131-1.el7.x86_64.rpm
 python-lxml-3.2.1-4.el7.x86_64.rpm
 python-urwid-1.1.1-3.el7.x86_64.rpm
 python34-3.4.5-2.el7.x86_64.rpm
 pyparsing-2.0.3-2.el7.centos.noarch.rpm
 python34-PyYAML-3.11-2.el7.x86_64.rpm
 scylla-1.5.0-20161221.654919c.el7.centos.x86_64.rpm
 scylla-boost-filesystem-1.58.0-11.el7.centos.x86_64.rpm
 scylla-boost-program-options-1.58.0-11.el7.centos.x86_64.rpm
 scylla-boost-date-time-1.58.0-11.el7.centos.x86_64.rpm
 scylla-boost-system-1.58.0-11.el7.centos.x86_64.rpm
 scylla-boost-thread-1.58.0-11.el7.centos.x86_64.rpm
 scylla-conf-1.5.0-20161221.654919c.el7.centos.x86_64.rpm
 scylla-boost-test-1.58.0-11.el7.centos.x86_64.rpm
 scylla-env-1.0-1.el7.centos.noarch.rpm
 scylla-kernel-conf-1.5.0-20161221.654919c.el7.centos.x86_64.rpm
 python34-libs-3.4.5-2.el7.x86_64.rpm
 qt-4.8.5-11.el7.x86_64.rpm
 thrift-0.9.1-13.el7.x86_64.rpm
 tzdata-java-2015g-1.el7.noarch.rpm
 yajl-2.0.4-4.el7.x86_64.rpm
 yaml-cpp-0.5.1-6.el7.x86_64.rpm
 java-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64.rpm

制作本地 REPO,脚本 make_local_repo.sh 内容如下,我们需要保证该包和 YUM 缓存具备一样的目录结构:

#!/bin/bash
set -x

OPS_BASE_PATH=/home/admin/ops/admin/20170316_build_scylladb
SCYLLA_VERSION=1.5
REPO_NAME=scylla_${SCYLLA_VERSION}_repo
LOCAL_REPO_PATH=${OPS_BASE_PATH}/${REPO_NAME}

releasever=`rpm -qi centos-release | grep "Version" | awk -F ':' '{print$2}' | sed 's/ //g'`
basearch=`rpm -qi centos-release | grep "Architecture" | awk -F ':' '{print$2}' | sed 's/ //g'`
yum_cache_path=/var/cache/yum/${basearch}/${releasever}

cd ${yum_cache_path}
tar zcvf ${OPS_BASE_PATH}/${REPO_NAME}.tar.gz ./*

这样,在 /home/admin/ops/admin/20170316_build_scylladb 下就生成了一个本地安装包 scylla_1.5_repo.tar.gz

安装

拷贝 REPO 至 172.16.134.15,分发:

#!/bin/bash
set -x

OPS_BASE_PATH=/home/admin/ops/admin/20170316_build_scylladb
SCYLLA_VERSION=1.5
REPO_NAME=scylla_${SCYLLA_VERSION}_repo
releasever=`rpm -qi centos-release | grep "Version" | awk -F ':' '{print$2}' | sed 's/ //g'`
basearch=`rpm -qi centos-release | grep "Architecture" | awk -F ':' '{print$2}' | sed 's/ //g'`
yum_cache_path=/var/cache/yum/${basearch}/${releasever}

pscp -h list_all ${OPS_BASE_PATH}/${REPO_NAME}.tar.gz /tmp
pssh -h list_all "sudo tar zxvf /tmp/${REPO_NAME}.tar.gz -C ${yum_cache_path}"

修改 scylla.repo

[scylla]
name=Scylla for Centos $releasever - $basearch
baseurl=file:///var/cache/yum/$basearch/$releasever/
enabled=1
gpgcheck=0

[scylla-generic]
name=Scylla for centos $releasever
baseurl=file:///var/cache/yum/$basearch/$releasever/
enabled=1
gpgcheck=0

[scylla-3rdparty]
name=Scylla 3rdParty for Centos $releasever - $basearch
baseurl=file:///var/cache/yum/$basearch/$releasever/
enabled=1
gpgcheck=0

[scylla-3rdparty-generic]
name=Scylla 3rdParty for Centos $releasever
baseurl=file:///var/cache/yum/$basearch/$releasever/
enabled=1
gpgcheck=0

分发 scylla.repo

pscp -h list_all /etc/yum.repos.d/scylla.repo /tmp
pssh -h list_all "sudo cp /tmp/scylla.repo /etc/yum.repos.d/"

安装 scylla:

pssh -h list_all "sudo yum install -y scylla"

配置及启动

分发list_all 到所有节点 /tmp 目录:

pscp -h list_all list_all /tmp

修改 /etc/scylla/scylla.yaml ,脚本 init_scylla_config.sh 内容如下:

#!/bin/bash

processor_num=`cat /proc/cpuinfo  | grep processor | wc -l`
for ip in `cat /tmp/list_all`;do ip_list="${ip_list},${ip}";done
ip_list=`echo ${ip_list} | sed 's/^[ \t,]*//g'`
host_ip=`hostname -i`

sudo cp /etc/scylla/scylla.yaml /etc/scylla/scylla.yaml.oringin
cp /etc/scylla/scylla.yaml /tmp

sed -i "s/cluster_name: 'Test Cluster'/cluster_name: 'Dev Test Cluster'/"  /tmp/scylla.yaml
sed -i "s/seeds: \"127.0.0.1\"/seeds: \"${ip_list}\"/" /tmp/scylla.yaml
sed -i "s/#memtable_flush_writers: 8/memtable_flush_writers: ${processor_num}/" /tmp/scylla.yaml

sudo sed -i "s/listen_address: localhost/listen_address: ${host_ip}/" /tmp/scylla.yaml
sudo sed -i "s/rpc_address: localhost/rpc_address: ${host_ip}/" /tmp/scylla.yaml
sudo sed -i "s/api_address: 127.0.0.1/api_address: ${host_ip}/" /tmp/scylla.yaml
 
sudo cp /tmp/scylla.yaml /etc/scylla/scylla.yaml

分发脚本并执行:

pscp -h list_all init_scylla_config.sh /tmp
pssh -h list_all "sudo /bin/bash /tmp/init_scylla_config.sh"

初始化,虚拟机请一路 YES (直到最后询问是否需要安装 node_exporter 的时候选择 NO):

sudo scylla_setup
sudo reboot

重启后启动进程:

sudo systemctl start scylla-server
sudo systemctl start scylla-jmx
# 观察集群情况
nodetool status

你可能感兴趣的:(ScyllaDB 学习 - 基础部署)