도구 성능 테스트를 위해서 용량이 큰 파일이 필요한데,
마땅히 구할 방도가 없어서 고민하던 중 필요한 사이즈의 더미 파일을 만들어 볼 생각을 해봤다.

그랬더니, 이와 같은 고민을 하는 사람이 많다는 사실을 알게 되었고,
이러한 파일을 만드는 방법을 제공해주고 있다는 사실도 알게 되었다.

$ dd if=/dev/zero of=[filename] bs=[blocksize] count=[repeat]

 실제 사용 방법은 아래와 같다.

$ dd if=/dev/zero of=./test bs=100M count=2

위와 같이 하면 200M 크기의 test라는 이름의 파일이 생성된다.


count의 용도는 다음과 같다.

$ dd if=/dev/zero of=./10G bs=10G count=1
dd: memory exhausted by input buffer of size 10737418240 bytes (10 GiB)

10GB짜리 파일 하나를 만들려고 하는데 10GB x 1 count로 만들면 위와 같이 메모리 에러가 발생할 수 있다.

$ dd if=/dev/zero of=./10G bs=1G count=10
10+0 레코드 들어옴
10+0 레코드 나감
10737418240 바이트 (11 GB) 복사됨, 74.6861 초, 144 MB/초

그런데, 위와 같이 1GB 짜리를 10번 반복해서 만들라고 하면 된다!
이러한 것을 잘 이용하면 더 멋지게 컴퓨터 생활을 할 수 있을 것이다.


반응형

HDD를 물리적으로 추가하였는데, Ubuntu에서 자동으로 붙지 않는다.
USB 같은 것은 자동으로 잘 잡아주면서... 이거 왠지 사용자 친화적이지 않다.

그래서, CLI로 추가 작업을 진행해주어야 한다.


1. HDD 잘 인식하는지 확인하기

   - HDD 관련 작업은 fdisk 명령어로 대부분 처리할 수 있다.

$ sudo fdisk -l

Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders, total 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00089aab

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   100663295    50330624   83  Linux
/dev/sda2       100665342   104855551     2095105    5  Extended
/dev/sda5       100665344   104855551     2095104   82  Linux swap / Solaris

Disk /dev/sdb: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders, total 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

   - /dev/sda 는 잘 연결되어 있고, /dev/sdb는 물리적으로만 잘 붙어있다는 것을 확인할 수 있다.
   - 친절히 제일 마지막 줄에 파티션 테이블도 안만들어져 있다고 알려주고 있다.


2. 파티션 작업

   - 앞에서 찾아낸 작업해야할 HDD를 지정해서 파티션 작업을 진행하면 된다.

$ sudo fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xb9110add.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-419430399, default 2048): (enter)
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399): (enter)
Using default value 419430399

Command (m for help): p

Disk /dev/sdb: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders, total 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb9110add

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048   419430399   209714176   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

   - 각자의 상황에 따라 위와 같이 출력되지 않거나 다른 옵션을 선택해야할 경우도 있을 것이다.
   - 일단은 필자의 상황으로 설명을 하도록 하겠다. 다양한 옵션에 대한 설명은 생략!


3. 포맷

   - 파티션 작업을 했다고 바로 사용할 수는 없다. 포맷을 하고 사용해야 한다. 파일시스템을 만들어주는 과정이다.

$ sudo mkfs.ext4 /dev/sdb1
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
13107200 inodes, 52428544 blocks
2621427 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
1600 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
 4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done                           
Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

   - ext4가 아닌 다른 파일시스템을 사용할 사람은 바꾸면 된다.


4. UUID 확인

   - 앞에서 붙인 HDD를 다루기 위해서는 고유의 값인 UUID를 알아야 한다.

$ ls -l /dev/disk/by-uuid/
합계 0
lrwxrwxrwx 1 root root 10  6월 22 18:22 29f6905f-be40-4321-b7c0-7658f2cb4c3e -> ../../sdb1
lrwxrwxrwx 1 root root 10  6월 22 18:06 822b2062-39d1-4ba3-ab4d-fdc332fec050 -> ../../sda5
lrwxrwxrwx 1 root root 10  6월 22 18:06 94200076-d0b4-4dea-97d4-ee5bedc01bf5 -> ../../sda1


5. mount 등록

   - 방금 만든 파티션은 지금 접근해서 사용할 수는 없다. 파티션을 마운트(mount) 해주어야 사용할 수가 있는 것이다.
   - 하지만, 한 번만 사용할 것이 아니라 매번 부팅할 때마다 마운트 되는 것이 필요하다.

$ sudo mkdir /srv/repository

   - 마운트 하고자 하는 경로의 디렉토리를 미리 만들어 두자.

$ sudo nano /etc/fstab

...
UUID=29f6905f-be40-4321-b7c0-7658f2cb4c3e       /srv/repository ext4    errors=remount-ro       0       1

   - 부팅 時 자동으로 마운트할 내용을 위와 같이 적어주면 된다.

$ sudo mount -a

   - 재부팅하지 않아도 마운트 시킬 수 있다.

$ sudo chown hp14:hp14 /srv/repository

   - 권한은 마운트 뒤에 설정해주면 적용된다.


6. 확인

   - 잘 붙었는지 확인해보자.

$ df -h
Filesystem      Size     Used    Avail   Use%    Mounted on
/dev/sda1        48G       11G     35G     24%     /
none               4.0K          0     4.0K      0%      /sys/fs/cgroup
udev               991M     4.0K    991M     1%      /dev
tmpfs              201M     900K    200M    1%      /run
none               5.0M          0     5.0M    0%      /run/lock
none             1002M       76K   1001M   1%      /run/shm
none              100M        40K    100M   1%      /run/user
/dev/sdb1       197G       60M    187G   1%      /srv/repository



여기까지 하면 끄~~읕


반응형

윈도우7을 사용하게 되면서,
(최근까지 XP만 사용한 고리타분한 주인장^^) 정말 신경쓰이게 거슬리는 것이 하나 있었다.


사용하지 않을, 설치하지 않을 선택적 업데이트 목록이 자꾸 눈에 보이는 것이다.
매일 업데이트를 확인해서 설치를 해야 직성이 풀리는 최신병 환자로써 정말 신경쓰인다!!!

안보이게 하기는 정말 쉽다.


설치하기 싫은 언어팩들을 선택해서(체크박스가 아니다!),
오른쪽 마우스 버튼을 눌러 메뉴에 나오는 [업데이트 숨기기]를 선택하면 된다.


필요한 업데이트만 보인다!

하아~ 손에 박힌 쪼꼬만 가시를 쏙~ 뽑아낸 기분이다.


반응형

기본 한글입력기인 ibus를 사용하는 것은 왠지 불편하다.
그래서 대중적인, 리눅스를 사용하는 한국인이라면 왠지 다 알고 있어야 할 것 같은 nabi를 사용하곤 한다.

설치는 정말 쉽다.

sudo apt-get install nabi

그런 다음 [설정] - [언어 지원] - [키보드 입력기]를 선택하면 된다.


"Hangul"로 설정하고 나서 로그아웃/로그인 또는 재부팅을 하면 다음과 같은 팝업을 볼 수 있다.


이제는 편하게 한글을 사용하면 되긴 하는데... 여기에서 이슈는 저 팝업창을 없애버리고 싶은 충동이다!

12.04 버전까지만해도 시스템트레이로 옮기기를 하면 되었느데,
최근에는 이러한 기능을 공식적으로 지원하지 않는다. 지원하지 않는 것이 아니라 막았다고 보는 것이 맞을 것이다.

사실 이는 Ubuntu 측에서 지원하지 않는 것이 아니라 다른 방식을 지원하는 것이고,
새로운 방식을 nabi가 지원하지 않는다라는 것이 더 정확한 대답일 것이다.


물론 우리의 뛰어난 리눅서분들은 이러한 상황을 극복할 수 있는 방법들을 만들어내었다.
그런데, 좀 문제가 있는 것이... 기존 패키지 내용을 패치하는 방식을 통해서 해결을 하고 있는 것이다.
PPA 추가를 통해서 제공하지 않는 기능을 제공하도록 패치를 하는 것이다 보니
지속적으로 사용 가능한지에 대해서 보장을 할 수가 없다.


깔끔하게 사용하기 위해서는 IBus 방식을 사용하던지 아니면
그냥 위와 같이 별도의 팝업으로 뜨도록 내버려두는 것을 권장한다.

반응형


1. JDK 설치

   - http://whatwant.tistory.com/660


2. PostgreSQL 설치

$ sudo apt-get install postgresql



3. Apache

   - Proxy 기능이 필요하므로 해야할 일이 조금 더 있다.

$ sudo apt-get install apache2 libapache2-mod-proxy-html

$ sudo a2enmod proxy
$ sudo a2enmod proxy_http
$ sudo service apache2 restart



4. Git

   - http://whatwant.tistory.com/658


5. Download

   - 최근 사이트가 변경되면서... 웹사이트에서 다운로드 페이지 등의 호환성에서 IE는 잘 안되는 경우가 있다.
   - 다운로드는 잘 되니 그냥 아래와 같이 수행하면 된다.



6. DB 계정 및 db 생성

$ sudo su - postgres

$ createuser -A -D -P -E gerrit2
$ createdb -E UTF-8 -O gerrit2 reviewdb

$ exit


7. Gerrit 운영 계정 생성

$ cd /srv/install/gerrit

$ sudo adduser gerrit2
$ sudo chown -R gerrit2:gerrit2 /srv/install/gerrit/


8. 설치하기

$ sudo su gerrit2
$ cd /srv/install/gerrit

$ java -jar ./gerrit-2.8.4.war init -d /srv/install/gerrit/workspace

 

*** Gerrit Code Review 2.8.4
***

Create '/srv/install/gerrit/workspace' [Y/n]?  (Enter)

*** Git Repositories
***

Location of Git repositories   [git]: repositories

*** SQL Database
***

Database server type           [h2]: postgresql
Server hostname                [localhost]: (Enter)
Server port                    [(POSTGRESQL default)]: (Enter)
Database name                  [reviewdb]: (Enter)
Database username              [gerrit2]: (Enter)
gerrit2's password             : (passwd)
              confirm password : (passwd)

*** User Authentication
***

Authentication method          [OPENID/?]: http
Get username from custom HTTP header [y/N]? (Enter)
SSO logout URL                 : (Enter)

*** Email Delivery
***

SMTP server hostname           [localhost]: smtp.gmail.com
SMTP server port               [(default)]: 587
SMTP encryption                [NONE/?]: (Enter)
SMTP username                  [gerrit2]:  xxx@gmail.com
   @gmail.com's password  : (passwd)
              confirm password : (passwd)

*** Container Process
***

Run as                         [gerrit2]: (Enter)
Java runtime                   [/usr/local/java/jdk1.7.0_55/jre]: (Enter)
Copy gerrit-2.8.war to /srv/install/gerrit/workspace/bin/gerrit.war [Y/n]? (Enter)
Copying gerrit-2.8.war to /srv/install/gerrit/workspace/bin/gerrit.war

*** SSH Daemon
***

Listen on address              [*]: (Enter)
Listen on port                 [29418]: (Enter)

Gerrit Code Review is not shipped with Bouncy Castle Crypto v144
  If available, Gerrit can take advantage of features
  in the library, but will also function without it.
Download and install it now [Y/n]? (Enter)
Downloading http://www.bouncycastle.org/download/bcprov-jdk16-144.jar ... OK
Checksum bcprov-jdk16-144.jar OK
Generating SSH host key ... rsa... dsa... done

*** HTTP Daemon
***

Behind reverse proxy           [y/N]? (Enter)
Use SSL (https://)             [y/N]? (Enter)
Listen on address              [*]: (Enter)
Listen on port                 [8080]: (Enter)
Canonical URL                  [http://chani-VBox:8080/]: http://localhost:8080/

*** Plugins
***

Install plugin reviewnotes version v2.8.4 [y/N]? y
Install plugin download-commands version v2.8.4 [y/N]? y
Install plugin replication version v2.8.4 [y/N]? y
Install plugin commit-message-length-validator version v2.8.4 [y/N]? y

Initialized /srv/install/gerrit/workspace
Executing /srv/install/gerrit/workspace/bin/gerrit.sh start
Starting Gerrit Code Review: OK
Waiting for server on localhost:8080 ... OK
Opening http://localhost:8080/#/admin/projects/ ...No protocol specified
No protocol specified
OK

     - 나중에 설정 내용은 변경할 수 있으므로 최대한 기본값으로 정했다.


9. Apache Configuration

$ sudo su gerrit2

$ htpasswd -c /srv/install/gerrit/workspace/etc/passwords "admin"

$ exit

 

$ sudo nano /etc/apache2/sites-available/gerrit2

 

<VirtualHost *:8080>
        ServerName localhost

        ProxyRequests Off
        ProxyVia Off
        ProxyPreserveHost On

        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>

        <Location /login/>
                AuthType Basic
                AuthName "Gerrit Code Review"
                Require valid-user
                AuthUserFile /srv/install/gerrit/workspace/etc/passwords
        </Location>

        AllowEncodedSlashes On
        ProxyPass / http://127.0.0.1:8081/ nocanon

</VirtualHost>


     - 추가로 sites-enabled 디렉토리에 동적링크도 만들어주자.

$ cd /etc/apache2/sites-enabled
$ sudo ln -s ../sites-available/gerrit2 ./001-gerrit2


     - 위와 같이 설정을 하였으면 Apache의 port 설정에도 추가해줘야 한다.

$ sudo nano /etc/apache2/ports.conf


NameVirtualHost *:8080
Listen 8080


     - 위와 같이 8081 포트에 대해서 설정을 추가로 적어주면 된다.

$ sudo service apache2 restart

 
     - gerrit 의 설정값도 다시 한 번 살펴봐야 한다.

$ sudo su gerrit2

$ nano /srv/install/gerrit/workspace/etc/gerrit.config


[gerrit]
        basePath = repositories
        canonicalWebUrl = http://localhost:8080/
[database]
        type = postgresql
        hostname = localhost
        database = reviewdb
        username = gerrit2
[auth]
        type = HTTP
[sendemail]
        smtpServer = smtp.gmail.com
        smtpServerPort = 587
        smtpUser = xxx@gmail.com
[container]
        user = gerrit2
        javaHome = /usr/local/java/jdk1.7.0_55/jre
[sshd]
        listenAddress = *:29418
[httpd]
        listenUrl = proxy-http://127.0.0.1:8081/
[cache]
        directory = cache

 

$ sudo su gerrit2

$ cd /srv/install/gerrit/workspace/
$ ./bin/gerrit.sh restart


     - [ http://localhost:8080 ] 주소로 접속을 하면 위와 같이 이름과 암호를 물어본다.
     - 앞에서 "htpasswd"로 만든 계정을 이용해서 로그인하면 된다.


     - 드디어 길고 긴 과정을 거쳐서 gerrit의 화면이 나왔다.



9. 후기

     - 최근 시스템을 구축하면서 Gerrit에 대해서 활용팁(?) 등을 많이 얻었는데,
       집에서 테스트 해보기 위해 우선 예전 설치 방식으로 설치를 다시 한 번 진행해보았다.
     - 앞으로 Gerrit과 관련된 다른 내용을 추가해보도록 하겠다.

반응형

GitLab에서는 E-mail을 기반으로 사용자 관리가 이루어진다.

특히 새로운 사용자를 추가할 때 패스워드를 바로 설정하지 않는다.
임시 패스워드를 등록된 이메일 주소로 발송을 해주게 된다.

이 때, GitLab에 smtp 셋팅이 안되어 있으면 난감하다.
그래서 일단 급한대로 Gmail을 smtp로 셋팅하는 방법을 찾아보았다.

물론 Gitlab에서는 친절히 직접 설명을 해주고 있다.
   - https://gist.github.com/xavierjurado/3138813

$ sudo su - git
$ cd /home/git/gitlab/
$ nano ./config/environments/production.rb

다음의 내용을 수정 및 추가하자.

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true

  config.action_mailer.smtp_settings = {
     :address              => "smtp.gmail.com",
     :port                 => 587,
     :domain               => 'gmail.com',
     :user_name            => 'whatwant@gmail.com',
     :password             => 'xxx',
     :authentication       =>  :plain,
     :enable_starttls_auto => true
  }

발신자 정보도 셋팅을 해야한다.

$ nano ./config/gitlab.yml

    ## Email settings
    # Email address used in the "From" field in mails sent by GitLab
    email_from: whatwant@gmail.com


이제 GitLab만 재시작 하면 된다.

$ exit
$ sudo /etc/init.d/gitlab restart



이렇게 하면 이메일 발송 기능은 잘 동작하지만,
서버 주소 등에 있어서는 집에서 혼자 설치해서 사용하기에 좀 신경써야 하는 점은 귀찮다.

반응형

GitHub는 무료로 서비스를 해주지만, 해당 서비스를 내 서버에서 운영할 수는 없다.
물론 돈을 주면 가능하긴 하다지만... 저렴한 인생으로써는...^^

그래서 찾아보던 중 오픈소스 프로젝트로 진행중인 GitLab을 알게 되었다.
설치 과정이 단순하진 않지만... 나만의 GitHub 구축을 위해서 !!!


공식 홈페이지에 설치 가이드가 너무나 잘 나와 있다.
   - https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md


앞에서 작성한 포스트를 참고해도 좋다.
   - http://whatwant.tistory.com/332



01. 필수 패키지 설치

$ sudo apt-get install build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate python-docutils



02. Git 설치

   - http://whatwant.tistory.com/658


03. Ruby 설치

$ sudo su -
$ curl -L https://get.rvm.io | sudo bash -s stable
$ source /etc/profile
$ rvm install 2.0.0
$ rvm use 2.0.0
$ rvm --default use 2.0.0 

 

$ nano /etc/environment

 

PATH="......:/usr/local/rvm/bin"

 

$ gem install bundler --no-ri --no-rdoc



04. 계정 만들기

$ adduser --disabled-login --gecos 'GitLab' git



05. GitLab-Shell 설치하기

$ cd /home/git

$ sudo -u git -H git clone http://github.com/gitlabhq/gitlab-shell.git -b v1.7.9

$ cd gitlab-shell

$ sudo -u git -H cp config.yml.example config.yml
$ sudo -u git -H nano config.yml

 

...
gitlab_url: "http://localhost/"
...

 

$ sudo su - git
$ cd /home/git/gitlab-shell
$ ./bin/install



08. Database

   - 필자의 취향으로 일단 PostgreSQL로 진행해보자.

$ sudo apt-get install postgresql libpq-dev

$ sudo -u postgres psql -d template1

 

# CREATE ROLE git LOGIN ENCRYPTED PASSWORD 'password' NOINHERIT VALID UNTIL 'infinity';
# CREATE DATABASE gitlabhq_production OWNER git;
# \q


   - 접속이 잘 되는지 테스트 함 해보자.

$ sudo -u git -H psql -d gitlabhq_production



09. GitLab 다운로드

$ cd /home/git
$ sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git -b 6-3-stable gitlab

 


10. GitLab 환경 설정

$ cd /home/git/gitlab

$ sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml


   - 도메인을 지정하고 싶으면 다음처럼 수정 작업을 하면 된다.

$ sudo -u git -H nano config/gitlab.yml


...
   host: localhost
...


   - 권한 조정이 필요하다.

$ sudo chown -R git log/
$ sudo chown -R git tmp/
$ sudo chmod -R u+rwX  log/
$ sudo chmod -R u+rwX  tmp/


   - satellites를 위한 디렉토리를 하나 생성하고, 필요한 디렉토리를 만들자.

$ sudo -u git -H mkdir /home/git/gitlab-satellites


   - 필요한 디렉토리를 추가로 더 만들자.

$ cd /home/git/gitlab

$ sudo -u git -H mkdir tmp/pids/
$ sudo -u git -H mkdir tmp/sockets/
$ sudo chmod -R u+rwX  tmp/pids/
$ sudo chmod -R u+rwX  tmp/sockets/

$ sudo -u git -H mkdir public/uploads
$ sudo chmod -R u+rwX  public/uploads


   - 엄청 귀찮넹... 스크립트로 만들어서 제공하지....

   -  Unicorn 환경 설정을 진행하자.

$ sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb


   - 고성능이 필요하면 cluster mode를 활성화 하자. 방법은 간단하다 ?!

$ sudo -u git -H nano config/unicorn.rb


   - worker_processes를 3으로 변경하면 된다 ?!

...
worker_processes 2
...


   - 이번에는 Rack attack config를 진행하자.

$ sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb


   - rack attack middleware를 설정하고 싶으면 다음과 같이 하자.

$ sudo -u git -H nano config/application.rb


   - 주석처리된 부분을 찾아서 주석 표시를 지우면 된다고 한다. (뭘 하는지는 아직 모르겠다.)

...
   # config.middleware.use Rack::Attack
...



11. 기본 사용자 설정

   - Git 사용자 설정을 하자.

$ sudo -u git -H git config --global user.name "GitLab"
$ sudo -u git -H git config --global user.email "gitlab@whatwant.com"
$ sudo -u git -H git config --global core.autocrlf input


   - 위 설정은 다음의 설정에서도 적용이 필요하다.

$ sudo -u git -H nano config/gitlab.yml



12. Database 환경 파일 설정

   - PostgreSQL을 사용하는 경우이다.

$ sudo -u git cp config/database.yml.postgresql config/database.yml


   - git 계정에서만 읽어볼 수 있게 하기 위한 권한 설정을 하자.

$ sudo -u git -H chmod o-rwx config/database.yml



13. Install Gems

$ sudo su - git
$ cd /home/git/gitlab
$ bundle install --deployment --without development test mysql aws



14. Database 생성

$ sudo su - git
$ cd /home/git/gitlab
$ bundle exec rake gitlab:setup RAILS_ENV=production


   - 설치과정 끝에 나오는 메시지를 잘 확인해야 한다.

...
Administrator account created:

login............admin@local.host
password.....5iveL!fe



15. Init Script 설정하기

$ cd /home/git/gitlab
$ sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
$ sudo chmod +x /etc/init.d/gitlab
$ sudo update-rc.d gitlab defaults 21



16. log 관리하기

$ sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab



17. 환경 설정이 잘 되었는지 점검

   - 환경 설정이 잘 되었는지 확인을 해야하는데...
   - 우선 우리는 기본 설정값과 다른 git 경로부터 수정하고 확인을 하자.

$ sudo -u git nano config/gitlab.yml

 

...
git:
   bin_path: /usr/local/bin/git
...


   - git 경로를 제대로 적어주고나서 환경 설정 값들을 확인해보자.
 

$ sudo su - git
$ cd /home/git/gitlab
$ bundle exec rake gitlab:env:info RAILS_ENV=production

 


18. 시작

   - 이후 부터는 재부팅 될 때 자동으로 실행이 되겠지만, 지금은 직접 한 번 실행을 해보자.

$ sudo service gitlab start

 

Starting the GitLab Unicorn web server...
Starting the GitLab Sidekiq event dispatcher...
The GitLab Unicorn webserver with pid 1478 is running.
The GitLab Sidekiq job dispatcher with pid 1506 is running.
GitLab and all its components are up and running.



19. 상태 점검

   - green으로 나오면 좋은 것이다 ^^

$ sudo su - git
$ cd /home/git/gitlab
$ sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production



20. Nginx


http://tuwlab.com/10476
http://kkame.kr/106
http://blog.naver.com/PostView.nhn?blogId=delltin&logNo=90184174945

   - 개인적으로 Apache2의 대용품(?)으로 좋아하다가 요즘은 살짝 관심을 끊은 Nginx ... ^^
   - GitLab은 공식적으로 웹서버로 Nginx를 추천한다고 한다.

$ sudo apt-get install nginx


   - 설정도 진행을 하자.

$ sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
$ sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab


   -  수정할 것도 있다.

$ sudo nano /etc/nginx/sites-available/gitlab

 

...
   server_name localhost;
...


   - 재시작 !

$ sudo service nginx restart



21. 사이트 테스트

   - [ http://localhost/ ] 접속


   - ID / Password = [ admin@local.host / 5iveL!fe ]


   - 패스워드 재설정 창이 나온다.
   - 여기에서 재설정을 하면 다시 로그인 창이 나온다. 다시 로그인을 하면 된다.


   - 드디어 제대로 된 화면이 나왔다 !!!



헥헥... 너무 힘들다.... 이거, 반드시 스크립트 제공해줘야 한다 !!!

여하튼 일단 페이지 빵! 뜨는 것 까지는 성공~

반응형


공식 홈페이지에 설치 가이드가 너무나 잘 나와 있다.
   - https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md

아래 글은 거의 대부분 위의 가이드를 따르고 있다.
따라서 해보면서 조금 애매한 부분이거나 개인적인 환경에 맞추기 위해 일부 추가/수정했을 뿐이다.



01. 기본 에디터 설정

   - 특이하게도 기본 에디터 설정부터 설명을 해준다. vim을 추천하긴 하는데, 필자같은 경우는 nano가 좋다 ^^
   - vim을 사용하실 분들은 아래 설정을 참고하시고, 아니신 분은 그냥 무시 !

$ sudo apt-get install -y vim
$ sudo update-alternatives --set editor /usr/bin/vim.basic



02. 필수 패키지 설치

$ sudo apt-get install build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate



03. Python

   - 특정 버전의 Python을 요구한다.

$ sudo apt-get install python
$ python --version


   - 2.x 버전이 설치되어있으면 OK
   - 만약 3.x 버전이 설치되어 있으면 아래와 같은 과정 수행 필요

$ sudo apt-get install python2.7
$ sudo ln -s /usr/bin/python /usr/bin/python2


   - 추가적으로 설치해야할 패키지

$ sudo apt-get install python-docutils



04. Git 설치

   - v1.7.10 이상의 버전이 필요하다.
   - 설치가 필요하다면 다음과 같이 하면 된다.
      ▷ http://whatwant.tistory.com/643


05. Ruby 설치

   - 특정 버전의 Ruby가 필요하다.

$ sudo apt-get remove ruby1.8

$ cd /srv/install/ruby
$ wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz
$ tar zxvf ruby-2.0.0-p247.tar.gz
$ cd ruby-2.0.0-p247

$ ./configure --disable-install-rdoc
$ make
$ sudo make install

$ sudo gem install bundler --no-ri --no-rdoc



06. 계정 만들기

$ sudo adduser --disabled-login --gecos 'GitLab' git



07. GitLab-Shell 설치하기

$ cd /home/git

$ sudo -u git -H git clone http://github.com/gitlabhq/gitlab-shell.git
$ cd gitlab-shell

$ sudo -u git -H git checkout v1.7.1
$ sudo -u git -H cp config.yml.example config.yml

$ sudo -u git -H nano config.yml


   - URL 부분을 수정해야 한다.
 

...
gitlab_url: "http://localhost/"
...


   - 설치 진행하자.

$ sudo -u git -H ./bin/install



08. Database

   - 필자의 취향으로 일단 PostgreSQL로 진행해보자.

$ sudo apt-get install postgresql libpq-dev

$ sudo -u postgres psql -d template1

 

# CREATE ROLE git LOGIN ENCRYPTED PASSWORD 'password' NOINHERIT VALID UNTIL 'infinity';
# CREATE DATABASE gitlabhq_production OWNER git;
# \q


   - 접속이 잘 되는지 테스트 함 해보자.

$ sudo -u git -H psql -d gitlabhq_production



09. GitLab 다운로드

$ cd /home/git
$ sudo -u git -H git clone http://github.com/gitlabhq/gitlabhq.git gitlab
$ cd ./gitlab
$ sudo -u git -H git checkout 6-2-stable

 


10. GitLab 환경 설정

$ cd /home/git/gitlab

$ sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml


   - 도메인을 지정하고 싶으면 다음처럼 수정 작업을 하면 된다.

$ sudo -u git -H nano config/gitlab.yml


...
   host: localhost
...


   - 권한 조정이 필요하다.

$ sudo chown -R git log/
$ sudo chown -R git tmp/
$ sudo chmod -R u+rwX  log/
$ sudo chmod -R u+rwX  tmp/


   - satellites를 위한 디렉토리를 하나 생성하고, 필요한 디렉토리를 만들자.

$ sudo -u git -H mkdir /home/git/gitlab-satellites


   - 필요한 디렉토리를 추가로 더 만들자.

$ cd /home/git/gitlab

$ sudo -u git -H mkdir tmp/pids/
$ sudo -u git -H mkdir tmp/sockets/
$ sudo chmod -R u+rwX  tmp/pids/
$ sudo chmod -R u+rwX  tmp/sockets/

$ sudo -u git -H mkdir public/uploads
$ sudo chmod -R u+rwX  public/uploads


   - 엄청 귀찮넹... 스크립트로 만들어서 제공하지....

   -  Unicorn 환경 설정을 진행하자.

$ sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb


   - 고성능이 필요하면 cluster mode를 활성화 하자. 방법은 간단하다 ?!

$ sudo -u git -H nano config/unicorn.rb


   - worker_processes를 3으로 변경하면 된다 ?!

...
worker_processes 2
...


   - 이번에는 Rack attack config를 진행하자.

$ sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb


   - rack attack middleware를 설정하고 싶으면 다음과 같이 하자.

$ sudo -u git -H nano config/application.rb


   - 주석처리된 부분을 찾아서 주석 표시를 지우면 된다고 한다. (뭘 하는지는 아직 모르겠다.)

...
   # config.middleware.use Rack::Attack
...



11. 기본 사용자 설정

   - Git 사용자 설정을 하자.

$ sudo -u git -H git config --global user.name "GitLab"
$ sudo -u git -H git config --global user.email "gitlab@whatwant.com"
$ sudo -u git -H git config --global core.autocrlf input


   - 위 설정은 다음의 설정에서도 적용이 필요하다.

$ sudo -u git -H nano config/gitlab.yml



12. Database 환경 파일 설정

   - PostgreSQL을 사용하는 경우이다.

$ sudo -u git cp config/database.yml.postgresql config/database.yml


   - git 계정에서만 읽어볼 수 있게 하기 위한 권한 설정을 하자.

$ sudo -u git -H chmod o-rwx config/database.yml



13. Install Gems

$ cd /home/git/gitlab

$ sudo gem install charlock_holmes --version '0.6.9.4'


   - PostgreSQL 사용자들은 다음과 같이...

$ sudo -u git -H bundle install --deployment --without development test mysql aws



14. Database 생성

$ sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production


   - 설치과정 끝에 나오는 메시지를 잘 확인해야 한다.

...
Administrator account created:

login............admin@local.host
password.....5iveL!fe



15. Init Script 설정하기

$ sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
$ sudo chmod +x /etc/init.d/gitlab
$ sudo update-rc.d gitlab defaults 21



16. log 관리하기

$ sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab



17. 환경 설정이 잘 되었는지 점검

   - 환경 설정이 잘 되었는지 확인을 해야하는데...
   - 우선 우리는 기본 설정값과 다른 git 경로부터 수정하고 확인을 하자.

$ sudo -u nano config/gitlab.yml

 

...
git:
   bin_path: /usr/local/bin/git
...


   - git 경로를 제대로 적어주고나서 환경 설정 값들을 확인해보자.
 

$ sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production

 


18. 시작

   - 이후 부터는 재부팅 될 때 자동으로 실행이 되겠지만, 지금은 직접 한 번 실행을 해보자.

$ sudo service gitlab start

 

Starting the GitLab Unicorn web server...
Starting the GitLab Sidekiq event dispatcher...
The GitLab Unicorn webserver with pid 1478 is running.
The GitLab Sidekiq job dispatcher with pid 1506 is running.
GitLab and all its components are up and running.



19. 상태 점검

   - green으로 나오면 좋은 것이다 ^^

$ sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production



20. Nginx

   - 개인적으로 Apache2의 대용품(?)으로 좋아하다가 요즘은 살짝 관심을 끊은 Nginx ... ^^
   - GitLab은 공식적으로 웹서버로 Nginx를 추천한다고 한다.

$ sudo apt-get install nginx


   - 설정도 진행을 하자.

$ sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
$ sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab


   -  수정할 것도 있다.

$ sudo nano /etc/nginx/sites-available/gitlab

 

...
   server_name localhost;
...


   - 재시작 !

$ sudo service nginx restart



21. 사이트 테스트

   - [ http://localhost/ ] 접속


   - ID / Password = [ admin@local.host / 5iveL!fe ]


   - 패스워드 재설정 창이 나온다.
   - 여기에서 재설정을 하면 다시 로그인 창이 나온다. 다시 로그인을 하면 된다.


   - 드디어 제대로 된 화면이 나왔다 !!!



헥헥... 너무 힘들다.... 이거, 반드시 스크립트 제공해줘야 한다 !!!

여하튼 일단 페이지 빵! 뜨는 것 까지는 성공~



반응형

+ Recent posts