GitLabのFreeBSDへのインストールが,噂以上に難しかった件について(3)

GitLabのFreeBSDへのインストールが,噂以上に難しかった件について(2) - なぜか数学者にはワイン好きが多い
続けます!


Redis

なんと贅沢なシステムなんだ...爆速KVSのRedisもいるんだね.

pkg install redis

# Configure redis to use sockets
cp -pvi /usr/local/etc/redis.conf /usr/local/etc/redis.conf.orig
sed -e 's/^# unixsocket /unixsocket /' -e 's/^port .*/port 0/' /usr/local/etc/redis.conf.orig | tee /usr/local/etc/redis.conf

# Activate the changes to redis.conf
/usr/local/etc/rc.d/redis onestart
Starting redis.

# Add git to the redis group
pw usermod git -G redis

Redisはインストールが超簡単なので.ラクチン.

GitLab

GitLab本体のインストールだね.

# We'll install GitLab into home directory of the user "git"
cd /home/git

# Clone the Source

% git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-2-stable gitlab
Cloning into 'gitlab'...
remote: Counting objects: 90902, done.
remote: Compressing objects: 100% (23680/23680), done.
remote: Total 90902 (delta 68948), reused 86670 (delta 65895)
Receiving objects: 100% (90902/90902), 73.37 MiB | 344.00 KiB/s, done.
Resolving deltas: 100% (68948/68948), done.
Checking connectivity... done.


Configure It

# Go to GitLab installation folder
cd /home/git/gitlab

# Copy the example GitLab config
cp -vi config/gitlab.yml.example config/gitlab.yml
config/gitlab.yml.example -> config/gitlab.yml

# Update GitLab config file, follow the directions at top of file
emacs config/gitlab.yml

ホスト名
  #gitlab:
   192.168.1.3:

メールアドレス
    #email_from: example@example.com
    email_from: my@example.com

    # Email server smtp settings are in [a separate file](initializers/smtp_settings.rb.sample).

パス違い
    #bin_path: /usr/bin/git
    bin_path: /usr/local/bin/git         

# Set email server smtp configuration

cp -vi config/initializers/smtp_settings.rb.sample config/initializers/smtp_settings.rb
emacs config/initializers/smtp_settings.rb



# Make sure GitLab can write to the log/ and tmp/ directories
chown -R git log/
chown -R git tmp/
chmod -R u+rwX log/
chmod -R u+rwX tmp/

# Create directory for satellites
mkdir -v /home/git/gitlab-satellites
chmod -v u+rwx,g=rx,o-rwx /home/git/gitlab-satellites

# Make sure GitLab can write to the tmp/pids/ and tmp/sockets/ directories
chmod -v -R u+rwX tmp/pids/
chmod -v -R u+rwX tmp/sockets/


# Make sure GitLab can write to the public/uploads/ directory
chmod -v -R u+rwX  public/uploads

# Copy the example Unicorn config
cp -vi config/unicorn.rb.example config/unicorn.rb

# Enable cluster mode if you expect to have a high load instance
# Ex. change amount of workers to 3 for 2GB RAM server
# emacs config/unicorn.rb

# Copy the example Rack attack config
cp -vi config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb

# Configure Git global settings for git user, useful when editing via web
# Edit user.email according to what is set in gitlab.yml
git config --global user.name "GitLab"
git config --global user.email "my@example.com"
git config --global core.autocrlf input

# Configure Redis connection settings
cp -pvi config/resque.yml.example config/resque.yml

なんか細かい設定をメモし忘れてる気がする...また追記しますね.
ここまで!

Calbee Light! かっぱえびせん

これはウマイ!普通のかっぱえびせんよりもサクっとしていて,味も歯ごたえも良いです.気に入りました.
原材料名は,「小麦粉」,「でん粉」,「植物油」,「えび」,「砂糖」,「食塩」,「甘味料(甘草)」等で,エネルギーは60グラム当たり271kcal,ナトリウムの食塩相当量は1.4グラムだそうです.

GitLabのFreeBSDへのインストールが,噂以上に難しかった件について(2)

GitLabのFreeBSDへのインストールが,噂以上に難しかった件について - なぜか数学者にはワイン好きが多い

git本体の次は,Rubyを準備します.

Ruby

% pkg info -g ruby\*
ruby-1.9.3.484_2,1
ruby19-gems-1.8.29
ruby20-2.0.0.353_6,1
rubygem-test-unit-2.5.5

Ruby19とRuby20が入ってるね.
% pkg search -x '^ruby[0-9]{2}-[0-9]'
ruby20-2.0.0.481,1
ruby21-2.1.2,1

パッケージではもうRuby19は無いのかも.Ruby21を入れてメインにしようね.

% ruby --version
ruby 1.9.3p484 (2013-11-22 revision 43786) [amd64-freebsd10]

今はメインが19になっている.

# pkg install ruby21
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
pkg: docbook has a missing dependency: docbook500
pkg: plexhometheater has a missing dependency: lame
The following 1 packages will be affected (of 0 checked):

New packages to be INSTALLED:
        ruby21: 2.1.2,1

The process will require 24 MB more space.
5 MB to be downloaded.

Proceed with this action? [y/N]: y
Fetching ruby21-2.1.2,1.txz: 100%    5 MB 881.3k/s    00:06    
Checking integrity... done (0 conflicting)
[1/1] Installing ruby21-2.1.2,1: 100%

rubyコマンドはruby19のハードリンクになってるね.

# ls -l /usr/local/bin/ruby*
-rwxr-xr-x  2 root  wheel  5688  6月  1 01:50 /usr/local/bin/ruby
-rwxr-xr-x  2 root  wheel  5688  6月  1 01:50 /usr/local/bin/ruby19
-rwxr-xr-x  1 root  wheel  5720  7月  6 06:42 /usr/local/bin/ruby20
-rwxr-xr-x  1 root  wheel  5720  8月 21 17:58 /usr/local/bin/ruby21

ruby21のハードリンクにしてしまおう.

# rm -v /usr/local/bin/ruby
/usr/local/bin/ruby
# ln -v /usr/local/bin/ruby21 /usr/localbin/ruby              
/usr/local/bin/ruby => /usr/local/bin/ruby21
# ruby --version
ruby 2.1.2p95 (2014-05-08 revision 45877) [amd64-freebsd10]

入っていなかったら,Bundlerもいれておこうね.

% gem install bundler --no-ri --no-rdoc

System User

専用のユーザを作ろうね.

# adduser 
Username: git
Full name: GitLab
Uid (Leave empty for default): 
Login group [git]: 
Login group is git. Invite git into other groups? []: 
Login class [default]: 
Shell (sh csh tcsh git-shell bash rbash nologin) [sh]: tcsh
Home directory [/home/git]: 
Home directory permissions (Leave empty for default): 
Use password-based authentication? [yes]: no
Lock out the account after creation? [no]: 
Username   : git
Password   : <disabled>
Full Name  : GitLab
Uid        : 1003
Class      : 
Groups     : git 
Home       : /home/git
Home Mode  : 
Shell      : /bin/tcsh
Locked     : no
OK? (yes/no): yes
adduser: INFO: Successfully added (git) to the user database.
Add another user? (yes/no): no
Goodbye!

適当.
まぁ,これはあとからいくらでも変えられるし.

Database

データベースが必要なんだね.
PostgreSQLが大推奨だそうなので,従うよ.

#### Install the database packages
# pkg install postgresql93-server
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 2 packages will be affected (of 0 checked):

New packages to be INSTALLED:
        postgresql93-server: 9.3.5
        postgresql93-client: 9.3.5

The process will require 25 MB more space.
5 MB to be downloaded.

Proceed with this action? [y/N]: y
Fetching postgresql93-server-9.3.5.txz: 100%    3 MB   1.1M/s    00:03    
Fetching postgresql93-client-9.3.5.txz: 100%    2 MB   1.0M/s    00:02    
Checking integrity... done (0 conflicting)
[1/2] Installing postgresql93-client-9.3.5: 100%
===> Creating users and/or groups.
Creating group 'pgsql' with gid '70'.
Creating user 'pgsql' with uid '70'.

  =========== BACKUP YOUR DATA! =============
  As always, backup your data before
  upgrading. If the upgrade leads to a higher
  minor revision (e.g. 8.3.x -> 8.4), a dump
  and restore of all databases is
  required. This is *NOT* done by the port!

  Press ctrl-C *now* if you need to pg_dump.
  ===========================================
[2/2] Installing postgresql93-server-9.3.5: 100%
# emacs -nw /etc/rc.conf

postgresql_enable="YES"

# /usr/local/etc/rc.d/postgresql start
postgres cannot access the server configuration file "/usr/local/pgsql/data/postgresql.conf": No such file or directory
pg_ctl: could not start server
Examine the log output.

おっと.イニシャライズ忘れたよ.
# /usr/local/etc/rc.d/postgresql initdb

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /usr/local/bin/postgres -D /usr/local/pgsql/data
or
    /usr/local/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start

#  /usr/local/bin/pg_ctl -D /usr/local/pgsql/data start
pg_ctl: rootでは実行できません
サーバプロセスの所有者となる(非特権)ユーザとして(例えば"su"を使用して)
ログインしてください。

おっと.rootじゃダメね.

# su pgsql
$ /usr/local/bin/pg_ctl -D /usr/local/pgsql/data start
サーバは起動中です。
$ LOG:  ending log output to stderr
HINT:  Future log output will go to log destination "syslog".

#### Login to PostgreSQL

$ psql -d template1
psql (9.3.5)
"help" でヘルプを表示します.

#### Create a user for GitLab.

template1=# CREATE USER git CREATEDB;
CREATE ROLE

#### Create the GitLab production database & grant all privileges on database

template1=# CREATE DATABASE gitlabhq_production OWNER git;
CREATE DATABASE

#### Quit the database session
template1=# \q
$ 
#### Try connecting to the new database with the new user
# su git
% psql -d gitlabhq_production
psql (9.3.5)
"help" ??????????.

gitlabhq_production=> 

最後,日本語が化けましたが気にしない.

ここまでで!

Calbee 進撃の巨人チップス うすしお味

うすしお味で,量も少なめなので1人で食べるには良い感じです.
おまけが付いているので,量に対して割高だというのは気付かなかったことに.

原材料名は,「じゃがいも(遺伝子組換えでない)」,「植物油」,「食塩(石垣の塩60%使用)」,「こんぶエキスパウダー」,「デキストリン」等で,エネルギーは22グラム当たり123kcal,ナトリウムの食塩相当量は0.2グラムだそうです.

またまたCapistrano

前に散々capistranoで悩んでから,はや4年.
Solaris9+Capistranoはダメだった - なぜか数学者にはワイン好きが多い

またまた,使います.

gemでFreeBSDにサクッとインストールしてみます.


ドキュメントでは

Installation

Add this line to your application's Gemfile:

gem 'capistrano', '~> 3.2.0'

And then execute:

$ bundle install

とbundlerでバージョン3.2.0以上を入れるようになっていますが,gem searchしても指定バージョンが入るようなので,gemで入れてみます.

$ gem search ^capistrano$

*** REMOTE GEMS ***

capistrano (3.2.1)

$ sudo su
$ gem install capistrano --no-doc --no-ri
Fetching: net-ssh-2.9.1.gem (100%)
Successfully installed net-ssh-2.9.1
Fetching: colorize-0.7.3.gem (100%)
Successfully installed colorize-0.7.3
Fetching: sshkit-1.5.1.gem (100%)
Successfully installed sshkit-1.5.1
Fetching: capistrano-3.2.1.gem (100%)
Capistrano 3.1 has some breaking changes, like `deploy:restart` callback should be added manually to your deploy.rb. Please, check the CHANGELOG: http://goo.gl/SxB0lr

If you're upgrading Capistrano from 2.x, we recommend to read the upgrade guide: http://goo.gl/4536kB
Successfully installed capistrano-3.2.1
Done installing documentation for net-ssh, colorize, sshkit, capistrano (0 sec).
4 gems installed

なんかメッセージが最期に出ました.
バージョンが上がってずいぶん変わったよって言っているみたいなので,深く気にしないでおきます.
入ったみたいです.

$ cap --version
Capistrano Version: 3.2.1 (Rake Version: 10.1.0)

サーバ監視スクリプトという名目のテストプロジェクトを作成.

$ mkdir -v servers
mkdir: created directory `servers'
$ cd servers/
$ cap install
mkdir -p config/deploy
create config/deploy.rb
create config/deploy/staging.rb
create config/deploy/production.rb
mkdir -p lib/capistrano/tasks
Capified

config/deploy/production.rbにサーバを追加.

server "myserver501", user: "hadoop", roles: [:hadoop, :client]
server "myserver502", user: "hadoop", roles: [:hadoop, :client]

Capfileに適当な処理を追加.

desc "Disk Info"
task :disk do on roles(:all) do |host|
    execute "df -h"
  end
end

実行.

$ sudo -u hadoop /usr/local/bin/cap production disk
INFO[7cbc909f] Running /usr/bin/env df -h on myserver502
DEBUG[7cbc909f] Command: df -h
INFO[a79eb9b6] Running /usr/bin/env df -h on myserver501
DEBUG[a79eb9b6] Command: df -h
DEBUG[7cbc909f]         Filesystem            Size  Used Avail Use% Mounted on
DEBUG[7cbc909f]         /dev/sda1             7.9G  863M  7.1G  11% /
DEBUG[7cbc909f]         tmpfs                 3.9G     0  3.9G   0% /dev/shm
DEBUG[7cbc909f]         /dev/sda10            232G  110G  122G  48% /home
DEBUG[7cbc909f]         /dev/sda5             4.0G  142M  3.8G   4% /tmp
DEBUG[7cbc909f]         /dev/sda3              20G  7.7G   13G  39% /usr
DEBUG[7cbc909f]         /dev/sda6             4.0G  2.2G  1.8G  55% /var
INFO[7cbc909f] Finished in 0.120 seconds with exit status 0 (successful).
DEBUG[a79eb9b6]         Filesystem            Size  Used Avail Use% Mounted on
DEBUG[a79eb9b6]         /dev/sda2             267G  101G  167G  38% /
DEBUG[a79eb9b6]         tmpfs                 3.9G     0  3.9G   0% /dev/shm
INFO[a79eb9b6] Finished in 0.148 seconds with exit status 0 (successful).

むちゃくちゃ見辛いw

ここを変更.

task :disk do on roles(:all) do |host|
↓
task :disk do on roles(:all), in: :sequence do |host|

実行.

$ sudo -u hadoop /usr/local/bin/cap production disk
INFO[2d2bd683] Running /usr/bin/env df -h on myserver501
DEBUG[2d2bd683] Command: df -h
DEBUG[2d2bd683]         Filesystem            Size  Used Avail Use% Mounted on
DEBUG[2d2bd683]         /dev/sda2             267G  101G  167G  38% /
DEBUG[2d2bd683]         tmpfs                 3.9G     0  3.9G   0% /dev/shm
INFO[2d2bd683] Finished in 0.144 seconds with exit status 0 (successful).
INFO[f96460ee] Running /usr/bin/env df -h on myserver502
DEBUG[f96460ee] Command: df -h
DEBUG[f96460ee]         Filesystem            Size  Used Avail Use% Mounted on
DEBUG[f96460ee]         /dev/sda1             7.9G  864M  7.1G  11% /
DEBUG[f96460ee]         tmpfs                 3.9G     0  3.9G   0% /dev/shm
DEBUG[f96460ee]         /dev/sda10            232G  111G  121G  48% /home
DEBUG[f96460ee]         /dev/sda5             4.0G  142M  3.8G   4% /tmp
DEBUG[f96460ee]         /dev/sda3              20G  7.7G   13G  39% /usr
DEBUG[f96460ee]         /dev/sda6             4.0G  2.2G  1.8G  55% /var
INFO[f96460ee] Finished in 0.194 seconds with exit status 0 (successful).

イイネ!