• websocket数据流解析


    ceilometer获取数据暂时先不做解答,本篇注重websocket解决浏览器与openstack组件之间的实时状态更新。

    大致流程如下:

    nginx配置的反向代理如下:

    /etc/nginx/nginx.conf

    include /etc/nginx/conf.d/*.conf;

    /etc/nginx/conf.d/openstack.conf

    upstream websocket_beijing {
        server 192.168.213.88:4500;
    }
    
    server {
        listen 81;
        #server_name horizon.plcloud.com;
    
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    
        location / {
            include uwsgi_params;
            uwsgi_pass unix:/var/run/uwsgi/openstack.sock;
        }
        location /static/{
            alias /home/zzw/develop/horizon/static/;
        }
    }
    
    
    server {
        listen 4600;
    
        location / {
            proxy_pass http://websocket_beijing;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    }

    日志说明:

    /var/log/nginx/access.log #nginx访问日志 

    /var/log/nginx/error.log #nginx错误日志

    uwsgi配置:

    websocket.ini -> /home/zzw/develop/ceilometer/etc/ceilometer/websocket.ini

    /etc/uwsgi/vassals/openstack.ini

    # awcloud horizon uwsgi config file
    [uwsgi]
    
    # Django-related settings
    # the virtualenv (full path)
    # home = /var/plcloud/horizon/.venv
    
    # the base directory (full path)
    chdir = /home/zzw/develop/horizon/openstack_dashboard/wsgi
    # Django's wsgi file
    file = django.wsgi
    
    # maximum number of worker processes
    processes = 4
    
    # the socket (use the full path to be safe
    socket = /var/run/uwsgi/%n.sock
    # with appropriate permissions - may be needed
    chmod-socket = 777
    daemonize = /var/log/uwsgi/%n.log

    日志说明:

    /var/log/uwsgi/openstack.log

    /var/log/uwsgi/websocket.log

    redis配置订阅模式:

    /etc/redis.conf

    daemonize yes
    pidfile /var/run/redis/redis.pid
    port 6379
    tcp-backlog 511
    bind 0.0.0.0
    timeout 0
    tcp-keepalive 0
    loglevel notice
    logfile /var/log/redis/redis.log
    databases 16
    save 900 1
    save 300 10
    save 60 10000
    stop-writes-on-bgsave-error yes
    rdbcompression yes
    rdbchecksum yes
    dbfilename dump.rdb
    dir /var/lib/redis/
    slave-serve-stale-data yes
    slave-read-only yes
    repl-disable-tcp-nodelay no
    slave-priority 100
    appendonly no
    appendfilename "appendonly.aof"
    appendfsync everysec
    no-appendfsync-on-rewrite no
    auto-aof-rewrite-percentage 100
    auto-aof-rewrite-min-size 64mb
    lua-time-limit 5000
    slowlog-log-slower-than 10000
    slowlog-max-len 128
    notify-keyspace-events ""
    hash-max-ziplist-entries 512
    hash-max-ziplist-value 64
    list-max-ziplist-entries 512
    list-max-ziplist-value 64
    set-max-intset-entries 512
    zset-max-ziplist-entries 128
    zset-max-ziplist-value 64
    hll-sparse-max-bytes 3000
    activerehashing yes
    client-output-buffer-limit normal 0 0 0
    client-output-buffer-limit slave 256mb 64mb 60
    client-output-buffer-limit pubsub 32mb 8mb 60
    hz 10
    aof-rewrite-incremental-fsync yes

    日志说明:

    /var/log/redis/redis.log

    ceilometer配置:

    ├── ceilometer.conf
    ├── ceilometertab.ini
    ├── matchmaker_ring.json
    ├── pipeline.yaml
    ├── policy.json
    ├── sources.json
    └── templates
        ├── default.html
        └── default.sms

    日志说明:

    ├── agent-notification.log
    ├── alarm-evaluator.log
    ├── alarm-notifier.log
    ├── api.log
    ├── auditor.log
    ├── central.log
    ├── checker.log
    ├── collector.log
    ├── compute.log
    ├── websocket.log
    └── zmq-receiver.log

    配置过程报错集锦:

    1. uwsgi缺少对openssl支持,/var/log/uwsgi/websocket.log 报错如下:

    [pid: 23996|app: 0|req: 8/8] 192.168.216.48 () {48 vars in 983 bytes} [Thu Apr 23 13:21:07 2015] GET /websocket?uid=33d5edff940f4812b5368e54499991e4&region=lab-test => generated 0 bytes in 1 msecs (HTTP/1.1 500) 0 headers in 0 bytes (1 switches on core 9999)
    you need to build uWSGI with SSL support to use the websocket handshake api function !!!

    解决方法:重新编译uwsgi,支持openssl

    cd uwsgi-2.0.4/
    make
    stop uwsgi
    python setup.py install
    start uwsgi
  • 相关阅读:
    IDEA 快捷键
    Python3开启自带http服务
    redis-creating server tcp listening socket 127.0.0.1:6379: bind No error
    moco的使用方法
    tomcat程序闪退,如何让tomcat不闪退,可以看见报错
    java 项目中Error linstenerStart 报错解决方法
    Linux 常用命令
    TS数据类型及语法
    RabbitMQ的下载和安装
    vue 控制 input 的 disabled
  • 原文地址:https://www.cnblogs.com/forilen/p/4533143.html
Copyright © 2020-2023  润新知