日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

docker 买了腾讯服务器后的学习

發(fā)布時(shí)間:2023/12/3 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 docker 买了腾讯服务器后的学习 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

騰訊云買(mǎi)了? ?打算用?

?


登錄成功后:
Last login: Mon Nov 11 13:37:02 2019 from 221.12.17.87
[root@VM_0_13_centos ~]# ip addr ? ? ? ? ?#查看ip地址
[root@VM_0_13_centos ~]# uname -r ?#查看centeros內(nèi)核版本? docker要求 ?centeros內(nèi)核在3.10以上
3.10.0-862.el7.x86_64
[root@VM_0_13_centos ~]# yum install docker ? ? ? ? #聯(lián)網(wǎng)安裝docker ?中間有一次輸入y要下載東西
[root@VM_0_13_centos ~]# systemctl start docker ? ? #啟動(dòng)docker
[root@VM_0_13_centos ~]# docker -v ? ? ?#查看docker版本
Docker version 1.13.1, build 7f2769b/1.13.1
[root@VM_0_13_centos ~]# systemctl enable docker ? ? #設(shè)置docker開(kāi)機(jī)啟動(dòng)
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.ser
vice.
[root@VM_0_13_centos ~]# systemctl stop docker ? #也可以停止docker
[root@VM_0_13_centos ~]# docker -v ? ?#查看docker版本
Docker version 1.13.1, build 7f2769b/1.13.1
[root@VM_0_13_centos ~]# docker search mysql ?#在線搜索docker的mysql鏡像 ?這個(gè)沒(méi)什么用
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? #剛才關(guān)閉了docker
[root@VM_0_13_centos ~]# systemctl start docker ? # 剛才關(guān)閉了docker? ? 啟動(dòng)docker

[root@VM_0_13_centos ~]# clear? ? #清理界面

https://hub.docker.com/? ? ?這里可以找docker鏡像的版本

[root@VM_0_13_centos ~]# docker search mysql? #查找mysql鏡像
[root@VM_0_13_centos ~]# docker pull mysql? ?#拉取最新的mysql鏡像??? latest最新版本的鏡像? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
[root@VM_0_13_centos ~]# docker images? #查看當(dāng)前下載好的鏡像
[root@VM_0_13_centos ~]# docker pull mysql:5.5? ?#拉取mysql5.5的鏡像??
[root@VM_0_13_centos ~]# docker rmi d404d78aa797? ? #刪除指定id的鏡像
[root@VM_0_13_centos ~]# docker images d404d78aa797? ?#沒(méi)有用的命令。壓根就沒(méi)這個(gè)命令
?[root@VM_0_13_centos ~]# docker ps? ? ? ? ? ? ? ? ? ? ? #查看運(yùn)行中的鏡像

[root@VM_0_13_centos ~]# docker search tomcat? ? ? ? ?#搜索tomcat鏡像
[root@VM_0_13_centos ~]# docker pull tomcat? ? ? ? #拉取tomcat的鏡像
[root@VM_0_13_centos ~]# docker images? ? ? ? ? ? ? #查看現(xiàn)有鏡像
[root@VM_0_13_centos ~]# docker ps? ? ? ? ? ? ? ? ? ? ? #查看運(yùn)行中的鏡像

?

?

[root@VM_0_13_centos ~]# docker images ? ?#下載好的鏡像
[root@VM_0_13_centos ~]# docker ps ? ?#運(yùn)行中的鏡像
[root@VM_0_13_centos ~]# docker run --name mytomcat2 -d tomcat? 不能用? #運(yùn)行鏡像 (忘記映射端口了 ?這個(gè)不能用)
[root@VM_0_13_centos ~]# docker ps ?#運(yùn)行中的鏡像
[root@VM_0_13_centos ~]# docker stop 0d9f1656799c ? ?#停止運(yùn)行中的鏡像
[root@VM_0_13_centos ~]# docker ps ? #運(yùn)行中的鏡像
[root@VM_0_13_centos ~]# docker stop 16d6eadacf1e ? #停止運(yùn)行中的鏡像
[root@VM_0_13_centos ~]# docker ps ? ?#運(yùn)行中的鏡像
[root@VM_0_13_centos ~]# docker ps -a ? ?#運(yùn)行中的鏡像和停止的鏡像
[root@VM_0_13_centos ~]# docker start 0d9f1656799c ? #啟動(dòng)已經(jīng)停止的鏡像(容器)
[root@VM_0_13_centos ~]# docker ps ? #運(yùn)行中的對(duì)象
[root@VM_0_13_centos ~]# docker stop 0d9f1656799c ? ? ?#停止運(yùn)行中的鏡像
[root@VM_0_13_centos ~]# docker ps ?#運(yùn)行中的鏡像
[root@VM_0_13_centos ~]# docker rm 0d9f1656799c ? #刪除已經(jīng)停止的鏡像
[root@VM_0_13_centos ~]# docker ps -a ? ?#運(yùn)行中的鏡像和停止的鏡像
??

?
[root@VM_0_13_centos ~]# docker ps ? ??#運(yùn)行中的鏡像
[root@VM_0_13_centos ~]# docker stop 0d9f1656799c ? ?#停止運(yùn)行中的鏡像
[root@VM_0_13_centos ~]# docker ps ? ? ?#運(yùn)行中的鏡像
[root@VM_0_13_centos ~]# docker stop 16d6eadacf1e ? ?#停止運(yùn)行中的鏡像
[root@VM_0_13_centos ~]# docker ps ? #運(yùn)行中的鏡像
[root@VM_0_13_centos ~]# docker ps -a ? ?#運(yùn)行中的鏡像和停止的鏡像
[root@VM_0_13_centos ~]# docker images ? #下載好的鏡像 ?
[root@VM_0_13_centos ~]# docker run -d -p 8888:8080 tomcat? ? #啟動(dòng)tomcat
[root@VM_0_13_centos ~]# docker ps ? ?#運(yùn)行中的鏡像
[root@VM_0_13_centos ~]# docker ps -a? ? #運(yùn)行中的鏡像和停止的鏡像
[root@VM_0_13_centos ~]# service firewalld status? ? ?#防火墻狀態(tài)
? ?Active: inactive (dead) ?
[root@VM_0_13_centos ~]# service firewalld stop? ? ?#停用防火墻(騰訊好像默認(rèn)是停用的)

[root@VM_0_13_centos ~]# docker logs 2c9f0c97245d ?#日志
[root@VM_0_13_centos ~]# docker run -d -p 8889:8080 tomcat ? ?#啟動(dòng)tomcat
[root@VM_0_13_centos ~]# docker run -d -p 8887:8080 tomcat ? ?#一個(gè)鏡像可以啟動(dòng)多個(gè)tomcat
[root@VM_0_13_centos ~]# docker ps ?#運(yùn)行中的鏡像(容器)
?
?

[root@VM_0_13_centos ~]# docker ps ? ? #查看運(yùn)行中的鏡像
[root@VM_0_13_centos ~]# docker stop abefecfa6a61 ? #停止運(yùn)行中的鏡像(指定id)
[root@VM_0_13_centos ~]# docker ps ? ?#查看運(yùn)行中的鏡像
[root@VM_0_13_centos ~]# docker images ? ?#查看已下載的鏡像
[root@VM_0_13_centos ~]# docker run -p 3306:3306 --name mysql02 -e MYSQL_ROOT_PASSWORD=123456 -d mysql ?#啟動(dòng)mysql(沒(méi)有自定字符集)
[root@VM_0_13_centos ~]# docker stop a08a88b2ea42 ? #停止運(yùn)行中的鏡像(指定id)
[root@VM_0_13_centos ~]# docker ps -a ? #查看所有運(yùn)行和停止的鏡像
[root@VM_0_13_centos ~]# docker rm a08a88b2ea42 ? #刪除已經(jīng)停止的鏡像
[root@VM_0_13_centos ~]# docker rm 281a9b9f9fd5 ?#這個(gè)命令可以刪除鏡像也可以刪除停止運(yùn)行的鏡像,運(yùn)行中的必須停止后刪除

#不同版本的mysql 可以同時(shí)啟動(dòng)? ? 但是端口要不一樣
[root@VM_0_13_centos ~]# docker run -p 3306:3306 --name mysql5.5 -e MYSQL_ROOT_PASSWORD=123456 -d mysql --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci? ?#啟動(dòng)mysql 并指定字符集
[root@VM_0_13_centos ~]# docker run -p 3306:3306 --name mysql5.5 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.5 -
-character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci??#啟動(dòng)mysql 并指定字符集3306端口? 鏡像mysql5.5

[root@VM_0_13_centos ~]# docker run -p 3307:3306 --name mysql_latest -e MYSQL_ROOT_PASSWORD=123456 -d mysql:l
atest --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci??#啟動(dòng)mysql 并指定字符集3307端口鏡mysqllatest

?

上面是? ?第5章SpringBoot_Docker? ? 全部看完了? 挺好用的。

?

?

下面是? ?第6章SpringBoot數(shù)據(jù)訪問(wèn)

[root@VM_0_13_centos ~]# docker ps -a ? #查看已經(jīng)停止和正在運(yùn)行的鏡像(容器)
[root@VM_0_13_centos ~]# docker start abefecfa6a61 ? #啟動(dòng)已經(jīng)聽(tīng)通知的鏡像(容器)
abefecfa6a61
[root@VM_0_13_centos ~]# docker ps ? #查看正在運(yùn)行的鏡像(容器)
[root@VM_0_13_centos ~]# docker stop abefecfa6a61 ? #停止正在運(yùn)行的鏡像(容器)
?

?

?

第7章SpringBoot原理

這節(jié)沒(méi)用docker

?

?

?

?第8章SpringBoot緩存
[root@VM_0_13_centos ~]# docker images? ?#查看下載好的鏡像
[root@VM_0_13_centos ~]# docker ps? ? ?#正在運(yùn)行的鏡像(容器)
[root@VM_0_13_centos ~]# docker ps -a? ? #正在運(yùn)行和已經(jīng)停止的鏡像(容器)
[root@VM_0_13_centos ~]# docker rm 13f20f7c86ae? ?#刪除已經(jīng)停止的鏡像(容器)
13f20f7c86ae
[root@VM_0_13_centos ~]# docker rm a30fa73f63f5? ? ??#刪除已經(jīng)停止的鏡像(容器)
a30fa73f63f5
[root@VM_0_13_centos ~]# docker rmi 752be83a5396? ??#刪除已經(jīng)下載好的鏡像

[root@VM_0_13_centos ~]# docker images? ??#查看下載好的鏡像

[root@VM_0_13_centos ~]# docker pull redis? ? #拉取redis鏡像

[root@VM_0_13_centos ~]# docker run -d -p 6379:6379 --name myredis redis? ? #啟動(dòng)redis鏡像并做端口映射

?

?

?

第9章SpringBoot消息

[root@VM_0_13_centos ~]# docker pull rabbitmq:3-management ? #拉取rabittmq鏡像
[root@VM_0_13_?~]# docker run -d -p 5672:5672 -p 15672:15672 --name myrabbitmq 5ab234e119da ?#運(yùn)行rabbitmq鏡像


[root@VM_0_13_centos ~]# docker rmi 36ed80b6a1b1 ? 刪除鏡像
[root@VM_0_13_centos ~]# docker images ? 已經(jīng)下載好的鏡像
[root@VM_0_13_centos ~]# docker rmi 5ab234e119da ? 刪除鏡像
[root@VM_0_13_centos ~]# docker stop dd491afb90ae ?停止運(yùn)行中的容器
[root@VM_0_13_centos ~]# docker rm dd491afb90ae ?刪除容器
[root@VM_0_13_centos ~]# docker ps -a ? 查看所有容器 停止和運(yùn)行的都顯示
[root@VM_0_13_centos ~]# docker pull rabbitmq:3-management ? ?下載帶管理界面的rabbitmq
[root@VM_0_13_centos ~]# docker images ? ?查看下載好的鏡像
[root@VM_0_13_centos ~]# docker run -d -p 5672:5672 -p 15672:15672 --name myrabbitmq 36ed80b6a1b1 ? ?啟動(dòng)rabbitMq
[root@VM_0_13_centos ~]# docker ps ? ?查看正在運(yùn)行的容器
?

?

第10章SpringBoot檢索

$ ?docker ?pull ?openjdk? ?#elasticearch需要java環(huán)境

$ docker ?run ?-d ?-it ?--name myopenjdk ?openjdk ?/bin/bash? ?啟動(dòng)java環(huán)境

[root@VM_0_13_centos ~]# docker stop dcdf2364fb88 ?停止容器
[root@VM_0_13_centos ~]# docker rm 1bed98e3bf77 ?刪除容器
[root@VM_0_13_centos ~]# docker search elasticsearch ? 搜索鏡像(這個(gè)命令沒(méi)什么用)
[root@VM_0_13_centos ~]# docker pull elasticsearch:5.6.9 ? 下載elasticsearch:5.6.9鏡像
#啟動(dòng)elasticsearch:5.6.9 ?
[root@VM_0_13_centos ~]#

docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9200:9200 -p 9300:9300 --name elasticsearch01 5c1e1ecfe33a
[root@VM_0_13_centos ~]# docker rmi 5e9d896dc62c ?刪除鏡像
[root@VM_0_13_centos ~]# docker pull elasticsearch:2.4.6 ? 下載elasticsearch:2.4.6
[root@VM_0_13_centos ~]# docker images ?查看鏡像下載好的
#啟動(dòng)elasticsearch:2.4.6 ?
[root@VM_0_13_centos ~]#

docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9201:9200 -p 9301:9300 --name elasticsearch02 5e9d896dc62c
[root@VM_0_13_centos ~]# docker ps -a ? ?查看所有容器停止的和沒(méi)有停止的
[root@VM_0_13_centos ~]# docker start 9bb596831d2d ? ?啟動(dòng)容器
[root@VM_0_13_centos ~]# docker ps ? ?查看正在運(yùn)行的容器

?

?

第11章SpringBoot任務(wù)

這個(gè)沒(méi)有docker命令

?

?

?

第12章SpringBoot安全

這章也沒(méi)有docker

?

?

第13章SpringBoot分布式

docker images? 查看下載好的鏡像

docker pull zookeeper:3.4.11? ? 下載zookeeper

docker run --name zookeeper01 -p 2181:2181 --restart always -d? ? xxxxxxxid? ?啟動(dòng)zookeeper

docker ps

?

[root@VM_0_13_centos ~]# docker ps -a ? 查看容器包括運(yùn)行和停止的
[root@VM_0_13_centos ~]# docker stop 27bef5f236d3 ? 停止運(yùn)行中的容器
[root@VM_0_13_centos ~]# docker rm 27bef5f236d3 ? 刪除容器
[root@VM_0_13_centos ~]# docker rmi 56d414270ae3 ?刪除鏡像
[root@VM_0_13_centos ~]# docker pull zookeeper:3.4.11 ? ?下載zookeeper
[root@VM_0_13_centos ~]# docker images ? 查看下載好的鏡像
[root@VM_0_13_centos ~]# docker run --name zookeeper01 -p 2181:2181 --restart always -d 56d414270ae3 ? ?啟動(dòng)zookeeper
[root@VM_0_13_centos ~]# docker ps ? 查看運(yùn)行中的容器
?
?

第14章SpringBoot熱部署

沒(méi)有docker命令

?

?

第15章SpringBoot監(jiān)管

沒(méi)有docker命令

?

?

?

百度搜索 dockers hub

1.安裝jdk

$ ?docker ?pull ?openjdk

$ docker ?run ?-d ?-it ?--name myopenjdk ?openjdk ?/bin/bash

2.安裝elasticsearch?

docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9200:9200 -p 9300:9300 --name ES01 5c1e1ecfe33a

? ? ? ?#啟動(dòng)elasticsearch:5.6.9的鏡像

#??https://hub.docker.com/? ? ?這里可以找docker鏡像的版本

#下面的都做過(guò)了看一下就好了

Last login: Tue Nov 12 13:56:07 2019 from 221.12.17.87
[root@VM_0_13_centos ~]# docker search elasticsearch? ?#查找elasticsearch
?
[root@VM_0_13_centos ~]# docker pull elasticsearch:5.6.9? ? #拉這個(gè)版本是視頻上的

Get https://registry.docker-cn.com/v1/_ping: dial tcp 106.14.52.175:443: i/o timeout? ?#超時(shí)

[root@VM_0_13_centos ~]# docker pull elasticsearch:6.2.1? ?#找不到這個(gè)版本
Trying to pull repository docker.io/library/elasticsearch ...?
manifest for docker.io/elasticsearch:6.2.1 not found
[root@VM_0_13_centos ~]# docker pull elasticsearch:6.5.0? ?#這個(gè)照著博客上的版本可以了? ?這個(gè)版本太高用不了
Status: Downloaded newer image for docker.io/elasticsearch:6.5.0?

[root@VM_0_13_centos ~]# docker images? ?#目前有的鏡像 已經(jīng)下載好了
REPOSITORY ? ? ? ? ? ? ? ?TAG ? ? ? ? ? ? ? ? IMAGE ID ? ? ? ? ? ?CREATED ? ? ? ? ? ? SIZE
docker.io/elasticsearch ? 6.5.0 ? ? ? ? ? ? ? ff171d17e77c ? ? ? ?12 months ago ? ? ? 774 MB
[root@VM_0_13_centos ~]#

docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9200:9200 -p 9300:9300 --name ES01 5c1e1ecfe33a

? ? ? ?#啟動(dòng)elasticsearch:5.6.9的鏡像
efc5eac2266b6205c111523b29184554e300ce3ee0261477d7d8175ede004b3c
[root@VM_0_13_centos ~]# docker ps? ?#查看已經(jīng)啟動(dòng)的鏡像
CONTAINER ID? ?IMAGE? ?COMMAND? ?CREATED? ? STATUS? ?PORTS? ?NAMES
efc5eac2266b ? ? ? ?ff171d17e77c ? ? ? ?"/usr/local/bin/do..." ? 14 seconds ago ? ? ?Up 14 seconds ? ? ? 0.0.
0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp ? ES01

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

zimuge視頻上的docker命令匯總

第十一章redis緩存? ? ?這是第一次使用到docker

[root@VM_0_13_centos ~]# systemctl status docker? ?查看docker運(yùn)行狀態(tài)
● docker.service - Docker Application Container Engine
? ?Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
? ?Active: active (running) since Mon 2019-11-11 13:46:58 CST; 4 weeks 1 days ago? ?docker正在運(yùn)行
? ? ?Docs: http://docs.docker.com?

[root@VM_0_13_centos ~]# systemctl restart docker?? ?如果docker沒(méi)有啟動(dòng) 就重啟docker

[root@VM_0_13_centos ~]# docker images? ? 查看有哪些鏡像了

[root@VM_0_13_centos ~]# docker search redis? ? ?查看有哪些redis的版本

[root@VM_0_13_centos ~]# docker pull redis:5.0.5? ? 這是老師找到的比較穩(wěn)定的版本

如果你不懂的話? 可以暫時(shí)把docker理解為一個(gè)虛擬機(jī)? 但是不一樣的 這是2回事

https://raw.githubusercontent.com/antirez/redis/4.0/redis.conf? ? ?這個(gè)配置文件 修改一下redis官方默認(rèn)的配置文件

剛才做了一下docker restart docker? ?然后docker ps -all 就剩下 zookeeper容器還在了

[root@VM_0_13_centos ~]# docker ps? ?? ? 只有 zookeeper01了
[root@VM_0_13_centos ~]# docker ps -all? ? ?也只有 zookeeper01了

?

注意:后面所有的操作命令都要在這個(gè)目錄/home/docker/redis下進(jìn)行

獲取 redis 的默認(rèn)配置模版

# 獲取 redis 的默認(rèn)配置模版 # 這里主要是想設(shè)置下 redis 的 log / password / appendonly # redis 的 docker 運(yùn)行參數(shù)提供了 --appendonly yes 但沒(méi) password wget https://raw.githubusercontent.com/antirez/redis/4.0/redis.conf -O conf/redis.conf# 直接替換編輯 sed -i 's/logfile ""/logfile "access.log"/' conf/redis.conf; sed -i 's/# requirepass foobared/requirepass 123456/' conf/redis.conf; sed -i 's/appendonly no/appendonly yes/' conf/redis.conf; sed -i 's/bind 127.0.0.1/bind 0.0.0.0/' conf/redis.conf;

[root@VM_0_13_centos redis]# pwd? ? ?linux如何查看當(dāng)前目錄的完整路徑
/home/docker/redis??

[root@VM_0_13_centos redis]# pwd
/home/docker/redis
[root@VM_0_13_centos redis]# cd conf
[root@VM_0_13_centos conf]# pwd
/home/docker/redis/conf

示例:

? ? 1、刪除文件夾實(shí)例:

? ? rm -rf /var/log/httpd

? ? 將會(huì)刪除/var/log/httpd目錄以及其下所有文件、文件夾

? ? 2、刪除文件使用實(shí)例:

? ? rm -f /var/log/httpd/access.log

? ? 將會(huì)強(qiáng)制刪除/var/log/httpd/access.log這個(gè)文件

注意:使用 rm -rf 的時(shí)候一定要小心,Linux沒(méi)有回收站。

創(chuàng)建宿主機(jī) redis 容器的數(shù)據(jù)和配置文件目錄??

mkdir命令用于建立名稱(chēng)為 dirName 之子目錄。?-p 確保目錄名稱(chēng)存在,不存在的就建一個(gè)。

[root@VM_0_13_centos redis]# mkdir /home/docker/redis/{conf,data} -p? ? ? 創(chuàng)建這2個(gè)目錄/conf/data
[root@VM_0_13_centos redis]# cd /home/docker/redis? ? ?進(jìn)入目錄

?這個(gè)配置文件 修改一下redis官方默認(rèn)的配置文件

?wget是Linux下下載文件的最常用命令。wget支持HTTP,HTTPS和FTP協(xié)議,支持自動(dòng)下載,即可以在用戶(hù)退出系統(tǒng)后在后臺(tái)執(zhí)行,直到下載結(jié)束。? ? ? ? -O是大寫(xiě)的o? 不是數(shù)字也不是小寫(xiě)的o? ? 尼瑪就一直是錯(cuò)在這里啊啊啊
[root@VM_0_13_centos redis]# wget https://raw.githubusercontent.com/antirez/redis/4.0/redis.conf -O?conf/redis.conf

[root@VM_0_13_centos redis]# cd /home/docker/redis? ? ?進(jìn)入目錄

[root@VM_0_13_centos redis]# pwd? ? 當(dāng)前目錄
/home/docker/redis

[root@VM_0_13_centos redis]# ls -ltr? 查看當(dāng)前目錄的文件? ?以后就在/home/docker/redis文件夾中操作了
total 68
drwxr-xr-x 2 root root ?4096 Dec 10 20:22 data
-rw-r--r-- 1 root root 58766 Dec 10 20:22 redis.conf
drwxr-xr-x 2 root root ?4096 Dec 10 20:23 conf

就是字符串替換? ?下面的代碼
[root@VM_0_13_centos redis]# sed -i 's/logfile ""/logfile "access.log"/' conf/redis.conf;

logfile原來(lái)為空字符串的 現(xiàn)在遠(yuǎn)程access.log?
[root@VM_0_13_centos redis]# sed -i 's/# requirepass foobared/requirepass 123456/' conf/redis.conf;

原來(lái)不用密碼訪問(wèn)的現(xiàn)在修改為 密碼登錄123456
[root@VM_0_13_centos redis]# sed -i 's/appendonly no/appendonly yes/' conf/redis.conf;

原來(lái)持久化為no 現(xiàn)在修改為yes
[root@VM_0_13_centos redis]# sed -i 's/bind 127.0.0.1/bind 0.0.0.0/' conf/redis.conf;

原來(lái)只有127.0.0.1才能訪問(wèn)現(xiàn)在修改為全部ip可以訪問(wèn)

protected-mode 是在沒(méi)有顯式定義 bind 地址(即監(jiān)聽(tīng)全網(wǎng)段),又沒(méi)有設(shè)置密碼 requirepass時(shí),protected-mode 只允許本地回環(huán) 127.0.0.1 訪問(wèn)。改為bind 0.0.0.0

容器相當(dāng)于類(lèi)? ? 鏡像相當(dāng)于對(duì)象

?


[root@VM_0_13_centos ~]# pwd? ?查看當(dāng)前全路徑
[root@VM_0_13_centos ~]# docker search redis? ?搜索redis鏡像?

[root@VM_0_13_centos ~]# docker images? ? ?查詢(xún)已經(jīng)下載好的鏡像

[root@VM_0_13_centos ~]# mkdir /home/docker/redis/{conf,data} -p? ? ?# 這里我們?cè)?/home/docker 下創(chuàng)建

[root@VM_0_13_centos ~]# cd /home/docker/redis? ?打開(kāi)指定目錄

[root@VM_0_13_centos redis]# pwd? ? 當(dāng)前全路徑
/home/docker/redis

[root@VM_0_13_centos redis]# ls -a? ?-a 顯示所有文件及目錄 (ls內(nèi)定將文件名或目錄名稱(chēng)開(kāi)頭為"."的視為隱藏檔,不會(huì)列出)
conf ?data ?redis.conf

ls 顯示目錄下的文件名

-a 顯示所有文件(包含隱藏文件),以.開(kāi)頭的文件為隱藏文件

-A 顯示所有文件(不包含.和..)

[root@VM_0_13_centos redis]# docker rm 34b604a489e4? ? ?刪除容器

[root@VM_0_13_centos redis]# docker rmi 63130206b0fa? ? 刪除鏡像

[root@VM_0_13_centos redis]# docker images? ? 不能再redis目錄下面做? 必須cd ~ 回到主目錄才行? 不然報(bào)下面這行的錯(cuò)誤
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

[root@VM_0_13_centos redis]# docker pull redis:5.0.5? ? 拉redis:5.0.5這個(gè)鏡像

[root@VM_0_13_centos redis]# cd ..? ?回到上層目錄

[root@VM_0_13_centos /]# cd ~? ? 回到主目錄

[root@VM_0_13_centos redis]# docker logs myredis5? ?沒(méi)啟動(dòng)起來(lái)查看日志?# 如果沒(méi)有 myredis 說(shuō)明啟動(dòng)失敗 查看錯(cuò)誤日志

[root@VM_0_13_centos redis]# cat conf/redis.conf? ? ? 查看這個(gè)redis.conf文件

[root@VM_0_13_centos conf]# vi redis.conf? ?編輯redis.conf這個(gè)文件

[root@VM_0_13_centos conf]# docker ps? ? 查看運(yùn)行的容器? ?# 查看活躍的容器

[root@VM_0_13_centos conf]# docker ps -a? ?查看所有運(yùn)行和停止運(yùn)行的容器

[root@VM_0_13_centos redis]# docker stop 8a3ec673e16f? ? 停止運(yùn)行中的容器

[root@VM_0_13_centos redis]# rm -rf /home/docker/redis? ? ?刪除/home/docker/redis目錄下的所有文件夾和文件

[root@VM_0_13_centos redis]# sed -i 's/logfile ""/logfile "access.log"/' conf/redis.conf;
[root@VM_0_13_centos redis]# sed -i 's/# requirepass foobared/requirepass 123456/' conf/redis.conf;
[root@VM_0_13_centos redis]# sed -i 's/appendonly no/appendonly yes/' conf/redis.conf;
[root@VM_0_13_centos redis]# sed -i 's/bind 127.0.0.1/bind 0.0.0.0/' conf/redis.conf;

[root@VM_0_13_centos redis]# docker run -p 6379:6379 -v $PWD/data:/data:rw -v $PWD/conf/redis.conf:/etc/redis/redis.conf:ro ? --privileged=true --name myredis5 ? -d redis redis-server /etc/redis/redis.conf ??
?啟動(dòng)redis? ?必須一行寫(xiě)命令不然就會(huì)出錯(cuò)的

# 命令分解
docker run \
-p 6379:6379 \ # 端口映射 宿主機(jī):容器
-v $PWD/data:/data:rw \ # 映射數(shù)據(jù)目錄 rw 為讀寫(xiě)
-v $PWD/conf/redis.conf:/etc/redis/redis.conf:ro \ # 掛載配置文件 ro 為readonly
--privileged=true \ # 給與一些權(quán)限
--name myredis \ # 給容器起個(gè)名字
-d redis redis-server /etc/redis/redis.conf # deamon 運(yùn)行容器 并使用配置文件啟動(dòng)容器內(nèi)的 redis-server?

[root@VM_0_13_centos redis]# docker logs myredis5? ?啟動(dòng)失敗就看看日志

[root@VM_0_13_centos redis]# docker inspect myredis5?# 查看 myredis 的 ip 掛載 端口映射等信息

[root@VM_0_13_centos redis]# docker port myredis5??# 查看 myredis 的端口映射
6379/tcp -> 0.0.0.0:6379
[root@VM_0_13_centos redis]# docker exec -it myredis5 bash? ?三、訪問(wèn) redis 容器服務(wù)
root@26b861b7ec37:/data#?
root@26b861b7ec37:/data# redis-cli
127.0.0.1:6379>?
127.0.0.1:6379> exit? ?退出
?root@26b861b7ec37:/data# exit? ?退出
exit

?[root@VM_0_13_centos ~]#?

四、開(kāi)啟防火墻端口,提供外部訪問(wèn)
[root@VM_0_13_centos redis]# firewall-cmd --zone=public --add-port=6379/tcp --permanent
FirewallD is not running
[root@VM_0_13_centos redis]# firewall-cmd -reload
usage: see firewall-cmd man page
firewall-cmd: error: unrecognized arguments: -reload
[root@VM_0_13_centos redis]# firewall-cmd --query-port=6379/tcp
FirewallD is not running
[root@VM_0_13_centos redis]#?

?

[root@VM_0_13_centos ~]# docker logs myredis5? ?看一下redis的日志,這里暫時(shí)沒(méi)有日志
?
[root@VM_0_13_centos ~]# docker port myredis5? ? ?檢查redis的端口? 6379
6379/tcp -> 0.0.0.0:6379
[root@VM_0_13_centos ~]# docker exec -it myredis5 bash? ? ? 現(xiàn)在是在主機(jī)上面,進(jìn)入redis試試
root@26b861b7ec37:/data#?
root@26b861b7ec37:/data# redis-cli
127.0.0.1:6379>?
127.0.0.1:6379> keys *
(error) NOAUTH Authentication required.? ? ? 沒(méi)有登錄
127.0.0.1:6379> auth 123456? ? ?登錄 一下
OK
127.0.0.1:6379> keys *? ? ? 查詢(xún)
(empty list or set)
127.0.0.1:6379>?
127.0.0.1:6379> exit? ? 退出
root@26b861b7ec37:/data#?
root@26b861b7ec37:/data# exit? ?退出redis
exit
[root@VM_0_13_centos ~]# firewall-cmd --query-port=6379/tcp? ? ?6379端口開(kāi)放了沒(méi)
FirewallD is not running
[root@VM_0_13_centos ~]# firewall-cmd --zone=public --add-port=6379/tcp -permanent? ? ? 開(kāi)放6379端口
usage: see firewall-cmd man page? ?
firewall-cmd: error: unrecognized arguments: -permanent
[root@VM_0_13_centos ~]# firewall-cmd --reload? ? ?重啟防火墻
FirewallD is not running? ?
[root@VM_0_13_centos ~]# firewall-cmd --query-port=6379/tcp? ? ? 6379端口開(kāi)放了沒(méi)
FirewallD is not running? ?
[root@VM_0_13_centos ~]#? ??

這個(gè)docker的內(nèi)容還是很多的? ? ?這里希望開(kāi)發(fā)人員能快速搭建環(huán)境? ?

redis如何運(yùn)維? ?docker如何管理? ?不是這節(jié)課內(nèi)容? ? 我講的你理解不了就下載windows版的

安裝起來(lái)方便后面章節(jié)的學(xué)習(xí)? ? 只要能把redis安裝起來(lái)都無(wú)所謂? ?

?

[root@VM_0_13_centos ~]# docker exec -it myredis5 bash? ? 登錄redis
root@26b861b7ec37:/data# redis-cli
127.0.0.1:6379> keys *
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth 123456? ?登錄密碼
OK
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379> set age 1? ?練習(xí)set集合
OK
127.0.0.1:6379> incr age
(integer) 2
127.0.0.1:6379> incr age
(integer) 3
127.0.0.1:6379> decr age
(integer) 2
127.0.0.1:6379> incrby age 2
(integer) 4
127.0.0.1:6379> decrby age 3
(integer) 1
127.0.0.1:6379> setex 10 yangjiabin
(error) ERR wrong number of arguments for 'setex' command
127.0.0.1:6379> set name 10 yangjiabin
(error) ERR syntax error
127.0.0.1:6379> setex name 10 yangjiabin? ? ?設(shè)置name字段有效期為10秒鐘
OK
127.0.0.1:6379> get name? ?獲取name
"yangjiabin"
127.0.0.1:6379> get name
"yangjiabin"
127.0.0.1:6379> get name? ?超過(guò)10秒鐘就沒(méi)有數(shù)據(jù)了? ?一般有效期用在短信驗(yàn)證碼上面
(nil)
127.0.0.1:6379> lpush queue1 1? ? ? ?list的使用場(chǎng)景? ? ?l-left? ?r-right? ?lpush-left push? ? rpop-right pop??
(integer) 1
127.0.0.1:6379> lpush queue1 2
(integer) 2
127.0.0.1:6379> lpop queue1? ? ? 雙向鏈表結(jié)構(gòu)? 可以實(shí)現(xiàn)棧? 也可以實(shí)現(xiàn)隊(duì)列? 可以實(shí)現(xiàn)簡(jiǎn)單的消息隊(duì)列
"2"
127.0.0.1:6379> lpush queue1 3
(integer) 2
127.0.0.1:6379> rpush queue1 4
(integer) 3
127.0.0.1:6379> rpop queue1
"4"
127.0.0.1:6379> lpop queue1
"3"
127.0.0.1:6379> lpop queue1
"1"
127.0.0.1:6379> lpop queue1
(nil)
127.0.0.1:6379> lpush queue2 a? ? ?向隊(duì)列推入abcd
(integer) 1
127.0.0.1:6379> lpush queue2 b
(integer) 2
127.0.0.1:6379> lpush queue2 c
(integer) 3
127.0.0.1:6379> lpush queue2 d? ? 最新的在最上面
(integer) 4
127.0.0.1:6379> lrange queue2 0 4? ? ?這種適合最新文章的排序展示
1) "d"
2) "c"
3) "b"
4) "a"
127.0.0.1:6379> sadd "user:101" 1? ? 用戶(hù)感興趣的內(nèi)容
(integer) 1
127.0.0.1:6379> sadd "user:101" 2
(integer) 1
127.0.0.1:6379> sadd "user:102" 1
(integer) 1
127.0.0.1:6379> sadd "user:102" 3
(integer) 1
127.0.0.1:6379> sinter "user:101" "user:102"? ? 101和102用戶(hù)的交集
1) "1"
127.0.0.1:6379> sunion "user:101" "user:102"? ?101和102用戶(hù)的并集
1) "1"
2) "2"
3) "3"
127.0.0.1:6379> hset user102 name yangjiabin? ? ? ?hash存儲(chǔ)對(duì)象
(integer) 1
127.0.0.1:6379> hset user102 age 18
(integer) 1
127.0.0.1:6379> hset user102 sex male
(integer) 1
127.0.0.1:6379> hget user103
(error) ERR wrong number of arguments for 'hget' command
127.0.0.1:6379> hget user102
(error) ERR wrong number of arguments for 'hget' command
127.0.0.1:6379> hget user102 name
"yangjiabin"
127.0.0.1:6379> hget user102 age
"18"
127.0.0.1:6379> hget user102 sex
"male"
127.0.0.1:6379>?
127.0.0.1:6379> zadd hot_product 100 apple? ? 熱銷(xiāo)商品可以按照分?jǐn)?shù)排序
(integer) 1
127.0.0.1:6379> zadd hot_product 99 htc
(integer) 1
127.0.0.1:6379> zadd hot_product 98 hawe
(integer) 1
127.0.0.1:6379> zrange hot_product 0 -1? ? ?正序
1) "hawe"
2) "htc"
3) "apple"
127.0.0.1:6379> zrevrange hot_product 0 -1? ? 逆序
1) "apple"
2) "htc"
3) "hawe"
127.0.0.1:6379>?
127.0.0.1:6379> exit? ? 退出
root@26b861b7ec37:/data# exit? ?退出
exit
[root@VM_0_13_centos ~]#?

第11章終于看完了?

?

?

第12章整合分布式文件系統(tǒng)fastdfs

算過(guò)了? ? 全是封裝號(hào)調(diào)用了一下

?

第13章服務(wù)器推送技術(shù)? ??

sse 和websoket? websocket更加通用一些? ??

?

?

第14章消息隊(duì)列的整合與使用

算了? ? 消息隊(duì)列? 算了

?

?第十五章 郵件發(fā)送的整合與使用

這個(gè)看代碼好了? ? 還是比較簡(jiǎn)單的??

這個(gè)視頻對(duì)應(yīng)的docker不是很好? ?只是輔助springboot搭建一下環(huán)境而已??

講解的太快了。

?

第16章響應(yīng)式框架webflux

這個(gè)可能史下一代的框架? 代替springboot的

還是不是很成熟 有bug

全部看完了

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?


?

總結(jié)

以上是生活随笔為你收集整理的docker 买了腾讯服务器后的学习的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。