(编辑:jimmy 日期: 2024/12/29 浏览:2)
本文是基于CentOS 7.3系统环境,进行MySQL和Redis的安装和使用
(1) 拉取MySQL镜像
docker pull mysql:5.6
(2) 运行并配置MySQL
docker run -p 3306:3306 --name xz_mysql -v /data/mysql/conf:/etc/mysql/conf.g -v /data/mysql/logs:/logs -v /data/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
(3) 进入MySQL镜像容器
docker exec -it xz_mysql /bin/bash
(4) 进入MySQL
mysql -uroot -p123456
(1) 拉取Redis镜像
docker pull redis:3.2
(2) 运行并配置Redis
docker run -p 6379:6379 --name xz_redis -v /data/redis/conf/redis.conf:/usr/local/etc/redis/redis.conf -v /data/mysql/data:/data -d redis:3.2 redis server /usr/local/etc/redis/redis.conf --appendonly yes
(3) 新建配置文件redis.conf
cd /usr/local/etc/redis/redis.conf vim redis.conf 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
(4) 进入redis镜像容器
docker exec -it xz_redis redis-cli