neokylin6,centos,redhat,fedora 中django+celery+rabbitmq環境安裝過程

來源:互聯網
上載者:User

簡介:django是基於web的python外掛程式,celery是一個任務隊列,而rabbitmq是訊息佇列,部署這樣一套系統用於非同步執行任務。

0.安裝系統時候要安裝 tk-8.5.7-5.el6.x86_64,若沒有安裝可以從光碟片安裝

1.yum源不好用的可以使用epel的源
下載:http://mirrors.ustc.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
去/etc/yum.repos.d下設定gpgcheck=0

mv ns6-adv.repo  ns6-adv.repo.bak

2.安裝pip(python包管理工具)
wget  http://python-distribute.org/distribute_setup.py
sudo python distribute_setup.py
wget  https://github.com/pypa/pip/raw/master/contrib/get-pip.py
sudo python get-pip.py

可以通過pip help來查看協助。簡單用的話只要pip search和pip install就好了。

3.安裝django
pip install django

4.安裝celery
easy_install celery

5.安裝python-django-celery
easy_install django-celery
ubuntu中(easy_install python-django-celery)

6.安裝 rabbitmq-server (tk需要先安裝好)
yum install rabbitmq-server.noarch librabbitmq.x86_64 

運行:
rabbitmq-server &
查看狀態:rabbitmqctl  status
service rabbitmq-server start|stop

項目寫好後,如下方式啟動celery
python manage.py celeryd --loglevel=INFO -f /var/log/celery.log&
python manage.py runserver

配置celery為demon運行1
https://github.com/celery/celery/tree/master/extra/centos 下載所需指令碼
cp celeryd /etc/init.d/
cp celeryd.sysconfig /etc/sysconfig/celeryd
修改配置:

# contents should be placed in the file /etc/sysconfig/celeryd,copy this file to /etc/sysconfig/celeryd,copy# Names of nodes to start (space-separated)CELERYD_NODES="localhost"# Where to chdir at start. This could be the root of a virtualenv.CELERYD_CHDIR="/opt/openstack/httpd/oadt"# How to call celeryd-multiCELERYD_MULTI="$CELERYD_CHDIR/manage.py celeryd_multi"# How to call "manage.py celery"#CELERY_BIN="$CELERYD_CHDIR/manage.py celery"# Extra argumentsCELERYD_OPTS="--time-limit=300 --concurrency=8 --loglevel=INFO"# Name of the celery config module.CELERY_CONFIG_MODULE="celeryconfig"# Create log/pid dirs, if they don't already existCELERY_CREATE_DIRS=1# %n will be replaced with the nodenameCELERYD_LOG_FILE="/var/log/OADT/oadtdeploy.log"CELERYD_PID_FILE="/var/run/celery/%n.pid"# Workers run as an unprivileged userCELERYD_USER=rootCELERYD_GROUP=root# Name of the projects settings module.export DJANGO_SETTINGS_MODULE="oadt.settings"

service celeryd restart
service celeryd stop

配置celery為demon運行2(使用supervisor)

install supervisord with apt-get
create /etc/supervisor/conf.d/celery.conf config file
paste somethis in the celery.conf file

[program:celery]
directory = /my_project/
command = /usr/bin/python manage.py celery worker
plus (if you need) some optional and useful stuff (with dummy values)

user = celery_user
group = celery_group
stdout_logfile = /var/log/celeryd.log
stderr_logfile = /var/log/celeryd.err
autostart = true
environment=PATH="/some/path/",FOO="bar"
restart supervisor (or do supervisorctl reread; supervisorctl add celery)

after that you get the nice ctl commands to manage the celery process:

supervisorctl start/restart/stop celery

supervisorctl tail [-f] celery [stderr]

部署到apache

建立oadt.conf放在/etc/httpd/conf.d下,內容如下

WSGIScriptAlias / /opt/openstack/httpd/oadt/oadt/wsgi.pyWSGIPythonPath /opt/openstack/httpd/oadt/<Directory /opt/openstack/httpd/oadt/><Files wsgi.py>Order deny,allowAllow from all</Files></Directory>Alias /static/ /opt/openstack/httpd/oadt/hosts/static/<Directory /opt/openstack/httpd/oadt/hosts/static/>Order deny,allowAllow from all</Directory>

重啟service httpd restart 既可

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.