/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
}

wget https://npm.taobao.org/mirrors/node/v14.17.6/node-v14.17.6-linux-x64.tar.xz
tar -xJvf ./node-v14.17.6-linux-x64.tar.xz
mkdir  -pv /alidata/server/nodejs/nodejs-14
cp -rf ./node-v14.17.6-linux-x64/*  /alidata/server/nodejs/nodejs-14
sudo ln -sf /alidata/server/nodejs/nodejs-14/bin/node /usr/local/bin/
sudo ln -sf /alidata/server/nodejs/nodejs-14/bin/npm /usr/local/bin/
sudo ln -sf /alidata/server/nodejs/nodejs-14/bin/npx /usr/local/bin/
node -v

apisix版本:2.13.0-alpine
apisix-dashboard版本:2.10.1-alpine
etcd版本:3.4.16-debian-10-r14

https://registry.hub.docker.com/r/apache/apisix
https://registry.hub.docker.com/r/apache/apisix-dashboard

1)部署etcd

docker run -d --name etcd \
        --net host \
        -p 2379:2379 \
        -p 2380:2380 \
        -e ALLOW_NONE_AUTHENTICATION=yes \
        -e ETCD_ADVERTISE_CLIENT_URLS=http://127.0.0.1:2379 \
        bitnami/etcd:3.4.16-debian-10-r14

2)部署apisix

mkdir -p /opt/apisix/{conf,logs}
mkdir -p /opt/apisix-dashboard/{conf,logs}
touch /opt/apisix/conf/config.yaml
touch /opt/apisix-dashboard/conf/config.yaml

docker run -d --name apisix \
        --net host \
        -p 9080:9080 \
        -p 9180:9180 \
        -v /opt/apisix/conf/config.yaml:/usr/local/apisix/conf/config.yaml \
        -v /opt/apisix/logs:/tmp/logs \
        apache/apisix:2.13.0-alpine

3)部署apisix-dashboard

docker run -d --name apisix-dashboard \
        --net host \
        -p 9000:9000 \
        -v /opt/apisix-dashboard/conf/conf.yaml:/usr/local/apisix-dashboard/conf/conf.yaml \
        -v /opt/apisix-dashboard/logs:/tmp/logs \
        apache/apisix-dashboard:2.10.1-alpine

安装Apisix

安装文档:https://apisix.apache.org/zh/docs/apisix/installation-guide/

如果当前系统没有安装 OpenResty,请使用以下命令来安装 OpenResty 和 APISIX 仓库:

sudo yum install -y https://repos.apiseven.com/packages/centos/apache-apisix-repo-1.0-1.noarch.rpm

如果已安装 OpenResty 的官方 RPM 仓库,请使用以下命令安装 APISIX 的 RPM 仓库:

sudo yum-config-manager --add-repo https://repos.apiseven.com/packages/centos/apache-apisix.repo

查询可安装的版本

yum search apisix --showduplicates

安装

yum install -y apisix-2.15.3

安装后的目录是/usr/local/apisix和/usr/local/openresty

启动apisix

systemctl daemon-reload
systemctl enable apisix
systemctl start apisix
# apisix网关地址:http://x.x.x.x:9080
# apisix api地址:http://x.x.x.x:9180/apisix/admin

安装Apisix-Dashboard

安装到/usr/local/apisix/dashboard目录
sudo yum install -y https://github.com/apache/apisix-dashboard/releases/download/v3.0.1/apisix-dashboard-3.0.1-0.el7.x86_64.rpm
systemctl enable apisix-dashboard
systemctl start apisix-dashboard

apisix-dashboard地址:http://x.x.x.x:9000
systemctl restart apisix-dashboard