下載
下載地址:https://redis.io/download
在/usr/local/src目錄下執(zhí)行下載。
wget http://download.redis.io/releases/redis-3.2.8.tar.gz
安裝
解壓到/usr/local/src目錄,放源碼包。
tar xzf redis-3.2.8.tar.gz
創(chuàng)建目錄/usr/local/redis:
make dir /usr/local/redis
進入源碼目錄:
cd /usr/local/src/redis-3.2.8
然后執(zhí)行下面make命令編譯安裝到目錄/usr/local/redis/ (放執(zhí)行文件)。
make PREFIX=/usr/local/redis install
軟連接
程序做軟連接到bin目錄,方便直接執(zhí)行。
ln -s /usr/local/redis/bin/redis-cli /usr/local/bin/redis-cli
ln -s /usr/local/redis/bin/redis-sentinel /usr/local/bin/redis-sentinel
ln -s /usr/local/redis/bin/redis-server /usr/local/bin/redis-server
配置文件
復制配置文件,在源碼包里有sentinel.conf和redis.conf文件,復制到/etc/redis/目錄下,如果有多個實例,建議改名,如本實例用的redis端口是7021,sentinel是17021:
cp /usr/local/src/redis-3.2.8/redis.conf /etc/redis/redis_6379.conf
cp /usr/local/src/redis-3.2.8/sentinel.conf /etc/redis/sentinel_26379.conf
redis_master_6379.conf配置
修改配置以下參數(shù):
port 6379
daemonize yes
#requirepass 123456
#masterauth 123456
其中,daemonize屬性改為yes(后臺運行)。
redis_slave_6380.conf 配置:
修改配置以下參數(shù):
port 6380
daemonize yes
#requirepass yingjun
slaveof 192.168.248.128 6379
masterauth 123456
其他slave配置同此配置。
sentinel_26379.conf 配置
port 23791
daemonize yes
logfile "/var/log/sentinel_63791.log"
#master-1
sentinel monitor master-1 192.168.248.128 6379 2
#sentinel auth-pass master-1 yingjun
sentinel_26380.conf 配置
port 23780
daemonize yes
logfile "/var/log/sentinel_63780.log"
#master-1
sentinel monitor master-1 192.168.248.128 6379 2
#sentinel auth-pass master-1 yingjun
啟動
順序依次啟動服務。
redis-server /etc/redis/redis_master_6379.conf
redis-server /etc/redis/redis_slave_6380.conf
redis-sentinel /etc/redis/sentinel_26379.conf
redis-sentinel /etc/redis/sentinel_26380.conf
查看進程是否都已經(jīng)啟動
[root@iZj6cqZ redis]# ps -ef | grep redis
root 10910 1 0 08:11 ? 00:00:00 redis-server 127.0.0.1:6379
root 10918 1 0 08:11 ? 00:00:00 redis-server 127.0.0.1:6380
root 10939 1 0 08:15 ? 00:00:00 redis-sentinel *:26379 [sentinel]
root 10944 1 0 08:15 ? 00:00:00 redis-sentinel *:26380 [sentinel]
root 10948 10851 0 08:15 pts/1 00:00:00 grep --color=auto redis
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。