Docker安装Redis(docker-compose.yml)

Docker安装RabbitMQ(docker-compose.yml)
 

前置条件

请先安装Docker 

 

创建docker-compose.yml文件

version: '2'
services:

  #redis容器
  redis:
    #定义主机名
    hostname: myredis
    #使用的镜像
    image: redis:5.0.2
    #容器的映射端口
    ports:
      - 6381:6379
    restart: always
    #定义挂载点
    volumes:
      - ./redis/data:/data
    #环境变量
    environment:
      - TZ=Asia/Shanghai
      - LANG=en_US.UTF-8

将以上文件保存为docker-compose.yml文件

 

启动docker-compose脚本

docker-compose up

 

启动日志

AppledeMacBook-Pro:~ apple$ cd ~/Docker/Workspace/
AppledeMacBook-Pro:Workspace apple$ ls
activemq	rabbitmq
AppledeMacBook-Pro:Workspace apple$ mkdir redis
AppledeMacBook-Pro:Workspace apple$ cd redis/
AppledeMacBook-Pro:redis apple$ ls
AppledeMacBook-Pro:redis apple$ vim docker-compose.yml
AppledeMacBook-Pro:redis apple$ docker-compose up
Creating network "redis_default" with the default driver
Pulling redis (redis:5.0.2)...
5.0.2: Pulling from library/redis
a5a6f2f73cd8: Pull complete
a6d0f7688756: Pull complete
53e16f6135a5: Pull complete
b761e99e9c9c: Pull complete
13686b3f2e29: Pull complete
667e8fd02be2: Pull complete
Creating redis_redis_1 ... done
Attaching to redis_redis_1
redis_1  | 1:C 16 Apr 2019 14:57:30.990 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1  | 1:C 16 Apr 2019 14:57:30.992 # Redis version=5.0.2, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1  | 1:C 16 Apr 2019 14:57:30.992 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1  | 1:M 16 Apr 2019 14:57:30.993 * Running mode=standalone, port=6379.
redis_1  | 1:M 16 Apr 2019 14:57:30.993 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1  | 1:M 16 Apr 2019 14:57:30.993 # Server initialized
redis_1  | 1:M 16 Apr 2019 14:57:30.993 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis_1  | 1:M 16 Apr 2019 14:57:30.994 * Ready to accept connections
redis_1  | 1:M 16 Apr 2019 14:59:16.765 * DB saved on disk
redis_1  | 1:M 16 Apr 2019 14:59:28.481 * DB saved on disk

 

Redis命令行

AppledeMacBook-Pro:~ apple$ redis-cli -h 127.0.0.1 -p 6381
127.0.0.1:6381> 
127.0.0.1:6381> 
127.0.0.1:6381> keys
(error) ERR wrong number of arguments for 'keys' command
127.0.0.1:6381> keys *
(empty list or set)
127.0.0.1:6381> 
127.0.0.1:6381> 
127.0.0.1:6381> 
127.0.0.1:6381> flushall
OK

 

 

  • 6
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值