安装命令

sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
sudo systemctl enable docker

设置registry-mirrors

vim /etc/docker/daemon.json,添加以下内容:

{
    "registry-mirrors": [
        "https://xxx.mirror.xxx.com"
    ]
}

重启服务

sudo systemctl daemon-reload
sudo systemctl restart docker

gitlab配置文件:/etc/gitlab/gitlab.rb

启动服务 sudo gitlab-ctl start
停止服务 sudo gitlab-ctl stop
重启服务 sudo gitlab-ctl restart

修改配置后,执行以下命令:

sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart(可选,建议执行)

备份gitlab

sudo gitlab-rake gitlab:backup:create
备份目录:/var/opt/gitlab/backups/

恢复gitlab备份

把备份文件放到/var/opt/gitlab/backups/

sudo gitlab-ctl stop
sudo gitlab-rake gitlab:backup:restore BACKUP=备份文件名称
sudo gitlab-ctl start

配置:

back_log    1000
character_set_server    utf8mb4
collation_server    utf8mb4_general_ci
interactive_timeout 3600
max_connections 1000
wait_timeout    3600

创建数据库和用户:

CREATE DATABASE abc CHARACTER SET utf8mb4;
CREATE USER 'user1'@'localhost' IDENTIFIED BY 'xxx';
GRANT ALL PRIVILEGES ON abc.* TO 'user1'@'localhost';
FLUSH PRIVILEGES;

# Building the binary of the App
FROM golang:1.19 AS build

# `boilerplate` should be replaced with your project name
WORKDIR /go/src/boilerplate

# Copy all the Code and stuff to compile everything
COPY . .

# Downloads all the dependencies in advance (could be left out, but it's more clear this way)
RUN go mod download

# Builds the application as a staticly linked one, to allow it to run on alpine
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o app .


# Moving the binary to the 'final Image' to make it smaller
FROM alpine:latest as release

WORKDIR /app

# Create the `public` dir and copy all the assets into it
RUN mkdir ./static
COPY ./static ./static

# `boilerplate` should be replaced here as well
COPY --from=build /go/src/boilerplate/app .

# Add packages
RUN apk -U upgrade \
    && apk add --no-cache dumb-init ca-certificates \
    && chmod +x /app/app

# Exposes port 3000 because our program listens on that port
EXPOSE 3000

ENTRYPOINT ["/usr/bin/dumb-init", "--", "sh", "-c", "/app/app"]

/usr/sbin/logrotate -d -f /etc/logrotate.d/nginx
/usr/sbin/logrotate -f /etc/logrotate.d/nginx

logrotate命令格式

logrotate [OPTION...]
-d, --debug :debug模式,测试配置文件是否有错误。
-f, --force :强制转储文件。
-m, --mail=command :压缩日志后,发送日志到指定邮箱。
-s, --state=statefile :使用指定的状态文件。
-v, --verbose :显示转储过程。

常用的指令解释,这些指令都可以在man logrotate 中找得到。
daily 指定转储周期为每天
monthly 指定转储周期为每月
weekly <-- 每周轮转一次(monthly)
rotate 4 <-- 同一个文件最多轮转4次,4次之后就删除该文件
create 0664 root utmp <-- 轮转之后创建新文件,权限是0664,属于root用户和utmp组
dateext <-- 用日期来做轮转之后的文件的后缀名
compress <-- 用gzip对轮转后的日志进行压缩
minsize 30K <-- 文件大于30K,而且周期到了,才会轮转
size 30k <-- 文件必须大于30K才会轮转,而且文件只要大于30K就会轮转不管周期是否已到
missingok <-- 如果日志文件不存在,不报错
notifempty <-- 如果日志文件是空的,不轮转
delaycompress <-- 下一次轮转的时候才压缩
sharedscripts <-- 不管有多少文件待轮转,prerotate和postrotate 代码只执行一次
prerotate <-- 如果符合轮转的条件
则在轮转之前执行prerotate和endscript 之间的shell代码
postrotate <-- 轮转完后执行postrotate 和 endscript 之间的shell代码

/data/tomcat/*/*.log {
    su root root  # centos7上不加这里会报错 error: skipping...Set "su" directive in config file to tell 
    logrotate which user/group should be used for rotation.
    rotate 15
    daily
    copytruncate
    compress
    notifempty
    missingok
}
#!/bin/bash
path=$(cd `dirname $0`;pwd)
 
cd $path
echo $path
current_date=`date -d "-1 day" "+%Y%m%d"`
echo $current_date
split -b 65535000 -d -a 4 /home/nohup.out /home/log/log_${current_date}_
cat /dev/null > nohup.out

cat /etc/logrotate.d/nginx

/var/log/nginx/*.log /var/log/nginx/*/*.log {
        daily
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 640 nobody
        sharedscripts
        postrotate
                if [ -f /var/run/nginx/nginx.pid ]; then
                        kill -USR1 `cat /var/run/nginx/nginx.pid`
                fi
        endscript
}