daemonでDjangoを動かす方法など
http://cr.yp.to/daemontools.html
# インストール sudo yum -y install rpm-build wget http://mirrors.qmailtoaster.com/daemontools-toaster-0.76-1.3.6.src.rpm rpmbuild --rebuild daemontools-toaster-0.76-1.3.6.src.rpm sudo rpm -ivh ~/rpmbuild/RPMS/x86_64/daemontools-toaster-0.76-1.3.6.x86_64.rpm # systemd のユニットファイル sudo tee /etc/systemd/system/daemontools.service <<EOS [Unit] Description = daemontools After = network.target [Service] ExecStart = /command/svscanboot Restart = always Type = simple [Install] WantedBy = multi-user.target EOS # daemontools を起動 sudo systemctl daemon-reload sudo systemctl start daemontools sudo systemctl status daemontools sudo systemctl enable daemontools # サービスの設定 sudo mkdir /service/.w1-1 sudo mkdir /service/.w1-2 sudo mkdir /service/.w2-1 sudo mkdir /service/.w2-2 sudo mkdir /service/.w2-3 sudo ln -sf /vagrant/w1.sh /service/.w1-1/run sudo ln -sf /vagrant/w1.sh /service/.w1-2/run sudo ln -sf /vagrant/w2.sh /service/.w2-1/run sudo ln -sf /vagrant/w2.sh /service/.w2-2/run sudo ln -sf /vagrant/w2.sh /service/.w2-3/run sudo touch /service/.w1-1/down sudo touch /service/.w1-2/down sudo touch /service/.w2-1/down sudo touch /service/.w2-2/down sudo touch /service/.w2-3/down sudo ln -sf .w1-1 /service/w1-1 sudo ln -sf .w1-2 /service/w1-2 sudo ln -sf .w2-1 /service/w2-1 sudo ln -sf .w2-2 /service/w2-2 sudo ln -sf .w2-3 /service/w2-3 # サービスを開始する sudo svc -u /service/* # サービスの一覧表示 sudo svstat /service/* # サービスの再起動 sudo svc -t /service/* # サービスを停止する sudo svc -d /service/* # サービスを無効にする sudo svc -d /service/* && sudo svc -x /service/* && sudo rm /service/*
- supevisor
# インストール sudo yum -y install supervisor # supervisor 起動 sudo systemctl start supervisord.service sudo systemctl status supervisord.service sudo systemctl enable supervisord.service # サービスの設定 sudo tee /etc/supervisord.d/app.ini <<EOS [program:w1] command=/vagrant/w1.sh process_name=%(program_name)s-%(process_num)d numprocs=2 autostart=false [program:w2] command=/vagrant/w2.sh process_name=%(program_name)s-%(process_num)d numprocs=3 autostart=false EOS # 反映 sudo supervisorctl update # サービスの開始 sudo supervisorctl start all # サービスの再起動 sudo supervisorctl restart all # サービスの停止 sudo supervisorctl stop all
$ sudo systemctl daemon-reload #サービスの再読み込みをする。 $ sudo systemctl daemon-reload # サービスをスタート $ sudo systemctl start sampled # 動いているか確認 $ systemctl status sampled # システム起動時に自動的に実行させる $ sudo systemctl enable sampled #起動時に実行する設定が有効かチェックする $ systemctl is-enabled sampled # 起動時に実行する設定を取り消す $ systemctl disable sampled
$ cd /etc/systemd/system/ $ sudo vim sampled.service
iniファイルにて設定とかの流れ。
[Unit] Description=Sample Daemon [Service] ExecStart=/usr/local/lib/sampled.py Restart=always Type=forking PIDFile=/var/run/sampled.pid [Install] WantedBy=multi-user.target
AWSでelasticsearchとkibanaをinstall
そもそもAWSのポートが空いてなかった。
$ netstat -na | grep LISTEN ... tcp 0 0 ::1:9200 :::* LISTEN ...
## elasticsearch install $ curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.1.0.tar.gz $ tar -xvzf elasticsearch-5.6.0.tar.gz $ cd elasticsearch-5.6.0/bin $ ES_JAVA_OPTS="-Xms512m -Xmx512m" ./bin/elasticsearch ## $ vim config/jvm.optionsでいじってもいいかも $ curl -O "https://artifacts.elastic.co/downloads/kibana/kibana-5.6.0-linux-x86_64.tar.gz" $ tar -xvzf kibana-5.6.0-linux-x86_64.tar.gz $ cd kibana-5.6.0-linux-x86_64 $ vim config/kibana.yml # Kibana is served by a back end server. This setting specifies the port to use. server.port: 5601 # Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values. # The default is 'localhost', which usually means remote machines will not be able to connect. # To allow connections from remote users, set this parameter to a non-loopback address. server.host: "0.0.0.0" $ ./bin/kibana & ## logstash install $ curl -O "https://artifacts.elastic.co/downloads/logstash/logstash-5.6.0.tar.gz" $ tar -xvzf logstash-5.6.0.tar.gz
Elasticsearchを用いて、kibanaで分析する
ElasticSearchで分析するやり方があるらしい。
データの投入はSparkを使ったりするっぽいよ。
$ ES_JAVA_OPTS="-Xms512m -Xmx512m" ./bin/elasticsearch
PostgreSQLのCentOS7での立ち上げ方やコマンドなどの便利なサイト+自動インストール
#!/bin/sh # -*- MAINTAINER -*- Lasha Gogua Lh4cKg@gmail.com # -*- RUN -*- $ bash install.sh # system update and install epel package yum update -y && yum upgrade -y wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm rpm -ivh epel-release-7-5.noarch.rpm yum update -y && yum upgrade -y sudo dnf install redhat-rpm-config # install gcc package and other necessary packages cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime yum groupinstall 'Development Tools' 'Performance Tools' -y yum install -y openssl-devel readline-devel gdbm-devel sqlite-devel bzip2-devel tk-devel ncurses-devel libaio-devel libxml2-devel libxslt-devel java-1.8.0-openjdk zsh yum install -y atlas-devel lapack-devel blas-devel yum install vim -y yum install mc -y # install mysql #wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm #rpm -ivh mysql-community-release-el7-5.noarch.rpm #yum update -y && yum upgrade -y #yum install mysql-server mysql-devel -y #systemctl start mysqld.service #systemctl enable mysqld.service #mysql_secure_installation # install postgres yum install postgresql-server postgresql-devel postgresql-contrib -y postgresql-setup initdb # use md5 insted of ident # vim /var/lib/pgsql/data/pg_hba.conf mv -f pg_hba.conf /var/lib/pgsql/data/pg_hba.conf systemctl start postgresql systemctl enable postgresql # install nginx yum install nginx -y mv -f nginx.conf /etc/nginx/nginx.conf systemctl start nginx systemctl enable nginx systemctl restart nginx # required libraries for Python installation yum install libjpeg libjpeg-devel -y yum install freetype-devel libpng-devel -y yum install zlib zlib-devel -y yum install krb5-devel -y yum install openssl openssl-devel -y yum install libffi libffi-devel -y yum install gmp gmp-devel -y # install Python.3.6 version # example: 3.6.1 = 3.3.6 => Python.3.3.6 or 3.6.1=2.7.11 => Python.2.7.11 wget http://python.org/ftp/python/3.6.1/Python-3.6.1.tgz tar -xvf Python-3.6.1.tgz mv -f Python-3.6.1 /opt/ && cd /opt/Python-3.6.1 ./configure make && make altinstall cd # install pip wget https://bootstrap.pypa.io/get-pip.py # use Python version | python3.3 or python python3.6 get-pip.py pip3.6 install uwsgi pip3.6 install virtualenv virtualenvwrapper
workonの設定は以下 kidnohr.hatenadiary.com