远端服务器环境初始化

982 阅读4分钟

一、标准化部署基础环境

  • 新购cvm,CentOS 8.2 x64
[root@VM-0-12-centos ~]# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)
[root@VM-0-12-centos ~]# yum update -y
  • 本地免密登录
➜  ~ sudo vim /etc/hosts
➜  ~ ssh-copy-id -i ~/.ssh/id_rsa.pub root@se
➜  ~ ssh root@se

二、部署docker 20.10.11环境

[root@VM-0-12-centos ~]# rpm -qa | grep docker
[root@VM-0-12-centos ~]# yum remove docker docker-common docker-selinux docker-engine
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-Epel.repo; 配置:ID 为 "failovermethod" 的 OptionBinding 不存在
未找到匹配的参数: docker
未找到匹配的参数: docker-common
未找到匹配的参数: docker-selinux
未找到匹配的参数: docker-engine
没有软件包需要移除。
依赖关系解决。
无需任何处理。
完毕!
[root@VM-0-12-centos ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
[root@VM-0-12-centos ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-Epel.repo; 配置:ID 为 "failovermethod" 的 OptionBinding 不存在
添加仓库自:https://download.docker.com/linux/centos/docker-ce.repo

[root@VM-0-12-centos ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-Epel.repo; 配置:ID 为 "failovermethod" 的 OptionBinding 不存在
添加仓库自:http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

[root@VM-0-12-centos ~]# yum clean all
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-Epel.repo; 配置:ID 为 "failovermethod" 的 OptionBinding 不存在
47 文件已删除

[root@VM-0-12-centos ~]# yum makecache
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-Epel.repo; 配置:ID 为 "failovermethod" 的 OptionBinding 不存在
EPEL for redhat/centos 8 - x86_64                                                                                                                            6.4 MB/s |  11 MB     00:01
CentOS Linux 8 - AppStream                                                                                                                                   7.6 MB/s | 8.1 MB     00:01
CentOS Linux 8 - BaseOS                                                                                                                                      3.3 MB/s | 3.5 MB     00:01
CentOS Linux 8 - Extras                                                                                                                                       14 kB/s |  10 kB     00:00
Docker CE Stable - x86_64                                                                                                                                     37 kB/s |  19 kB     00:00
元数据缓存已建立。

[root@VM-0-12-centos ~]# yum list docker-ce --showduplicates | sort -r
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-Epel.repo; 配置:ID 为 "failovermethod" 的 OptionBinding 不存在
docker-ce.x86_64                3:20.10.9-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.8-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.7-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.6-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.5-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.4-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.3-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.2-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.1-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.11-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.10-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.0-3.el8                 docker-ce-stable
docker-ce.x86_64                3:19.03.15-3.el8                docker-ce-stable
docker-ce.x86_64                3:19.03.14-3.el8                docker-ce-stable
docker-ce.x86_64                3:19.03.13-3.el8                docker-ce-stable
上次元数据过期检查:0:00:06 前,执行于 2021年11月18日 星期四 14时17分40秒。
可安装的软件包
[root@VM-0-12-centos ~]# yum -y install docker-ce
[root@VM-0-12-centos ~]# systemctl start  docker
[root@VM-0-12-centos ~]# systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
[root@VM-0-12-centos ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.11
 Server: Docker Engine - Community
 Engine:
  Version:          20.10.11
[root@VM-0-12-centos ~]# docker info

三、部署docker 2.1.1环境

[root@VM-0-12-centos ~]# mkdir -p /data/source
[root@VM-0-12-centos source]# wget https://github.com/docker/compose/releases/download/v2.1.1/docker-compose-linux-x86_64
[root@VM-0-12-centos source]# chmod 700 docker-compose-linux-x86_64
[root@VM-0-12-centos source]# cp docker-compose-linux-x86_64 /usr/local/bin/docker-compose
[root@VM-0-12-centos ~]# cd ~/ ; pwd ; docker-compose version
/root
Docker Compose version v2.1.1

四、部署harbor 2.3.4环境

[root@VM-0-12-centos ~]# cd /data/source/ ; wget https://github.com/goharbor/harbor/releases/download/v2.3.4/harbor-offline-installer-v2.3.4.tgz
[root@VM-0-12-centos source]# tar zxvf harbor-offline-installer-v2.3.4.tgz

五、部署Nginx环境

[root@VM-0-12-centos ~]# docker pull nginx
[root@VM-0-12-centos ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    ea335eea17ab   20 hours ago   141MB
[root@VM-0-12-centos ~]# mkdir -p /data/logs
[root@VM-0-12-centos ~]# mkdir -p /data/conf/
[root@VM-0-12-centos data]# mkdir -p /data/apps/nginx
[root@VM-0-12-centos data]# mkdir -p /data/apps/nginx/conf.d
[root@VM-0-12-centos data]# mkdir -p /data/apps/nginx/logs
[root@VM-0-12-centos data]# vim /data/apps/nginx/nginx.conf 
user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;
  #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

[root@VM-0-12-centos conf.d]# vim /data/apps/nginx/conf.d/default.conf 
server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}
[root@VM-0-12-centos ~]# docker run -d --name nginx -p 80:80 -p 443:443 -v /data/apps/nginx/nginx.conf:/etc/nginx/nginx.conf -v /data/apps/nginx/conf.d:/etc/nginx/conf.d -v /data/apps/nginx/logs:/var/log/nginx nginx
e1bd2f55730592886b3a13d7eb7b6257ccd829bb22997d528708009d1caac439

[root@VM-0-12-centos ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS                                                                      NAMES
e1bd2f557305   nginx     "/docker-entrypoint.…"   4 seconds ago   Up 3 seconds   0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   nginx
  1. 常用工具安装mwget/axel
wget http://jaist.dl.sourceforge.net/project/kmphpfm/mwget/0.1/mwget_0.1.0.orig.tar.bz2
tar -jxvf mwget_0.1.0.orig.tar.bz2
yum install bzip2
bzip2 -d mwget_0.1.0.orig.tar.bz2
tar -jxvf mwget_0.1.0.orig.tar.bz2

yum install gcc-c++
yum install openssl-devel
yum install intltool

./configure
make
make install


[root@node2 ~]# wget http://files.cnblogs.com/files/xiaochina/axel-2.4.tar.gz
[root@node2 ~]# tar zxvf axel-2.4.tar.gz
[root@node2 axel-2.4]# ./configure
[root@node2 axel-2.4]# make
[root@node2 axel-2.4]# make install

  1. 包/DEV管理工具安装
[root@node2 ~]# yum install npm
npm install --global yarn

[root@node2 ~]# yarn --version
1.22.11

#[root@node2 ~]# yarn install && yarn dev