“This is my third day of the November Gwen Challenge.The final text challenge in 2021”.

preface

There is a saying in the line that a programmer who has not deleted a library is not a qualified programmer. I had the privilege to experience deleting a server once. One day of daily development, I boarded the server and checked the log files, and found a large number of historical log files. The console outputs a quick output and then prompts you that some directories cannot be deleted. I hit LL, the log is gone, then CD to the root directory, check, sure enough, all files are gone. There was a buzz, and I realized I might be in serious trouble. I just deleted the server. Later, I reported it to my boss. Fortunately, it was just a test environment, and no serious consequences were caused. I was asked to try to recover.

After executing rm -rf /*, the system does not crash immediately, and the programs that have been running can still run normally. So I can export all the data immediately

1. Install the Linux operating system

1.1 Downloading the Image File

Isoredirect.centos.org/centos/7/is…

Select an appropriate domestic proxy address and download the ISO image file of the corresponding version

1.2 Making usb boot disk

  • Prepare a memory not less than one memory8GtheU disk
  • Download and installUltraISOCD burning tool (direct search engine search to download the latest version)
  • Run as an administratorUltraISO, click on thefileOpen theDownloaded image file (CentOS-7-x86_64-DVD-2003.iso)
  • Click Start → Write hard disk image

  • Select a hard disk drive (USB flash drive)USB-HDD+, click Write

  • Write complete, drive disk production is complete

1.3 OS Installation

  • Change the boot option toUSBFor the first boot item, depending on your computer model inBIOSInterface modification.
  • The installation window is displayed, and complete the installation according to the instructions. Specific reference video: www.bilibili.com/video/BV1Lz…

2. The Docker installation

Official website: www.docker.com/

2.1 Uninstalling Earlier Versions

 sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
Copy the code

2.2 Install necessary system tools

sudo yum install -y yum-utils device-mapper-persistent-data lvm2
Copy the code

2.3 Adding Software Source Information

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Copy the code

2.4 Updating the YUM Cache

sudo yum makecache fast
Copy the code

2.5 installation Docker – ce

sudo yum -y install docker-ce
Copy the code

2.6 Starting the Docker Service

sudo systemctl start docker
Copy the code

2.7 Configuring Ali Cloud Mirroring

  • Open the configuration file daemon.json
vi /etc/docker/daemon.json
Copy the code
  • Enter the mirror address
{
 "registry-mirrors":["https://6kx4zyno.mirror.aliyuncs.com"]
}
Copy the code
  • Restart the Docker service
sudo systemctl restart docker
Copy the code

3. The JDK installation

3.1 Uninstalling the Built-in OpenJDK

  • View the current Java version

    • java -version 
      Copy the code
    • [root@localhost ~]# Java -version openJDK version "1.8.0_242" OpenJDK Runtime Environment (build 1.8.0_242-b08 64-bit Server VM (Build 25.242-B08, Mixed mode)Copy the code
  • See how many Java packages are installed

    • rpm -qa | grep java
      Copy the code
    • / root @ localhost ~ # RPM - qa | grep Java javassist 3.16.1-10. El7. Noarch nuxwdog - the client - Java - 1.0.5-1. El7. X86_64 Tzdata - Java - 2019 - c - 1. El7. Noarch python - javapackages - 3.4.1 track - 11. El7. Noarch Java - 1.8.0 comes with - its - headless - 1.8.0.242. B08-1. El7. X86_64 javapackages - tools - 3.4.1 track - 11. El7. Noarch Pki - base - Java - 10.5.17-6. El7. Noarch Java -- 1.8.0 comes with its - 1.8.0.242. B08-1. El7. X86_64 javamail - 1.4.6-8 el7. NoarchCopy the code
  • Uninstall all openJDK packages

    • RPM -e --nodeps java-1.8.0-openJDK-headless-1.8.0.242.b08-1.el7.x86_64 RPM -e --nodeps java-1.8.0-openJDK-headless-1.8.0.242.b08-1.el7.x86_64 RPM -e --nodeps Java -- 1.8.0 comes with its - 1.8.0.242. B08-1. El7. X86_64Copy the code
  • Check whether the uninstallation is complete

  • [root@localhost ~]# Java -version-bash: /usr/bin/java: no such file or directoryCopy the code

3.2 Installing JDK1.8 Linux

  • Download address www.oracle.com/java/techno…

  • Upload the decompressed installation package

    tar -zxvf jdk-8u301-linux-x64.tar.gz
    Copy the code
  • Modify environment variables based on your installation path

  • vim /etc/profile
    Copy the code
    Export JAVA_HOME=/usr/ jav/jdk1.8.0_301 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin export PATH=$PATH:${JAVA_PATH}Copy the code
  • Reload the configuration file

    source /etc/profile
    Copy the code
  • Verify that the installation is successful

    java -version
    Copy the code
  • If the following information is displayed, the installation is successful

    [root@iZ8vbeak6j8zpan8owflsyZ mydata]# java -version
    java version "1.8.0_301"
    Java(TM) SE Runtime Environment (build 1.8.0_301-b09)
    Java HotSpot(TM) 64-Bit Server VM (build 25.301-b09, mixed mode)
    Copy the code

4. Nginx installation

  • Download and install the Linux installation package nginx.org/en/download…

  • Nginx relies on the GCC compilation environment, so you need to install a compilation environment to enable Nginx to compile.

    yum install gcc-c++
    Copy the code
  • The HTTP module of Nginx needs to use PCRE to parse regular expressions. Pcre needs to be installed

    yum install -y pcre pcre-devel
    Copy the code
  • Install the dependent decompression package

    yum install -y zlib zlib-devel
    Copy the code
  • The SSL function requires the OpenSSL library. Install OpenSSL

    yum install -y openssl openssl-devel
    Copy the code
  • Compile the installation

    • Go to the nginx directory

      cd /mydata/nginx
      Copy the code
    • Execute the command

      ./configure
      Copy the code
    • Run the make command

      make
      Copy the code
    • Run the make install command

      make install
      Copy the code
  • The default installation is /usr/local/nginx

  • Start the

    ./usr/local/nginx/sbin/nginx
    Copy the code
  • If the welcome page is displayed after you access the IP address, the installation is successful

If the access is not successful, check and disable the firewall

  • Checking the Firewall Status
systemctl status firewalld.service
Copy the code
  • Disabling the Firewall
systemctl stop firewalld.service
Copy the code
  • Permanently Disable the Firewall
systemctl disable firewalld.service
Copy the code

5. Install tomcat

  • Download and install the Linux installation package

  • Unpack the

    Tar ZXVF - apache tomcat - 9.0.50. Tar. GzCopy the code
  • Start the

    ./mydata/tomcat9/bin/startup.sh
    Copy the code
  • Check whether the installation is successful. Port 8080 is started by default. If the welcome page is displayed, the installation is successful

6. InstallationMySQL

6.1 Manually Installing version 5.7

In order to build quickly, I used Docker installation, which will be introduced later.

  • Installing version 5.7

    • wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
      Copy the code
    • yum -y install mysql57-community-release-el7-10.noarch.rpm
      Copy the code
    • yum -y install mysql-community-server
      Copy the code
    • systemctl start mysqld.service
      Copy the code
    • Viewing the Default Password

      grep "password" /var/log/mysqld.log
      Copy the code
    • Mysql -uroot -p (note: Enter the default password)Copy the code
    • set global validate_password_policy=0;
      Copy the code
    • set global validate_password_length=1;
      Copy the code
    • ALTER USER 'root'@'localhost' IDENTIFIED BY 'your new password '; (Note: Change your new password here)Copy the code
  • The mysql configuration file is stored in /etc/my.cnf by default

    You are advised to change the default port number

    Modify port=3666 in configuration file

  • Uninstall MySQL

    • See what files are available

      rpm -qa|grep -i mysql
      Copy the code
    • Unload one by one

      Yum removeCopy the code
    • Delete some legacy files

      find / -name mysql
      Copy the code
    • Delete one by one

      Rm - rf filesCopy the code

6.2 Docker installation version 8.0

There are many people on the Internet to share, but it is just a simple installation, there are many pits did not mention, must be in my order to operate, can effectively avoid pits.

  • Download the image file (latest version 8.0 by default)
docker pull mysql
Copy the code
  • Run the container
Docker run -itd --name mysql8.0 \ -p 3306:3306 \ -e MYSQL_ROOT_PASSWORD=123456 mysqlCopy the code
  • Copy all files to be mounted to the local PC
mkdir -p /mydata/mysql/conf mkdir -p /mydata/mysql/logs mkdir -p /mydata/mysql/data mkdir -p /mydata/mysql/mysql-files Docker cp mysql8.0: / etc/mysql/my CNF/mydata/mysql/conf/my CNF docker cp mysql8.0: / etc/mysql/conf. D /mydata/mysql/conf/conf.dCopy the code

There is a small hole here. Do not change the permission of the configuration file. Otherwise, the configuration will not take effect. I was chMOD 777 at the time, and it didn’t work anyway, and then I read the log to solve it bit by bit.

  • Remove the container
Docker stop mysql8.0 docker rm mysql8.0Copy the code
  • Rerun the container and mount it
Docker run - itd - name mysql8.0 \ -p 3306: \ 3306 - v/mydata/mysql/conf: / etc/mysql \ v/mydata/mysql/logs: / logs \ - v /mydata/mysql/data:/var/lib/mysql \ -v /mydata/mysql/mysql-files:/var/lib/mysql-files \ -e MYSQL_ROOT_PASSWORD=root@123456 mysqlCopy the code
  • Restart the
Docker restart mysql8.0Copy the code

7. Install Redis

Juejin. Cn/post / 700111…

## background run
daemonize yes
## Extranet connection
protected-mode no
#Only local connections are allowed
# bind 127.0.0.1
## port
port 6666
## connect password
requirepass 123456
#Set database total
databases 256
## log file
logfile ./redislog.log
#Set the data file storage directoryDir/usr/local/redis - 6.0.6Copy the code

8. GitLab installation

  • Downloading the image File
    docker pull docker.io/gitlab/gitlab-ce
    Copy the code
  • Create a mount directory
    mkdir -p /var/gitlab/etc
    mkdir -p /var/gitlab/log
    mkdir -p /var/gitlab/data
    Copy the code
  • Start the container
    Docker run \ --detach \ --publish 2222:22 \ --publish 777:7777 \ --publish 844:443 \ --hostname 192.168.10.59 \ -v /var/gitlab/etc:/etc/gitlab \ -v /var/gitlab/log:/var/log/gitlab \ -v /var/gitlab/data:/var/opt/gitlab \ -v /etc/localtime:/etc/localtime:ro \ --name gitlab \ --restart always \ --privileged=true gitlab/gitlab-ce:latestCopy the code
  • Modify the/var/gitlab/etc/gitlab.rb
    vi /var/gitlab/etc/gitlab.rb
    Copy the code
    #Modify the HTTPcloneIs displayed
    # external_url 'GENERATED_EXTERNAL_URL'External_url 'http://192.168.0.106:7777'#Modify the SSHcloneIs displayed
    gitlab_rails['gitlab_shell_ssh_port'] = 2222
    Copy the code
  • Modify the/var/gitlab/data/gitlab-rails/etc/gitlab.ymlChange the port to the correct port
    vi /var/gitlab/data/gitlab-rails/etc/gitlab.yml
    Copy the code
  • Restart gitlab
    docker restart gitlab
    Copy the code
  • Example Initialize the administrator password
    • docker exec  -it gitlab /bin/bash
      Copy the code
    • gitlab-rails console
      Copy the code
    • user = User.where(username: 'root').first
      Copy the code
    • user.password='root@123'
      Copy the code
    • user.save
      Copy the code
  • Visit the address http://192.168.0.106:7777 login account, create good warehouse, configured account.
  • Code synchronization

Synchronize the local code to gitLab

#Local synchronization to remote repository
git push -u origin master
#Switch branch
git checkout uat
Copy the code

9. The node installation

  • Downloading the Installation package

    Wget HTTP: / / https://cdn.npm.taobao.org/dist/node/v14.16.0/node-v14.16.0-linux-x64.tar.xzCopy the code
  • Unpack the

    Xz -d node-v14.16.0-linux-x64.tar.xz tar - XVF node-v14.16.0-linux-x64.tarCopy the code
  • Set up a soft connection in the /usr/bin directory and make it global

    Ln -s /usr/local/node-node-v14.16.0 -linux-x64/bin/node /usr/local/bin/node ln -s / usr/local/node/node - v14.16.0 - Linux - x64 / bin/NPM/usr/local/bin/NPMCopy the code
  • Verify that the installation is successful

    node -v
    Copy the code
  • Install CNPM

    npm install -g cnpm --registry=https://registry.npm.taobao.org
    Copy the code
  • Creating a Soft connection

    Ln -s/usr/local/node/node - v14.16.0 - Linux - x64 / bin/CNPM/usr/local/bin/CNPMCopy the code
  • Verifying the Installation

cnpm -v
Copy the code
  • Switch to taobao source image
    npm install yarn -g
    #Creating a Soft connectionLn -s/usr/local/node/node - v14.16.0 - Linux - x64 / bin/yarn/usr/local/bin/yarn#View the current source address
    yarn config get registry
    #Switch to Taobao Source
    yarn config set registry https://registry.npm.taobao.org/
    #Check whether the switchover is successful
    yarn config get registry
    Copy the code

10. Jenkins installation

  • Downloading the image File

    docker pull jenkins/jenkins
    Copy the code
  • Create a mount folder to view configuration and data information

    mkdir -p /var/jenkins_mount
    chmod 777 /var/jenkins_mount
    Copy the code
  • Start the container

    docker run -d -p 8080:8080 \ -p 50000:50000 \ -v /var/jenkins_mount:/var/jenkins_home \ -v / mydata jdk1.8.0 _301: / var/jdk1.8.0 _301 \ v/usr/share/maven: / var/maven \ - v/etc/localtime: / etc/localtime \ -- the name jenkins jenkins/jenkinsCopy the code
  • Modify Jenkins software download image

    vi  /var/jenkins_mount/hudson.model.UpdateCenter.xml
    Copy the code
    <? The XML version = '1.1' encoding = "utf-8"? > <sites> <site> <id>default</id> <url>https://updates.jenkins.io/update-center.json</url> </site> </sites>Copy the code

Amend the url to tsinghua university official mirror address: mirrors.tuna.tsinghua.edu.cn/jenkins/upd…

<? The XML version = '1.1' encoding = "utf-8"? > <sites> <site> <id>default</id> <url>https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</url> </site> </sites>Copy the code
  • Reboot it, Jenkins.

    docker restart jenkins 
    Copy the code
  • Visit Jenkins to view the password

    cat /var/jenkins_mount/secrets/initialAdminPassword
    Copy the code
  • Set the account as prompted

  • Installation of related Applications

    • maven
    yum install maven
    Copy the code
    • git
    yum install git
    Copy the code
    • Maven Automatic Installation
    • The JDK bring
    [root@localhost jenkins_mount]# docker exec -it jenkins /bin/bash
    jenkins@d9218f4c506e:/$ echo $JAVA_HOME
    /opt/java/openjdk
    Copy the code
    • Automatic installation of the JDK can also be used

    Maven uses automatic downloads, whereas the JDK uses mount

    • Install the plug-in Nodejs
      • Set up the INSTALLATION of CNPM in global configuration
      • In the job configuration to build the environment, select Provide Node & NPM bin/ Folder to PATH and specify the version to be automatically installed
  • Configure the SSH remote connection

Configure the connection to the server

  • Jenkins time is not allowed to change
System.setProperty('org.apache.commons.jelly.tags.fmt.timeZone'.'Asia/Shanghai')
Copy the code

11. Nginx installation and configuration

  • Download decompression (limited space, simple operation, not detailed introduction here)
  • Address concatenation removes prefix API
location ^~/api/ {
       	    proxy_set_header Host $host;
            proxy_set_header  X-Real-IP        $remote_addr;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_set_header  X-NginX-Proxy true;
	
            proxy_pass http://192.168.0.106:8090/;
    	}
Copy the code
  • Rewrite the prefix removal API/)
location ^~/api/ {
        proxy_set_header Host $host;
        proxy_set_header  X-Real-IP        $remote_addr;
        proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header X-NginX-Proxy true;

        rewrite ^/order/(.*)$ /$1 break;
        proxy_pass http://192.168.0.106:8090/api;
    }
Copy the code
server { listen 1111; server_name localhost; location / { root html/erp-web-uat; index index.html index.htm; } location ^~/api/ { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-NginX-Proxy true; Proxy_pass http://192.168.0.106:8091/; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }}Copy the code

12. Zen Installation

  • Downloading the image File

    docker pull easysoft/zentao
    Copy the code
  • Create a Docker network driver

    Docker network create --subnet=172.172.172.0/24 ZentaonetCopy the code
  • Create a mount directory

    mkdir -p /mydata/chandao/zentaopms
    mkdir -p /mydata/chandao/mysqldata
    Copy the code
  • Activate the Zen path container

    docker run --name zentao \
                -p 9000:80 \
                -v /mydata/chandao/zentaopms:/www/zentaopms \
                -v /mydata/chandao/mysqldata:/var/lib/mysql \
                -d easysoft/zentao
    Copy the code
  • View the IP address inside the container

The goal is not to use Zen Dao’s own internal database, but to use our own services

    docker network inspect bridge
Copy the code

Is commonly 172.172.172. * * *

  • Set the password mode for database connection

    [mysqld]
    default-authentication-plugin=mysql_native_password
    Copy the code
  • An address resolution error may occur

    [mysqld]
    skip-name-resolve
    Copy the code
  • If that still doesn’t work, modify the database connection

    select host,user,plugin,authentication_string from mysql.user
    Copy the code
    %	root	mysql_native_password	*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
    localhost	mysql.infoschema	caching_sha2_password	$A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED
    localhost	mysql.session	caching_sha2_password	$A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED
    localhost	mysql.sys	caching_sha2_password	$A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED
    localhost	root	caching_sha2_password	$A$005$tOo""SB	y@fnlVu3WzwZGqrggMqgcCWpJ3Ru16Cnc/mUdtceS/SStUCea3
    Copy the code
    ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
    Copy the code

After modifying the configuration, restart the device and try again

13. Configure multiple environments

13.1 the Tomcat configuration

<Service name="ERP_UAT">
    <Connector port="8091" protocol="HTTP / 1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <Engine name="ERP_UAT" defaultHost="localhost">

      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
      <Host name="localhost"  appBase="erp_uat"
            unpackWARs="true" autoDeploy="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs/erp_uat"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
      </Host>
    </Engine>
</Service>

Copy the code

conclusion

Here is basically a complete recovery, fortunately, the deletion is only a test environment, lessons learned, in the future when operating delete command must be more careful.