redis单机安装
一、安装依赖,redis是C语言写的
[root@t2 ~]# yum install -y gcc
二、下载redis
mkdir /app && cd app
[root@t2 app]# wget http://download.redis.io/releases/redis-5.0.8.tar.gz
三、解压安装包
tar -zxvf redis-5.0.8.tar.gz
四、编译安装redis
#进入解压目录
[root@t2 app]# cd redis-5.0.8
#编译
[root@t2 redis-5.0.8]# make
#出现这个说明成功编译
Hint: It's a good idea to run 'make test' ;)
make[1]: Leaving directory `/app/redis-5.0.8/src'
#make test 运行测试,确认redis的功能是否正常
#我centos7缺tcl包、执行以下命令安装、安装完重新编译
[root@t2 ~]# yum install tcl -y
[root@t2 ~]# make distclean
[root@t2 ~]# make
#出现下面的提示说明测试成功
\o/ All tests passed without errors!
Cleanup: may take some time... OK
make[1]: Leaving directory `/app/redis-5.0.8/src
#指定目录安装
[root@t2 src]# make install PREFIX=/app/redis/
#出现以下提示就成功了
Hint: It's a good idea to run 'make test' ;)
INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
五、启动redis
#复制配置文件到刚刚的安装目录/app/redis
cd /app/redis && mkdir conf && cd conf
cp /app/redis-5.0.8/redis.conf ./
#创建pid文件
[root@t2 redis]# pwd
/app/redis
#创建以下目录存数据,pid,日志
[root@t2 redis]# mkdir {pid,logs,data}
[root@t2 pid]# cd pid/
[root@t2 pid]# touch redis_6379.pid
#更改配置文件(我主要改了下面我贴出来的,其他都没改)
[root@t2 conf]# cat redis.conf |grep -v ^"#" | grep -v ^$
bind 0.0.0.0
port 6379
daemonize yes
pidfile /app/redis/pid/redis_6379.pid
logfile "/app/redis/logs/redis-6379.log"
dbfilename dump-6379.rdb
dir /app/redis/data
appendfilename "appendonly.aof"
###启动
[root@t2 bin]# pwd
/app/redis/bin
[root@t2 bin]# ./redis-server ../conf/redis.conf
六、测试
#连接测试、成功安装了redis
[root@t2 bin]# ./redis-cli
127.0.0.1:6379> set tzh 11
OK
127.0.0.1:6379> get tzh
"11"
127.0.0.1:6379> exit
docker run -d \
--name redis6 \
--restart always \
-p 26379:6379 \
-v redis6-data:/data \
--ulimit nofile=65535:65535 \
--log-driver json-file \
--log-opt max-size=100m \
--log-opt max-file=3 \
--health-cmd='redis-cli -a "Redis5_Strong_Passwd_ChangeMe" ping | grep PONG || exit 1' \
--health-interval=30s \
--health-timeout=5s \
--health-retries=5 \
redis:6.2.18 \
redis-server \
--bind 0.0.0.0 \
--protected-mode yes \
--port 6379 \
--requirepass "Redis5_Strong_Passwd_ChangeMe" \
--appendonly yes \
--appendfsync everysec \
--save 900 1 \
--save 300 10 \
--save 60 10000 \
--stop-writes-on-bgsave-error yes \
--rdbcompression yes \
--rdbchecksum yes \
--tcp-keepalive 300 \
--timeout 0 \
--databases 16 \
--maxclients 10000
docker run -d \
--name redis5 \
--restart always \
-p 6380:6379 \
-v redis5-data:/data \
--ulimit nofile=65535:65535 \
--log-driver json-file \
--log-opt max-size=100m \
--log-opt max-file=3 \
--health-cmd='redis-cli -a "Redis5_Strong_Passwd_ChangeMe" ping | grep PONG || exit 1' \
--health-interval=30s \
--health-timeout=5s \
--health-retries=5 \
redis:5.0.14 \
redis-server \
--bind 0.0.0.0 \
--protected-mode yes \
--port 6379 \
--requirepass "Redis5_Strong_Passwd_ChangeMe" \
--appendonly yes \
--appendfsync everysec \
--save 900 1 \
--save 300 10 \
--save 60 10000 \
--stop-writes-on-bgsave-error yes \
--rdbcompression yes \
--rdbchecksum yes \
--tcp-keepalive 300 \
--timeout 0 \
--databases 16 \
--maxclients 10000

浙公网安备 33010602011771号