当前位置:网站首页>Docker安装Mysql、Redis
Docker安装Mysql、Redis
2022-06-11 06:00:00 【暴躁的程序猿啊】
centos安装docker步骤
这里
启动docker服务
systemctl start docker
设置docker开机自启动
systemctl enable docker
查看所有镜像
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
redis latest 7faaec683238 7 months ago 113MB
tomcat 9.0 9427bc9144fa 8 months ago 680MB
nacos/nacos-server latest bdf60dc2ada3 10 months ago 1.05GB
hello-world latest d1165f221234 15 months ago 13.3kB
zookeeper 3.5.7 6bd990489b09 2 years ago 245MB
mysql 5.7.26 e9c354083de7 2 years ago 373MB
redis 3.2 87856cc39862 3 years ago 76MB
拉取mysql5.7版本镜像
docker pull mysql:5.7
运行镜像
docker run --name mysql
-v /mydata/mysql/data:/var/lib/mysql\
-v /mydata/mysql/conf:/etc/mysql\
-v /mydata/mysql/log:/var/log/mysql\
-e MYSQL_ROOT_PASSWORD=root\
-p 3306:3306 -d mysql:5.7
参数
-v /mydata/mysql/data:/var/lib/mysql\ 将数据文件挂载到主机 :前面的是主机目的地址:后面的是容器中的目录地址
-v /mydata/mysql/conf:/etc/mysql\ 将配置文件挂载到主机
-v /mydata/mysql/log:/var/log/mysql\ 将日志文件挂载到主机
查看运行的容器
docker ps
[root~]# docker p
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6f2e3327238f mysql:5.7.26 "docker-entrypoint.s…" 6 months ago Exited (0) 6 months ago mysql
进入到交互式mysql中
docker exec -it 6f2e3327238f /bin/bash
修改mysql的配置文件 设置字符编码等
vim /mydata/mysql/conf/my.cnf
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8
skip-character-set-client-handshake
skip-name-resolve
重启mysql docker restart mysql
安装redis
拉取镜像
docker pull redis
启动redis
创建文件夹
mkdir -p /mydata/redis/conf
touch /mydata/redis/conf/redis.conf
docker run -p 6379:6379 --name redi -v /mydata/redis/data:/data\
-v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf\
-d redis redis-server /etc/redis/redis.conf --privileged=true
注意,最新版的命令不同,容器内的conf文件的位置变为了/usr/local/etc/redis/redis.conf
mkdir -p /mydata/redis/conf
touch /mydata/redis/conf/redis.con
进入到redis控制台
docker exec -it redis redis-cli
开启redis持久化
vim /mydata/redis/conf/redis.conf
加入
bind 0.0.0.0 开启远程权限
appendonly yes 开启aof持久化
重启redis
docker restart redis
边栏推荐
- Box model
- Matlab实现均值滤波与FPGA进行对比,并采用modelsim波形仿真
- 跨境电商测评自养号团队应该怎么做?
- Sqli-labs less-01
- Gilde failed to go to the listener to call back the reason record when loading the Gaussian blur image
- Array partial method
- Devsecops in Agile Environment
- Qmake implementation of QT project Pro script to vs solution
- NLP-D46-nlp比赛D15
- Twitter data collection (content, fans, keywords, etc.)
猜你喜欢

Build the first power cloud platform

Servlet

Global case | how an airline with a history of 100 years can expand and transform to promote innovation in the aviation industry

Compliance management 101: processes, planning and challenges

Sign for this "plug-in" before returning home for the new year

我们真的需要会议耳机吗?

Global case | how Capgemini connects global product teams through JIRA software and confluence

Detailed steps for installing mysql-5.6.16 64 bit green version

Do you know the functions of getbit and setbit in redis?

跨境电商测评自养号团队应该怎么做?
随机推荐
Installing MySQL for Linux
Cenos7 builds redis-3.2.9 and integrates jedis
Méthode de la partie du tableau
What do you need to know about Amazon evaluation?
JS -- reference type
使用Genymotion Scrapy控制手机
Sqli-libs range 23-24 filtration and secondary injection practice
Vscode plug-in development
Clojure installation of metabase source code secondary development
Implementation of data access platform scheme (Youzu network)
PgSQL reports an error: current transaction is aborted, commands ignored until end of transaction block
修复Yum依赖冲突
Metabase源码二次开发之Clojure 安装
Quartz2d drawing technology
Database basic instruction set
Chapter 2 of machine learning [series] logistic regression model
Don't be afraid of xxE vulnerabilities: understand their ferocity and detection methods
JIRA software annual summary: release of 12 important functions
使用Batch枚舉文件
This is probably the most comprehensive project about Twitter information crawler search on the Chinese Internet