标签:virt exe col gis 数据库数据 本地 error manage creating
快速搭建以下的环境:
VM环境
成品镜像
$ vagrant box add centos-7 ./centos-7.0-x86_64.box
$ vagrant init centos-7
$ vagrant up
$ vagrant ssh
修改端口
管理员
$ su root
# 密码 vagrant
$ whoami
入门案例:https://www.cnblogs.com/lawsssscat/p/12676477.html
修改语言:https://blog.csdn.net/liupeifeng3514/article/details/79005568
虚拟容器
docker常用命令
另外:
docker 容器重启策略:docker inspect 容器ID
删除旧版本
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
安装:官网教程 https://docs.docker.com/engine/install/centos/ (不推荐)
# 推荐
$ sudo yum install docker
开启
$ sudo systemctl start docker
$ sudo systemctl enable docker
阿里云容器镜像服务:https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
$ sudo mkdir -p /etc/docker
$ sudo tee /etc/docker/daemon.json <<-‘EOF‘
{
"registry-mirrors": ["https://eslh5xx9.mirror.aliyuncs.com"]
}
EOF
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
启动mysql
异常处理:error creating overlay mount to /var/lib/docker/overlay2
$ sudo docker pull mysql:5.7
$ sudo docker images
$ sudo docker run --name mysql --privileged=true -p 3307:3306 -v /dev/mydata/mysql/log:/var/log/mysql -v /dev/mydata/mysql/data:/var/lib/mysql -v /dev/mydata/mysql/conf:/etc/mysql -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7
-v
文件目录(卷)映射/dev/mydata/mysql/log:/var/log/mysql
日志映射到本地/dev/mydata/mysql/data:/var/lib/mysql
数据库数据映射到本地/dev/mydata/mysql/conf:/etc/mysql
配置文件映射到本地MYSQL_ROOT_PASSWORD=root
(必须)设置数据库密码进入mysql
docker exec -it mysql /bin/bash
Docker官网关于MySQL:5.7:https://hub.docker.com/_/mysql
Docker官网关于MySQL:5.7的Dockerfile:https://github.com/docker-library/mysql/blob/d284e15821ac64b6eda1b146775bf4b6f4844077/5.7/Dockerfile
修改编码
vim /dev/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_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
重启mysql ,并进入
docker restart mysql
docker exec -it mysql /bin/bash
开启随docker启动而启动
$ sudo docker update mysql --restart=always
安装
$ sudo docker pull redis
开启数据持久化
vim /dev/mydata/redis/conf/redis.conf
输入配置
# 启用AOF持久化
appendonly yes
启动
$ sudo docker run --name redis -v /dev/mydata/redis/data:/data -v /dev/mydata/redis/conf:/etc/redis -p 6379:6379 -d redis redis-server /etc/redis/redis.conf
$
注意:这里的路径映射不能是文件,因为会被覆盖为目录,再次启动会报错
开启随docker启动而启动
$ sudo docker update redis --restart=always
客户端登录
docker exec -it redis redis-cli
docker restart redis
- Redis Desktop Manager 可视化工具
- redis 系列: https://blog.csdn.net/LawssssCat/article/details/105087326
标签:virt exe col gis 数据库数据 本地 error manage creating
原文地址:https://www.cnblogs.com/lawsssscat/p/12687207.html