我已经在appscale VM上部署了我的GAE应用程序。应用程序运行正常,但我看不到查看数据存储数据的界面。与在谷歌应用程序引擎中一样,我们可以通过访问:8000端口的应用程序来查看数据存储。对此有任何想法吗?
下面是在 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
实施步骤:
- 从 ~/运行 enable-datastore-viewer.sh
- 编辑/etc/nginx/sites-enabled/appscale-.conf 文件
- 查找以以下内容开头的行:允许
- 更改该 IP,保存文件 重新加载nginx
- :服务nginx重新加载
官方答案在这里: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 仪表板上的应用程序控制台页面。