1滔驾、安裝配置redis的cluster集群
1.1環(huán)境準備
六臺服務器
① 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/
創(chuàng)建軟連接:ln -sv /usr/local/redis/bin/redis-* /usr/bin/
創(chuàng)建用戶:groupadd -g 1500 redis && useradd -u 1500 -g 1500 redis -s /sbin/nologin
創(chuàng)建相關目錄: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
創(chuàng)建軟連接: 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 創(chuàng)建 redis cluster 集群
創(chuàng)建: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 查看集群狀態(tài)
1.3.1 驗證master狀態(tài)
1.3.2 驗證集群狀態(tài)
1.3.3 查看集群node對應關系
1.3.4 驗證集群寫入key
2、安裝配置memcached高可用
2.1 環(huán)境準備
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
改為如下內(nèi)容:
55 /* FreeBSD 4.x doesn't have IOV_MAX exposed. */
56 #ifndef IOV_MAX
57 # define IOV_MAX 1024
58 #endif
繼續(xù)安裝:make && make install
2.3 驗證是否可執(zhí)行
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 驗證數(shù)據(jù)
3俄讹、安裝VMware exsi
3.1 安裝準備
調整內(nèi)存及虛擬化功能