月別アーカイブ: 2017年1月

技術書2016

ここ1年で買った技術書を整理してみた。

我ながらよく買ってる。しかし身になってない(苦笑。

諦めてEl capitanにGraphite

諦めて、おうちのEl capitanでせめてもの画面だけは見ようとしてみる。いきなりつまずく。

$vagrant plugin install vagrant-vbguest
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

An error occurred while installing ffi (1.9.14), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.9.14'` succeeds before bundling.

gemインストールもNG。

$gem install ffi -v '1.9.14'
Fetching: ffi-1.9.14.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing ffi:
	ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/ffi-1.9.14 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/ffi-1.9.14/ext/ffi_c/gem_make.out

Xcodeのコマンドラインツールを入れてみる。前もやった気がするが。

$ xcode-select --install
$ sudo xcodebuild -license
$ gem install ffi -v '1.9.14'
Building native extensions.  This could take a while...
Successfully installed ffi-1.9.14
Parsing documentation for ffi-1.9.14
Installing ri documentation for ffi-1.9.14
1 gem installed

vagrant upしたら怒られた

$vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'mayflower/trusty64-puppet3' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'mayflower/trusty64-puppet3'
    default: URL: https://atlas.hashicorp.com/mayflower/trusty64-puppet3
==> default: Adding box 'mayflower/trusty64-puppet3' (v0.7.2) for provider: virtualbox
    default: Downloading: https://atlas.hashicorp.com/mayflower/boxes/trusty64-puppet3/versions/0.7.2/providers/virtualbox.box
==> default: Box download is resuming from prior download progress
==> default: Successfully added box 'mayflower/trusty64-puppet3' (v0.7.2) for 'virtualbox'!
==> default: Importing base box 'mayflower/trusty64-puppet3'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'mayflower/trusty64-puppet3' is up to date...
==> default: Setting the name of the VM: synthesize-master_default_1484155138036_88827
Vagrant cannot forward the specified ports on this VM, since they
would collide with some other application that is already listening
on these ports. The forwarded port to 8443 is already in use
on the host machine.

To fix this, modify your current project's Vagrantfile to use another
port. Example, where '1234' would be replaced by a unique host port:

  config.vm.network :forwarded_port, guest: 443, host: 1234

Sometimes, Vagrant will attempt to auto-correct this for you. In this
case, Vagrant was unable to. This is usually because the guest machine
is in a state which doesn't allow modifying port forwarding. You could
try 'vagrant reload' (equivalent of running a halt followed by an up)
so vagrant can attempt to auto-correct this upon booting. Be warned
that any unsaved work might be lost.

Vagrantfileを修正。ひとまず8445に。

config.vm.network :forwarded_port, guest: 443, host: 8445

起動できた!

 

grafanaインストール他

新規にEC2イメージを作ったところかたスタート。まずはVirtualBoxをインストール。色々と大ハマリ。結局、Oracleページよりrpmをダウンロードしてインストール

# yum install VirtualBox-5.1-5.1.12_112440_el7-1.x86_64.rpm  --skip-broken
(中略)
飛ばしました (依存性の問題):
  VirtualBox-5.1.x86_64 0:5.1.12_112440_el7-1                                   
  libXcursor.x86_64 0:1.1.14-2.1.9.amzn1                                        
  libXinerama.x86_64 0:1.1.2-2.7.amzn1                                          
  libXmu.x86_64 0:1.1.1-2.8.amzn1                                               
  libXt.x86_64 0:1.1.4-6.1.9.amzn1                                              
  libvpx.x86_64 0:1.2.0-1.0.amzn1  

【参考】skip-brokenとは

続いて、Vagrantインストール。こちらも、本家よりrpmを入手してインストール。続いてGraphite。

$ wget https://github.com/obfuscurity/synthesize/archive/master.zip
$ unzip master.zip
$ cd synthesize-master/
$ vagrant plugin install vagrant-vbguest
$ vagrant up
No usable default provider could be found for your system.

Vagrant relies on interactions with 3rd party systems, known as
"providers", to provide Vagrant with resources to run development
environments. Examples are VirtualBox, VMware, Hyper-V.

The easiest solution to this message is to install VirtualBox, which
is available for free on all major platforms.

If you believe you already have a provider available, make sure it
is properly installed and configured. You can see more details about
why a particular provider isn't working by forcing usage with
`vagrant up --provider=PROVIDER`, which should give you a more specific
error message for that particular provider.

どうもVirtualBoxがVagrantから見えない・・・。色々はまったが、Amazon LinuxはXenで稼働しており、VirtualBoxはインストールできないとか。(仮想化上ではそもそもVirtualBoxが動かないとか)。Graphiteはソースを入手。

$git clone https://github.com/graphite-project/graphite-web.git
$git clone https://github.com/graphite-project/carbon.git
$git clone https://github.com/graphite-project/whisper.git
$git clone https://github.com/graphite-project/ceres.git

各フォルダでビルド。

python setup.py install

オフィシャルに従いもろもろ追加。

yum install python-devel cairo-devel libffi-devel

djangoをインストール

pip install Django==1.10.5

次は怒られた。

$ pip install cairocffi
You are using pip version 6.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting cairocffi
  Downloading cairocffi-0.7.2.tar.gz (75kB)
    100% |████████████████████████████████| 77kB 2.9MB/s 
    Complete output from command python setup.py egg_info:
    unable to execute 'gcc': No such file or directory
    unable to execute 'gcc': No such file or directory

まずはpipをアップグレードして、gccもインストール。他もろもろ。

$pip install --upgrade pip
$yum install gcc
$/usr/local/bin/pip install cairocffi
$/usr/local/bin/pip install django-tagging
$/usr/local/bin/pip install pytz
$/usr/local/bin/pip install pyparsing
$

いよいよDBセットアップがエラー

PYTHONPATH=/opt/graphite/webapp/ django-admin.py migrate --settings=graphite.settings --run-syncdb
/opt/graphite/webapp/graphite/settings.py:249: UserWarning: SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better security
  warn('SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better security')
Traceback (most recent call last):
  File "/usr/local/bin/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 341, in execute
    django.setup()
  File "/usr/local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/usr/local/lib/python2.7/site-packages/django/apps/config.py", line 199, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/opt/graphite/webapp/graphite/account/models.py", line 16, in <module>
    from django.contrib.auth import models as auth_models
  File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/models.py", line 4, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/base_user.py", line 52, in <module>
    class AbstractBaseUser(models.Model):
  File "/usr/local/lib/python2.7/site-packages/django/db/models/base.py", line 119, in __new__
    new_class.add_to_class('_meta', Options(meta, app_label))
  File "/usr/local/lib/python2.7/site-packages/django/db/models/base.py", line 316, in add_to_class
    value.contribute_to_class(cls, name)
  File "/usr/local/lib/python2.7/site-packages/django/db/models/options.py", line 214, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "/usr/local/lib/python2.7/site-packages/django/db/__init__.py", line 33, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line 211, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line 115, in load_backend
    return import_module('%s.base' % backend_name)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 28, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

MySQLが無いらしいのでインストール。python-mysqlを入れようとすると、

$pip install mysql-python
Collecting mysql-python
  Using cached MySQL-python-1.2.5.zip
Installing collected packages: mysql-python
  Running setup.py install for mysql-python ... error
    Complete output from command /usr/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-9lfWr3/mysql-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-bKFVV6-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb
    creating build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    running build_ext
    building '_mysql' extension
    creating build/temp.linux-x86_64-2.7
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql55 -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -fPIC -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1
mysql.c:44:23: fatal error: my_config.h: そのようなファイルやディレクトリはありません

大胆に以下をやったら、通った♡

$yum install mysql-*
pip install mysql-python
Collecting mysql-python
  Using cached MySQL-python-1.2.5.zip
Installing collected packages: mysql-python
  Running setup.py install for mysql-python ... done
Successfully installed mysql-python-1.2.5

次はスキーマ構築

PYTHONPATH=/opt/graphite/webapp/ django-admin.py migrate --settings=graphite.settings --run-syncdb

さあ起動と思ったらApacheが無かった。

$yum install httpd24 httpd24-tools
$yum install mod24_wsgi-py27
$pip install twisted

その後も公式を見ながら悪戦苦闘も断念。。。

Linuxでのタイムゾーン変更

現在の設定を確認、UTCになっている。

[root@www]# strings /etc/localtime
TZif2
TZif2
UTC0
[root@www]#

コピーを残してタイムゾーンを変更。変わった。

[root@www]# ln -sf  /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
[root@www]# strings /etc/localtime
TZif2
	JCST
TZif2
JCST
JST-9
[root@www]#

 

MacでCPUのスペックを確認する方法

家で使っているMBA(Mid 2013)ですが、買い替えをしたくてスペック調査。

bash-3.2# sysctl machdep.cpu.brand_string

machdep.cpu.brand_string: Intel(R) Core(TM) i5-4250U CPU @ 1.30GHz

bash-3.2#

GeekBenchで見るとこんな感じ。MacBookPro 13inchが3500(シングルコア)なのでもう1世代我慢かなぁ。ちなみにMac Mini Mid 2011はシングルコアで2,824、マルチコアで8,067。

Amazon fire tv stickにkodiをインストールしてDVD ISOを見れるようにした件

ずーっと欲しかったソリューション。

これまではUniversalMediaServerを使ってたけれども、Amazon fire tv stickにkodiをインストール。ただ、Macのファイル共有との相性が悪くてNFSを利用。

http://kodi.wiki/view/NFS に記載の「-N flag is set, but shares still won’t work」でハマりました。SIPが効いていたのでファイル更新ができず・・・。

SIPロック解除して、更新。完了。

Mac OS X 10.11 changed the way the user is allowed to interact with certain system files, including anything in /System/Library/LaunchDaemons/ This is due to SIP (System Integrity Protection). Follow these steps to disable SIP, set the -N option in com.apple.nfsd.plist, and re-enable SIP