我正在使用mod_wsgi作为网关接口在Apache2上运行我的一个应用程序。当我在Web服务器上运行该应用程序时,我收到以下错误,我仅在代码中提供了spark内容,因为该错误与spark命令有关。请帮帮我,过去3天来我一直遇到这个错误。谢谢
error.log
[Tue Jun 19 11:05:53.656687 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] Traceback (most recent call last):, referer: http://10.218.39.53/test_wsgi/riws/v1_0/
[Tue Jun 19 11:05:53.656689 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] File "/data/mlapi/deps/venv/lib/python3.5/site-packages/flask/app.py", line 1612, in full_dispatch_request, referer:
[Tue Jun 19 11:05:53.656690 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] rv = self.dispatch_request(), referer:
[Tue Jun 19 11:05:53.656692 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] File "/data/mlapi/deps/venv/lib/python3.5/site-packages/flask/app.py", line 1598, in dispatch_request, referer:
[Tue Jun 19 11:05:53.656694 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] return self.view_functions[rule.endpoint](**req.view_args), referer: http://10.218.39.53/test_wsgi/riws/v1_0/
[Tue Jun 19 11:05:53.656695 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] File "/data/mlapi/deps/venv/lib/python3.5/site-packages/flask_restplus/api.py", line 313, in wrapper, referer:
[Tue Jun 19 11:05:53.656696 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] resp = resource(*args, **kwargs), referer:
[Tue Jun 19 11:05:53.656697 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] File "/data/mlapi/deps/venv/lib/python3.5/site-packages/flask/views.py", line 84, in view, referer:
[Tue Jun 19 11:05:53.656699 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] return self.dispatch_request(*args, **kwargs), referer:
[Tue Jun 19 11:05:53.656700 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] File "/data/mlapi/deps/venv/lib/python3.5/site-packages/flask_restplus/resource.py", line 44, in dispatch_request, referer:
[Tue Jun 19 11:05:53.656701 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] resp = meth(*args, **kwargs), referer:
[Tue Jun 19 11:05:53.656703 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] File "/data/mlapi/service/start/riws/v1_0/datascience.py", line 65, in post, referer: http://10.218.39.53/test_wsgi/riws/v1_0/
[Tue Jun 19 11:05:53.656704 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] spark = SparkSession.builder.appName('local').getOrCreate(), referer:
[Tue Jun 19 11:05:53.656710 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] File "/data/mlapi/deps/venv/lib/python3.5/site-packages/pyspark/sql/session.py", line 173, in getOrCreate, referer:
[Tue Jun 19 11:05:53.656711 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] sc = SparkContext.getOrCreate(sparkConf), referer:
[Tue Jun 19 11:05:53.656712 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] File "/data/mlapi/deps/venv/lib/python3.5/site-packages/pyspark/context.py", line 331, in getOrCreate, referer:
[Tue Jun 19 11:05:53.656714 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] SparkContext(conf=conf or SparkConf()), referer:
[Tue Jun 19 11:05:53.656715 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] File "/data/mlapi/deps/venv/lib/python3.5/site-packages/pyspark/context.py", line 118, in __init__, referer:
[Tue Jun 19 11:05:53.656716 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] conf, jsc, profiler_cls), referer:
[Tue Jun 19 11:05:53.656717 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] File "/data/mlapi/deps/venv/lib/python3.5/site-packages/pyspark/context.py", line 180, in _do_init, referer:
[Tue Jun 19 11:05:53.656719 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] self._jsc = jsc or self._initialize_context(self._conf._jconf), referer: http://10.218.39.53/test_wsgi/riws/v1_0/
[Tue Jun 19 11:05:53.656720 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] File "/data/mlapi/deps/venv/lib/python3.5/site-packages/pyspark/context.py", line 270, in _initialize_context, referer:
[Tue Jun 19 11:05:53.656721 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] return self._jvm.JavaSparkContext(jconf), referer:
[Tue Jun 19 11:05:53.656723 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] File "/data/mlapi/deps/venv/lib/python3.5/site-packages/py4j/java_gateway.py", line 1428, in __call__, referer:
[Tue Jun 19 11:05:53.656724 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] answer, self._gateway_client, None, self._fqn), referer:
[Tue Jun 19 11:05:53.656725 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] File "/data/mlapi/deps/venv/lib/python3.5/site-packages/py4j/protocol.py", line 328, in get_return_value, referer:
[Tue Jun 19 11:05:53.656726 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] format(target_id, ".", name)), referer: http://10.218.39.53/test_wsgi/riws/v1_0/
[Tue Jun 19 11:05:53.656728 2018] [wsgi:error] [pid 1373638] [client 10.57.83.224:63703] py4j.protocol.Py4JError: An error occurred while calling None.org.apache.spark.api.java.JavaSparkContext, referer:
@ api.route('/',methods = [“ post”]) @ api.expect(upload_parser) ModelApis(资源)类: def get(): 返回“预测方法仅适用于HTTP POST调用。”
def post(self):
# BASIC HOUSEKEEPING
result = {'scores':[], 'success':True, 'model_details': {'name': model_name, 'version': model_version}}
serve_root = os.getcwd()
dir_path = os.path.dirname(os.path.realpath(__file__))
os.chdir(dir_path)
sys.path.insert(0, dir_path)
from pyspark.context import SparkContext
from pyspark.sql.session import SparkSession
#
#sc = SparkContext('local')
#spark = SparkSession(sc)
spark = SparkSession.builder.appName('local').getOrCreate()
这是我的虚拟配置
#ServerName score.server.com
WSGIApplicationGroup %{GLOBAL}
WSGISocketPrefix /var/run/wsgi
WSGIDaemonProcess score threads=5
#python-home=/data/mlapi:/data/mlapi/deps/venv/lib/python3.5
WSGIScriptAlias /test_wsgi /data/mlapi/service/start/post.wsgi
<Directory /data/mlapi/service/start>
#WSGIProcessGroup score
#AllowOverride All
Require all granted
#Allow from all
</Directory>
Alias /static /data/mlapi/service/start/static
<Directory /data/mlapi/service/start/static/>
WSGIProcessGroup score
#WSGIApplicationGroup %{GLOBAL}
#AllowOverride All
Require all granted
#Allow from all
</Directory>
ErrorLog logs/error.log
#ErrorLog /tmp/error.log
LogLevel debug
#CustomLog /tmp/access.log combined
CustomLog logs/access.log combined