运维必备工具安装

系统测试:OpenEuler24.03LTS,Centos 8 stream

理论上不限制系统,其他系统可对一些命令自行做修改即可

Nginx(RPM安装)

资料来源:Nginx入门笔记 | 严千屹博客

官方文档:nginx:Linux 软件包

截止2025年4月20日目前:nginx最新版本:1.26.3

image-20250420132345655

centos7或centos8

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
sudo yum install -y tar gcc make pcre pcre-devel zlib zlib-devel openssl openssl-devel
sudo yum install yum-utils -y
#添加nginx源
sudo cat >/etc/yum.repos.d/nginx.repo << "EOF"
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
EOF
sudo yum install nginx -y
sudo systemctl enable nginx --now
nginx -v

因为没有适配openeuler的版本,这里直接用centos8的来代替,兼容的没关系,你可以根据你的系统去自行替换

原本是$releasever的,但是没有openeuler的版本直接用8来代替也就是centos8,openeuler兼容centos

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
sudo yum install -y tar gcc make pcre pcre-devel zlib zlib-devel openssl openssl-devel
sudo cat >/etc/yum.repos.d/nginx.repo << "EOF"
[nginx-stable]
name=nginx stable repo
#baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
baseurl=http://nginx.org/packages/centos/8/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
#baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
baseurl=http://nginx.org/packages/mainline/centos/8/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
EOF
sudo yum install nginx -y
sudo systemctl enable nginx --now
nginx -v

Docker

截止2025年4月20日目前:

docker-compose最新版2.35.1 版

docker-ce最新版:Docker 文档 26.1.3

centos7或centos8

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
sudo curl -L "https://qygit.qianyisky.cn/https://github.com/docker/compose/releases/download/v2.35.1/docker-compose-linux-x86_64" -o /usr/local/bin/docker-compose
#卸载旧版本
sudo yum -y remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
sudo yum remove docker-ce docker-ce-cli containerd.io docker-compose docker-machine docker-swarm -y
sudo rm /etc/yum.repos.d/docker-ce.repo
sudo rm -rf /var/lib/docker

sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum install docker-ce -y
sudo systemctl enable --now docker
sudo chmod +x /usr/local/bin/docker-compose
sudo tee /etc/docker/daemon.json > /dev/null <<'EOF'
{
"registry-mirrors": [
"https://docker.xuanyuan.me",
"https://docker.m.daocloud.io",
"https://docker.1ms.run",
"https://docker.1panel.live",
"https://registry.cn-hangzhou.aliyuncs.com",
"https://docker.qianyios.top"
],
"max-concurrent-downloads": 10,
"log-driver": "json-file",
"log-level": "warn",
"log-opts": {
"max-size": "10m",
"max-file": "3"
},
"data-root": "/var/lib/docker"
}
EOF
systemctl daemon-reload
systemctl restart docker
docker-compose --version
docker version

openeuler

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
sudo curl -L "https://qygit.qianyisky.cn/https://github.com/docker/compose/releases/download/v2.35.1/docker-compose-linux-x86_64" -o /usr/local/bin/docker-compose
#卸载旧版本
sudo yum -y remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
sudo yum remove docker-ce docker-ce-cli containerd.io docker-compose docker-machine docker-swarm -y
sudo rm /etc/yum.repos.d/docker-ce.repo
sudo rm -rf /var/lib/docker

sudo yum install -y device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo sed -i 's/\$releasever/8/g' /etc/yum.repos.d/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io -y
sudo systemctl enable --now docker
sudo chmod +x /usr/local/bin/docker-compose
sudo tee /etc/docker/daemon.json > /dev/null <<'EOF'
{
"registry-mirrors": [
"https://docker.xuanyuan.me",
"https://docker.m.daocloud.io",
"https://docker.1ms.run",
"https://docker.1panel.live",
"https://registry.cn-hangzhou.aliyuncs.com",
"https://docker.qianyios.top"
],
"max-concurrent-downloads": 10,
"log-driver": "json-file",
"log-level": "warn",
"log-opts": {
"max-size": "10m",
"max-file": "3"
},
"data-root": "/var/lib/docker"
}
EOF
systemctl daemon-reload
systemctl restart docker
docker-compose --version
docker version

PHP(RPM)

截止2025年4月20日目前:PHP最新版8.4.6

centos 8 stream

默认安装最新版8.3.19

1
2
3
4
yum update -y
yum install yum-utils -y
rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
yum install -y php php-fpm php-cli php-common php-devel php-gd php-pdo php-mbstring php-bcmath php-xml php-process php-intl php-soap php-ldap php-opcache

openeuler24.03lts

欧拉系统有自己的仓库,默认安装最新版8.3.19

1
2
3
yum update -y
yum install -y php php-fpm php-cli php-common php-devel php-gd php-pdo php-mbstring php-bcmath php-xml php-process php-intl php-soap php-ldap php-opcache
php -v

Mysql LTS

截止2025年4月20日目前:Mysql LTS最新版8.4.5

资料来源:Linux安装Mysql8.4.2 LTS | 严千屹博客

image-20250420154015199

image-20250420154554656

这是在root目录下,自行去到root目录,你也可以自己定义路径

注意:如果需要搭载php使用,需要安装php7.2,因为rpm -ivh mysql-community-libs-compat是php的依赖。;如果不安装php,则无需安装php7.2的依赖。

这里就演示需要php,版本7.2以上,安装教程

centos 8 stream,openeuler

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
mkdir mysql-install
tar -xvf mysql-8.4*.rpm-bundle.tar -C mysql-install
cd mysql-install

# 卸载 mariadb 相关的包
yum remove mariadb mariadb-config mariadb-libs -y
# 如果之前安装过 MySQL 社区版,也需要一并移除
yum remove mysql-community-common mysql-community-icu-data-files mysql-community-client-plugins mysql-community-libs mysql-community-client mysql-community-server mysql-community-libs-compat -y
# 最好按照以下顺序按照,不然会报错
#全局的依赖(common)
rpm -ivh mysql-community-common-8.4.5-1.el8.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.4.5-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.4.5-1.el8.x86_64.rpm
rpm -ivh mysql-community-libs-8.4.5-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-8.4.5-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-8.4.5-1.el8.x86_64.rpm
#php依赖文件
rpm -ivh mysql-community-libs-compat-8.4.5-1.el8.x86_64.rpm
systemctl enable mysqld --now
mysqlpasswd=$(awk '/temporary password/ {print $NF}' /var/log/mysqld.log)
mysql -u root -p"$mysqlpasswd"
#Qianyios@007是修改后的密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Qianyios@007';
FLUSH PRIVILEGES;
exit
mysql -uroot -pQianyios@007

例子1:可以设置123456为密码

1
2
3
4
5
6
7
8
9
mysql -uroot -pQianyios@007
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Qianyios@007';
SHOW VARIABLES LIKE 'validate_password%';
SET GLOBAL validate_password.policy = LOW;
SET GLOBAL validate_password.length = 6;
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
FLUSH PRIVILEGES;
exit
mysql -uroot -p123456

containerd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum clean all && yum makecache
sudo yum install -y containerd.io

sudo mkdir -p /etc/containerd/certs.d/docker.io
sudo mkdir -p /etc/containerd/certs.d/registry.k8s.io
sudo mkdir -p /etc/containerd/certs.d/k8s.gcr.io
sudo mkdir -p /etc/containerd/certs.d/ghcr.io
sudo mkdir -p /etc/containerd/certs.d/gcr.io
sudo mkdir -p /etc/containerd/certs.d/quay.io
sudo mkdir -p /etc/containerd/certs.d/registry-1.docker.io

sudo tee /etc/containerd/certs.d/docker.io/hosts.toml > /dev/null <<'EOF'
server = "https://docker.io"

[host."https://registry.cn-hangzhou.aliyuncs.com/"]
capabilities = ["pull", "resolve"]
[host."https://docker.xuanyuan.me"]
capabilities = ["pull", "resolve"]
[host."https://docker.m.daocloud.io"]
capabilities = ["pull", "resolve"]
[host."https://docker.1ms.run"]
capabilities = ["pull", "resolve"]
[host."https://docker.1panel.live"]
capabilities = ["pull", "resolve"]
[host."https://docker.qianyios.top/"]
capabilities = ["pull", "resolve"]
[host."https://reg-mirror.giniu.com"]
capabilities = ["pull", "resolve"]
EOF

sudo tee /etc/containerd/certs.d/registry-1.docker.io/hosts.toml > /dev/null <<'EOF'
server = "https://registry-1.docker.io"

[host."https://registry.cn-hangzhou.aliyuncs.com/"]
capabilities = ["pull", "resolve"]
[host."https://docker.xuanyuan.me"]
capabilities = ["pull", "resolve"]
[host."https://docker.m.daocloud.io"]
capabilities = ["pull", "resolve"]
[host."https://docker.1ms.run"]
capabilities = ["pull", "resolve"]
[host."https://docker.1panel.live"]
capabilities = ["pull", "resolve"]
[host."https://docker.qianyios.top/"]
capabilities = ["pull", "resolve"]
[host."https://reg-mirror.giniu.com"]
capabilities = ["pull", "resolve"]
EOF


sudo tee /etc/containerd/certs.d/k8s.gcr.io/hosts.toml > /dev/null <<'EOF'
server = "https://k8s.gcr.io"

[host."https://registry.aliyuncs.com/google_containers"]
capabilities = ["pull", "resolve"]
EOF

sudo tee /etc/containerd/certs.d/ghcr.io/hosts.toml > /dev/null <<'EOF'
server = "https://ghcr.io"

[host."https://ghcr.m.daocloud.io/"]
capabilities = ["pull", "resolve"]
EOF

sudo tee /etc/containerd/certs.d/gcr.io/hosts.toml > /dev/null <<'EOF'
server = "https://gcr.io"

[host."https://gcr.m.daocloud.io/"]
capabilities = ["pull", "resolve"]
EOF

sudo tee /etc/containerd/certs.d/registry.k8s.io/hosts.toml > /dev/null <<'EOF'
server = "registry.k8s.io"

[host."k8s.m.daocloud.io"]
capabilities = ["pull", "resolve", "push"]
[host."https://registry.aliyuncs.com/v2/google_containers"]
capabilities = ["pull", "resolve"]
EOF

sudo tee /etc/containerd/certs.d/quay.io/hosts.toml > /dev/null <<'EOF'
server = "https://quay.io"

[host."https://quay.tencentcloudcr.com/"]
capabilities = ["pull", "resolve"]
EOF

sudo sh -c 'containerd config default > /etc/containerd/config.toml'
sudo sed -i 's#sandbox_image = "registry.k8s.io/pause:.*"#sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.10"#' /etc/containerd/config.toml
sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml
sed -i '/\[plugins\."io\.containerd\.grpc\.v1\.cri"\.registry\]/!b;n;s/config_path = ""/config_path = "\/etc\/containerd\/certs.d"/' /etc/containerd/config.toml
# 重启 containerd 服务
sudo systemctl daemon-reload
sudo systemctl restart containerd.service
sudo ctr image ls

系统更换Yum源办法

阿里网站:repo安装包下载_开源镜像站-阿里云 (aliyun.com)

Centos Stream 8

1
2
3
4
5
mkdir repo.bak
mv /etc/yum.repos.d/* repo.bak/
wget -O /etc/yum.repos.d/CentOS-Stream-AppStream.repo https://mirrors.aliyun.com/repo/centos-stream/8/CentOS-Stream-AppStream.repo
wget -O /etc/yum.repos.d/CentOS-Stream-BaseOS.repo https://mirrors.aliyun.com/repo/centos-stream/8/CentOS-Stream-BaseOS.repo
dnf clean all && dnf makecache

Centos 7

1
2
3
4
mkdir repo.bak
mv /etc/yum.repos.d/* repo.bak/
wget -O /etc/yum.repos.d/Centos-7.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all && yum makecache

Centos 8

1
2
3
4
mkdir repo.bak
mv /etc/yum.repos.d/* repo.bak/
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
yum clean all && yum makecache

Rocky 系列

1
2
3
4
5
6
7
8
sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g' \
-e
's|^#baseurl=http://mirrors.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g' \
-i.bak \
/etc/yum.repos.d/Rocky-*.repo

yum clean all && yum makecache
特别声明
千屹博客旗下的所有文章,是通过本人课堂学习和课外自学所精心整理的知识巨著
难免会有出错的地方
如果细心的你发现了小失误,可以在下方评论区告诉我,或者私信我!
非常感谢大家的热烈支持!