MySQL5.7が立ち上がらないエラーが出た。
mysqlが立ち上がらないエラーが出た。
#service mysql start Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details. #systemctl status mysql.service # systemctl status mysql.service ● mysql.service - LSB: Start and stop the mysql database server daemon Loaded: loaded (/etc/init.d/mysql) Active: failed (Result: exit-code) since ... Docs: man:systemd-sysv-generator(8) Process: 10495 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE) # less /var/log/mysqld.log 2017-07-10T15:53:03.811572Z 0 [Note] Server socket created on IP: '::'. 2017-07-10T15:53:03.821949Z 0 [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory) 2017-07-10T15:53:03.821979Z 0 [ERROR] Can't start server: can't create PID file: No such file or directory 2017-07-10T15:56:26.571644Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more d etails).
pid-fileがかけませんというエラーだった。
# less /etc/my.cnf [mysqld] ... pid-file=/var/run/mysqld/mysqld.pid ...
ファイルをかけるようにする。
# mkdir /var/run/mysqld # chown mysql:mysql /var/run/mysqld # service mysqld start
Python3の四捨五入
Pythonの四捨五入は思った挙動をしないことがある。多分、丸め込みが原因。
In [1]: round(2.5, 0) Out[1]: 2.0 In [2]: round(2.0, 0) Out[2]: 2.0 In [3]: round(3.5, 0) Out[3]: 4.0
四捨五入はDecimalを使用したほうがいい。
from decimal import Decimal scores = '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split() def _round(a_list, y): data = list(map(Decimal, a_list)) return round(sum(data) / len(data), y) # 小数第二位の場合 print(_round(scores, 2))
cookieについて
HttpOnlyがtrueの場合、そのcookieはクライアントサイドでjavascriptによる取得ができない。 行動履歴ログをタグ埋め込みで取得する際は要注意。
AWS(Red Hat)にpython3.6をインストールしてpipやvirtualenvを作成する方法。
- 2020/02 追記 ↓が楽
add-apt-repository ppa:deadsnakes/ppa apt-get update apt-get install python3.6 python3.6-venv -y
python3.6をインストール。
##いるものをインストール。 $ sudo yum install yum-utils make wget $ sudo yum install zlib-devel -y $ sudo yum install gcc libffi-devel python-devel openssl-devel $ cd ~ ## wgetよりpython3.6をゲット $ wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz $ tar xzf Python-3.6.1.tgz $ cd Python-3.6.1 $ ./configure --enable-optimizations ## /usr/local/binにインストールするため。 $ sudo make -j8 $ sudo make altinstall ## pip3.6もインストールされる。 Collecting setuptools Collecting pip Installing collected packages: setuptools, pip Successfully installed pip-9.0.1 setuptools-28.8.0
virtualenvのインストールとvirtualenvの作成。pipはhttpsのものはできない。
# /usr/local/bin/pip3.6 install virtualenv virtualenvwrapper $ virtualenv --version 15.1.0 $ sudo vi ~/.bash_profile ### Virtualenvwrapper export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3.6 if [ -f /usr/local/bin/virtualenvwrapper.sh ]; then export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh fi ################### $ source ~/.bash_profile # bigdata作成 $ mkvirtualenv bigdata $ workon bigdata (bigdata) $ できるようになったーーーー