分类 "Linux" 下的文章

1. 迁移前准备

  • 版本一致性检查:确保新旧服务器的 GitLab 版本完全一致(可通过 sudo gitlab-rake gitlab:env:info 查看版本),否则可能导致恢复失败。
  • 备份策略制定

    • 使用 sudo gitlab-rake gitlab:backup:create 创建全量备份(包含仓库、数据库、用户权限等数据),备份文件默认存储在 /var/opt/gitlab/backups
    • 手动备份配置文件

      • /etc/gitlab/gitlab.rb(主配置文件)
      • /etc/gitlab/gitlab-secrets.json(密钥文件)
        避免因配置文件丢失导致恢复失败。

阅读全文

问题:ubuntu如何安装consul、fabio搭建微服务?

方法:
一、安装consul
1、下载

wget https://releases.hashicorp.com/consul/1.3.0/consul_1.3.0_linux_amd64.zip
unzip consul_1.3.0_linux_amd64.zip
sudo mv consul /usr/local/bin/consul

阅读全文

问题:rqworker 运行时报错ERROR:root:Authentication required. 使用的是redis作为存储,因为redis设置了密码

解决:可以通过--url参数设置redis连接链接;也可以通过export设置redis连接链接为环境变量

方法:

1、rq连接redis

from rq import Queue
from redis import StrictRedis
from .config import config

redis_config = { 
    'host': config['RQ_SVR'],
    'db': config['RQ_DB'],
    'password': config['RQ_PASS']
    }   
redis_url = 'redis://:{password}@{host}:6379/{db}'.format(**redis_config)
redis_conn = StrictRedis.from_url(redis_url)
q = Queue(connection=redis_conn)

阅读全文

问题:导出文件时,如何将字节流返回给前端,前端通过blob方式获取

方法:
Tornado

import xlwt
from io import BytesIO

class ApiDownloadHandler(BaseHandler):
    @login_required()
    def post(self):
        # 设置响应头
        self.set_header('Content-Type', 'application/x-xls')
        # filename 不能为中文
        self.set_header('Content-Disposition', 'attachment; filename=download.xls')
        wb = xlwt.Workbook()
        ws = wb.add_sheet('Sheet1')
        style0 = xlwt.easyxf('font: name Microsoft YaHei Light, height 220; align: vert centre, horiz center')
        # title
        header = ['序号', '姓名', '年龄']
        for i in range(len(header)):
            ws.write(0, i, header[i], style0)
            ws.col(i).width = 4000
        sio = BytesIO()
        # 这点很重要,传给save函数的不是保存文件名,而是一个StringIO流
        wb.save(sio)
        self.write(sio.getvalue())

阅读全文