systemctl stop firewalld && systemctl disable firewalld
setenforce 0
vim /etc/selinux/config
#编辑 SELINUX=disabled
iptables -F && iptables-save
yum -y install docker
systemctl start docker
systemctl enable docker
# docker版本
[root@localhost ~]# docker --version
Docker version 1.13.1, build 7d71120/1.13.1
docker search redis
docker pull redis
宿主机的位置选择可以根据磁盘空间大小自由选择
宿主机redis.cof文件
位置 : /data/redis/conf/redis.cof
mkdir -p /data/redis/conf
cd /data/redis/conf
vi redis.conf
#将⭐七、配置文件内容 进行复制
宿主机redis-data
位置 : /data/redis/data
mkdir -p /data/redis/data
docker run -itd --name redis --restart=always --log-opt max-size=100m --log-opt max-file=2 -p 6379:6379 -v /data/redis/conf/redis.conf:/etc/redis/redis.conf -v /data/redis/data:/data redis redis-server /etc/redis/redis.conf --appendonly yes --requirepass qwe123
老版本
docker在启动的时候可能会报错
;是因为老版本的docker日志驱动程序是:journald
... unknown log opt 'max-file' for journald log driver
修改配置文件
vim /etc/sysconfig/docker
#编辑
原文:OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false'
编辑后:OPTIONS='--selinux-enabled --log-driver=json-file --signature-verification=false'
重启dokcer加载配置文件
systemctl daemon-reload && systemctl restart docker
docker ps -a | grep redis
docker logs -f redis
docker exec -it redis redis-cli
redis.conf配置文件
protected-mode no
port 6379
tcp-backlog 511
#redis密码 强烈建议设置复杂一些
requirepass qwe123
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile ""
databases 30
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir ./
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-disable-tcp-nodelay no
replica-priority 100
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
appendonly yes
appendfilename "appendonly.aof"
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
slowlog-max-len 128
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
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes