四、安装配置redis的cluster集群、memcached高可用及VMware exsi

1、安装配置redis的cluster集群

1.1环境准备

六台服务器

① 192.168.37.17:6379

② 192.168.37.27:6379

③ 192.168.37.37:6379

④ 192.168.37.47:6379

⑤ 192.168.37.57:6379

⑥ 192.168.37.67:6379

1.2 编译安装redis(六台服务器相同)

安装相关依赖库:yum -y install gcc  automake autoconf libtool make zlib zlib-devel  tcl

切换目录:cd /usr/local/src/

解包:tar xvf redis-4.0.14.tar.gz

切换目录:cd redis-4.0.14

安装:make PREFIX=/usr/local/redis install

复制配置文件:mkdir /usr/local/redis/etc    cp /usr/local/src/redis-4.0.14/redis.conf  /usr/local/redis/etc/

创建软连接:ln -sv /usr/local/redis/bin/redis-* /usr/bin/

创建用户:groupadd -g 1500 redis && useradd -u 1500 -g 1500 redis -s /sbin/nologin

创建相关目录:mkdir -pv /usr/local/redis/{etc,logs,data,run}

更改权限:chown redis.redis -R /usr/local/redis/

1.3 安装 集群管理工具 redis-trib.rb

yum安装:yum install ruby rubygems -y

cp /usr/local/src/redis-4.0.14/src/redis-trib.rb /usr/bin/

版本较低无法使用:


删除:rm -f /usr/bin/redis-trib.rb

1.4 解决 ruby 版本较低问题:

卸载ruby:yum remove ruby rubygems -y

删除文件:rm -f /usr/bin/redis-trib.rb

下载2.5版本ruby:wget https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.5.tar.gz

解包:tar xf ruby-2.5.5.tar.gz

切换目录:cd ruby-2.5.5

安装: ./configuremake && make install

创建软连接: cp /opt/redis-4.0.14/src/redis-trib.rb /usr/local/redis/bin/


1.5 修改配置文件

[root@cent711 ~]#cat /usr/local/redis/etc/redis.conf | grep "^[a-Z]"

protected-mode no

port 6379

tcp-backlog 511

timeout 0

tcp-keepalive 300

daemonize yes

supervised no

pidfile /usr/local/redis/run/redis_6379.pid

loglevel notice

logfile "/usr/local/redis/logs/redis.log"

databases 16

always-show-logo yes

save 900 1

save 300 10

save 60 10000

stop-writes-on-bgsave-error no

rdbcompression yes

rdbchecksum yes

dbfilename dump.rdb

dir /usr/local/redis/data

slave-serve-stale-data yes

slave-read-only yes

repl-diskless-sync no

repl-diskless-sync-delay 5

repl-disable-tcp-nodelay no

slave-priority 100

lazyfree-lazy-eviction no

lazyfree-lazy-expire no

lazyfree-lazy-server-del no

slave-lazy-flush no

appendonly no

appendfilename "appendonly.aof"

appendfsync everysec

no-appendfsync-on-rewrite no

auto-aof-rewrite-percentage 100

auto-aof-rewrite-min-size 64mb

aof-load-truncated yes

aof-use-rdb-preamble no

lua-time-limit 5000

cluster-enabled yes

cluster-config-file nodes-6379.conf

cluster-node-timeout 15000

slowlog-log-slower-than 10000

slowlog-max-len 128

latency-monitor-threshold 0

notify-keyspace-events ""

hash-max-ziplist-entries 512

hash-max-ziplist-value 64

list-max-ziplist-size -2

list-compress-depth 0

set-max-intset-entries 512

zset-max-ziplist-entries 128

zset-max-ziplist-value 64

hll-sparse-max-bytes 3000

activerehashing yes

client-output-buffer-limit normal 0 0 0

client-output-buffer-limit slave 256mb 64mb 60

client-output-buffer-limit pubsub 32mb 8mb 60

hz 10

aof-rewrite-incremental-fsync yes


依次拷贝到其他服务器:scp /usr/local/redis/etc/redis.conf 192.168.37.67:/usr/local/redis/etc/redis.conf

启动:redis-server /usr/local/redis/etc/redis.conf

1.6 创建 redis cluster 集群

创建:redis-trib.rb create  --replicas 1 192.168.37.17:6379  192.168.37.27:6379 192.168.37.37:6379 192.168.37.47:6379 192.168.37.57:6379 192.168.37.67:6379



1.3 查看集群状态

1.3.1 验证master状态


1.3.2 验证集群状态



1.3.3 查看集群node对应关系


1.3.4 验证集群写入key



2、安装配置memcached高可用

2.1 环境准备

server1:192.168.37.57

server2:192.168.37.67

2.2 部署 repcached

安装相关依赖库:yum -y install libevent libevent-devel gcc  automake autoconf libtool make zlib zlib-devel

下载包:wget https://sourceforge.net/projects/repcached/files/repcached/2.2.1-1.2.8/memcached-1.2.8-repcached-2.2.1.tar.gz

解包:tar xvf memcached-1.2.8-repcached-2.2.1.tar.gz

切换目录:cd memcached-1.2.8-repcached-2.2.1

安装:./configure  --prefix=/usr/local/repcached  --enable-replication

make #报错如下


解决报错:

vim memcached.c

56 #ifndef IOV_MAX

57 #if defined(__FreeBSD__) || defined(__APPLE__)

58 # define IOV_MAX 1024

59 #endif

60 #endif

改为如下内容:

55 /* FreeBSD 4.x doesn't have IOV_MAX exposed. */

56 #ifndef IOV_MAX

57 # define IOV_MAX 1024

58 #endif

继续安装:make && make install

2.3 验证是否可执行

memcached -h



2.4 启动  memcache

2.4.1 server 1 相关操作

/usr/local/repcached/bin/memcached -d -m 2048 -p 11211 -u root -c 2048 -x 192.168.37.67 -X 16000



2.4.2server 2 相关操作

/usr/local/repcached/bin/memcached-d -m 2048 -p 11211 -u root -c 2048 -x192.168.37.57 -X 16000

2.5 连接到 memcache 验证数据


3、安装VMware exsi

3.1 安装准备

调整内存及虚拟化功能


3.2 开始安装

3.3 安装完成


3.4 登录web管理界面



你可能感兴趣的:(四、安装配置redis的cluster集群、memcached高可用及VMware exsi)