卸载分区
umount /mnt/mongo
格式化为xfs(会丢失所有数据)
mkfs.xfs /dev/mapper/vg1-lvMongo -f
修改fstab,类型修改为xfs
vim /etc/fstab
change ext4 to xfs
自动挂载
mount -a
cannot concatenate ‘str’ and ‘NoneType’ objects
./psycopg/psycopg.h:31:22: fatal error: libpq-fe.h: No such file or directory
yum install libpqxx-devel
pip install psycopg2
后就web.py可以happy的访问数据库了
postgres — PostgreSQL database server 安装和简单配置教程(centos7)
安装:
yum install postgresql-server
配置开机启动:
systemctl enable postgresql
初始化数据库:
postgresql-setup initdb
创建和删除数据库:
[root@web4 ~]# su - postgres Last login: Mon Mar 20 01:14:46 CST 2017 on pts/0 -bash-4.2$ -bash-4.2$ createdb xxxxx -bash-4.2$ createdb mydb -bash-4.2$ dropdb mydb
访问数据库:
psql xxxxx
web.py注册为服务(centos7)
命令行脚本:
/usr/bin/python /mnt/www/xxx/scripts/mq.py
创建服务文件(服务名xxx)
vim /usr/lib/systemd/system/xxx.service
xxx.service 文件内容
[Unit] Description=The doufu python message queue server After=network.target remote-fs.target nss-lookup.target [Service] Type=simple #PIDFile= #ExecStartPre= #ExecStartPre= ExecStart=/usr/bin/python /mnt/www/xxx/scripts/mq.py ExecReload=/usr/bin/python /mnt/www/xxx/scripts/mq.py KillSignal=SIGQUIT TimeoutStopSec=5 KillMode=process PrivateTmp=true [Install] WantedBy=multi-user.target
# 启用服务(开机自动启动) systemctl enable xxx.service # 查看服务状态 systemctl status xxx.service # 开始服务 systemctl start xxx.service # 查看服务状态 systemctl status xxx.service
pkg_resources.DistributionNotFound: Flask==0.10.1
现象:
装完新版mrq运行示例又报错:
[root@web4 test-mrq]# mrq-run tasks.Fetch url http://www.google.com Traceback (most recent call last): File "/bin/mrq-run", line 5, infrom pkg_resources import load_entry_point File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 3011, in parse_requirements(__requires__), Environment() File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 626, in resolve raise DistributionNotFound(req) pkg_resources.DistributionNotFound: Flask==0.10.1
解决方法:
yum install python-flask
继续报错:
[root@web4 test-mrq]# mrq-run tasks.Fetch url http://www.google.com Traceback (most recent call last): File "/bin/mrq-run", line 5, infrom pkg_resources import load_entry_point File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 3011, in parse_requirements(__requires__), Environment() File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 626, in resolve raise DistributionNotFound(req) pkg_resources.DistributionNotFound: subprocess32==3.2.5
ImportError: cannot import name _NONE
故障现象:
运行pip示例报错
[root@i test-mrq]# mrq-run tasks.Fetch url http://www.google.com 2017-03-18 23:11:18.162884 [DEBUG] mongodb_jobs: Connecting to MongoDB at [('127.0.0.1', 27017)]/mrq... Traceback (most recent call last): File "/usr/bin/mrq-run", line 9, inload_entry_point('mrq==0.1.18', 'console_scripts', 'mrq-run')() File "/usr/lib/python2.7/site-packages/mrq/bin/mrq_run.py", line 52, in main job = worker_class.job_class(None) File "/usr/lib/python2.7/site-packages/mrq/job.py", line 52, in __init__ self.collection = context.connections.mongodb_jobs.mrq_jobs File "/usr/lib/python2.7/site-packages/mrq/utils.py", line 160, in __getattr__ value = factory(attr) File "/usr/lib/python2.7/site-packages/mrq/context.py", line 159, in _connections_factory db = MongoClient(config_obj, **kwargs)[mongo_name] File "/usr/lib64/python2.7/site-packages/pymongo/mongo_client.py", line 461, in __init__ self._topology.open() File "/usr/lib64/python2.7/site-packages/pymongo/topology.py", line 151, in open self._ensure_opened() File "/usr/lib64/python2.7/site-packages/pymongo/topology.py", line 378, in _ensure_opened self._update_servers() File "/usr/lib64/python2.7/site-packages/pymongo/topology.py", line 441, in _update_servers server.open() File "/usr/lib64/python2.7/site-packages/pymongo/server.py", line 46, in open self._monitor.open() File "/usr/lib64/python2.7/site-packages/pymongo/monitor.py", line 78, in open self._executor.open() File "/usr/lib64/python2.7/site-packages/pymongo/periodic_executor.py", line 83, in open thread.start() File "/usr/lib64/python2.7/threading.py", line 746, in start _start_new_thread(self.__bootstrap, ()) File "/usr/lib64/python2.7/site-packages/gevent/thread.py", line 40, in start_new_thread greenlet = Greenlet.spawn(function, *args, **kwargs) File "/usr/lib64/python2.7/site-packages/gevent/greenlet.py", line 201, in spawn g = cls(*args, **kwargs) File "/usr/lib64/python2.7/site-packages/gevent/greenlet.py", line 75, in __init__ hub = get_hub() File "/usr/lib64/python2.7/site-packages/gevent/hub.py", line 169, in get_hub hub = _threadlocal.hub = hubtype(*args, **kwargs) File "/usr/lib64/python2.7/site-packages/gevent/hub.py", line 268, in __init__ loop_class = _import(self.loop_class) File "/usr/lib64/python2.7/site-packages/gevent/hub.py", line 198, in _import return _import(path[-1]) File "/usr/lib64/python2.7/site-packages/gevent/hub.py", line 210, in _import x = __import__(module) File "/usr/lib/python2.7/site-packages/mrq/monkey.py", line 150, in mrq_safe_import result = orig_import(*args, **kwargs) File "core.pyx", line 10, in init gevent.core (gevent/gevent.core.c:41156) File "/usr/lib/python2.7/site-packages/mrq/monkey.py", line 150, in mrq_safe_import result = orig_import(*args, **kwargs) File "/usr/lib64/python2.7/site-packages/gevent/signal.py", line 19, in from gevent._util import _NONE as _INITIAL ImportError: cannot import name _NONE
解决方法:
cd /usr/local/src
wget https://codeload.github.com/pricingassistant/mrq/zip/master
mv master mrq-master.zip
unzip mrq-master.zip
pip install mrq -e /usr/local/src/mrq-master
原因:
gevent.coros过时了,被gevent.lock替代了
mrq: ImportError: No module named coros
故障现象:
运行mrq示例(mrq-run tasks.Fetch url http://www.google.com),报错
[root@web4 test-mrq]# mrq-run tasks.Fetch url http://www.google.com Traceback (most recent call last): File "/bin/mrq-run", line 9, in load_entry_point('mrq==0.1.18', 'console_scripts', 'mrq-run')() File "/usr/lib/python2.7/site-packages/mrq/bin/mrq_run.py", line 33, in main set_current_config(cfg) File "/usr/lib/python2.7/site-packages/mrq/context.py", line 82, in set_current_config patch_import() File "/usr/lib/python2.7/site-packages/mrq/monkey.py", line 127, in patch_import import gevent.coros File "/usr/lib64/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ result = _import(*args, **kwargs) ImportError: No module named coros
解决方法:
yum install python-gevent
./python/py_defines.h:38:20: fatal error: Python.h: No such file or directory
pip 安装mrp(pip install mrq)报错
./python/py_defines.h:38:20: fatal error: Python.h: No such file or directory
解决方法:
yum install python-devel