• docker-sentry


    1. 准备镜像

    docker pull redis 
    docker pull postgres 
    docker pull sentry
    
    [root@localhost ~]# docker images
    REPOSITORY   TAG              IMAGE ID       CREATED         SIZE
    redis        latest           621ceef7494a   9 hours ago     104MB
    python       latest           da24d18bf4bf   26 hours ago    885MB
    postgres     latest           acf5fb8bfd76   27 hours ago    314MB
    sentry       latest           fe6992de61df   15 months ago   869MB
    centos       centos7.6.1810   f1cb7c7d58b7   22 months ago   202MB
    
    

    2. 启动容器

    1.启动容器
    [root@localhost ~]# docker run -d --name sentry-redis redis
    1414c5295452f8c17f387df01dadbbad6fad31baa5cbd8fb2dc4d4bc63839ada
    [root@localhost ~]# docker run -d --name sentry-postgres -e POSTGRES_PASSWORD=123456 -e POSTGRES_USER=sentry postgres 
    5d6f00d5153228ec74460cfe46cb5a237600a547dbb87a493a9349fb50047210
    [root@localhost ~]# docker run --rm sentry config generate-secret-key
    *cg#+eudt!en93ajdvlnbo&sm-t7g3odyn8fcavyu9@jbd89ae
    
    2.指定secret-key启动(容器互联)
    docker run -it --rm -e SENTRY_SECRET_KEY='*cg#+eudt!en93ajdvlnbo&sm-t7g3odyn8fcavyu9@jbd89ae' --link sentry-postgres:postgres --link sentry-redis:redis sentry upgrade
    
    [root@localhost ~]# docker run -d -p 9000:9000 --name my-sentry -e SENTRY_SECRET_KEY='*cg#+eudt!en93ajdvlnbo&sm-t7g3odyn8fcavyu9@jbd89ae' --link sentry-redis:redis --link sentry-postgres:postgres sentry 
    561fe43f0365d8bc7dc08bdbda325c785dff8aa91e9aff8973d1d45d07d3e95e
    
    [root@localhost ~]# docker run -d --name sentry-cron -e SENTRY_SECRET_KEY='*cg#+eudt!en93ajdvlnbo&sm-t7g3odyn8fcavyu9@jbd89ae' --link sentry-postgres:postgres --link sentry-redis:redis sentry run cron
    5ec4d8fc60602a6d6a3845f26e6d4ef6bdd0a454917df94d9675a859a0987f68
    
    [root@localhost ~]# docker run -d --name sentry-worker-1 -e SENTRY_SECRET_KEY='*cg#+eudt!en93ajdvlnbo&sm-t7g3odyn8fcavyu9@jbd89ae' --link sentry-postgres:postgres --link sentry-redis:redis sentry run worker 
    ef89055b7e210380e6c2e3951b70ea1903206ec7099730aea8d0ba03fbbb2799
    
    [root@localhost ~]# docker ps -a
    CONTAINER ID   IMAGE                   COMMAND                  CREATED          STATUS                        PORTS                    NAMES
    ef89055b7e21   sentry                  "/entrypoint.sh run …"   6 minutes ago    Up 5 minutes                  9000/tcp                 sentry-worker-1
    5ec4d8fc6060   sentry                  "/entrypoint.sh run …"   7 minutes ago    Up 7 minutes                  9000/tcp                 sentry-cron
    561fe43f0365   sentry                  "/entrypoint.sh run …"   7 minutes ago    Up 7 minutes                  0.0.0.0:9000->9000/tcp   my-sentry
    5d6f00d51532   postgres                "docker-entrypoint.s…"   21 minutes ago   Up 21 minutes                 5432/tcp                 sentry-postgres
    1414c5295452   redis                   "docker-entrypoint.s…"   22 minutes ago   Up 22 minutes                 6379/tcp                 sentry-redis
    

    3.配置

    1.进入sentry容器
    [root@localhost ~]# docker exec -it my-sentry /bin/bash
    
    2.设置用户
    root@561fe43f0365:/# sentry createuser
    
    3.添加项目,在项目中初始化DSN
    import sentry_sdk
    sentry_sdk.init("http://801a737f3d2f447585881a9b58b472cb@172.30.4.154:9000/2")
    
    print(time.time())
    
    4. 查看错误
    如下图
    

    image
    image

    postgresql使用:
    # 进入容器
    [root@localhost ~]# docker exec -it sentry-postgres /bin/bash
    root@5d6f00d51532:/#
    # 登录
    postgres@5d6f00d51532:/bin$ PGPASSWORD=123456 psql -U sentry    
    psql (13.1 (Debian 13.1-1.pgdg100+1))
    Type "help" for help.
    
    sentry=# 
    # 创建库
    sentry=# CREATE DATABASE test_one;
    CREATE DATABASE
    #查看库
    sentry-# l
                                  List of databases
       Name    | Owner  | Encoding |  Collate   |   Ctype    | Access privileges 
    -----------+--------+----------+------------+------------+-------------------
     postgres  | sentry | UTF8     | en_US.utf8 | en_US.utf8 | 
     sentry    | sentry | UTF8     | en_US.utf8 | en_US.utf8 | 
     template0 | sentry | UTF8     | en_US.utf8 | en_US.utf8 | =c/sentry        +
               |        |          |            |            | sentry=CTc/sentry
     template1 | sentry | UTF8     | en_US.utf8 | en_US.utf8 | =c/sentry        +
               |        |          |            |            | sentry=CTc/sentry
     test_one  | sentry | UTF8     | en_US.utf8 | en_US.utf8 | 
    (5 rows)
    # 切换库
    sentry-# c test_one
    You are now connected to database "test_one" as user "sentry".
    test_one-# 
    #创建表
    test_one=# CREATE TABLE COMPANY(
       ID INT PRIMARY KEY     NOT NULL,
       NAME           TEXT    NOT NULL,
       AGE            INT     NOT NULL,
       ADDRESS        CHAR(50),
       SALARY         REAL
    );
    # 查表结构
    test_one=# d
             List of relations
     Schema |  Name   | Type  | Owner  
    --------+---------+-------+--------
     public | company | table | sentry
    (1 row)
    
    test_one=# d company
                      Table "public.company"
     Column  |     Type      | Collation | Nullable | Default 
    ---------+---------------+-----------+----------+---------
     id      | integer       |           | not null | 
     name    | text          |           | not null | 
     age     | integer       |           | not null | 
     address | character(50) |           |          | 
     salary  | real          |           |          | 
    Indexes:
        "company_pkey" PRIMARY KEY, btree (id)
    
    # sentry 注册时的用户信息:
    sentry=# select * from auth_user;
                                       password                                    |          last_login          | id |     username      | first_name |       email   
        | is_staff | is_active | is_superuser |         date_joined          | is_managed | is_password_expired |     last_password_change      | session_nonce |       
       last_active          | flags | is_sentry_app 
    -------------------------------------------------------------------------------+------------------------------+----+-------------------+------------+---------------
    ----+----------+-----------+--------------+------------------------------+------------+---------------------+-------------------------------+---------------+-------
    ------------------------+-------+---------------
     pbkdf2_sha256$12000$w7tg7EmDd34n$V8L3gFxDPJM9zZhwjZmgyjnrChw2kyJ6xTx+OtXlQro= | 2021-01-13 20:57:34.83529+00 |  1 | 1792606920@qq.com |            | 1792606920@qq.
    com | t        | t         | t            | 2021-01-13 20:31:09.16419+00 | f          | f                   | 2021-01-13 20:31:09.255959+00 |               | 2021-0
    1-13 21:09:01.270177+00 |     0 | 
    (1 row)
    
    
  • 相关阅读:
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    线性表——数组实现
    this指针与const成员函数
    类对象拷贝是不是赋值操作??
    你真的理解内联函数吗?
    名字查找先于类型检查:函数重载与作用域
    谈谈函数调用
    推荐形参使用常量引用:void func(const T &);
  • 原文地址:https://www.cnblogs.com/quqinchao/p/14307560.html
Copyright © 2020-2023  润新知