当前位置:网站首页>大型电商项目-环境搭建
大型电商项目-环境搭建
2022-07-03 09:30:00 【小破程序员】
1.使用docker安装mysq5.7和 redis
docker pull mysql:5.7

执行下面的指令,然后mysql就装好了
docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root \
-d mysql:5.7
使用docker -ps 查看正在运行的容器

如下图说明mysql已经安装好并创建了一个容器正在运行
指令说明:
docker run -p 3306:3306 --name mysql 创建并启动mysql容器
ip 前面一个3306是docker的端口,后面的3306是容器内部mysql的端口
--name 就是给运行的容器起一个名字
-v /mydata/mysql/log:/var/log/mysql \ /mydata/mysql/log是linux本机的目录,后面/var/log/mysql \ 是mysql容器里面的目录,这里的意思是,将容器里的目录挂载到本机,当容器内对应目录中的文件发生改变的时候,本地的linux对应目录中的内容也会发生改变,这样做是为了简化操作,不用每次要看文件的时候都要先进入到容器中。在外部修改以后,容器内部也会跟着变化。
其实,每个容器都是一个完整的linux运行环境,拿mysql俩说,mysql容器包含linux的kernel(内核)和mysql软件
配置mysql, 在/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
安装redis
docker pull redis
然后配置redis,执行下面的命令,创建redis容器并在mydata下面映射redis的配置文件
docker run -p 6379:6379 --name redis \
-v /mydata/redis/data:/data \
-v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf \
-d redis redis-server /etc/redis/redis.conf
测试redis,启动redis客户端
docker exec -it redis redis-cli

这时候的redis数据只能保存在内存中,并不能持久话,配置redis的持久化,开启aof持久化。在redis.conf 配置文件中增加配置
appendonly yes
边栏推荐
- extern关键字
- Numpy quick start (I) -- pre knowledge (create array + constant + data type)
- Judging the connectivity of undirected graphs by the method of similar Union and set search
- Ut2014 learning notes
- Leetcode刷题---852
- Leetcode skimming ---374
- Multi-Task Feature Learning for Knowledge Graph Enhanced Recommendation
- Handwritten digit recognition: CNN alexnet
- A complete mall system
- 六、MySQL之数据定义语言(一)
猜你喜欢
Secure in mysql8.0 under Windows_ file_ Priv is null solution
Hands on deep learning pytorch version exercise solution - 2.6 probability
[SQL] an article takes you to master the operations related to query and modification of SQL database
Free online markdown to write a good resume
2021-09-22
一个30岁的测试员无比挣扎的故事,连躺平都是奢望
Linear regression of introduction to deep learning (pytorch)
MySQL reports an error "expression 1 of select list is not in group by claim and contains nonaggre" solution
High imitation Netease cloud music
Hands on deep learning pytorch version exercise solution -- implementation of 3-2 linear regression from scratch
随机推荐
Advantageous distinctive domain adaptation reading notes (detailed)
Leetcode刷题---10
Leetcode刷题---44
Free online markdown to write a good resume
C#项目-寝室管理系统(1)
High imitation bosom friend manke comic app
Leetcode skimming ---217
Leetcode刷题---75
MySQL报错“Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre”解决方法
mysql5.7安装和配置教程(图文超详细版)
Training effects of different data sets (yolov5)
[untitled] numpy learning
Model evaluation and selection
Data preprocessing - Data Mining 1
Leetcode刷题---852
Powshell's set location: unable to find a solution to the problem of accepting actual parameters
Leetcode刷题---217
Practical part: conversion of Oracle Database Standard Edition (SE) to Enterprise Edition (EE)
Content type ‘application/x-www-form-urlencoded;charset=UTF-8‘ not supported
Jupiter notebook changing font style and font size