分类目录归档:LINUX

docker学习(13)—镜像仓库的管理系统

一、容器的生命周期实践
1、什么是容器
容器类似胶囊公寓,它是一个精简版的操作系统,一般容器中只运行一个应用

2、容器是怎么来的
通过镜像创建容器,就是通过docker run命令创建的

3、容器有什么作用
容器起到了隔离的作用,独享空间、网络等等

4、常用命令
docker run --help
docker ps
docker stop 容器ID
docker start 容器ID
docker kill 容器ID
docker restart 容器ID
docker rm 容器ID
docker rm -f 容器ID

继续阅读docker学习(13)—镜像仓库的管理系统

docker学习(12)—docker镜像/仓库管理

一、docker镜像分层结构
最底层是一个base层,也即是一个操作系统层。它还会从base一层层的叠加生成

二、什么是层层叠加?
例如,安装一个软件,它就会在base层的基础上追加一层。它的好处就是资源共享

三、加速器的配置
1、计算时间
time docker pull nginx

2、创建或修改/etc/docker/daemon.json
添加:

{
  "registry-mirrors": [
    "https://registry.docker-cn.com",
    "http://hub-mirror.c.163.com",
    "https://docker.mirrors.ustc.edu.cn"
  ]
}

继续阅读docker学习(12)—docker镜像/仓库管理

CentOS使用podman代替docker

1、podman
(1)podman没有守护进程
(2)非root账户可以使用podman
(3)兼容docker镜像
(4)用法是和docker一致,只需要将命令中的docker更改为podman即可

2、安装
yum install podman

3、配置文件路径
/etc/containers

(1)配置容器仓库:/etc/containers/registries.conf
[registries.search]
registries = ['registry.access.redhat.com', 'registry.redhat.io', 'docker.io']

(2)配置镜像存储路径:/etc/containers/storage.conf
graphroot = "/var/lib/containers/storage"

继续阅读CentOS使用podman代替docker

CentOS8升级到RockyLinux

1、CentOS8官方更新源都关闭了,导致yum、dnf命令用不了。本来想升级到CentOS Stream 8,更新源不能用,安装不了centos-stream-repos包,而不安装centos-stream-repos又升级不了CentOS Stream,陷入死循环。。。

2、于是转投RockyLinux,在用脚本升级到RockyLinux看到还保留了一个地址:
https://dl.rockylinux.org/vault/centos/8.5.2111/
可以从这里安装需要的软件包,从而可以正常升级到CentOS Stream 8

3、升级RockyLinux脚本下载地址:
https://github.com/rocky-linux/rocky-tools/tree/main/migrate2rocky

4、CentOS Vault
https://vault.centos.org

yum update排除指定包

今天更新系统时报错:


Error: Package: 1:nginx-mod-http-perl-1.20.1-9.el7.x86_64 (@epel)
           Requires: nginx(abi) = 1.20.1
           Removing: 1:nginx-1.20.1-9.el7.x86_64 (@epel)
               nginx(abi) = 1.20.1
           Updated By: 1:nginx-1.20.2-1.el7.ngx.x86_64 (nginx)
               Not found
Error: Package: 1:nginx-mod-stream-1.20.1-9.el7.x86_64 (@epel)
           Requires: nginx(abi) = 1.20.1
           Removing: 1:nginx-1.20.1-9.el7.x86_64 (@epel)
               nginx(abi) = 1.20.1
           Updated By: 1:nginx-1.20.2-1.el7.ngx.x86_64 (nginx)
               Not found
Error: Package: 1:nginx-mod-mail-1.20.1-9.el7.x86_64 (@epel)
           Requires: nginx(abi) = 1.20.1
           Removing: 1:nginx-1.20.1-9.el7.x86_64 (@epel)
               nginx(abi) = 1.20.1
           Updated By: 1:nginx-1.20.2-1.el7.ngx.x86_64 (nginx)
               Not found
Error: Package: 1:nginx-mod-http-image-filter-1.20.1-9.el7.x86_64 (@epel)
           Requires: nginx(abi) = 1.20.1
           Removing: 1:nginx-1.20.1-9.el7.x86_64 (@epel)
               nginx(abi) = 1.20.1
           Updated By: 1:nginx-1.20.2-1.el7.ngx.x86_64 (nginx)
               Not found
Error: Package: 1:nginx-mod-http-xslt-filter-1.20.1-9.el7.x86_64 (@epel)
           Requires: nginx(abi) = 1.20.1
           Removing: 1:nginx-1.20.1-9.el7.x86_64 (@epel)
               nginx(abi) = 1.20.1
           Updated By: 1:nginx-1.20.2-1.el7.ngx.x86_64 (nginx)
               Not found
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

感觉是epel源和nginx源有冲突,所以可以更新时先排除nginx这个软件包

yum update -x {package-name}

CentOS7 安装nginx

1、依赖包
yum install gcc gcc-c++ autoconf automake make pcre pcre-devel zlib zlib-devel

2、编译
下载nginx源代码包,解压后编译
./configure --prefix=/appserver/nginx
make && make install

3、建立配置文件


cd /appserver/nginx
mkdir include
vi proxy.conf

输入:

upstream proxy_tomcat {
        server 192.168.52.9:8080;
}
server {
        location /tomcat/ {
        proxy_pass http://proxy_tomcat/;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        client_max_body_size 10m;
        client_body_buffer_size 128k;
        proxy_connect_timeout 300;
        proxy_send_timeout 300;
        proxy_read_timeout 300;
        proxy_buffer_size 4k;
        proxy_buffers 4 32k;
        proxy_busy_buffers_size 64k;
        proxy_temp_file_write_size 64k;
        }
        location /okfep/ {
        proxy_pass http://proxy_tomcat/okfep;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        client_max_body_size 10m;
        client_body_buffer_size 128k;
        proxy_connect_timeout 300;
        proxy_send_timeout 300;
        proxy_read_timeout 300;
        proxy_buffer_size 4k;
        proxy_buffers 4 32k;
        proxy_busy_buffers_size 64k;
        proxy_temp_file_write_size 64k;
        }

}

4、nginx.conf添加include


http {

    include       ../include/*.conf;

    include       mime.types;
    default_type  application/octet-stream;
......
}

5、nginx.conf修改nginx启动用户


......
user  root;
worker_processes  1;
......

docker学习(11)—使用docker安装rabbitmq 3.8

1、镜像的区别
management:带管理页面的
alpine:基于Alpine Linux制作的镜像
所以我们要选择带管理页面的版本

2、拉取镜像
docker pull rabbitmq:3.8-management

3、启动命令
建立配置目录、数据目录、日志目录
mkdir -p /data/rabbitmq/etc
mkdir -p /data/rabbitmq/lib
mkdir -p /data/rabbitmq/log

设置权限
chmod 777 /data/rabbitmq/etc
chmod 777 /data/rabbitmq/lib
chmod 777 /data/rabbitmq/log

否则容器启动报错:
touch: cannot touch '/etc/rabbitmq/rabbitmq.conf': Permission denied

继续阅读docker学习(11)—使用docker安装rabbitmq 3.8

redis学习(10)—redis哈希槽扩容与缩小

1、将节点重新加入集群
6387为主节点,6388为从节点
步骤看上一篇

2、重新分配槽号
redis-cli --cluster reshard 192.168.1.138:6381
说明:
ip:port:为集群中任意一个节点就行
步骤一:

>>> Performing Cluster Check (using node 192.168.1.138:6381)
M: c790b5f9584777ba8d9f96be5fe42b2efe646635 192.168.1.138:6381
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
S: 7599539245821b1a2e185439f3170b896b287106 192.168.1.138:6388
   slots: (0 slots) slave
   replicates ca77bc2a223c64a7af727b24172ae8f43d3e9b5a
S: b264b25c716863096d0c2fe39483130cbfeba894 192.168.1.138:6385
   slots: (0 slots) slave
   replicates f9200d36046d8325817c8014155e8f9950760da4
S: 33add5fdf6d9cc3eb8656c865403a34b237b4b73 192.168.1.138:6384
   slots: (0 slots) slave
   replicates 691e5855e8f274a6ea61dc95dbed89da87ed6053
S: d7bbc7bb0b501b421d527f6c302a8abe00aa535b 192.168.1.138:6386
   slots: (0 slots) slave
   replicates c790b5f9584777ba8d9f96be5fe42b2efe646635
M: f9200d36046d8325817c8014155e8f9950760da4 192.168.1.138:6383
   slots:[10923-16383] (5461 slots) master
   1 additional replica(s)
M: ca77bc2a223c64a7af727b24172ae8f43d3e9b5a 192.168.1.138:6387
   slots: (0 slots) master
   1 additional replica(s)
M: 691e5855e8f274a6ea61dc95dbed89da87ed6053 192.168.1.138:6382
   slots:[5461-10922] (5462 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
How many slots do you want to move (from 1 to 16384)? 4096

继续阅读redis学习(10)—redis哈希槽扩容与缩小

redis学习(9)—redis集群扩容与缩小

1、准备
回顾,上一篇把6381变成fail,6386变成master
还原:6381重新变成了master,6386变成了slave
docker stop redis-node-6
docker start redis-node-6

2、查看集群信息
登录进容器
redis-cli --cluster check 192.168.1.138:6381

3、增加2台redis节点
mkdir -p /data/redis/share/redis-node-7
mkdir -p /data/redis/share/redis-node-8
docker create --name redis-node-7 --net host --privileged=true -v /data/redis/share/redis-node-7:/data redis:5.0.7 --cluster-enabled yes --appendonly yes --port 6387
docker create --name redis-node-8 --net host --privileged=true -v /data/redis/share/redis-node-8:/data redis:5.0.7 --cluster-enabled yes --appendonly yes --port 6388

继续阅读redis学习(9)—redis集群扩容与缩小