源码地址 https://gitee.com/jiangli31346337/gulimall.git
安装docker
1.卸载系统之前的docker
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
准备
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
安装
sudo yum install -y docker-ce docker-ce-cli containerd.io
启动
systemctl start docker
开机启动
systemctl enable docker
设置淘宝镜像加速
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://7lr4t6cd.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
安装mysql
docker pull mysql:5.7
创建docker网络
查看docker默认三种网络
docker network ls
删除自定义网络
docker network rm 自定义networkID
创建docker自定义网络
docker network create --subnet=172.18.0.0/16 net1
启动mysql
docker run -d -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=123456 -e TZ=Asia/Shanghai --restart=always --privileged --net=net1 --ip 172.18.0.2 mysql:5.7
修改mysql配置
vi /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
修改开机启动
docker update kibana --restart=always
安装redis
docker pull redis
创建redis配置文件
mkdir -p /mydata/redis/conf
touch /mydata/redis/conf/redis.conf
启动redis
docker run -d -p 6379:6379 --name redis -v /mydata/redis/data:/data -v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf --restart=always redis redis-server /etc/redis/redis.conf
开启redis AOF持久化, RDB持久化默认开启.重启redis
vi /mydata/redis/conf/redis.conf
appendonly yes
配置maven
nexus-aliyun
central
Nexus aliyun
http://maven.aliyun.com/nexus/content/groups/public
jdk-1.8
true
1.8
1.8
1.8
1.8
配置Git
git config --global user.name "你的名字"
git config --global user.email "你的邮箱"
配置SSH免密登录Gitee
ssh-keygen -t rsa -C "注册时的邮箱"
3次回车生成密钥,查看密钥
cat ~/.ssh/id_rsa.pub
复制密钥,登录gitee,在设置->安全设置->SSH公钥,将.pub文件的内容粘贴进去
使用ssh -T [email protected] 测试是否成功. 输入yes
gitignore新增配置
**/mvnw
**/mvnw.cmd
**/.mvn
**/target/
**/.gitignore
.idea
docker pull elasticsearch:7.4.2
docker pull kibana:7.4.2
创建实例
discovery.type=single-node
表示,如果你正在使用单个节点开发,那就要添加这句话避开引导检查
mkdir -p /mydata/elasticsearch/config
mkdir -p /mydata/elasticsearch/data
chmod -R 777 /mydata/elasticsearch/
echo "http.host: 0.0.0.0" >> /mydata/elasticsearch/config/elasticsearch.yml
docker run -d --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx512m" -v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /mydata/elasticsearch/data:/usr/share/elasticsearch/data -v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins --net=net1 --ip 172.18.0.3 --restart=always elasticsearch:7.4.2
ik
https://github.com/medcl/elasticsearch-analysis-ik/releases
下载后放到plugin目录
kibana 填写es所在docker容器的ip
docker inspect XXXXXXX |grep IPAddress 这里xxxx是容器的id 通过docker ps查出
docker run --name kibana -e ELASTICSEARCH_HOSTS=http://172.18.0.3:9200 -p 5601:5601 --restart=always --net=net1 --ip 172.18.0.4 -d kibana:7.4.2
es测试数据 https://raw.githubusercontent.com/elastic/elasticsearch/master/docs/src/test/resources/accounts.json
POST /bank/account/_bulk
数据迁移
先创建正确的索引,然后使用吐下方法进行数据迁移
POST _reindex
{
"source":{
"index":"twitter"
},
"dest":{
"index":"new_twitter"
}
}
将旧索引的type下的数据进行迁移
POST _reindex
{
"source": {
"index": "bank",
"type": "account"
},
"dest": {
"index": "newbank"
}
}
安装nginx
docker run -p 80:80 --name nginx -v /mydata/nginx/html:/usr/share/nginx/html -v /mydata/nginx/logs:/var/log/nginx -v /mydata/nginx/conf:/etc/nginx --restart=always -d nginx:1.10
mapping
PUT product
{
"mappings": {
"properties": {
"skuId": {
"type": "long"
},
"spuId": {
"type": "keyword"
},
"skuTitle": {
"type": "text",
"analyzer": "ik_smart"
},
"skuPrice": {
"type": "keyword"
},
"skuImg": {
"type": "keyword",
"index": false,
"doc_values": false
},
"saleCount": {
"type": "long"
},
"hasStock": {
"type": "boolean"
},
"hotStore": {
"type": "long"
},
"brandId": {
"type": "long"
},
"catalogId": {
"type": "long"
},
"brandName": {
"type": "keyword",
"index": false,
"doc_values": false
},
"brandImg": {
"type": "keyword",
"index": false,
"doc_values": false
},
"catalogName": {
"type": "keyword",
"index": false,
"doc_values": false
},
"attrs": {
"type": "nested",
"properties": {
"attrId": {
"type": "long"
},
"attrName": {
"type": "keyword",
"index": false,
"doc_values": false
},
"attrValue": {
"type": "keyword"
}
}
}
}
}
}
Nginx代理给网关的时候,会丢失请求的host信息
proxy_set_header Host $host