1. 程式人生 > 其它 >第160天學習打卡(專案 穀粒商城 2)

第160天學習打卡(專案 穀粒商城 2)

Docker 安裝redis

docker pull redis


mkdir -p /home/redis/conf
touch /home/redis/conf/redis.conf


docker run -p 6379:6379 --name redis \
-v /home/redis/data:/data \
-v /home/redis/conf/redis.conf:/etc/redis/redis.conf \
-d redis redis-server /etc/redis/redis.conf



docker exec -it redis redis-cli
[root@stor01 ~]# docker pull redis
Using default tag: latest
latest: Pulling from library/redis
69692152171a: Pull complete
a4a46f2fd7e0: Pull complete
bcdf6fddc3bd: Pull complete
2902e41faefa: Pull complete
df3e1d63cdb1: Pull complete
fa57f005a60d: Pull complete
Digest: sha256:7e2c6181ad5c425443b56c7c73a9cd6df24a122345847d1ea9bb86a5afc76325
Status: Downloaded newer image for redis:latest
docker.io/library/redis:latest
[root@stor01 ~]# mkdir -p /home/redis/conf
[root@stor01 ~]# cd home/
-bash: cd: home/: No such file or directory
[root@stor01 ~]# cd /home/
[root@stor01 home]# ls
apache-tomcat-9.0.44-windows-x64 dockerfile jdk-8u291-linux-x64.tar.gz my_wordpress test
apache-tomcat-9.0.45 Dockerfile kuangapp qinjiang tomcatlogs
apache-tomcat-9.0.45.tar.gz docker-test-volume kuangshen readme.txt www
ceshi idea kuangshen.java redis
composetest jdk-8u291-linux-x64.rpm mysql swagger-demo-0.0.1-SNAPSHOT.jar
[root@stor01 home]# cd redis
[root@stor01 redis]# ls
conf
[root@stor01 redis]# cd conf/
[root@stor01 conf]# ls
[root@stor01 conf]# touch redis.conf
[root@stor01 conf]# docker run -p 6379:6379 --name redis \
> -v /home/redis/data:/data \
> -v /home/redis/conf/redis.conf:/etc/redis/redis.conf \
> -d redis redis-server /etc/redis/redis.conf
3f0d4b93585733149fbac8bf8f56ae6895ced9c37e30415840bbfb9105267546
docker: Error response from daemon: driver failed programming external connectivity on endpoint redis (42c7fe4056672cec5a27373b945e0f1ac073f889ba33d668658839559595ae84): Error starting userland proxy: listen tcp4 0.0.0.0:6379: bind: address already in use.
[root@stor01 conf]# netstat -tanlp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1070/sshd
tcp 0 0 0.0.0.0:36247 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:8888 0.0.0.0:* LISTEN 2015/python
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 22399/docker-proxy
tcp 0 0 0.0.0.0:49610 0.0.0.0:* LISTEN 32588/rpc.statd
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 21994/redis-server
tcp 0 0 0.0.0.0:26379 0.0.0.0:* LISTEN 20898/redis-sentine
tcp 0 0 127.0.0.1:6381 0.0.0.0:* LISTEN 9030/redis-server 1
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 32590/rpcbind
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 3238/nginx: master
tcp 0 0 0.0.0.0:20048 0.0.0.0:* LISTEN 32598/rpc.mountd
tcp 0 0 127.0.0.1:6379 127.0.0.1:43414 ESTABLISHED 21994/redis-server
tcp 0 0 127.0.0.1:51850 127.0.0.1:8888 TIME_WAIT -
tcp 0 0 127.0.0.1:6381 127.0.0.1:51562 ESTABLISHED 9030/redis-server 1
tcp 0 0 127.0.0.1:6379 127.0.0.1:57228 ESTABLISHED 21994/redis-server
tcp 0 0 127.0.0.1:51562 127.0.0.1:6381 ESTABLISHED 20898/redis-sentine
tcp 0 0 172.16.229.113:22 39.129.5.60:58158 ESTABLISHED 22735/sshd: root@pt
tcp 0 0 172.16.229.113:22 39.129.5.60:65250 ESTABLISHED 22773/sshd: root@no
tcp 0 0 172.16.229.113:8888 167.99.203.197:61000 ESTABLISHED 2015/python
tcp 0 0 172.16.229.113:8888 167.99.106.172:38372 ESTABLISHED 2015/python
tcp 0 0 127.0.0.1:43414 127.0.0.1:6379 ESTABLISHED 20898/redis-sentine
tcp 0 0 172.16.229.113:8888 8.133.179.231:49404 ESTABLISHED 2015/python
tcp 0 0 127.0.0.1:35494 127.0.0.1:6381 ESTABLISHED 20898/redis-sentine
tcp 0 0 172.16.229.113:33730 100.100.30.26:80 ESTABLISHED 18813/AliYunDun
tcp 0 0 172.16.229.113:57156 100.100.18.120:443 TIME_WAIT -
tcp 0 0 172.16.229.113:8888 50.18.103.180:57644 ESTABLISHED 2015/python
tcp 0 0 172.16.229.113:8888 104.152.52.25:50739 ESTABLISHED 2015/python
tcp 0 0 127.0.0.1:6381 127.0.0.1:35494 ESTABLISHED 9030/redis-server 1
tcp 0 0 127.0.0.1:45163 127.0.0.1:6381 ESTABLISHED 21994/redis-server
tcp 0 0 127.0.0.1:57228 127.0.0.1:6379 ESTABLISHED 20898/redis-sentine
tcp 0 0 127.0.0.1:6381 127.0.0.1:45163 ESTABLISHED 9030/redis-server 1
tcp6 0 0 :::44252 :::* LISTEN -
tcp6 0 0 :::2049 :::* LISTEN -
tcp6 0 0 :::26379 :::* LISTEN 20898/redis-sentine
tcp6 0 0 :::111 :::* LISTEN 32590/rpcbind
tcp6 0 0 :::20048 :::* LISTEN 32598/rpc.mountd
tcp6 0 0 :::40625 :::* LISTEN 32588/rpc.statd
[root@stor01 conf]# kill 21994
[root@stor01 conf]# docker run -p 6379:6379 --name redis -v /home/redis/data:/data -v /home/redis/conf/redis.conf:/etc/redis/redis.conf -d redis redis-server /etc/redis/redis.conf
docker: Error response from daemon: Conflict. The container name "/redis" is already in use by container "3f0d4b93585733149fbac8bf8f56ae6895ced9c37e30415840bbfb9105267546". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
[root@stor01 conf]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3f0d4b935857 redis "docker-entrypoint.s…" 3 minutes ago Created redis
950ef303c587 mysql:8.0.23 "docker-entrypoint.s…" 19 hours ago Up 18 hours 0.0.0.0:3306->3306/tcp, 33060/tcp mysql
57599ed1ba88 fa989ba2cbe1 "java -jar /app.jar …" 2 weeks ago Exited (143) 5 days ago kuangapp_kuangapp_1
686d572dfbfa efb4fa30f1cf "docker-entrypoint.s…" 2 weeks ago Exited (0) 5 days ago kuangapp_redis_1
76d02308eabb 7149d6fde740 "flask run" 2 weeks ago Exited (137) 2 weeks ago composetest_web_1
e05f32db1027 efb4fa30f1cf "docker-entrypoint.s…" 2 weeks ago Exited (0) 2 weeks ago composetest_redis_1
fa0487332774 d1165f221234 "/hello" 2 weeks ago Exited (0) 2 weeks ago cool_wu
[root@stor01 conf]# docker rm 3f0d4b935857
3f0d4b935857
[root@stor01 conf]# docker run -p 6379:6379 --name redis -v /home/redis/data:/data -v /home/redis/conf/redis.conf:/etc/redis/redis.conf -d redis redis-server /etc/redis/redis.conf
b457f1db47ccd8d70c0a589ac3c051cca5c7d7ef9a1447851b5f1ef7c24b1ad6
[root@stor01 conf]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b457f1db47cc redis "docker-entrypoint.s…" 20 seconds ago Up 19 seconds 0.0.0.0:6379->6379/tcp redis
950ef303c587 mysql:8.0.23 "docker-entrypoint.s…" 19 hours ago Up 18 hours 0.0.0.0:3306->3306/tcp, 33060/tcp mysql
[root@stor01 conf]# ls
redis,conf redis.conf
[root@stor01 conf]# rm redis.docker conf
rm: remove regular empty file ‘redis,conf’? y
[root@stor01 conf]# ls
redis.conf
[root@stor01 conf]# cat redis.conf
cat: redis.conf: Is a directory
[root@stor01 conf]# docker exec -it redis redis-cli
127.0.0.1:6379> set a b
(error) READONLY You can't write against a read only replica.
127.0.0.1:6379> slaveof no one
OK
127.0.0.1:6379> set a b
OK
127.0.0.1:6379>

遇到的問題:出現下面的錯誤,表示當前redis服務是隻讀的,沒有寫許可權,估計該服務是被當作從資料庫使用了。

27.0.0.1:6379> set a b
(error) READONLY You can't write against a read only replica

解決辦法:

127.0.0.1:6379> slaveof no one
OK
127.0.0.1:6379> set a b
OK

redis持久化操作, 我的修改不了這個檔案 所以沒有修改 而且 退出後再進人 也能獲取值

[root@stor01 conf]# vi redis.conf

appendonly yes

下載redis的視覺化客戶端 Redis-Desktop-manager(這個的安裝直接點下一步就行)

Maven (開發環境統一)

配置阿里雲映象
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>

配置jdk1.8編譯專案
<profiles>
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>

1.下載外掛 MyBatisX lombok

下載官網地址:Visual Studio Code - Code Editing. Redefined

2.下載viscode

安裝完成上面的之後需要在裡面安裝外掛

3.下載Git

下載網址:Git (git-scm.com)

Git裡生成公鑰的命令:

 git config --global user.name "使用者名稱(可以隨便寫)"
git config --global user.email "郵箱"
ssh-keygen -t rsa -C "郵箱"
cat ~/.ssh/id_rsa.pub

測試是否成功
ssh -T [email protected]

建立專案微服務

在碼雲上新建倉庫

商品服務 倉儲服務 訂單服務 優惠券服務 使用者服務

建立這幾個模組的共同點:

1.web、openfeign

2.每個服務, 包名 com.xxxx.gulimail.xxx(product/order/ware/coupon/member)

3.模組名:guilimail-coupon

這個pom.xml修改為以下內容

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>com.doudou.gulimall1</groupId>
<artifactId>gulimall1-ware</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>gulimall1</name>
<description>聚合服務</description>
<packaging>pom</packaging>

<modules>
<module>gulimall-coupon</module>
<module>gulimall-member</module>
<module>gulimall-order</module>
<module>gulimall-product</module>
<module>gulimall-ware</module>
</modules>


</project>

出現的錯誤

'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' a

解決辦法:加上下面一句

<packaging>pom</packaging>

修改.gitignore(這個是修改總的)

target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar



**/mvnw
**/mvnw.cmd

**/.mvn
**/target/

.idea
**/.gitignore

安裝Gitee外掛

推送檔案操作

在碼雲上進行檢視推送的內容:

B站學習網址:全網最強電商教程《穀粒商城》對標阿里P6/P7,40-60萬年薪嗶哩嗶哩bilibili