2

我已经在 appscale VM 上部署了我的 GAE 应用程序。应用程序运行正常,但我无法看到查看数据存储数据的界面。与谷歌应用引擎一样,我们可以通过在 :8000 端口访问应用程序来查看数据存储区。对此有任何想法吗?

4

2 回答 2

4

这是在 AppScale 上启用 GAE 数据存储查看器的脚本:

#!/bin/bash
#
# author: g@appscale.com
#
# Enable the datastore viewer and reload nginx.

ALLOW=""
APPS_ID=""
IP="all"
VIEWER_PORT="8099"

usage() {
        echo
        echo "Usage: $0 [app-id ...]"
        echo
        echo "Enable the dataviewer for app-id. If no app-id is specified, enable the viewer for all apps."
        echo "WARNING: the datastore viewer is not protected! Anyone can browse your data."
        echo "WARNING: restricting by IP should be used judiciously."
        echo
        echo "Options:"
        echo "     -h        this message"
        echo "     -i <IP>   allow connections only from this IP (default is open)"
        echo
}

while [ $# -gt 0 ]; do
        if [ "$1" = "-h" -o "$1" = "-help" -o "$1" = "--help" ]; then
                usage
                exit 1
        fi
    if [ -n "$1" -a "$1" = "-i" ]; then
        if [ -n "$2" ]; then
            IP="$2"
            ALLOW="allow $IP; 
      deny all;"
            shift;shift
            continue
        else
            usage
            exit 1
        fi
    fi
        if [ -n "$1" ]; then
                APPS_ID="$APPS_ID $1"
                shift
                continue
        fi
done

# Sanity checks.
if [ ! -e /etc/nginx/sites-enabled ]; then
        echo "ERROR: Cannot find nginx configurations. Is this an AppScale deployment?"
        exit 1
fi

# Get the list of running applications, and corresponding ports.
ps ax | grep appserver | grep -Ev '(grep|appscaledashboard)' | grep -- '--admin_port' | sed 's;.*--admin_port \([0-9]*\).*/var/apps/\(.*\)/app .*;\1 \2;g' | sort -ru | while read port app_id; do
        # Enable only for specified apps.
        if [ -n "$APPS_ID" ]; then
                found="no"
                for x in $APPS_ID ; do
                        if [ "$x" = "$app_id" ]; then
                                found="yes"
                                break
                        fi
                done
                if [ "$found" = "no" ]; then
                        continue
                fi
        fi

    let $((VIEWER_PORT += 1))

    # Do not apply if it's already there.
    if grep "datastore_viewer" /etc/nginx/sites-enabled/* > /dev/null ; then
        echo "Datastore viewer already enabled for $app_id."
        continue
    fi

    # Prepare the nginx config snippet.
    pippo="
upstream datastore_viewer_$VIEWER_PORT {
  server localhost:$port;
}
map \$scheme \$ssl {
    default off;
    https on;
}
server {
    listen $VIEWER_PORT;
    server_name datastore_viewer_server;
    location / {
      $ALLOW
      proxy_pass http://datastore_viewer_$VIEWER_PORT;
    }
}
"
    if [ -e /etc/nginx/sites-enabled/${app_id}.conf ]; then
        cp /etc/nginx/sites-enabled/${app_id}.conf /tmp
        echo "$pippo" >> /etc/nginx/sites-enabled/${app_id}.conf
        echo "Datastore viewer enabled for $app_id at http://$(cat /etc/appscale/my_public_ip):$VIEWER_PORT. Allowed IP: $IP."
        service nginx reload
    else
        echo "Cannot find configuration for ${app_id}."
    fi
done

https://github.com/AppScale/appscale/blob/master/scripts/enable-datastore-viewer.sh

实施步骤:

  1. 从 ~/ 运行 enable-datastore-viewer.sh
  2. 编辑 /etc/nginx/sites-enabled/appscale-.conf 文件
  3. 查找开头的行:允许
  4. 更改IP,保存文件
  5. 使用以下命令重新加载 nginx:服务 nginx 重新加载
于 2015-12-21T20:40:26.910 回答
3

官方答案在这里: https ://groups.google.com/forum/#!topic/appscale_community/ SCr1B8eZANA 并且基于remote_api。

如果你真的想要数据存储查看器,它是可用的,但在防火墙后面。要公开它(警告:此路径没有身份验证),您必须编辑 nginx 配置并重新加载它。

您还需要应用以下拉取请求: https ://github.com/AppScale/appscale/pull/1475

将此添加到 /usr/local/nginx/conf/sites-enabled/.conf

upstream datastore_viewer {
  server localhost:30000;
}
map $scheme $ssl {
    default off;
    https on;
}

server {
    listen 8090;
    server_name datastore_viewer_server;
    location / {
      proxy_pass http://datastore_viewer;
    }
}

然后使用以下命令重新加载 nginx: /usr/local/nginx/sbin/nginx -s reload

现在您应该能够在端口 8090 上进行部署并查看 GAE 控制台。如果您没有看到任何实体,请确保您运行统计信息生成器(每天运行)。要生成它们,请转到 AppScale Dashboard 上的 App Console 页面。

于 2014-03-05T00:00:57.653 回答