FreeBSD GitLab 설치

 

 

GitLab : https://about.gitlab.com/

Requirements : https://docs.gitlab.com/ce/install/requirements.html

 

 

locale 변경

locale 을 변경 하고 jail 에서 빠져나간후 다시 접속 하여 locale 을 확인 합니다.

이때 주의 할점은 :umask=022: 부분이 \ 를 추가 charset부분에도 \ 를 추가 해야 정상적으로 동작이 됩니다.

git /root > vi /etc/login.conf
        :umask=022:\
        :charset=ko_KR.UTF-8:\
        :lang=ko_KR.UTF-8


git /root > cap_mkdb /etc/login.conf
git /root > logout
root@BSD11:~ # qjail console git
Last login: Sun Sep 16 23:52:14 on pts/0
FreeBSD 11.1-RELEASE-p14 (GENERIC) #0: Thu Sep  6 05:04:10 UTC 2018

Welcome to your FreeBSD jail.
git /root > locale
LANG=ko_KR.UTF-8
LC_CTYPE="ko_KR.UTF-8"
LC_COLLATE="ko_KR.UTF-8"
LC_TIME="ko_KR.UTF-8"
LC_NUMERIC="ko_KR.UTF-8"
LC_MONETARY="ko_KR.UTF-8"
LC_MESSAGES="ko_KR.UTF-8"
LC_ALL=
git /root >

 

GitLab 설치

root@BSD11:~ # pkg update
root@BSD11:~ # pkg upgrade
root@BSD11:~ # pkg install www/gitlab-ce

~중략

===>   NOTICE:

This port is deprecated; you may wish to reconsider installing it:

Upstream no longer maintained, use devel/rubygem-webpacker-rails* instead.

It is scheduled to be removed on or after 2018-08-31.
Message from redis-4.0.11:

===>  CONFIGURATION NOTE:

      To setup "redis" you need to edit the configuration file:
      /usr/local/etc/redis.conf

      To run redis from startup, add redis_enable="YES"
      in your /etc/rc.conf.
Message from gitlab-ce-11.2.3:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv GITLAB vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Gitlab was installed successfully.

You now need to set up the various components of Gitlab, so please
follow the instructions in the guide at:

https://gitlab.fechner.net/mfechner/Gitlab-docu/blob/master/install/11.2-freebsd.md

If you just installed an major upgrade of GitLab, for example you
switched from 11.1.x to 11.2.x, please follow the instructions in the guide at:

https://gitlab.fechner.net/mfechner/Gitlab-docu/blob/master/update/11.1-11.2-freebsd.md

If you just installed an minor upgrade of GitLab please follow
the instructions in the guide at:

https://gitlab.fechner.net/mfechner/Gitlab-docu/blob/master/update/freebsd_patch_versions.md

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ GITLAB ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
root@BSD11:~ #

 

ports 설치

최신 pkg 사용을 위하여 repo 변경

root@BSD11:~ # mkdir -p /usr/local/etc/pkg/repos
root@BSD11:~ # vi /usr/local/etc/pkg/repos/FreeBSD.conf


FreeBSD: {
  url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest"
}

 

PostgreSQL 의 경우 gitlab 설치시 postgresql95 client 가 설치됩니다.

동일한 버젼으로 설치를 진행 합니다.

root@BSD11:~ # pkg info |grep -i post
ghostscript9-agpl-base-9.24_2  PostScript and PDF interpreter
ghostscript9-agpl-x11-9.24     PostScript and PDF interpreter, X11 support
postgresql95-client-9.5.14     PostgreSQL database (client)
rubygem-gitlab-flowdock-git-hook-1.0.1 GitLab-patched Git Post-Receive hook for Flowdock
rubygem-multipart-post-2.0.0   Ruby Library that Use with Net::HTTP to do multipart form posts
rubygem-pg0-0.21.0             Ruby interface to PostgreSQL library
rubygem-pg018-0.18.4           Ruby interface to PostgreSQL library
rubygem-slack-notifier1-1.5.1  Ruby wrapper for posting to slack webhooks
root@BSD11:~ #

 

PostgreSQL 설치

root@BSD11:~ # pkg install postgresql95-server postgresql95-contrib


~중략
To set limits, environment stuff like locale and collation and other
things, you can set up a class in /etc/login.conf before initializing
the database. Add something similar to this to /etc/login.conf:
---
postgres:\
        :lang=en_US.UTF-8:\
        :setenv=LC_COLLATE=C:\
        :tc=default:
---
and run `cap_mkdb /etc/login.conf'.
Then add 'postgresql_class="postgres"' to /etc/rc.conf.

======================================================================

To initialize the database, run

  /usr/local/etc/rc.d/postgresql initdb

You can then start PostgreSQL by running:

  /usr/local/etc/rc.d/postgresql start

For postmaster settings, see ~pgsql/data/postgresql.conf

NB. FreeBSD's PostgreSQL port logs to syslog by default
    See ~pgsql/data/postgresql.conf for more info

NB. If you're not using a checksumming filesystem like ZFS, you might
    wish to enable data checksumming. It can only be enabled during
    the initdb phase, by adding the "--data-checksums" flag to
    the postgres_initdb_flags rcvar.  Check the initdb(1) manpage
    for more info and make sure you understand the performance
    implications.

======================================================================

To run PostgreSQL at startup, add
'postgresql_enable="YES"' to /etc/rc.conf
Message from postgresql95-contrib-9.5.14:

The PostgreSQL contrib utilities have been installed. Please see
/usr/local/share/doc/postgresql/contrib/README
for more information.
root@BSD11:~ #

 

postgresql /etc/rc.conf 등록 및 initdb 실행

initdb 실행시 정상적으로 실행이 되지 않습니다.

root@BSD11:~ # sysrc postgresql_enable=YES
postgresql_enable:  -> YES
root@BSD11:~ # 

root@BSD11:~ # service postgresql initdb
이 데이터베이스 시스템에서 만들어지는 파일들은 그 소유주가 "pgsql" id로
지정될 것입니다. 또한 이 사용자는 서버 프로세스의 소유주가 됩니다.

데이터베이스 클러스터는 다음 로케일으로 초기화될 것입니다.
  COLLATE:  C
  CTYPE:    ko_KR.UTF-8
  MESSAGES: ko_KR.UTF-8
  MONETARY: ko_KR.UTF-8
  NUMERIC:  ko_KR.UTF-8
  TIME:     ko_KR.UTF-8
initdb: "ko_KR.UTF-8" 로케일에 알맞은 전문검색 설정을 찾을 수 없음
기본 텍스트 검색 구성이 "simple"(으)로 설정됩니다.

Data page checksums are disabled.

/usr/local/pgsql/data 디렉터리 만드는 중 ...완료
하위 디렉터리 만드는 중 ...완료
max_connections 초기값을 선택하는 중 ...100
기본 shared_buffers를 선택하는 중... 128MB
selecting dynamic shared memory implementation ... posix
환경설정 파일을 만드는 중 ...완료
/usr/local/pgsql/data/base/1 안에 template1 데이터베이스를 만드는 중 ...완료
pg_authid 초기화 중 ...완료
의존성 정보 초기화 중 ...완료
시스템 뷰들을 만드는 중 ... 완료
시스템 개체들 설명 자료 입력 중 ...완료
collation 만드는 중 ... 완료
인코딩 변환규칙(conversion)들을 만드는 중 ...완료
사전을 만드는 중... 완료
내장개체들의 액세스 권한을 설정 중 ... 완료
information schema 만드는 중 ...완료
서버측 언어인 PL/pgSqL 불러오는 중 ... 완료
template1 데이터베이스 청소 중 ...완료
template1 데이터베이스를 template0 데이터베이스로 복사 중 ...완료
template1 데이터베이스를 postgres 데이터베이스로 복사 중 ...완료
syncing data to disk ... 완료

경고: 로컬 연결의 인증 방법으로 "trust" 방식을 지정했습니다.
이 값을 바꾸려면, pg_hba.conf 파일을 수정하든지,
다음번 initdb 명령을 사용할 때, -A 옵션 또는 --auth-local,
--auth-host 옵션을 사용해서 인증 방법을 지정할 수 있습니다.

작업완료. 이제 다음 명령을 이용해서 서버를 가동 할 수 있습니다:

    /usr/local/bin/pg_ctl -D /usr/local/pgsql/data -l 로그파일 start

root@BSD11:~ #

 

postgresql 실행

git /root > service postgresql start
LOG:  could not create IPv6 socket: Protocol not supported
LOG:  ending log output to stderr
HINT:  Future log output will go to log destination "syslog".
git /root >

 

For PostgreqSQL < 9.6 execute:

blog 내용으로 설치 하였으면 해당 설정을 이용합니다. postgres user 로 설정 해야 합니다.

# create user git
# ATTENTION: for first installation superuser rights are needed; after installation this should be removed!
psql -d template1 -U pgsql -c "CREATE USER git CREATEDB SUPERUSER;"

# Create the GitLab production database & grant all privileges on database
psql -d template1 -U pgsql -c "CREATE DATABASE gitlabhq_production OWNER git;"

# Try connecting to the new database with the new user
psql -U git -d gitlabhq_production

# Connect as superuser to gitlab db and enable pg_trgm extension if not installed
psql -U pgsql -d gitlabhq_production -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"

 

For PostgreqSQL >= 9.6 execute:

# create user git
psql -d template1 -U postgres -c "CREATE USER git CREATEDB SUPERUSER;"

# Create the GitLab production database & grant all privileges on database
psql -d template1 -U postgres -c "CREATE DATABASE gitlabhq_production OWNER git;"

# Try connecting to the new database with the new user
psql -U git -d gitlabhq_production

# Connect as superuser to gitlab db and enable pg_trgm extension if not installed
psql -U postgres -d gitlabhq_production -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"

 

PostgreSQL 9.5 command

root@BSD11:~ # psql -d template1 -U pgsql -c "CREATE USER git CREATEDB SUPERUSER;"
CREATE ROLE
root@BSD11:~ # psql -d template1 -U pgsql -c "CREATE DATABASE gitlabhq_production OWNER git;"
CREATE DATABASE
root@BSD11:~ # psql -U git -d gitlabhq_production
gitlabhq_production=# \q
root@BSD11:~ # psql -U pgsql -d gitlabhq_production -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
CREATE EXTENSION

 

Redis 설정

root@BSD11:~ # echo 'unixsocket /var/run/redis/redis.sock' >> /usr/local/etc/redis.conf
root@BSD11:~ # echo 'unixsocketperm 770' >> /usr/local/etc/redis.conf
root@BSD11:~ # sysrc redis_enable=YES
redis_enable:  -> YES
root@BSD11:~ # service redis restart
redis not running? (check /var/run/redis/redis.pid).
Starting redis.
root@BSD11:~ # pw groupmod redis -m git

 

GitLab 설정

git 사용자 홈디렉토리를 변경 합니다.

root@BSD11:~ # vipw -d /etc
git:*:211:211::0:0:git user:/usr/local/git:/bin/sh
 
=> /usr/home 으로 변경합니다. 
git:*:211:211::0:0:git user:/usr/home/git:/bin/sh

 

git.yml 파일을 수정 합니다.

root@BSD11:~ # vi /usr/local/www/gitlab-ce/config/gitlab.yml
#    host: localhost
    host: gitlab.example.com 


root@BSD11:/usr/local/www/gitlab-ce # sysctl hw.ncpu
hw.ncpu: 2
root@BSD11:/usr/local/www/gitlab-ce #
root@BSD11:/usr/local/www/gitlab-ce # vi config/unicorn.rb
hw.ncpu 확인시 확인된 cpu 수로 worker 를 설정 2G 이상의 경우 worker default 3개로 사용
worker_processes 3 


root@BSD11:~ # su -l git -c "git config --global core.autocrlf input"
root@BSD11:~ # su -l git -c "git config --global gc.auto 0"
root@BSD11:~ # su -l git -c "git config --global repack.writeBitmaps true"
root@BSD11:~ # su -l git -c "git config --global receive.advertisePushOptions true"
root@BSD11:~ # su -l git -c "mkdir -p /usr/home/git/.ssh"

 

데이터 베이스 초기화 설정

yes 입력시 databasetable 을 생성 합니다.

root@BSD11:~ # chown git /usr/local/share/gitlab-shell
root@BSD11:~ # su -l git -c "cd /usr/local/www/gitlab-ce && rake gitlab:setup RAILS_ENV=production"

Do you want to continue (yes/no)? yes

root@BSD11:~ # chown root /usr/local/share/gitlab-shell

 

password 를 설정 합니다.

test1234

root@BSD11:~ # su -l git -c "cd /usr/local/www/gitlab-ce && rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=test1234"

 

System infomation 확인

root@BSD11:~ # su -l git -c "cd /usr/local/www/gitlab-ce && rake gitlab:env:info RAILS_ENV=production"

System information
System:
Current User:   git
Using RVM:      no
Ruby Version:   2.4.4p296
Gem Version:    2.7.6
Bundler Version:1.16.2
Rake Version:   12.3.1
Redis Version:  4.0.10
Git Version:    2.18.0
Sidekiq Version:5.1.3
Go Version:     unknown

GitLab information
Version:        11.1.6
Revision:       Unknown
Directory:      /usr/local/www/gitlab-ce
DB Adapter:     postgresql
URL:            http://localhost
HTTP Clone URL: http://localhost/some-group/some-project.git
SSH Clone URL:  git@localhost:some-group/some-project.git
Using LDAP:     no
Using Omniauth: no

GitLab Shell
Version:        7.1.4
Repository storage paths:
- default:      /usr/home/git/repositories
Hooks:          /usr/local/share/gitlab-shell/hooks
Git:            /usr/local/bin/git
root@BSD11:~ #

 

Compile GetText PO files & Compile Assets

root@BSD11:~ # su -l git -c "cd /usr/local/www/gitlab-ce && rake gettext:compile RAILS_ENV=production"
root@BSD11:~ # su -l git -c "cd /usr/local/www/gitlab-ce && rake yarn:install gitlab:assets:clean gitlab:assets:compile RAILS_ENV=production NODE_ENV=production"

 

For PostgreSQL < 9.6 execute:

blog 에서는 PostgreSQL 9.5 를 이용함으로 아래 command 를 입력합니다.

psql -d template1 -U pgsql -c "ALTER USER git WITH NOSUPERUSER;"

 

For PostgreSQL >= 9.6 execute:

psql -d template1 -U postgres -c "ALTER USER git WITH NOSUPERUSER;"

 

PostgreSQL 9.5 command

root@BSD11:~ # psql -d template1 -U pgsql -c "ALTER USER git WITH NOSUPERUSER;"

 

gitlab 데몬 실행

root@BSD11:~ # sysrc gitlab_enable=YES
gitlab_enable:  -> YES

root@BSD11:~ # service gitlab start
Regenerate Gitlab Gemfile.lock
Regenerate Gitaly Gemfile.lock
Starting GitLab Unicorn
Starting GitLab Sidekiq
Starting GitLab Workhorse
Starting Gitaly
master failed to start, check stderr log for details
..
~중략
root@BSD11:~ #

 

Nginx 설치

설치시 아래와 같이 size mismatch 가 발생하면 pkg update -f  로 pkg 를 갱신 합니다. 

root@BSD11:~ # pkg install nginx
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        nginx: 1.14.0_11,2

Number of packages to be installed: 1

The process will require 1 MiB more space.
418 KiB to be downloaded.
[git] [1/1] Fetching nginx-1.14.0_11,2.txz: 100%  418 KiB 428.0kB/s    00:01
pkg: cached package nginx-1.14.0_11,2: size mismatch, fetching from remote
[git] Fetching nginx-1.14.0_11,2.txz: 100%  418 KiB 428.0kB/s    00:01
pkg: cached package nginx-1.14.0_11,2: size mismatch, cannot continue
root@BSD11:~ # pkg update -f

 

Nginx 설치

root@BSD11:~ # pkg install nginx

Message from nginx-1.14.0_11,2:

===================================================================
Recent version of the NGINX introduces dynamic modules support.  In
FreeBSD ports tree this feature was enabled by default with the DSO
knob.  Several vendor's and third-party modules have been converted
to dynamic modules.  Unset the DSO knob builds an NGINX without
dynamic modules support.

To load a module at runtime, include the new `load_module'
directive in the main context, specifying the path to the shared
object file for the module, enclosed in quotation marks.  When you
reload the configuration or restart NGINX, the module is loaded in.
It is possible to specify a path relative to the source directory,
or a full path, please see
https://www.nginx.com/blog/dynamic-modules-nginx-1-9-11/ and
http://nginx.org/en/docs/ngx_core_module.html#load_module for
details.

Default path for the NGINX dynamic modules is

/usr/local/libexec/nginx.
===================================================================

 

Nginx 설정

root@BSD11:~ # vi /usr/local/etc/nginx/nginx.conf


http {
    include       mime.types;
    include       /usr/local/www/gitlab-ce/lib/support/nginx/gitlab;

 

Nginx /etc/rc.conf 에 enable

root@BSD11:~ # sysrc nginx_enable=YES
nginx_enable:  -> YES

 

gitlab 설정변경 및 nginx 실행

root@BSD11:~ # vi /usr/local/www/gitlab-ce/lib/support/nginx/gitlab

  listen 0.0.0.0:80 default_server;
#  listen [::]:80 default_server;

git /root > service nginx stop
Stopping nginx.
Waiting for PIDS: 6103.
git /root >service nginx start
Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Starting nginx.
git /root >


git /root > sockstat -4
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS
www      nginx      4460  8  tcp4   10.0.0.1:80           *:*
root     nginx      4459  8  tcp4   10.0.0.1:80           *:*
redis    redis-serv 3675  6  tcp4   10.0.0.1:6379         *:*
pgsql    postgres   3566  8  udp4   10.0.0.1:18280        10.0.0.1:18280
pgsql    postgres   3565  8  udp4   10.0.0.1:18280        10.0.0.1:18280
pgsql    postgres   3564  8  udp4   10.0.0.1:18280        10.0.0.1:18280
pgsql    postgres   3563  8  udp4   10.0.0.1:18280        10.0.0.1:18280
pgsql    postgres   3562  8  udp4   10.0.0.1:18280        10.0.0.1:18280
pgsql    postgres   3560  4  tcp4   10.0.0.1:5432         *:*
pgsql    postgres   3560  8  udp4   10.0.0.1:18280        10.0.0.1:18280
git /root >

 

점검 실행

root@BSD11:~ # su -l git -c "cd /usr/local/www/gitlab-ce && rake gitlab:check RAILS_ENV=production"

 

Web 접속

 

Username : root

password: test1234

 

주의!!! Rebooting 시 gitlab 이 정상적으로 기동이 되지 않습니다.

수동으로 service gitlab start 로 실행 해줘야 합니다.

root@BSD11:~ # service gitlab status
Regenerate Gitlab Gemfile.lock
Regenerate Gitaly Gemfile.lock
The GitLab Unicorn web server with pid 692 is running.
The GitLab Sidekiq job dispatcher is not running.
The GitLab Workhorse is not running.
Gitaly is not running.
root@BSD11:~ # service gitlab start
Regenerate Gitlab Gemfile.lock
Regenerate Gitaly Gemfile.lock
The Unicorn web server already running with pid 692, not restarting.
The Sidekiq job dispatcher is already running with pid 795, not restarting
The GitLab Workhorse is already running with pid 749, not restarting
Gitaly is already running with pid 752, not restarting

The GitLab Unicorn web server with pid 692 is running.
The GitLab Sidekiq job dispatcher with pid 795 is running.
The GitLab Workhorse with pid 749 is running.
Gitaly with pid 752 is running.
GitLab and all its components are up and running.
root@BSD11:~ #

 

 

 

FreeBSD postgresql96-server install

 

FreeBSD Version : 11 

Postgresql Version EOL 확인 https://www.postgresql.org/support/versioning/

 

Port install

root@bsd11:~ # whereis postgresql96-server
postgresql96-server: /usr/ports/databases/postgresql96-server
root@bsd11:~ # cd /usr/ports/databases/postgresql96-server/ && make install clean

 

or

pkg install

root@bsd11:~ # pkg install postgresql96-server postgresql96-client

 

설치완료후 메세지

Installing postgresql96-server-9.6.10...
===> Creating groups.
Creating group 'postgres' with gid '770'.
===> Creating users
Creating user 'postgres' with uid '770'.

  =========== 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!
  ===========================================
For procedural languages and postgresql functions, please note that
you might have to update them when updating the server.

If you have many tables and many clients running, consider raising
kern.maxfiles using sysctl(8), or reconfigure your kernel
appropriately.

The port is set up to use autovacuum for new databases, but you might
also want to vacuum and perhaps backup your database regularly. There
is a periodic script, /usr/local/etc/periodic/daily/502.pgsql, that
you may find useful. You can use it to backup and perform vacuum on all
databases nightly. Per default, it performs `vacuum analyze'. See the
script for instructions. For autovacuum settings, please review
~pgsql/data/postgresql.conf.

If you plan to access your PostgreSQL server using ODBC, please
consider running the SQL script /usr/local/share/postgresql/odbc.sql
to get the functions required for ODBC compliance.

Please note that if you use the rc script,
/usr/local/etc/rc.d/postgresql, to initialize the database, unicode
(UTF-8) will be used to store character data by default.  Set
postgresql_initdb_flags or use login.conf settings described below to
alter this behaviour. See the start rc script for more info.

To set limits, environment stuff like locale and collation and other
things, you can set up a class in /etc/login.conf before initializing
the database. Add something similar to this to /etc/login.conf:
---
postgres:\
        :lang=en_US.UTF-8:\
        :setenv=LC_COLLATE=C:\
        :tc=default:
---
and run `cap_mkdb /etc/login.conf'.
Then add 'postgresql_class="postgres"' to /etc/rc.conf.

======================================================================

To initialize the database, run

  /usr/local/etc/rc.d/postgresql initdb

You can then start PostgreSQL by running:

  /usr/local/etc/rc.d/postgresql start

For postmaster settings, see ~pgsql/data/postgresql.conf

NB. FreeBSD's PostgreSQL port logs to syslog by default
    See ~pgsql/data/postgresql.conf for more info

NB. If you're not using a checksumming filesystem like ZFS, you might
    wish to enable data checksumming. It can only be enabled during
    the initdb phase, by adding the "--data-checksums" flag to
    the postgres_initdb_flags rcvar.  Check the initdb(1) manpage
    for more info and make sure you understand the performance
    implications.

======================================================================

To run PostgreSQL at startup, add
'postgresql_enable="YES"' to /etc/rc.conf

===> SECURITY REPORT:
      This port has installed the following files which may act as network
      servers and may therefore pose a remote security risk to the system.
/usr/local/bin/postgres

      This port has installed the following startup scripts which may cause
      these network services to be started at boot time.
/usr/local/etc/rc.d/postgresql

      If there are vulnerabilities in these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports included in the Ports Collection. Please type 'make deinstall'
      to deinstall the port if this is a concern.

      For more information, and contact details about the security
      status of this software, see the following webpage:
https://www.postgresql.org/
===>  Cleaning for gmake-4.2.1_2
===>  Cleaning for gettext-runtime-0.19.8.1_1
===>  Cleaning for libiconv-1.14_11
===>  Cleaning for indexinfo-0.3.1
===>  Cleaning for gettext-tools-0.19.8.1
===>  Cleaning for autoconf-2.69_1
===>  Cleaning for m4-1.4.18,1
===>  Cleaning for texinfo-6.5,1
===>  Cleaning for help2man-1.47.6
===>  Cleaning for p5-Locale-gettext-1.07
===>  Cleaning for perl5-5.26.2
===>  Cleaning for autoconf-wrapper-20131203
===>  Cleaning for automake-1.16.1
===>  Cleaning for icu-62.1_2,1
===>  Cleaning for postgresql96-client-9.6.10
===>  Cleaning for pkgconf-1.4.2,1
===>  Cleaning for readline-7.0.3_1
===>  Cleaning for postgresql96-server-9.6.10
root@bsd11:/usr/ports/databases/postgresql96-server #

 

postgresSQL 설정

root@bsd11:~ # sysrc postgresql_enable=yes
postgresql_enable:  -> yes
root@bsd11:~ #

 

postgres initdb 실행 

root@bsd11:~ # service postgresql initdb
이 데이터베이스 시스템에서 만들어지는 파일들은 그 소유주가 "postgres" id로
지정될 것입니다. 또한 이 사용자는 서버 프로세스의 소유주가 됩니다.

데이터베이스 클러스터는 다음 로케일으로 초기화될 것입니다.
  COLLATE:  C
  CTYPE:    ko_KR.UTF-8
  MESSAGES: ko_KR.UTF-8
  MONETARY: ko_KR.UTF-8
  NUMERIC:  ko_KR.UTF-8
  TIME:     ko_KR.UTF-8
initdb: "ko_KR.UTF-8" 로케일에 알맞은 전문검색 설정을 찾을 수 없음
기본 텍스트 검색 구성이 "simple"(으)로 설정됩니다.

자료 페이지 체크섬 기능 사용 하지 않음

/var/db/postgres/data96 디렉터리 만드는 중 ...완료
하위 디렉터리 만드는 중 ...완료
max_connections 초기값을 선택하는 중 ...100
기본 shared_buffers를 선택하는 중... 128MB
사용할 동적 공유 메모리 관리방식을 선택하는 중 ... posix
환경설정 파일을 만드는 중 ...완료
부트스트랩 스크립트 실행 중 ... 완료
부트스트랩 다음 초기화 작업 중 ... 완료
자료를 디스크에 동기화 하는 중 ... 완료

경고: 로컬 연결의 인증 방법으로 "trust" 방식을 지정했습니다.
이 값을 바꾸려면, pg_hba.conf 파일을 수정하든지,
다음번 initdb 명령을 사용할 때, -A 옵션 또는 --auth-local,
--auth-host 옵션을 사용해서 인증 방법을 지정할 수 있습니다.

작업완료. 이제 다음 명령을 이용해서 서버를 가동 할 수 있습니다:

    /usr/local/bin/pg_ctl -D /var/db/postgres/data96 -l 로그파일 start

root@bsd11:~ #

 

Postgresql 실행

root@bsd11:~ # service postgresql start
로그: stderr 쪽 로그 출력을 중지합니다.
힌트: 자세한 로그는 "syslog" 쪽으로 기록됩니다.
root@bsd11:~ #
root@bsd11:~ # sockstat -4 |grep -i postgre
postgres postgres   839   4  tcp4   *:5432                *:*
root@bsd11:~ #

 

postgresql.conf 수정

root@bsd11:~ # vi /var/db/postgres/data96/postgresql.conf
#listen_addresses = 'localhost'         # what IP address(es) to listen on;
listen_addresses = '*'          # what IP address(es) to listen on;

 

인증 방법 변경 trust -> md5 변경

root@bsd11:~ # cp  /var/db/postgres/data96/pg_hba.conf /var/db/postgres/data96/pg_hba.conf.org
root@bsd11:~ # vi /var/db/postgres/data96/pg_hba.conf

변경전
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust

변경후
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             0.0.0.0/0            md5
# IPv6 local connections:
host    all             all             ::1/128              md5

 

postgres user pass 변경

root@bsd11:~ # passwd postgres
Changing local password for postgres
New Password:
Retype New Password:
root@bsd11:~ #

 

portgres user 로 변경후 작업

root@bsd11:~ # su - postgres
$ psql
psql (9.6.10)
도움말을 보려면 "help"를 입력하십시오.

postgres=# help
PostgreSQL에 대한 명령행 인터페이스인 psql을 사용하고 있습니다.
사용법:  \copyright 저작권 정보
         \h SQL 명령 도움말
         \? psql 명령 도움말
         \g 또는 명령 끝에 세미콜론(;) 쿼리 실행
         \q 종료
postgres=# \q

 

portgresSQL user 생성

$ createuser --interactive
추가할 새 롤(role)이름: db_user
새 롤을 superuser 권한으로 지정할까요? (y/n) n
이 새 롤에게 데이터베이스를 만들 수 있는 권할을 줄까요? (y/n) y
이 새 롤에게 또 다른 롤을 만들 수 있는 권한을 줄까요? (y/n) y
$

 

portgresSQL db 생성

$ createdb new_db

psql 에서 실행

postgres=# ALTER USER db_user WITH ENCRYPTED PASSWORD 'password';
ALTER ROLE

postgres=# GRANT ALL PRIVILEGES ON DATABASE new_db TO db_user;
GRANT

postgres-# \list
                               데이터베이스 목록
   이름    |  소유주  | 인코딩 | Collate |    Ctype    |      액세스 권한
-----------+----------+--------+---------+-------------+-----------------------
 db_user   | postgres | UTF8   | C       | ko_KR.UTF-8 |
 new_db    | postgres | UTF8   | C       | ko_KR.UTF-8 |
 postgres  | postgres | UTF8   | C       | ko_KR.UTF-8 |
 template0 | postgres | UTF8   | C       | ko_KR.UTF-8 | =c/postgres          +
           |          |        |         |             | postgres=CTc/postgres
 template1 | postgres | UTF8   | C       | ko_KR.UTF-8 | =c/postgres          +
           |          |        |         |             | postgres=CTc/postgres
(5개 행)

postgres-#

 

pgAdmin 설치

root@bsd11:~ # python2.7 -m ensurepip
root@bsd11:~ # pkg install py27-virtualenv
root@bsd11:~ # mkdir Workspace
root@bsd11:~ # cd Workspace/
root@bsd11:~/Workspace # virtualenv pgadmin4
New python executable in /root/Workspace/pgadmin4/bin/python2.7
Also creating executable in /root/Workspace/pgadmin4/bin/python
Installing setuptools, pip, wheel...done.
root@bsd11:~/Workspace # cd pgadmin4/bin/
root@bsd11:~/Workspace/pgadmin4/bin # chmod +x activate
root@bsd11:~/Workspace/pgadmin4/bin # ./activate

 

일반유저 작업 test / wheel Group

root@bsd11:~ # su - test

$ python2.7 -m ensurepip
Requirement already satisfied: setuptools in /usr/local/lib/python2.7/site-packages
Requirement already satisfied: pip in /usr/local/lib/python2.7/site-packages
$ virtualenv pgadmin4
New python executable in /usr/home/test/pgadmin4/bin/python2.7
Also creating executable in /usr/home/test/pgadmin4/bin/python
Installing setuptools, pip, wheel...done.
$ . pgadmin4/bin/activate
(pgadmin4) $

프롬프트가 (pgadmin4) $ 바뀌게 됩니다.

 

root user 에서 python dependencie 를 설치 및 pgadmin config 설정

root@bsd11:~ # pip install cryptography pyopenssl ndg-httpsclient pyasn1
root@bsd11:~ # pkg install py27-sqlite3
root@bsd11:~ # wget --no-check-certificate https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.5/pip/pgadmin4-1.5-py2.py3-none-any.whl
root@bsd11:~ # pip install pgadmin4-1.5-py2.py3-none-any.whl


root@bsd11:~ # su - test
$ python2.7 /usr/local/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
NOTE: Configuring authentication for SERVER mode.

Enter the email address and password to use for the initial pgAdmin user account:

Email address: test@test.com
Password:
Retype password:
Starting pgAdmin 4. Please navigate to http://localhost:5050 in your browser.

$ su - 
root@bsd11:~ # vi /usr/local/lib/python2.7/site-packages/pgadmin4/config.py
#DEFAULT_SERVER = 'localhost'
DEFAULT_SERVER = '0.0.0.0'

# The default port on which the app server will listen if not set in the
# environment by the runtime
DEFAULT_SERVER_PORT = 5050

 

일반유저에서 실행

$ python2.7 /usr/local/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
Starting pgAdmin 4. Please navigate to http://0.0.0.0:5050 in your browser.

 

pgAdmin4.py 실행하여 생성한 유저로 로그인을 합니다. 

 

FreeBSD Test Version 11.02

014XY 같은 BBS를 찾다 보니 Telnet 기반의 BBS Server 가 있어서 테스트 삼아 설치를 진행해 봤습니다.

단순한 설치 / telnet 접속 까지만 진행하며 그외 설정 파일을 구글링을 통하여 설정해 보시기 바랍니다.

Synchronet 은 ports 로 제공되지 않습니다. wget 으로 Source 를 받아 와야 하며

의존성 패키지의 경우 pkg install 로 설치를 진행 하였습니다.

참고 site : http://www.synchro.net/    http://wiki.synchro.net/install:nix

 

 

의존성 패키지 설치

root@BSD11-Test:~ # pkg install wget cryptlib gmake gcc nspr python pkgconf unzip zip cvs spidermonkey17 perl5

 

Synchronet 디렉토리 생성

root@BSD11-Test:~ # mkdir /usr/local/etc/sbbs
root@BSD11-Test:~ # cd /usr/local/etc/sbbs/

 

Synchronet 설치

root@BSD11-Test:/usr/local/etc/sbbs # wget ftp://vert.synchro.net/Synchronet/sbbs_src.tgz
root@BSD11-Test:/usr/local/etc/sbbs # wget ftp://vert.synchro.net/Synchronet/sbbs_run.tgz
root@BSD11-Test:/usr/local/etc/sbbs # tar -xzf sbbs_src.tgz && tar -xzf sbbs_run.tgz
root@BSD11-Test:/usr/local/etc/sbbs # cd src/sbbs3; gmake RELEASE=1
~중략
Compiling ../sbbs_ini.c
Compiling ../scfglib1.c
Compiling ../scfglib2.c
Compiling spyon.c
Compiling ../str_util.c
Compiling umonitor.c
Compiling ../userdat.c
Linking clang.freebsd.amd64.exe.release/umonitor
gmake[1]: Leaving directory '/usr/local/etc/sbbs/src/sbbs3/umonitor'
root@BSD11-Test:/usr/local/etc/sbbs/src/sbbs3 # cd /usr/local/etc/sbbs/xtrn/sbj; gmake
~중략
./sbj.c:94:11: note: expanded from macro 'A'
#define A 14    /* ace */
          ^
52 warnings generated.
root@BSD11-Test:/usr/local/etc/sbbs/xtrn/sbj # cd /usr/local/etc/sbbs/xtrn/sbl; gmake
~중략
65 warnings generated.
Linking clang.freebsd.amd64.exe.debug/smb2sbl
Compiling sblpack.c
Linking clang.freebsd.amd64.exe.debug/sblpack
root@BSD11-Test:/usr/local/etc/sbbs/xtrn/sbl #
root@BSD11-Test:/usr/local/etc/sbbs/xtrn/sbl # cd /usr/local/etc/sbbs/src/sbbs3/umonitor; gmake
root@BSD11-Test:/usr/local/etc/sbbs/src/sbbs3/umonitor # cd /usr/local/etc/sbbs/src/sbbs3/umonitor
root@BSD11-Test:/usr/local/etc/sbbs/src/sbbs3/umonitor # cp clang.freebsd.amd64.exe.debug/* /usr/local/etc/sbbs/exec/
root@BSD11-Test:/usr/local/etc/sbbs/src/sbbs3/umonitor # cd /usr/local/etc/sbbs/src/sbbs3/uedit; gmake
~중략
Compiling ../str_util.c
Compiling uedit.c
Compiling ../userdat.c
Linking clang.freebsd.amd64.exe.debug/uedit
root@BSD11-Test:/usr/local/etc/sbbs/src/sbbs3/uedit #
root@BSD11-Test:/usr/local/etc/sbbs/src/sbbs3/uedit # cp clang.freebsd.amd64.exe.debug/* /usr/local/etc/sbbs/exec/
root@BSD11-Test:/usr/local/etc/sbbs/src/sbbs3/uedit # cd /usr/local/etc/sbbs/src/sbbs3/syncview; gmake
~중략
gmake[1]: Entering directory '/usr/local/etc/sbbs/src/conio'
gmake[1]: Nothing to be done for 'mtlib'.
gmake[1]: Leaving directory '/usr/local/etc/sbbs/src/conio'
Compiling syncview.c
Linking clang.freebsd.amd64.exe.debug/syncview
root@BSD11-Test:/usr/local/etc/sbbs/src/sbbs3/syncview #
root@BSD11-Test:/usr/local/etc/sbbs/src/sbbs3/syncview # cp clang.freebsd.amd64.exe.debug/* /usr/local/etc/sbbs/exec/
root@BSD11-Test:/usr/local/etc/sbbs/exec # ln -s ../src/sbbs3/clang.freebsd.amd64.exe.release/* .
root@BSD11-Test:/usr/local/etc/sbbs/exec # ln -s ../src/sbbs3/scfg/clang.freebsd.amd64.exe.release/scfg* .
root@BSD11-Test:/usr/local/etc/sbbs/exec # gmake
~중략
BAJA v2.34-FreeBSD (rev 1.50) - Synchronet Shell/Module Compiler

Compiling yesnobar.src...
Resolving labels...

Done.
root@BSD11-Test:/usr/local/etc/sbbs/exec #

 

.cshrc 환경변수 추가

root@BSD11-Test:~ # vi .cshrc
# set path /usr/local/etc/sbbs/exec 추가 
set path = (/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin /usr/local/etc/sbbs/exec $HOME/bin)

setenv  EDITOR  vi
setenv  PAGER   more
setenv  BLOCKSIZE       K
# setenv 라인 추가 
setenv SBBSCTRL /usr/local/etc/sbbs/ctrl
root@BSD11-Test:~ # source .cshrc

 

실행 스크립트 /etc/rc.d 디렉토리에 설정

root@BSD11-Test:~ # cd /etc/rc.d/
root@BSD11-Test:/etc/rc.d # wget 'http://cvs.synchro.net/cgi-bin/viewcvs.cgi/*checkout*/install/rc.d/sbbs'
root@BSD11-Test:/etc/rc.d # chmod 555 sbbs

 

/etc/rc.conf 수정

root@BSD11-Test:~ # vi /etc/rc.conf

sbbs_dir="/usr/local/etc/sbbs"
sbbs_enable="YES"

 

콘솔에서 scfg 실행 / Synchronet 기본 설정을 진행 합니다.

(주의!!! ssh 및 telnet 환경에서는 정상적으로 실행 되지 않습니다.)

 

System -> Sysop (Admin) password 를 설정 합니다.

ESC 를 눌러 설정을 저장 합니다.

 

putty 접속시 Telnet 으로 접속을 합니다.

 

New 를 입력하여 신규 유저를 생성합니다.

 

User 를 생성 합니다.

 

 

 

 

 

1: Synchronet (Classic) 선택

 

user01 의 password 를 설정 합니다.

 

 

 

 

 

 

User 생성이 마무리 되었습니다.

추가적인 설정은 구글링을 통하여 설정 하시기 바랍니다.  🙂

 

 

 

FreeBSD mkdocs 설치

mkdocs 소개 

MkDocs is a fast, simple and downright gorgeous static site generator that’s geared towards building project documentation. Documentation source files are written in Markdown, and configured with a single YAML configuration file.

참고페이지 : https://demun.github.io/mkdocs-tuts/#mkdocs
   : https://www.mkdocs.org/#installation
official site : https://www.mkdocs.org/

사용법참고: https://demun.github.io/mkdocs-tuts/how/

 

mkdocs 설치

root@bsd11:~ # whereis py-mkdocs
py-mkdocs: /usr/ports/textproc/py-mkdocs
root@bsd11:~ #
root@bsd11:~ # cd /usr/ports/textproc/py-mkdocs && make install clean
Installing py27-mkdocs-1.0...
If you are using the Python v3.x version and a non-Unicode locale you'll get a r untime error when mkdocs is executed..
In that case please set the locale to a Unicode locale first, e.g. en_US.UTF-8 o r similar, before starting mkdocs.
~중략
root@bsd11:/usr/ports/textproc/py-mkdocs # rehash

 

mkdocs 사용

default 사용시 127.0.0.18000 로 open 됩니다.

root@bsd11:~ # mkdocs new mkdocs-tuts
INFO - Creating project directory: mkdocs-tuts
INFO - Writing config file: mkdocs-tuts/mkdocs.yml
INFO - Writing initial docs: mkdocs-tuts/docs/index.md
root@bsd11:~ # cd mkdocs-tuts

mkdocs serve 실행시 locale:8000 로 실행 됩니다. 
root@bsd11:~/mkdocs-tuts # mkdocs serve
INFO - Building documentation...
INFO - Cleaning site directory
[I 180903 22:39:37 server:292] Serving on http://127.0.0.1:8000
[I 180903 22:39:37 handlers:59] Start watching changes
[I 180903 22:39:37 handlers:61] Start detecting changes

 

–dev-addr 옵션 사용시 IP:port 를 지정할수 있습니다.

root@bsd11:~/mkdocs-tuts # mkdocs serve --dev-addr 192.168.0.100:80
INFO - Building documentation...
INFO - Cleaning site directory
[I 180903 22:44:20 server:292] Serving on http://192.168.0.100:80
[I 180903 22:44:20 handlers:59] Start watching changes
[I 180903 22:44:20 handlers:61] Start detecting changes
[I 180903 22:44:26 handlers:132] Browser Connected: http://192.168.0.100/
[I 180903 22:48:21 handlers:132] Browser Connected: http://192.168.0.100/#welcome-to-mkdocs
[I 180903 22:48:23 handlers:132] Browser Connected: http://192.168.0.100/


Port 확인
root@bsd11:~ # sockstat -4
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
root python2.7 6008 3 tcp4 175.211.33.9:80 *:*
root python2.7 6008 7 tcp4 175.211.33.9:80 192.168.0.10:8713
root python2.7 6008 8 tcp4 175.211.33.9:80 192.168.0.10:8718
root python2.7 6008 9 tcp4 175.211.33.9:80 192.168.0.10:8714
root python2.7 6008 10 tcp4 175.211.33.9:80 192.168.0.10:8715
root python2.7 6008 13 tcp4 175.211.33.9:80 192.168.0.10:8716
root python2.7 6008 15 tcp4 175.211.33.9:80 192.168.0.10:8717
test sshd 5978 3 tcp4 175.211.33.9:22 192.168.0.10:8685
root sshd 5975 3 tcp4 175.211.33.9:22 192.168.0.10:8685
test sshd 755 3 tcp4 175.211.33.9:22 192.168.0.10:8627
root sshd 752 3 tcp4 175.211.33.9:22 192.168.0.10:8627
root sendmail 682 3 tcp4 127.0.0.1:25 *:*
root sshd 679 4 tcp4 *:22 *:*

 

website 접속

Nginx 와 MKdocs 사용예

FreeBSD Nginx 설치는 아래 내용을 참고 하시면 됩니다.

[web-server] Nginx 설치

mkdocs serve 를 통하여 사용하지 않고 nginx or apache 로 구성된 웹서버에서 사용하시면 됩니다.

ex) /var/www/test.com 으로 구성된 nginx home 디렉토리에서 mkdocs-tuts 프로젝트를 만들고

build 까지 한후 web에서 접속한 예제 입니다.

root@bsd11:/var/www/test.com # mkdocs new mkdocs-tuts
INFO    -  Creating project directory: mkdocs-tuts
INFO    -  Writing config file: mkdocs-tuts/mkdocs.yml
INFO    -  Writing initial docs: mkdocs-tuts/docs/index.md
root@bsd11:/var/www/test.com #


root@bsd11:/var/www/test.com # cd mkdocs-tuts/
root@bsd11:/var/www/test.com/mkdocs-tuts # ll
total 1
drwxr-xr-x  2 root  www   3  9  5 01:02 docs/
-rw-r--r--  1 root  www  19  9  5 01:02 mkdocs.yml
root@bsd11:/var/www/test.com/mkdocs-tuts #


root@bsd11:/var/www/test.com/mkdocs-tuts # mkdocs build
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /var/www/test.com/mkdocs-tuts/site
root@bsd11:/var/www/test.com/mkdocs-tuts #

 

접속확인

 

Theme 변경

root@bsd11:/var/www/test.com/mkdocs-tuts # vi mkdocs.yml
site_name: My Docs
theme: readthedocs

root@bsd11:/var/www/test.com/mkdocs-tuts # mkdocs build
INFO - Cleaning site directory
INFO - Building documentation to directory: /var/www/test.com/mkdocs-tuts/site
root@bsd11:/var/www/test.com/mkdocs-tuts #

 

 

dropdown 적용

참고페이지: https://github.com/cjsheets/mkdocs-rtd-dropdown

설치 

test@docker-test:~$ pip install mkdocs-rtd-dropdown

 

http://readthedocs.sheets.ch/#installation

root@bsd11:/var/www/test.com/mkdocs-tuts # cat mkdocs.yml
site_name: Opensource manual
#theme: readthedocs
theme: rtd-dropdown
nav:
  - INFO: index.md
  - Reference:
      Linux: linux/linux.md
      Cloud: cloud/cloud.md
      Languge: lang/lang.md
      FreeBSD: freebsd/freebsd.md

root@bsd11:/var/www/test.com/mkdocs-tuts # tree
.
├── docs
│&nbsp;&nbsp; ├── cloud
│&nbsp;&nbsp; │&nbsp;&nbsp; └── cloud.md
│&nbsp;&nbsp; ├── freebsd
│&nbsp;&nbsp; │&nbsp;&nbsp; └── freebsd.md
│&nbsp;&nbsp; ├── index.md
│&nbsp;&nbsp; ├── lang
│&nbsp;&nbsp; │&nbsp;&nbsp; └── lang.md
│&nbsp;&nbsp; └── linux
│&nbsp;&nbsp;     └── linux.md
├── mkdocs.yml
└── site
    ├── 404.html
    ├── centos
    │&nbsp;&nbsp; └── centos
    │&nbsp;&nbsp;     └── index.html
    ├── cloud
    │&nbsp;&nbsp; └── cloud
    │&nbsp;&nbsp;     └── index.html
    ├── css
    │&nbsp;&nbsp; ├── theme_extra.css
    │&nbsp;&nbsp; └── theme.css
    ├── fonts
    │&nbsp;&nbsp; ├── fontawesome-webfont.eot
    │&nbsp;&nbsp; ├── fontawesome-webfont.svg
    │&nbsp;&nbsp; ├── fontawesome-webfont.ttf
    │&nbsp;&nbsp; └── fontawesome-webfont.woff
    ├── freebsd
    │&nbsp;&nbsp; └── freebsd
    │&nbsp;&nbsp;     └── index.html
    ├── how
    │&nbsp;&nbsp; └── index.html
    ├── img
    │&nbsp;&nbsp; └── favicon.ico
    ├── index.html
    ├── js
    │&nbsp;&nbsp; ├── jquery-2.1.1.min.js
    │&nbsp;&nbsp; ├── modernizr-2.8.3.min.js
    │&nbsp;&nbsp; └── theme.js
    ├── lang
    │&nbsp;&nbsp; └── lang
    │&nbsp;&nbsp;     └── index.html
    ├── linux
    │&nbsp;&nbsp; └── linux
    │&nbsp;&nbsp;     └── index.html
    ├── search
    │&nbsp;&nbsp; ├── lunr.js
    │&nbsp;&nbsp; ├── main.js
    │&nbsp;&nbsp; ├── search_index.json
    │&nbsp;&nbsp; └── worker.js
    ├── search.html
    ├── sitemap.xml
    ├── sitemap.xml.gz
    └── ubuntu
        └── ubuntu
            └── index.html

24 directories, 32 files
root@bsd11:/var/www/test.com/mkdocs-tuts #
root@bsd11:/var/www/test.com/mkdocs-tuts # cat docs/linux/linux.md
## CentOS

## Ubuntu

### System Command

### Package install
root@bsd11:/var/www/test.com/mkdocs-tuts #

 

 

 

 

 

FeeBSD locale 설정

site: https://www.freebsd.org/doc/handbook/using-localization.html

 

1./etc/login.conf 를 수정 하여 Global 설정을 변경 하는 방법 (모든 유저설정의 경우 설정)

/etc/login.conf 를 수정 합니다. 

root@bsd11:~ # vi /etc/login.conf

me:\
:charset=ko_KR.UTF-8:\
:lang=ko_KR.UTF-8:
root@bsd11:~ # cap_mkdb /etc/login.conf

 

재접속후 확인 

root@bsd11:~ # locale
LANG=ko_KR.UTF-8
LC_CTYPE="ko_KR.UTF-8"
LC_COLLATE="ko_KR.UTF-8"
LC_TIME="ko_KR.UTF-8"
LC_NUMERIC="ko_KR.UTF-8"
LC_MONETARY="ko_KR.UTF-8"
LC_MESSAGES="ko_KR.UTF-8"
LC_ALL=
root@bsd11:~ #

 

일반유저도 동일하게 적용됩니다.

별도의 .login_conf 를 수정할 필요가 없습니다.

$ cat .login_conf
# $FreeBSD: releng/11.1/share/skel/dot.login_conf 77995 2001-06-10 17:08:53Z ache $
#
# see login.conf(5)
#
#me:\
#       :charset=iso-8859-1:\
#       :lang=de_DE.ISO8859-1:
$ locale
LANG=ko_KR.UTF-8
LC_CTYPE="ko_KR.UTF-8"
LC_COLLATE="ko_KR.UTF-8"
LC_TIME="ko_KR.UTF-8"
LC_NUMERIC="ko_KR.UTF-8"
LC_MONETARY="ko_KR.UTF-8"
LC_MESSAGES="ko_KR.UTF-8"
LC_ALL=
$

 

 

 

2. 각각 설정할 경우 User Directory 의 .login_conf 를 수정 합니다. 

유저별 다른 Character Set 을 사용할 경우

$ vi .login_conf
#
#me:\
# :charset=iso-8859-1:\
# :lang=de_DE.ISO8859-1:


me:\
:charset=ko_KR.UTF-8:\
:lang=ko_KR.UTF-8:

$ locale
LANG=
LC_CTYPE="C"
LC_COLLATE="C"
LC_TIME="C"
LC_NUMERIC="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=
$

ssh 재접속후 확인

$ locale
LANG=ko_KR.UTF-8
LC_CTYPE="ko_KR.UTF-8"
LC_COLLATE="ko_KR.UTF-8"
LC_TIME="ko_KR.UTF-8"
LC_NUMERIC="ko_KR.UTF-8"
LC_MONETARY="ko_KR.UTF-8"
LC_MESSAGES="ko_KR.UTF-8"
LC_ALL=
$

 

/usr/share/skel 부분은 생략해도 됩니다.

Global 설정의 경우 /etc/login.conf 파일을 수정하는것이 간편합니다. 🙂

생성되는 user 전부를 변경하기 위하여 /usr/share/skel 디렉토리의 dot.login_conf를 변경 합니다. 

root@bsd11-Client:~ # vi /usr/share/skel/dot.login_conf
# $FreeBSD: releng/11.1/share/skel/dot.login_conf 77995 2001-06-10 17:08:53Z ach
e $
#
# see login.conf(5)
#
me:\
        :charset=ko_KR.UTF-8:\
        :lang=ko_KR.UTF-8:

 

Test 삼아 test1 user 를 생성해 봅니다. 🙂

root@bsd11-Client:~ # pw user add test2 -m
root@bsd11-Client:~ # passwd  test2
Changing local password for test2
New Password:
Retype New Password:

 

test2 로 변경후 locale 확인

$ locale
LANG=ko_KR.UTF-8
LC_CTYPE="ko_KR.UTF-8"
LC_COLLATE="ko_KR.UTF-8"
LC_TIME="ko_KR.UTF-8"
LC_NUMERIC="ko_KR.UTF-8"
LC_MONETARY="ko_KR.UTF-8"
LC_MESSAGES="ko_KR.UTF-8"
LC_ALL=
$

 

3.예전에 많이 쓰던 방법 🙂

요즘은 global 설정으로 /etc/login.conf 만 설정 합니다.

root 유저의 경우

root@bsd11-Client:~ # vi .cshrc
setenv LANG ko_KR.UTF-8
setenv LC_ALL ko_KR.UTF-8

root@bsd11-Client:~ # locale
LANG=ko_KR.UTF-8
LC_CTYPE="ko_KR.UTF-8"
LC_COLLATE="ko_KR.UTF-8"
LC_TIME="ko_KR.UTF-8"
LC_NUMERIC="ko_KR.UTF-8"
LC_MONETARY="ko_KR.UTF-8"
LC_MESSAGES="ko_KR.UTF-8"
LC_ALL=ko_KR.UTF-8
root@bsd11-Client:~ #

적용 로케일 확인

root@bsd11-Client:~ # locale -a
LANG=ko_KR.UTF-8
LC_CTYPE="ko_KR.UTF-8"
LC_COLLATE="ko_KR.UTF-8"
LC_TIME="ko_KR.UTF-8"
LC_NUMERIC="ko_KR.UTF-8"
LC_MONETARY="ko_KR.UTF-8"
LC_MESSAGES="ko_KR.UTF-8"
LC_ALL=

 

 

FreeBSD inspircd irc-server install

site: http://www.inspircd.org/

root@bsd11:~ # cd /usr/ports/irc/inspircd/ && make config

GEOIP , GUNTLS , LDAPAUTH , LDAPOPER 를 선택 합니다.

 

inspircd 를 설치 합니다.

root@bsd11:/usr/ports/irc/inspircd # make config install



~중략

Installing inspircd-2.0.26...
===> Creating groups.
Creating group 'ircd' with gid '72'.
===> Creating users
Creating user 'ircd' with uid '72'.
===> SECURITY REPORT:
This port has installed the following files which may act as network
servers and may therefore pose a remote security risk to the system.
/usr/local/bin/inspircd

This port has installed the following startup scripts which may cause
these network services to be started at boot time.
/usr/local/etc/rc.d/inspircd

If there are vulnerabilities in these programs there may be a security
risk to the system. FreeBSD makes no guarantee about the security of
ports included in the Ports Collection. Please type 'make deinstall'
to deinstall the port if this is a concern.

For more information, and contact details about the security
status of this software, see the following webpage:
http://www.inspircd.org/

root@bsd11:/usr/ports/irc/inspircd # rehash

root@bsd11:~ # sysrc inspircd_enable="YES"
inspircd_enable: -> YES
root@bsd11:~ #

config 없이 테스트 삼아 실행을 해 봅니다. :)
root@bsd11:~ # service inspircd start
Starting inspircd.
root@bsd11:~ #

root@bsd11:~ # sockstat -4
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
test sshd 1815 3 tcp4 192.168.0.100:22 192.168.0.10:7839
root sshd 1812 3 tcp4 192.168.0.100:22 192.168.0.10:7839
test sshd 729 3 tcp4 192.168.0.100:22 192.168.0.10:7727
root sshd 726 3 tcp4 192.168.0.100:22 192.168.0.10:7727
root sendmail 662 3 tcp4 127.0.0.1:25 *:*
root sshd 659 4 tcp4 *:22 *:*
root syslogd 530 7 udp4 *:514 *:*
root@bsd11:~ #

생각했던것 처럼 정상적으로 실행되지 않아 보입니다. 🙂

root@bsd11:~ # service inspircd stop
inspircd not running? (check /var/run/inspircd/inspircd.pid).
root@bsd11:~ #

root@bsd11:/var/log/inspircd # cat inspircd.log
Thu Aug 30 23:20:03 2018: ANNOUNCEMENT: Your configuration contains a deprecated value: <die:value> - you need to reread your config (at /usr/local/etc/inspircd/inspircd.conf:528)
Thu Aug 30 23:20:03 2018: ANNOUNCEMENT: Your configuration contains a deprecated value: <die:value> - you need to reread your config (at /usr/local/etc/inspircd/inspircd.conf:981)
root@bsd11:/var/log/inspircd #

 

inspircd.conf 수정

root@bsd11:/usr/local/etc/inspircd # vi inspircd.conf
528 #<die value="You should probably edit your config *PROPERLY* and try again.">
981 #<die value="User error. You didn't edit your config properly. Go back and try again.">

528/981 라인 부분을 주석 처리 합니다.

 

inspircd 데몬을 실행 합니다.

정상적으로 데몬이 실행 된것을 확인 할수 있습니다.

root@bsd11:~ # service inspircd start
Starting inspircd.
root@bsd11:~ # sockstat  -4
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS
ircd     inspircd   2982  6  udp4   *:43757               *:*
ircd     inspircd   2982  7  tcp46  *:6697                *:*
ircd     inspircd   2982  8  tcp46  *:6660                *:*
ircd     inspircd   2982  9  tcp46  *:6661                *:*
ircd     inspircd   2982  10 tcp46  *:6662                *:*
ircd     inspircd   2982  11 tcp46  *:6663                *:*
ircd     inspircd   2982  12 tcp46  *:6664                *:*
ircd     inspircd   2982  13 tcp46  *:6665                *:*
ircd     inspircd   2982  14 tcp46  *:6666                *:*
ircd     inspircd   2982  15 tcp46  *:6667                *:*
ircd     inspircd   2982  16 tcp46  *:6668                *:*
ircd     inspircd   2982  17 tcp46  *:6669                *:*
ircd     inspircd   2982  18 tcp46  *:7000                *:*
ircd     inspircd   2982  19 tcp46  *:7001                *:*

 

추가 설치 ssl 및 ldap 설정… (차후작성)

기본설치 만으로 irc  서버의 운영을 권장 하지 않으며 LDAP 및 SSL 인증과 묶어서 사용을 권장 합니다.

Default 설치후 보안 설정 없이 irc server 의 운영은 보안에 안좋습니다.

감사합니다. 🙂

irc client weechat 설치 의 경우 아래 링크를 참고해 주세요.

FreeBSD weechat irc Client install

 

 

gnutls ssl 인증서 를 사용하여 inspircd 설정

인증서 생성 openssl 이용한 방법

root@bsd11:~ # cd /usr/local/etc/inspircd/
root@bsd11:/usr/local/etc/inspircd # mkdir sslcert/
root@bsd11:/usr/local/etc/inspircd/sslcert # openssl req -x509 -nodes -newkey rsa:1024 -keyout key.pem -out cert.pem
Generating a 1024 bit RSA private key
....++++++
....++++++
writing new private key to 'key.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:KO
State or Province Name (full name) [Some-State]:seoul
Locality Name (eg, city) []:city
Organization Name (eg, company) [Internet Widgits Pty Ltd]:testirc
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:testirc
Email Address []:test@test.com

 

certtool 이용한 방법

# certtool --generate-privkey --outfile key.pem
# certtool --generate-self-signed --load-privkey key.pem --outfile cert.pem

 

 

inspircd.conf 파일을 설정 합니다.

root@bsd11:~ # cd /usr/local/etc/inspircd/
root@bsd11:/usr/local/etc/inspircd # vi inspircd.conf

<include file="examples/modules.conf">


<bind address="" port="6667" type="clients" ssl="gnutls">
<bind address="" port="6666" type="servers" ssl="gnutls">
#<gnutls cafile="" crlfile="" certfile="/usr/local/etc/inspircd/sslcert/cert.pem" keyfile="/usr/local/etc/inspircd/sslcert/key.pem" priority="NORMAL:-MD5" hash="sha1">
<gnutls cafile="" crlfile="" certfile="/usr/local/etc/inspircd/sslcert/cert.pem" keyfile="/usr/local/etc/inspircd/sslcert/key.pem" dh_bits="1024">


<include file="examples/opers.conf.example">
<files motd="examples/motd.txt.example" rules="examples/rules.txt.example">

root@bsd11:/usr/local/etc/inspircd # cd examples/
root@bsd11:/usr/local/etc/inspircd/examples # cp modules.conf.example modules.conf

root@bsd11:/usr/local/etc/inspircd/examples # vi modules.conf

<module name="m_md5.so">
<module name="m_ssl_gnutls.so">
<module name="m_spanningtree.so">

 

weechat 설정

irc.conf 파일에서 아래와 같이 설정을 변경 합니다.

$ cd .weechat/
$ vi irc.conf
ssl = on
ssl_cert = ""
ssl_dhkey_size = 1024
ssl_verify = off

 

 

접속후 화면

irc server 의 ssl ports 가 정상적으로 open 안된 경우 아래와 같은 메시지가 출력됩니다.

x11:17:13 testirc =!= | irc: TLS handshake failed
x11:17:13 testirc =!= | irc: error: An unexpected TLS packet was received.
x11:17:13 testirc -- | irc: reconnecting to server in 10 seconds

 

 

FreeBSD weechat irc Client install

IRC Server 를 설치 하다 보니 weechat 을 오랜만에 설치 합니다.

심플하게 terminal 에서 irc 를 사용한다고 하면 weechat 이 좋을거 같습니다.

gnome 이나 xfce Desktop 사용시에는 xirc 를 추천 합니다. 🙂

Linux irc Client 의 경우 https://www.tecmint.com/best-irc-clients-for-linux/ 사이트에서 가장 많이쓰는 irc client 를 확인할수 있습니다.

 

ports 로 weechat 설치

설치하다가 오류가 나서 pkg 로 설치 했습니다.

root@bsd11-Client:~ # whereis weechat
weechat: /usr/ports/irc/weechat

root@bsd11-Client:~ # cd /usr/ports/irc/weechat && make install clean

===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[6]: stopped in /usr/ports/emulators/tpm-emulator
*** Error code 1

Stop.
make[5]: stopped in /usr/ports/security/trousers
*** Error code 1

Stop.
make[4]: stopped in /usr/ports/security/trousers
*** Error code 1

Stop.
make[3]: stopped in /usr/ports/security/gnutls
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/security/gnutls
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/irc/weechat
*** Error code 1

Stop.
make: stopped in /usr/ports/irc/weechat
root@bsd11-Client:/usr/ports/irc/weechat # make MAKE_JOBS_UNSAFE=yes install clean
~중략

[0/1] /usr/local/bin/cmake -H/usr/ports/emulators/tpm-emulator/work/tpm_emulator-0.7.4 -B/usr/ports/emulators/tpm-emulator/work/.build
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/ports/emulators/tpm-emulator/work/.build
ninja: error: manifest 'build.ninja' still dirty after 100 tries

*** Error code 1

Stop.
make[6]: stopped in /usr/ports/emulators/tpm-emulator
*** Error code 1

Stop.
make[5]: stopped in /usr/ports/security/trousers
*** Error code 1

Stop.

 

 

pkg 명령어로 weechat 을 설치 합니다.

검색을 해보니 그냥 바이너리로 설치하는게 방법일거 같아서 pkg 명령어를 이용하여 설치 합니다.

서버 데몬이 아닌 간단히 의존성 없는 APP를 설치할 경우 pkg 를 이용하는것이 시간과 정신건강에 좋습니다.  🙂

root@bsd11-Client:~ # pkg install weechat
To run tcsd automatically, add the following line to /etc/rc.conf:

tcsd_enable="YES"

You might want to edit /usr/local/etc/tcsd.conf to reflect your setup.

If you want to use tcsd with software TPM emulator, use the following
configuration in /etc/rc.conf:

tcsd_enable="YES"
tcsd_mode="emulator"
tpmd_enable="YES"

To use TPM, add your_account to '_tss' group like following:

# pw groupmod _tss -m your_account
Message from lua52-5.2.4:

===> NOTICE:

The lua52 port currently does not have a maintainer. As a result, it is
more likely to have unresolved issues, not be up-to-date, or even be removed in
the future. To volunteer to maintain this port, please create an issue at:

https://bugs.freebsd.org/bugzilla

More information about port maintainership is available at:

https://www.freebsd.org/doc/en/articles/contributing/ports-contributing.html#maintain-port
root@bsd11-Client:~ #

sysrc 를 통하여 Deamon 을 enable 시켜줍니다. 
root@bsd11-Client:~ # sysrc tcsd_enable="YES"
tcsd_enable: -> YES
root@bsd11-Client:~ # sysrc tcsd_mode="emulator"
tcsd_mode: -> emulator
root@bsd11-Client:~ # sysrc tpmd_enable="YES"
tpmd_enable: -> YES
root@bsd11-Client:~ # cat /etc/rc.conf
hostname="bsd11-Client"
keymap="us.iso.kbd"
ifconfig_em0="DHCP"
sshd_enable="YES"
powerd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"
tcsd_enable="YES"
tcsd_mode="emulator"
tpmd_enable="YES"
root@bsd11-Client:~ #

 

일반유저에서 weechat 을 실행 합니다.

$ whoami
test1
$ weechat-curses

아래와 같은 화면을 볼수 있습니다.

/server add testirc 192.168.0.100/6667 를 입력하여 접속할 서버의 config 를 생성 합니다.

.weechat 디렉토리의 irc.conf 파일에 [server] 섹션 부분이 추가 됩니다.

/exit

exit 를 입력하여 weechat 에서 빠져 나옵니다.

weechat 을 실행 하고 나면 user directory 에 .weechat 디렉토리가 생성 됩니다.

 

.weechat 디렉토리의 irc.conf 파일을 설정 합니다. 

일반적인 접속 테스트만 진행하기 위하여 address 부분과 autoconnect , nick , username 만 설정 하였습니다.

$ vi irc.conf

[server_default]
addresses = "192.168.0.100/6667"
anti_flood_prio_high = 2
anti_flood_prio_low = 2
autoconnect = on
autojoin = ""
autoreconnect = on
autoreconnect_delay = 10
autorejoin = off
autorejoin_delay = 30
away_check = 0
away_check_max_nicks = 25
capabilities = ""
command = ""
command_delay = 0
connection_timeout = 60
ipv6 = off
local_hostname = ""
msg_kick = ""
msg_part = "WeeChat ${info:version}"
msg_quit = "WeeChat ${info:version}"
nicks = "test1,test11,test12,test13,test14"
nicks_alternate = on
notify = ""
password = ""
proxy = ""
realname = ""
sasl_fail = continue
sasl_key = ""
sasl_mechanism = plain
sasl_password = ""
sasl_timeout = 15
sasl_username = ""
split_msg_max_length = 512
ssl = off
ssl_cert = ""
ssl_dhkey_size = 2048
ssl_fingerprint = ""
ssl_priorities = "NORMAL:-VERS-SSL3.0"
ssl_verify = on
usermode = ""
username = "test1"


[server]
testirc.addresses = "192.168.0.100/6667"
testirc.proxy = ""
testirc.ipv6
testirc.ssl
testirc.ssl_cert = ""
testirc.ssl_priorities
testirc.ssl_dhkey_size
testirc.ssl_fingerprint = ""
testirc.ssl_verify
testirc.password
testirc.capabilities
testirc.sasl_mechanism
testirc.sasl_username
testirc.sasl_password
testirc.sasl_key
testirc.sasl_timeout
testirc.sasl_fail
testirc.autoconnect
testirc.autoreconnect
testirc.autoreconnect_delay
testirc.nicks = "test"
testirc.nicks_alternate
testirc.username = "test"
testirc.realname
testirc.local_hostname
testirc.usermode
testirc.command
testirc.command_delay
testirc.autojoin
testirc.autorejoin
testirc.autorejoin_delay
testirc.connection_timeout
testirc.anti_flood_prio_high
testirc.anti_flood_prio_low
testirc.away_check
testirc.away_check_max_nicks
testirc.msg_kick
testirc.msg_part
testirc.msg_quit
testirc.notify
testirc.split_msg_max_length

설정내용은 별도로 주석을 달지 않았습니다.

설정내용은 차후 업데이트 하도록 하겠습니다.

 

weechat 을 접속하여 irc server 에 접속을 합니다. 

$ weechat-curses

/join #testirc

channel 로 접속을 합니다.

weechat 설치가 완료 되었습니다. 🙂

 

charset 의 경우 .weechat 디렉토리의 $ charset.conf 에서 설정 할수 있습니다.

charset 의 경우 아래와 같이 변경 할수 있습니다. 

$ cd .weechat/
$ vi charset.conf
[default]
decode = "iso-8859-1"
encode = "UTF8"

decode 를 UTF8 로 변경 하여도 다시 iso-8859-1 로 변경 됩니다.

Locale 변경

freebsd 의 경우 Default C 로 locale 이 설정 되어 있습니다.

사용하는 user locale 을 변경 하기 위해선 home Directory 의 .login_conf 파일 수정이 필요 합니다.

$ vi .login_conf

# see login.conf(5)
#
#me:\
# :charset=iso-8859-1:\
# :lang=de_DE.ISO8859-1:
me:\
:charset=ko_KR.UTF-8:\
:lang=ko_KR.UTF-8:

재접속후 확인
$ locale
LANG=ko_KR.UTF-8
LC_CTYPE="ko_KR.UTF-8"
LC_COLLATE="ko_KR.UTF-8"
LC_TIME="ko_KR.UTF-8"
LC_NUMERIC="ko_KR.UTF-8"
LC_MONETARY="ko_KR.UTF-8"
LC_MESSAGES="ko_KR.UTF-8"
LC_ALL=
$

 

irc 접속하여 한글 테스트

혹시나 charset decode 부분을 UTF8 로 변경이 가능할수 있을거 같아 찾아 봤지만..

이런 메시지를 확인 했습니다. 🙂

 

weechat 에서 설정을 바꿀경우 /set charset.default.decode “UTF8” 으로도 바꿀수 있지만 decode 를 바꾸면 아래와 같은 메시지를 확인 할수 있습니다.

x23:21:39 weechat =!= | charset: UTF-8 is not allowed in charset decoding options (it is internal and default charset: decode of UTF-8 is OK even if you specify another
x | charset to decode)
x23:21:39 weechat =!= | Error: failed to set option “charset.default.decode”

 

/set charset 에서 확인시

charset.default.decode string “iso-8859-1”  선택하여 확인 하면 아래와 같은 메시지를 확인 할수 있습니다. 🙂

charset.default.decode: global decoding charset: charset used to decode incoming messages when they are not UTF-8 valid

 

FreeBSD major update 11.1 -> 11.2 update

make world 방법이 아닌 freebsd-update 를 이용한 방법 입니다.

mkae world 의 경우 차후 포스팅 하도록 하겠습니다. 🙂

root@bsd11:~ # freebsd-update upgrade -r 11.2-RELEASE
Looking up update.FreeBSD.org mirrors... none found.
Fetching metadata signature for 11.1-RELEASE from update.FreeBSD.org... done.
Fetching metadata index... done.
Fetching 1 metadata files... done.
Inspecting system... done.

The following components of FreeBSD seem to be installed:
kernel/generic src/src world/base world/doc world/lib32

The following components of FreeBSD do not seem to be installed:
kernel/generic-dbg world/base-dbg world/lib32-dbg

Does this look reasonable (y/n)? y

Fetching metadata signature for 11.2-RELEASE from update.FreeBSD.org... done.

~ 중략

47510....47520....47530....47540....47550....47560....47570....47580....47590....47600....47610....47620....47630....47640....47650....47660....
47670....47680....47690....47700....47710....47720....47730....47740....47750....47760....47770....47780....47790....47800....47810....47820....
47830....47840....47850....47860....47870....47880....47890....47900....47910....47920....47930....47940....47950....47960....47970....47980....
47990....48000....48010....48020....48030....48040....48050....48060....48070....48080....48090....48100....48110....48120....48130....48140....
48150....48160....48170....48180....48190....48200....48210....48220....48230....48240....48250....48260....48270....48280....48290....48300....
48310....48320....48330....48340....48350....48360....48370....48380....48390....48400....48410....48420....48430....48440....48450....48460....
48470....48480....48490....48500....48510.... done.
Applying patches...
Fetching 3598 files...

~중략

The following files will be updated as part of updating to 11.2-RELEASE-p2:
/.cshrc
/.profile
/COPYRIGHT
/bin/[
/bin/cat
/bin/chflags
/bin/chio
/bin/chmod
/bin/cp
/bin/csh
/bin/date
/bin/dd
/bin/df
/bin/domainname
/bin/echo
/bin/ed
/bin/expr
/bin/freebsd-version
/bin/getfacl
/bin/hostname
/bin/kenv
To install the downloaded upgrades, run "/usr/sbin/freebsd-update install".


root@bsd11:~ # /usr/sbin/freebsd-update install
Kernel updates have been installed. Please reboot and run
"/usr/sbin/freebsd-update install" again to finish installing updates.
root@bsd11:~ #
root@bsd11:~ # init 6

 

Rebooting 후 freebsd-update 실행

root@bsd11:~ # freebsd-update install
root@bsd11:~ # init 6

root@bsd11:~ # uname -a
FreeBSD bsd11 11.2-RELEASE-p2 FreeBSD 11.2-RELEASE-p2 #0: Tue Aug 14 21:45:40 UTC 2018 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64

/etc/rc.conf 을 기존 keymap을 us.iso.kdb 에서 us로 변경 해 줍니다.

 

keymap=”us”

root@bsd11:~ # cat /etc/rc.conf
hostname="bsd11"
#keymap="us.iso.kbd"
keymap="us"
ifconfig_em0="DHCP"
sshd_enable="YES"
ntpd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"
root@bsd11:~ #

 

 

 

FreeBSD Z file system ZFS

작성중인 문서 — 2018.03.16

official site: https://www.freebsd.org/doc/handbook/zfs.html

ZFS tuning : https://www.freebsd.org/doc/handbook/zfs-advanced.html

ZFS 특징 및 용어 설명: https://www.freebsd.org/doc/handbook/zfs-term.html#zfs-term-vdev 

 

Test 환경 kvm – FreeBSD11 / Disk VirtIO 3 Disk

ZFS tuning point 의 경우 별도로 테스트 하도록 하겠습니다.

이번 포스트의 경우 FreeBSD 11 환경에서 ZFS 파일시스템만 초점을 맞추도록 하겠습니다.

ZFS 테스트를 위하여 vm 에서 Disk 를 3개 붙였습니다.

 

ZFS  설정

ZFS 사용을 위하여 /boot/loader.conf 를 수정 합니다.

root@bsd11:~ # vi /boot/loader.conf
vfs.zfs.min_auto_ashift=12
zfs_load="YES"

 

ZFS Service 를 실행 하기 위하여 rc.conf 에 zfs_enable 를 추가 합니다.

root@bsd11:~ # sysrc zfs_enable=YES
zfs_enable: NO -> YES
root@bsd11:~ #

 

시스템을 리부팅 합니다.

root@bsd11:~ # init 6

 

 

Disk 확인

kvm 에서 VirtIO 로 Disk 를 붙였기 때문에 /dev/adaX 가 아닌 /dev/vtbDX 로 인식이 됩니다.

root@bsd11:~ # ls -al /dev/vtb*
crw-r-----  1 root  operator  0x3d Mar 13 20:30 /dev/vtbd0
crw-r-----  1 root  operator  0x48 Mar 13 20:30 /dev/vtbd1
crw-r-----  1 root  operator  0x49 Mar 13 20:30 /dev/vtbd2
root@bsd11:~ #

 

Single Disk Pool 추가

root@bsd11:~ # zpool create test /dev/vtbd0
root@bsd11:~ # df -h
Filesystem      Size    Used   Avail Capacity  Mounted on
/dev/ada0s1a     18G    7.0G    9.9G    41%    /
devfs           1.0K    1.0K      0B   100%    /dev
test             19G     23K     19G     0%    /test
root@bsd11:~ #

 

mount 확인

zpool create 명령어로 붙인 test 를 바로 디렉토리에 마운트 합니다. ;;

확인해 보니 zfs 기능을 사용하지 않고 단순하게 test 를 만들고 test 디렉토리에 마운트 하는것으로 보입니다.

root@bsd11:/test # mount
/dev/ada0s1a on / (ufs, local, journaled soft-updates)
devfs on /dev (devfs, local, multilabel)
test on /test (zfs, local, nfsv4acls)

 

ZFS 압축 파일 시스템 ex)

root@bsd11:~ # zfs create test/compressed
# zfs set compression=gzip test/compressed
root@bsd11:~ # zfs set compression=gzip test/compressed

 

ZFS 압축파일 시스템 해제

root@bsd11:~ # zfs set compression=off test/compressed

 

디렉토리 확인

root@bsd11:~ # df -h
Filesystem         Size    Used   Avail Capacity  Mounted on
/dev/ada0s1a        18G    7.0G    9.9G    41%    /
devfs              1.0K    1.0K      0B   100%    /dev
test                19G     23K     19G     0%    /test
test/compressed     19G     23K     19G     0%    /test/compressed
root@bsd11:~ #

 

data 파일시스템을 만들고 데이터 블록 복사본을 2개씩 유지

root@bsd11:~ # zfs create test/data
root@bsd11:~ # zfs copies=2 test/data

 

test 풀의 각 파일 시스템의 사용 가능한 공간은 동일 합니다.

root@bsd11:~ # df -h
Filesystem         Size    Used   Avail Capacity  Mounted on
/dev/ada0s1a        18G    7.0G    9.9G    41%    /
devfs              1.0K    1.0K      0B   100%    /dev
test                19G     23K     19G     0%    /test
test/compressed     19G     23K     19G     0%    /test/compressed
test/data           19G     23K     19G     0%    /test/data
root@bsd11:~ #

 

ZFS pool 삭제

root@bsd11:~ # zfs destroy test/compressed
root@bsd11:~ # zfs destroy test/data
root@bsd11:~ # zpool destroy test

 

 

Z-RAID

디스크 오류로 인한 데이터 손실을 피하는 방법으로 사용할수 있을것으로 보이며, Z-RAID 구성시 3개 이상의 Disk 가 필요 합니다.

Sun™ recommends that the number of devices used in a RAID-Z configuration be between three and nine. 
For environments requiring a single pool consisting of 10 disks or more, consider breaking it up into smaller RAID-Z groups. 
If only two disks are available and redundancy is a requirement, consider using a ZFS mirror. Refer to zpool(8) for more details.

ZFS 구성시 Disk 구성은 3~9 개를 권장 합니다.

 

Disk 확인

root@bsd11:~ # ls -al /dev/vtb*
crw-r-----  1 root  operator  0x3d Mar 13 20:30 /dev/vtbd0
crw-r-----  1 root  operator  0x48 Mar 13 20:30 /dev/vtbd1
crw-r-----  1 root  operator  0x49 Mar 13 20:30 /dev/vtbd2
root@bsd11:~ #

 

Z-RAID  구성

zpool create 명령어로 storage 를 생성 합니다.

root@bsd11:~ # zpool create storage raidz vtbd0 vtbd1 vtbd2

 

home file system 생성

root@bsd11:~ # zfs create storage/home

 

2개의 복사본을 유지 하며 gzip 으로 압축 가능하게 설정

root@bsd11:~ # zfs set copies=2 storage/home
root@bsd11:~ # zfs set compression=gzip storage/home

 

기존 /home  디렉토리 (유저 디렉토리) 를 마이그레이션 합니다.

root@bsd11:~ # cp -rp /home/* /storage/home
root@bsd11:~ # rm -rf /home /usr/home
root@bsd11:~ # ln -s /storage/home /home
root@bsd11:~ # ln -s /storage/home /usr/home

 

기존 유저로 ssh login 을 Test 합니다.

정상적으로 login 이 됩니다.

[root@test ~]# ssh test@bsd11
Last login: Sat Mar  3 21:49:33 2018
FreeBSD 11.1-RELEASE (GENERIC) #0 r321309: Fri Jul 21 02:08:28 UTC 2017

Welcome to FreeBSD!

Release Notes, Errata: https://www.FreeBSD.org/releases/
Security Advisories:   https://www.FreeBSD.org/security/
FreeBSD Handbook:      https://www.FreeBSD.org/handbook/
FreeBSD FAQ:           https://www.FreeBSD.org/faq/
Questions List: https://lists.FreeBSD.org/mailman/listinfo/freebsd-questions/
FreeBSD Forums:        https://forums.FreeBSD.org/

Documents installed with the system are in the /usr/local/share/doc/freebsd/
directory, or can be installed later with:  pkg install en-freebsd-doc
For other languages, replace "en" with a language code like de or fr.

Show the version of FreeBSD installed:  freebsd-version ; uname -a
Please include that output and any error messages when posting questions.
Introduction to manual pages:  man man
FreeBSD directory layout:      man hier

Edit /etc/motd to change this login announcement.
You can change the video mode on all consoles by adding something like
the following to /etc/rc.conf:

        allscreens="80x30"

You can use "vidcontrol -i mode | grep T" for a list of supported text
modes.
                -- Konstantinos Konstantinidis <kkonstan@duth.gr>
$ ls -al
total 22
drwxr-xr-x  3 test  wheel    11 Mar  3 23:42 .
drwxr-xr-x  3 root  wheel     3 Mar 13 21:04 ..
-rw-r--r--  1 test  wheel  1055 Mar  3 21:43 .cshrc
-rw-r--r--  1 test  wheel   254 Mar  3 21:43 .login
-rw-r--r--  1 test  wheel   163 Mar  3 21:43 .login_conf
-rw-------  1 test  wheel   379 Mar  3 21:43 .mail_aliases
-rw-r--r--  1 test  wheel   336 Mar  3 21:43 .mailrc
-rw-r--r--  1 test  wheel   802 Mar  3 21:43 .profile
-rw-------  1 test  wheel   281 Mar  3 21:43 .rhosts
-rw-r--r--  1 test  wheel   849 Mar  3 21:43 .shrc
drwxr-xr-x  2 test  wheel     3 Mar  3 23:42 public_html
$ whoami
test

 

ZFS snapshot 생성

root@bsd11:~ # zfs snapshot storage/home@2018-03-13

 

ZFS snapshot rollback Test

Test 를 위하여 public_html 을 삭제 합니다.

root@bsd11:~ # ls -al /home/test/ |grep -i public_html
drwxr-xr-x  2 test  wheel     3 Mar  3 23:42 public_html
root@bsd11:~ #
root@bsd11:~ # rm -rf /home/test/public_html/
root@bsd11:~ # ls -al /home/test | grep -i publ

 

ZFS rollback  을 테스트 합니다.

zfs list -t 을 지정 하여 snapshot 을 확인 한후 rollback 을 진행 합니다.

root@bsd11:~ # zfs list -t snapshot
NAME                      USED  AVAIL  REFER  MOUNTPOINT
storage/home@2017-03-13  32.0K      -  57.3K  -
root@bsd11:~ #
root@bsd11:~ # zfs rollback storage/home@2018-03-13
root@bsd11:~ # ls -al /home/test/ |grep -i public_html
drwxr-xr-x  2 test  wheel     3 Mar  3 23:42 public_html
root@bsd11:~ #

 

ZFS snapshot 제거

snapshot 제거및 snapshot 확인

root@bsd11:~ # zfs destroy storage/home@2018-03-13
root@bsd11:~ # zfs list -t snapshot
no datasets available
root@bsd11:~ #

 

 

ZFS 복구

 

모든 Z-RAID 를 확인 합니다.

root@bsd11:~ # zpool status -x
all pools are healthy
root@bsd11:~ #

모든 풀이 온라인 상태이며 정상 입니다.

 

Disk 확인

root@bsd11:~ # zpool status
  pool: storage
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        storage     ONLINE       0     0     0
          raidz1-0  ONLINE       0     0     0
            vtbd0   ONLINE       0     0     0
            vtbd1   ONLINE       0     0     0
            vtbd2   ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

 

비정상일시 아래와 같이 출력됩니다.

  pool: storage
 state: DEGRADED
status: One or more devices has been taken offline by the administrator.
	Sufficient replicas exist for the pool to continue functioning in a
	degraded state.
action: Online the device using 'zpool online' or replace the device with
	'zpool replace'.
 scrub: none requested
config:

	NAME        STATE     READ WRITE CKSUM
	storage     DEGRADED     0     0     0
	  raidz1    DEGRADED     0     0     0
	    da0     ONLINE       0     0     0
	    da1     OFFLINE      0     0     0
	    da2     ONLINE       0     0     0

errors: No known data errors

 

 

ZFS Disk 중 vtbd0 Disk 를 offline 으로 상태를 변경 합니다.

만약 Disk 가 하드웨어 이상이라고 하여도 아래와 같이 메시지가 출력 되며 System 을 Shutdown 후 Disk 교체후 storage 볼륨에 Repalace 하면 됩니다.

root@bsd11:~ # zpool status
  pool: storage
 state: DEGRADED
status: One or more devices has been taken offline by the administrator.
        Sufficient replicas exist for the pool to continue functioning in a
        degraded state.
action: Online the device using 'zpool online' or replace the device with
        'zpool replace'.
  scan: none requested
config:

        NAME                     STATE     READ WRITE CKSUM
        storage                  DEGRADED     0     0     0
          raidz1-0               DEGRADED     0     0     0
            4767353646844092173  OFFLINE      0     0     0  was /dev/vtbd0
            vtbd1                ONLINE       0     0     0
            vtbd2                ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

Replace 명령어는 다음과 같습니다.

zpool replace $zfs_pool_name $disk_name

root@bsd11:~ # zpool replace storage vtbd0
invalid vdev specification
use '-f' to override the following errors:
/dev/vtbd0 is part of active pool 'storage'
root@bsd11:~ #

 

 

붙어 있는 Disk 를 그대로 활용할 경우 zfs online 으로 설정 하시면 됩니다.

별도로 Disk 를 붙여서 replace 할경우에만 zpool replace storage 를 사용 하면 됩니다.

root@bsd11:~ # zpool replace storage vtbd0
invalid vdev specification
use '-f' to override the following errors:
/dev/vtbd0 is part of active pool 'storage'
root@bsd11:~ # zpool online storage vtbd0
root@bsd11:~ # zpool status
  pool: storage
 state: ONLINE
  scan: resilvered 17.5K in 0h0m with 0 errors on Tue Mar 13 22:16:57 2018
config:

        NAME        STATE     READ WRITE CKSUM
        storage     ONLINE       0     0     0
          raidz1-0  ONLINE       0     0     0
            vtbd0   ONLINE       0     0     0
            vtbd1   ONLINE       0     0     0
            vtbd2   ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

Disk 를 변경하여 테스트

root@bsd11:~ # zpool status
  pool: storage
 state: DEGRADED
status: One or more devices has been taken offline by the administrator.
        Sufficient replicas exist for the pool to continue functioning in a
        degraded state.
action: Online the device using 'zpool online' or replace the device with
        'zpool replace'.
  scan: resilvered 17.5K in 0h0m with 0 errors on Tue Mar 13 22:16:57 2018
config:

        NAME                     STATE     READ WRITE CKSUM
        storage                  DEGRADED     0     0     0
          raidz1-0               DEGRADED     0     0     0
            4767353646844092173  OFFLINE      0     0     0  was /dev/vtbd0
            vtbd1                ONLINE       0     0     0
            vtbd2                ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

vm Shtudown 후 10G Volume 을 추가 하였습니다.

root@bsd11:~ # ls -al /dev/vtbd*
crw-r-----  1 root  operator  0x3d Mar 13 22:20 /dev/vtbd0
crw-r-----  1 root  operator  0x48 Mar 13 22:20 /dev/vtbd1
crw-r-----  1 root  operator  0x49 Mar 13 22:20 /dev/vtbd2
crw-r-----  1 root  operator  0x4a Mar 13 22:20 /dev/vtbd3
root@bsd11:~ #

 

Zpool Replace

zfs replace $pool_name $기존disk $신규disk 형식으로 사용 하시면 됩니다.

root@bsd11:~ # zpool replace storage vtbd0 vtbd3
root@bsd11:~ # zpool status
  pool: storage
 state: ONLINE
  scan: resilvered 178K in 0h0m with 0 errors on Tue Mar 13 22:29:36 2018
config:

        NAME        STATE     READ WRITE CKSUM
        storage     ONLINE       0     0     0
          raidz1-0  ONLINE       0     0     0
            vtbd3   ONLINE       0     0     0
            vtbd1   ONLINE       0     0     0
            vtbd2   ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

Data Verification

Checksums can be disabled, but it is not recommended! Checksums take very little storage space and provide data integrity. 
Many ZFS features will not work properly with checksums disabled. 
There is no noticeable performance gain from disabling these checksums.

요약:

zfs 에서는 물결성을 위하여 Checksum을 사용 하며 해당기능을 Disable 할수 있습니다.

성능차이가 미비함으로 Disable 을 하지 않는것이 좋습니다.

 

 

체크섬 확인은 스크러빙 이며 다음 명령어를 사용하여 zfs pool 무결성을 검증할수 있습니다.

root@bsd11:~ # zpool scrub storage

 

 

검사전

scan: resilvered 178K in 0h0m with 0 errors on Tue Mar 13 22:29:36 2018

root@bsd11:~ # zpool status
  pool: storage
 state: ONLINE
  scan: resilvered 178K in 0h0m with 0 errors on Tue Mar 13 22:29:36 2018
config:

        NAME        STATE     READ WRITE CKSUM
        storage     ONLINE       0     0     0
          raidz1-0  ONLINE       0     0     0
            vtbd3   ONLINE       0     0     0
            vtbd1   ONLINE       0     0     0
            vtbd2   ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

 

검사후

scan: scrub repaired 0 in 0h0m with 0 errors on Tue Mar 13 22:35:57 2018

root@bsd11:~ # zpool status storage
  pool: storage
 state: ONLINE
  scan: scrub repaired 0 in 0h0m with 0 errors on Tue Mar 13 22:35:57 2018
config:

        NAME        STATE     READ WRITE CKSUM
        storage     ONLINE       0     0     0
          raidz1-0  ONLINE       0     0     0
            vtbd3   ONLINE       0     0     0
            vtbd1   ONLINE       0     0     0
            vtbd2   ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

스크럽 지속 시간의 경우 저장된 데이터의 양에 따라 다르며 많은 양의 데이터 확인시 오랜 시간이 걸릴 것입니다. 스크럼 확인시 한번에 하나씩 확인이 가능 합니다.

 

 

Zpool 관리

https://www.freebsd.org/doc/handbook/zfs-zpool.html

ZFS 관리의 경우 2가지 유틸로 나뉘며 zpool 유틸의 경우 풀의 작동을 제어
디스크 추가, 제거 , 교체 및 관리를 합니다.

zfs 유틸리티는 파일 시스템 과 볼륨 모두의 데이터 셋트 생성, 삭제를 관리 합니다.

 

 

pool 생성및 제거

mirror pool 을 생성합니다.

root@bsd11:~ # zpool create testpool mirror /dev/vtbd0 /dev/vtbd1
invalid vdev specification
use '-f' to override the following errors:
/dev/vtbd0 is part of potentially active pool 'storage'
root@bsd11:~ #

기존에 storage pool 에서 사용하여 정상적으로 생성이 안됩니다.

 

zpool labelclear 로 GPT 헤더를 삭제 합니다.

root@bsd11:~ # zpool labelclear -f /dev/vtbd0
root@bsd11:~ # zpool labelclear -f /dev/vtbd1
root@bsd11:~ # zpool labelclear -f /dev/vtbd2
root@bsd11:~ # zpool labelclear -f /dev/vtbd3

 

zpool create 로 testpool 을 mirror 로 생성 합니다.

root@bsd11:~ # zpool create testpool mirror /dev/vtbd0 /dev/vtbd1
root@bsd11:~ # zpool status
  pool: testpool
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        testpool    ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            vtbd0   ONLINE       0     0     0
            vtbd1   ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

여러 vdev 를 만들때는 아래와 같이 생성 합니다.

zfs 용어의 경우 포스트 최상의 링크중 zfs 특징및 용어 설명을 참고 하시기 바랍니다.

root@bsd11:~ # zpool create testpool mirror /dev/vtbd0 /dev/vtbd1 mirror /dev/vtbd2 /dev/vtbd3
root@bsd11:~ # zpool status
  pool: testpool
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        testpool    ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            vtbd0   ONLINE       0     0     0
            vtbd1   ONLINE       0     0     0
          mirror-1  ONLINE       0     0     0
            vtbd2   ONLINE       0     0     0
            vtbd3   ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

RAID-Z2 pool 생성

root@bsd11:~ # zpool create testpool raidz2 /dev/vtbd0p1 /dev/vtbd0p2 /dev/vtbd0p3 /dev/vtbd0p4 /dev/vtbd0p5 /dev/vtbd0p6
root@bsd11:~ # zpool status
  pool: testpool
 state: ONLINE
  scan: none requested
config:

        NAME         STATE     READ WRITE CKSUM
        testpool     ONLINE       0     0     0
          raidz2-0   ONLINE       0     0     0
            vtbd0p1  ONLINE       0     0     0
            vtbd0p2  ONLINE       0     0     0
            vtbd0p3  ONLINE       0     0     0
            vtbd0p4  ONLINE       0     0     0
            vtbd0p5  ONLINE       0     0     0
            vtbd0p6  ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

 

장치 추가 및 제거

zpool attach 를 시용 하여 기존 vdev 에 디스크를 추가하거나, zpool add를 사용하여 vdev를 풀에 추가 할수 있습니다.

단일 디스크의 경우 중복성이 없기 때문에 손상이 발견 되었을시 복구 되지 않습니다.

zpool attach 를 사용하여 vdev에 디스크를 추가 하여 미러를 생성할수 있으며 중복성과 읽기 성능을 향상시킬수 있습니다.

root@bsd11:~ # zpool create testpool /dev/vtbd0p1
root@bsd11:~ # zpool status
  pool: testpool
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        testpool    ONLINE       0     0     0
          vtbd0p1   ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

zpool attach 명령어를 이용하여 mirror 구성을 합니다.

root@bsd11:~ # zpool attach testpool vtbd0p1 vtbd0p2
root@bsd11:~ # zpool status
  pool: testpool
 state: ONLINE
  scan: resilvered 78.5K in 0h0m with 0 errors on Thu Mar 15 21:22:36 2018
config:

        NAME         STATE     READ WRITE CKSUM
        testpool     ONLINE       0     0     0
          mirror-0   ONLINE       0     0     0
            vtbd0p1  ONLINE       0     0     0
            vtbd0p2  ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

Test 를 위하여 vm 을 zfs 로 설치 하였으며
Disk 를 동일하게 40G x2개 붙였습니다.

OS 40G Test Disk 40G

기존 Disk 의 ada0p3 용량을 확인 합니다.

root@bsd11:~ # gpart list
Geom name: ada0
modified: false
state: OK
fwheads: 16
fwsectors: 63
last: 83886039
first: 40
entries: 152
scheme: GPT
Providers:
1. Name: ada0p1
   Mediasize: 524288 (512K)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 20480
   Mode: r0w0e0
   rawuuid: edce08d3-2127-11e8-a62a-8fd7aec5b81f
   rawtype: 83bd6b9d-7f41-11dc-be0b-001560b84f0f
   label: gptboot0
   length: 524288
   offset: 20480
   type: freebsd-boot
   index: 1
   end: 1063
   start: 40
2. Name: ada0p2
   Mediasize: 2147483648 (2.0G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 1048576
   Mode: r1w1e0
   rawuuid: edd96866-2127-11e8-a62a-8fd7aec5b81f
   rawtype: 516e7cb5-6ecf-11d6-8ff8-00022d09712b
   label: swap0
   length: 2147483648
   offset: 1048576
   type: freebsd-swap
   index: 2
   end: 4196351
   start: 2048
3. Name: ada0p3
   Mediasize: 40800092160 (38G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 2148532224
   Mode: r1w1e1
   rawuuid: ede26582-2127-11e8-a62a-8fd7aec5b81f
   rawtype: 516e7cba-6ecf-11d6-8ff8-00022d09712b
   label: zfs0
   length: 40800092160
   offset: 2148532224
   type: freebsd-zfs
   index: 3
   end: 83884031
   start: 4196352
Consumers:
1. Name: ada0
   Mediasize: 42949672960 (40G)
   Sectorsize: 512
   Mode: r2w2e3

 

신규 디스크의 용량을 설정 합니다.

root@bsd11:~ # gpart create -s GPT ada1
ada1 created
root@bsd11:~ # gpart add -t freebsd-zfs -s 512K ada1
ada1p1 added
root@bsd11:~ # gpart add -t freebsd-zfs -s 2G ada1
ada1p2 added
root@bsd11:~ # gpart add -t freebsd-zfs  ada1
ada1p3 added
root@bsd11:~ #
root@bsd11:~ # gpart show
=>      40  83886000  ada0  GPT  (40G)
        40      1024     1  freebsd-boot  (512K)
      1064       984        - free -  (492K)
      2048   4194304     2  freebsd-swap  (2.0G)
   4196352  79687680     3  freebsd-zfs  (38G)
  83884032      2008        - free -  (1.0M)

=>      40  83886000  ada1  GPT  (40G)
        40      1024     1  freebsd-zfs  (512K)
      1064   4194304     2  freebsd-zfs  (2.0G)
   4195368  79690672     3  freebsd-zfs  (38G)

root@bsd11:~ #

 

zpool attach zroot vdev 에 ada1p3 를 추가 합니다.

root@bsd11:~ # zpool status
  pool: zroot
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       ONLINE       0     0     0
          ada0p3    ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ # zpool attach zroot ada0p3 ada1p3
Make sure to wait until resilver is done before rebooting.

If you boot from pool 'zroot', you may need to update
boot code on newly attached disk 'ada1p3'.

Assuming you use GPT partitioning and 'da0' is your new boot disk
you may use the following command:

        gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0

root@bsd11:~ #

 

gpart 명령어로 부팅 가능하게 설정 합니다.

root@bsd11:~ # gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada1
partcode written to ada1p1
bootcode written to ada1
root@bsd11:~ # zpool status
  pool: zroot
 state: ONLINE
status: One or more devices is currently being resilvered.  The pool will
        continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
  scan: resilver in progress since Thu Mar 15 22:35:38 2018
        4.70G scanned out of 6.65G at 50.2M/s, 0h0m to go
        4.70G resilvered, 70.75% done
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            ada0p3  ONLINE       0     0     0
            ada1p3  ONLINE       0     0     0  (resilvering)

errors: No known data errors
root@bsd11:~ #

 

resilvering 의 경우 ada0p3 의 내용을 ada1p3 로 mirror 구성 하게 되며 시간이 다소 걸립니다.

(용량에 따라 차등합니다.)

완료후 상태

root@bsd11:~ # zpool status
  pool: zroot
 state: ONLINE
  scan: resilvered 6.65G in 0h2m with 0 errors on Thu Mar 15 22:37:50 2018
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            ada0p3  ONLINE       0     0     0
            ada1p3  ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

testpool 을 생성 합니다. vtbd0 와 vtbd1 Disk 를 추가 하였습니다.

root@bsd11:~ # zpool create testpool mirror /dev/vtbd0 /dev/vtbd1
root@bsd11:~ # zpool status
  pool: testpool
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        testpool    ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            vtbd0   ONLINE       0     0     0
            vtbd1   ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

지금 상태에서는 vtbdX Disk 를 제거 할수 없습니다.

Disk 를 추가 합니다.

root@bsd11:~ # zpool add testpool mirror vtbd2 vtbd3
root@bsd11:~ # zpool status
  pool: testpool
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        testpool    ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            vtbd0   ONLINE       0     0     0
            vtbd1   ONLINE       0     0     0
          mirror-1  ONLINE       0     0     0
            vtbd2   ONLINE       0     0     0
            vtbd3   ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

Test 를 위하여 vtbd2 Disk 를 제거 합니다.

충분한 여분의 중복이 있는 경우에만 Disk 를 제거 할수 있습니다.
미러구룹에 있는 하나의 디스크는 스트라이프로 동작합니다.

root@bsd11:~ # zpool detach testpool vtbd2
root@bsd11:~ # zpool status
  pool: testpool
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        testpool    ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            vtbd0   ONLINE       0     0     0
            vtbd1   ONLINE       0     0     0
          vtbd3     ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

POOL 상태 체크

 

Disk 교체

zpool replace 는 이전 디스크의 모든 데이터를 새 디스크로 복사 합니다.
작업이 완료되면 이전 디스크가 vdev 에서 연결이 끊어 집니다.

root@bsd11:~ # zpool create testpool mirror /dev/vtbd0 /dev/vtbd1
root@bsd11:~ # zpool status
  pool: testpool
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        testpool    ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            vtbd0   ONLINE       0     0     0
            vtbd1   ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

vtbd1 Disk 를 vtbd2 로 교체 합니다.

root@bsd11:~ # zpool status
  pool: testpool
 state: ONLINE
  scan: resilvered 80K in 0h0m with 0 errors on Thu Mar 15 23:07:04 2018
config:

        NAME        STATE     READ WRITE CKSUM
        testpool    ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            vtbd0   ONLINE       0     0     0
            vtbd2   ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

Scrubbing pool

zfs pool 을 정기적으로 매월 한번이상 scrub 작업을 하는게 좋습니다.
디스크를 많이 사용하는 동안 실행 하면 성능이 저하 됩니다.

root@bsd11:~ # zpool scrub testpool
root@bsd11:~ # zpool status
  pool: testpool
 state: ONLINE
  scan: scrub repaired 0 in 0h0m with 0 errors on Thu Mar 15 23:10:20 2018
config:

        NAME        STATE     READ WRITE CKSUM
        testpool    ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            vtbd0   ONLINE       0     0     0
            vtbd2   ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

Self-Healing Test

데이터 블록과 함께 저장되는 체크섬은 파일 시스템이 자동으로 복구 되도록 합니다.
체크섬이 저장 장치 풀의 다른 Disk 에 기록된 데이터와 일치하는 데이터를 자동으로 복구 합니다.

 

root@bsd11:/usr/local/etc # zpool status
  pool: testpool
 state: ONLINE
  scan: scrub repaired 5K in 0h0m with 0 errors on Thu Mar 15 23:17:43 2018
config:

        NAME        STATE     READ WRITE CKSUM
        testpool    ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            vtbd0   ONLINE       0     0     0
            vtbd1   ONLINE       0     0     0

errors: No known data errors
root@bsd11:/usr/local/etc #

 

Self-healing test 를 위하여 임이의 파일을 복사 한후 checksum 을 생성 합니다.

root@bsd11:~ # cd /usr/local/etc/
root@bsd11:/usr/local/etc # cp * /testpool/
cp: apache24 is a directory (not copied).
cp: bash_completion.d is a directory (not copied).
cp: man.d is a directory (not copied).
cp: newsyslog.conf.d is a directory (not copied).
cp: periodic is a directory (not copied).
cp: php is a directory (not copied).
cp: php-fpm.d is a directory (not copied).
cp: rc.d is a directory (not copied).
cp: ssl is a directory (not copied).
root@bsd11:/usr/local/etc # cd
root@bsd11:~ # sha1 /testpool > checksum.txt
root@bsd11:~ # cat checksum.txt
SHA1 (/testpool) = 34d4723284883bf65b788e6674c7e475dc4102e9
root@bsd11:~ #

 

vtbd0 Disk 를 dd 로 날립니다.

root@bsd11:~ # zpool export testpool
root@bsd11:~ # dd if=/dev/random of=/dev/vtbd0 bs=1m count=200
200+0 records in
200+0 records out
209715200 bytes transferred in 2.680833 secs (78227611 bytes/sec)
root@bsd11:~ #
root@bsd11:~ # zpool import testpool

 

testpool 의 cksum 을 확인 합니다.

root@bsd11:~ # zpool status testpool
  pool: testpool
 state: ONLINE
status: One or more devices has experienced an unrecoverable error.  An
        attempt was made to correct the error.  Applications are unaffected.
action: Determine if the device needs to be replaced, and clear the errors
        using 'zpool clear' or replace the device with 'zpool replace'.
   see: http://illumos.org/msg/ZFS-8000-9P
  scan: scrub repaired 5K in 0h0m with 0 errors on Thu Mar 15 23:17:43 2018
config:

        NAME        STATE     READ WRITE CKSUM
        testpool    ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            vtbd0   ONLINE       0     0     0
            vtbd1   ONLINE       0     0     1

errors: No known data errors
root@bsd11:~ #

 

오류의 영향을 받지 않은 vtbd0 미러 디스크에 있는 중복성 사용을 감지
원본과 체크섬을 비교 하여 동일한지 여부를 출력합니다.

root@bsd11:~ # sha1 /testpool >> checksum.txt
root@bsd11:~ # cat checksum.txt
SHA1 (/testpool) = 34d4723284883bf65b788e6674c7e475dc4102e9
SHA1 (/testpool) = 34d4723284883bf65b788e6674c7e475dc4102e9
root@bsd11:~ #

풀 데이터를 의도적으로 변경 하기 전/후의 체크섬이 동일 합니다.
ZFS 가 체크섬이 다를때 자동으로 오류를 감지 하고 수정합니다.
pool 이 충분한 중복이 있는 경우에만 가능하며 단일 장치로 구성된 풀에는 자체 치유 기능이 없습니다.

 

스크러빙 작업 에서 vtbd0 에서 데이터를 읽고 vtbd1 에 잘못된 체크섬의 데이터를 다시 작성 합니다.

root@bsd11:~ # zpool scrub testpool
root@bsd11:~ # zpool status
  pool: testpool
 state: ONLINE
status: One or more devices has experienced an unrecoverable error.  An
        attempt was made to correct the error.  Applications are unaffected.
action: Determine if the device needs to be replaced, and clear the errors
        using 'zpool clear' or replace the device with 'zpool replace'.
   see: http://illumos.org/msg/ZFS-8000-9P
  scan: scrub repaired 253K in 0h0m with 0 errors on Thu Mar 15 23:30:15 2018
config:

        NAME        STATE     READ WRITE CKSUM
        testpool    ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            vtbd0   ONLINE       0     0     0
            vtbd1   ONLINE       0     0    29

errors: No known data errors
root@bsd11:~ #

 

스크럽작업이 완료되면 zpool clear 를 실행하여 오류를 지울수 있습니다.

root@bsd11:~ # zpool clear testpool
root@bsd11:~ # zpool status
  pool: testpool
 state: ONLINE
  scan: scrub repaired 253K in 0h0m with 0 errors on Thu Mar 15 23:30:15 2018
config:

        NAME        STATE     READ WRITE CKSUM
        testpool    ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            vtbd0   ONLINE       0     0     0
            vtbd1   ONLINE       0     0     0

errors: No known data errors
root@bsd11:~ #

 

imports and export pool

root@bsd11:~ # zpool export testpool
root@bsd11:~ # zpool import
   pool: testpool
     id: 4252914017303616931
  state: ONLINE
 action: The pool can be imported using its name or numeric identifier.
 config:

        testpool    ONLINE
          mirror-0  ONLINE
            vtbd0   ONLINE
            vtbd1   ONLINE
root@bsd11:~ # df -h
Filesystem      Size    Used   Avail Capacity  Mounted on
/dev/ada0s1a     18G    7.8G    9.1G    46%    /
devfs           1.0K    1.0K      0B   100%    /dev
root@bsd11:~ #

 

import -o 옵션을 사용하여 경로를 지정 할수 있습니다.

경로를 지정하게 되면 $경로/$pool_name 로 됩니다.

root@bsd11:~ # zpool import -o altroot=/mnt testpool
root@bsd11:~ # df -h
Filesystem      Size    Used   Avail Capacity  Mounted on
/dev/ada0s1a     18G    7.8G    9.1G    46%    /
devfs           1.0K    1.0K      0B   100%    /dev
testpool        9.6G    265K    9.6G     0%    /mnt/testpool
root@bsd11:~ #

 

Storage pool upgrade

FreeBSD 를 업그레이드 하면 ZFS Version 이 업그레이드 되며 새로운 기능을 지원할수 있습니다. 업그레이드 할수 있지만 다운그레이드는 불가 합니다.

# 이전에 사용하던 pool 도 upgrade 해야 하는지 여부는 확인이 필요 할것으로 보입니다. 🙂

 

root@bsd11:~ # zpool upgrade

 

이전에 사용하던 pool upgrade

root@bsd11:~ # zpool upgrade testpool

 

zpool history

root@bsd11:~ # zpool history
History for 'testpool':
2018-03-15.23:06:26 zpool create testpool mirror /dev/vtbd0 /dev/vtbd1
2018-03-15.23:07:09 zpool replace testpool vtbd1 vtbd2
2018-03-15.23:10:25 zpool scrub testpool
2018-03-15.23:13:10 zpool replace testpool vtbd2 vtbd1
2018-03-15.23:14:25 zpool export testpool
2018-03-15.23:16:48 zpool import testpool
2018-03-15.23:17:48 zpool scrub testpool
2018-03-15.23:18:08 zpool clear testpool
2018-03-15.23:24:30 zpool export testpool
2018-03-15.23:25:49 zpool import testpool
2018-03-15.23:30:20 zpool scrub testpool
2018-03-15.23:32:46 zpool clear testpool
2018-03-15.23:37:30 zpool export testpool
2018-03-15.23:39:04 zpool import -o altroot=/mnt testpool

root@bsd11:~ #

 

-i 옵션 zfs 이벤트 까지 표시

root@bsd11:~ # zpool history -i
History for 'testpool':
2018-03-15.23:06:26 [txg:5] create pool version 5000; software version 5000/5; uts bsd11 11.1-RELEASE 1101001 amd64
2018-03-15.23:06:26 zpool create testpool mirror /dev/vtbd0 /dev/vtbd1
2018-03-15.23:07:04 [txg:16] scan setup func=2 mintxg=3 maxtxg=16
2018-03-15.23:07:04 [txg:17] scan done errors=0
2018-03-15.23:07:04 [txg:18] vdev attach replace vdev=/dev/vtbd2 for vdev=/dev/vtbd1
2018-03-15.23:07:09 [txg:19] detach vdev=/dev/vtbd1
2018-03-15.23:07:09 zpool replace testpool vtbd1 vtbd2
2018-03-15.23:10:20 [txg:57] scan setup func=1 mintxg=0 maxtxg=57
2018-03-15.23:10:20 [txg:58] scan done errors=0
2018-03-15.23:10:25 zpool scrub testpool
2018-03-15.23:13:05 [txg:94] scan setup func=2 mintxg=3 maxtxg=94
2018-03-15.23:13:05 [txg:95] scan done errors=0
2018-03-15.23:13:05 [txg:96] vdev attach replace vdev=/dev/vtbd1 for vdev=/dev/vtbd2
2018-03-15.23:13:10 [txg:97] detach vdev=/dev/vtbd2
2018-03-15.23:13:10 zpool replace testpool vtbd2 vtbd1
2018-03-15.23:14:25 zpool export testpool
2018-03-15.23:16:43 [txg:117] open pool version 5000; software version 5000/5; uts bsd11 11.1-RELEASE 1101001 amd64
2018-03-15.23:16:43 [txg:119] import pool version 5000; software version 5000/5; uts bsd11 11.1-RELEASE 1101001 amd64
2018-03-15.23:16:48 zpool import testpool
2018-03-15.23:17:43 [txg:132] scan setup func=1 mintxg=0 maxtxg=132
2018-03-15.23:17:43 [txg:133] scan done errors=0
2018-03-15.23:17:48 zpool scrub testpool
2018-03-15.23:18:08 zpool clear testpool
2018-03-15.23:24:30 zpool export testpool
2018-03-15.23:25:44 [txg:219] open pool version 5000; software version 5000/5; uts bsd11 11.1-RELEASE 1101001 amd64
2018-03-15.23:25:44 [txg:221] import pool version 5000; software version 5000/5; uts bsd11 11.1-RELEASE 1101001 amd64
2018-03-15.23:25:49 zpool import testpool
2018-03-15.23:30:15 [txg:276] scan setup func=1 mintxg=0 maxtxg=276
2018-03-15.23:30:15 [txg:277] scan done errors=0
2018-03-15.23:30:20 zpool scrub testpool
2018-03-15.23:32:46 zpool clear testpool
2018-03-15.23:37:30 zpool export testpool
2018-03-15.23:38:58 [txg:369] open pool version 5000; software version 5000/5; uts bsd11 11.1-RELEASE 1101001 amd64
2018-03-15.23:38:58 [txg:371] import pool version 5000; software version 5000/5; uts bsd11 11.1-RELEASE 1101001 amd64
2018-03-15.23:39:04 zpool import -o altroot=/mnt testpool

root@bsd11:~ #

 

-l 옵션 사용자 이름 및 hostname 표시

root@bsd11:~ # zpool history -l
History for 'testpool':
2018-03-15.23:06:26 zpool create testpool mirror /dev/vtbd0 /dev/vtbd1 [user 0 (root) on bsd11]
2018-03-15.23:07:09 zpool replace testpool vtbd1 vtbd2 [user 0 (root) on bsd11]
2018-03-15.23:10:25 zpool scrub testpool [user 0 (root) on bsd11]
2018-03-15.23:13:10 zpool replace testpool vtbd2 vtbd1 [user 0 (root) on bsd11]
2018-03-15.23:14:25 zpool export testpool [user 0 (root) on bsd11]
2018-03-15.23:16:48 zpool import testpool [user 0 (root) on bsd11]
2018-03-15.23:17:48 zpool scrub testpool [user 0 (root) on bsd11]
2018-03-15.23:18:08 zpool clear testpool [user 0 (root) on bsd11]
2018-03-15.23:24:30 zpool export testpool [user 0 (root) on bsd11]
2018-03-15.23:25:49 zpool import testpool [user 0 (root) on bsd11]
2018-03-15.23:30:20 zpool scrub testpool [user 0 (root) on bsd11]
2018-03-15.23:32:46 zpool clear testpool [user 0 (root) on bsd11]
2018-03-15.23:37:30 zpool export testpool [user 0 (root) on bsd11]
2018-03-15.23:39:04 zpool import -o altroot=/mnt testpool [user 0 (root) on bsd11]

root@bsd11:~ #

 

zpool 모니터링

root@bsd11:~ # zpool iostat
               capacity     operations    bandwidth
pool        alloc   free   read  write   read  write
----------  -----  -----  -----  -----  -----  -----
testpool     372K  9.94G      0      0     96    447
root@bsd11:~ #

 

zpool iostat -v  의 Verbose 옵션 입니다.

Disk read/write 까지 표시 됩니다.

root@bsd11:~ # zpool iostat -v
               capacity     operations    bandwidth
pool        alloc   free   read  write   read  write
----------  -----  -----  -----  -----  -----  -----
testpool     372K  9.94G      0      0     82    382
  mirror     372K  9.94G      0      0     82    382
    vtbd0       -      -      0      0  2.02K  1.65K
    vtbd1       -      -      0      0  1.38K  1.65K
----------  -----  -----  -----  -----  -----  -----

root@bsd11:~ #

 

 

ZFS 관리

https://www.freebsd.org/doc/handbook/zfs-zfs.html

zfs 유틸리티는 pool에 있는 ZFS 데이터 세트를 생성, 삭제 및 관리 합니다.

 

데이터 세트 생성 및 제거

root@bsd11:~ # zfs list
NAME                   USED  AVAIL  REFER  MOUNTPOINT
zroot                 6.65G  29.9G    88K  /zroot
zroot/ROOT             627M  29.9G    88K  none
zroot/ROOT/default     627M  29.9G   627M  /
zroot/jails           4.76G  29.9G   112K  /usr/jails
zroot/jails/basejail  1003M  29.9G   979M  /usr/jails/basejail
zroot/jails/database  1.95G  29.9G  1.95G  /usr/jails/database
zroot/jails/httpd     1.83G  29.9G  1.83G  /usr/jails/httpd
zroot/jails/newjail   4.66M  29.9G  4.66M  /usr/jails/newjail
zroot/jails/www       4.75M  29.9G  4.75M  /usr/jails/www
zroot/tmp               88K  29.9G    88K  /tmp
zroot/usr             1.27G  29.9G    88K  /usr
zroot/usr/home          88K  29.9G    88K  /usr/home
zroot/usr/ports        665M  29.9G   665M  /usr/ports
zroot/usr/src          633M  29.9G   633M  /usr/src
zroot/var              604K  29.9G    88K  /var
zroot/var/audit         88K  29.9G    88K  /var/audit
zroot/var/crash         88K  29.9G    88K  /var/crash
zroot/var/log          164K  29.9G   164K  /var/log
zroot/var/mail          88K  29.9G    88K  /var/mail
zroot/var/tmp           88K  29.9G    88K  /var/tmp
root@bsd11:~ #

 

신규 데이터 세트를 생성 하고 LZ4 압축을 활성화 합니다.

root@bsd11:~ # zfs create -o compress=lz4 zroot/zroottest
root@bsd11:~ # zfs list
NAME                   USED  AVAIL  REFER  MOUNTPOINT
zroot                 6.65G  29.9G    88K  /zroot
zroot/ROOT             627M  29.9G    88K  none
zroot/ROOT/default     627M  29.9G   627M  /
zroot/jails           4.76G  29.9G   112K  /usr/jails
zroot/jails/basejail  1003M  29.9G   979M  /usr/jails/basejail
zroot/jails/database  1.95G  29.9G  1.95G  /usr/jails/database
zroot/jails/httpd     1.83G  29.9G  1.83G  /usr/jails/httpd
zroot/jails/newjail   4.66M  29.9G  4.66M  /usr/jails/newjail
zroot/jails/www       4.75M  29.9G  4.75M  /usr/jails/www
zroot/tmp               88K  29.9G    88K  /tmp
zroot/usr             1.27G  29.9G    88K  /usr
zroot/usr/home          88K  29.9G    88K  /usr/home
zroot/usr/ports        665M  29.9G   665M  /usr/ports
zroot/usr/src          633M  29.9G   633M  /usr/src
zroot/var              604K  29.9G    88K  /var
zroot/var/audit         88K  29.9G    88K  /var/audit
zroot/var/crash         88K  29.9G    88K  /var/crash
zroot/var/log          164K  29.9G   164K  /var/log
zroot/var/mail          88K  29.9G    88K  /var/mail
zroot/var/tmp           88K  29.9G    88K  /var/tmp
zroot/zroottest         88K  29.9G    88K  /zroot/zroottest
root@bsd11:~ #

 

이전에 생성된 데이터 세트를 삭제 합니다.

root@bsd11:~ # zfs list
NAME                   USED  AVAIL  REFER  MOUNTPOINT
zroot                 6.65G  29.9G    88K  /zroot
zroot/ROOT             627M  29.9G    88K  none
zroot/ROOT/default     627M  29.9G   627M  /
zroot/jails           4.76G  29.9G   112K  /usr/jails
zroot/jails/basejail  1003M  29.9G   979M  /usr/jails/basejail
zroot/jails/database  1.95G  29.9G  1.95G  /usr/jails/database
zroot/jails/httpd     1.83G  29.9G  1.83G  /usr/jails/httpd
zroot/jails/newjail   4.66M  29.9G  4.66M  /usr/jails/newjail
zroot/jails/www       4.75M  29.9G  4.75M  /usr/jails/www
zroot/tmp               88K  29.9G    88K  /tmp
zroot/usr             1.27G  29.9G    88K  /usr
zroot/usr/home          88K  29.9G    88K  /usr/home
zroot/usr/ports        665M  29.9G   665M  /usr/ports
zroot/usr/src          633M  29.9G   633M  /usr/src
zroot/var              604K  29.9G    88K  /var
zroot/var/audit         88K  29.9G    88K  /var/audit
zroot/var/crash         88K  29.9G    88K  /var/crash
zroot/var/log          164K  29.9G   164K  /var/log
zroot/var/mail          88K  29.9G    88K  /var/mail
zroot/var/tmp           88K  29.9G    88K  /var/tmp
zroot/zroottest         88K  29.9G    88K  /zroot/zroottest
root@bsd11:~ # zfs destroy zroot/zroottest
root@bsd11:~ # zfs list
NAME                   USED  AVAIL  REFER  MOUNTPOINT
zroot                 6.65G  29.9G    88K  /zroot
zroot/ROOT             627M  29.9G    88K  none
zroot/ROOT/default     627M  29.9G   627M  /
zroot/jails           4.76G  29.9G   112K  /usr/jails
zroot/jails/basejail  1003M  29.9G   979M  /usr/jails/basejail
zroot/jails/database  1.95G  29.9G  1.95G  /usr/jails/database
zroot/jails/httpd     1.83G  29.9G  1.83G  /usr/jails/httpd
zroot/jails/newjail   4.66M  29.9G  4.66M  /usr/jails/newjail
zroot/jails/www       4.75M  29.9G  4.75M  /usr/jails/www
zroot/tmp               88K  29.9G    88K  /tmp
zroot/usr             1.27G  29.9G    88K  /usr
zroot/usr/home          88K  29.9G    88K  /usr/home
zroot/usr/ports        665M  29.9G   665M  /usr/ports
zroot/usr/src          633M  29.9G   633M  /usr/src
zroot/var              604K  29.9G    88K  /var
zroot/var/audit         88K  29.9G    88K  /var/audit
zroot/var/crash         88K  29.9G    88K  /var/crash
zroot/var/log          164K  29.9G   164K  /var/log
zroot/var/mail          88K  29.9G    88K  /var/mail
zroot/var/tmp           88K  29.9G    88K  /var/tmp
root@bsd11:~ #

zfs 최신 버전의 경우 zfs destroy 가 비동식 으로 동작 합니다.
여유공간이 풀에 표시되는데 몇분 정도 걸릴수 있습니다.

 

볼륨 생성 및 삭제

zfs 볼륨은 모든 파일 시스템으로 포멧될수 있으며, 파일 시스템 없이 원시 데이터를
저장 할수 있습니다. 사용자에게는 볼륨은 일반 디스크처럼 보입니다.

root@bsd11:~ # zfs create -V 250m -o compression=on zroot/fat32
root@bsd11:~ # zfs list zroot
NAME    USED  AVAIL  REFER  MOUNTPOINT
zroot  6.90G  29.7G    88K  /zroot
root@bsd11:~ # zfs list
NAME                   USED  AVAIL  REFER  MOUNTPOINT
zroot                 6.90G  29.7G    88K  /zroot
zroot/ROOT             627M  29.7G    88K  none
zroot/ROOT/default     627M  29.7G   627M  /
zroot/fat32            260M  29.9G    56K  -
zroot/jails           4.76G  29.7G   112K  /usr/jails
zroot/jails/basejail  1003M  29.7G   979M  /usr/jails/basejail
zroot/jails/database  1.95G  29.7G  1.95G  /usr/jails/database
zroot/jails/httpd     1.83G  29.7G  1.83G  /usr/jails/httpd
zroot/jails/newjail   4.66M  29.7G  4.66M  /usr/jails/newjail
zroot/jails/www       4.75M  29.7G  4.75M  /usr/jails/www
zroot/tmp               88K  29.7G    88K  /tmp
zroot/usr             1.27G  29.7G    88K  /usr
zroot/usr/home          88K  29.7G    88K  /usr/home
zroot/usr/ports        665M  29.7G   665M  /usr/ports
zroot/usr/src          633M  29.7G   633M  /usr/src
zroot/var              604K  29.7G    88K  /var
zroot/var/audit         88K  29.7G    88K  /var/audit
zroot/var/crash         88K  29.7G    88K  /var/crash
zroot/var/log          164K  29.7G   164K  /var/log
zroot/var/mail          88K  29.7G    88K  /var/mail
zroot/var/tmp           88K  29.7G    88K  /var/tmp
root@bsd11:~ #

 

zroot 볼륨의 fat32 를 msdos 타입으로 포멧 한후 /mnt 에 마운트 합니다.

-F32 지정시 잘못된 인수로 인식 하여 -F 옵션 없이 테스트 하였습니다.

root@bsd11:~ # newfs_msdos  /dev/zvol/zroot/fat32
newfs_msdos: cannot get number of sectors per track: Operation not supported
newfs_msdos: cannot get number of heads: Operation not supported
newfs_msdos: trim 62 sectors to adjust to a multiple of 63
/dev/zvol/zroot/fat32: 511648 sectors in 31978 FAT16 clusters (8192 bytes/cluster)
BytesPerSec=512 SecPerClust=16 ResSectors=1 FATs=2 RootDirEnts=512 Media=0xf0 FATsecs=125 SecPerTrack=63 Heads=16 HiddenSecs=0 HugeSectors=511938
root@bsd11:~ # mount -t msdosfs /dev/zvol/zroot/fat32 /mnt
mount_msdosfs: /dev/zvol/zroot/fat32: Invalid argument
root@bsd11:~ # mount -t msdosfs /dev/zvol/zroot/fat32 /mnt
root@bsd11:~ # df -h |grep -i mnt
/dev/zvol/zroot/fat32    250M     16K    250M     0%    /mnt
root@bsd11:~ # mount |grep -i mnt
/dev/zvol/zroot/fat32 on /mnt (msdosfs, local)
root@bsd11:~ #

 

데이터세트 이름변경

데이터 세트의 이름은 zfs rename 으로 변경 할수 있으며 최상위 볼륨의 이름도 변경 할수 있습니다. 최상위 볼륨의 이름을 변경 하게 되면 상속된 속성값이 변경 됩니다.
데이터 세트의 이름을 변경하면 마운트를 해제된 다음 새 위치 에서 다시 마운트 됩니다.
-u 옵션 사용시 해당 remount 를 방지 할수 있습니다.

root@bsd11:~ # zfs list
NAME                   USED  AVAIL  REFER  MOUNTPOINT
zroot                 6.90G  29.7G    88K  /zroot
zroot/ROOT             627M  29.7G    88K  none
zroot/ROOT/default     627M  29.7G   627M  /
zroot/fat32            260M  29.9G    68K  -
zroot/jails           4.76G  29.7G   112K  /usr/jails
zroot/jails/basejail  1003M  29.7G   979M  /usr/jails/basejail
zroot/jails/database  1.95G  29.7G  1.95G  /usr/jails/database
zroot/jails/httpd     1.83G  29.7G  1.83G  /usr/jails/httpd
zroot/jails/newjail   4.66M  29.7G  4.66M  /usr/jails/newjail
zroot/jails/www       4.75M  29.7G  4.75M  /usr/jails/www
zroot/tmp               88K  29.7G    88K  /tmp
zroot/usr             1.27G  29.7G    88K  /usr
zroot/usr/home          88K  29.7G    88K  /usr/home
zroot/usr/ports        665M  29.7G   665M  /usr/ports
zroot/usr/src          633M  29.7G   633M  /usr/src
zroot/var              604K  29.7G    88K  /var
zroot/var/audit         88K  29.7G    88K  /var/audit
zroot/var/crash         88K  29.7G    88K  /var/crash
zroot/var/log          164K  29.7G   164K  /var/log
zroot/var/mail          88K  29.7G    88K  /var/mail
zroot/var/tmp           88K  29.7G    88K  /var/tmp
root@bsd11:~ # zfs rename zroot/fat32 zroot/fat16
root@bsd11:~ # zfs list
NAME                   USED  AVAIL  REFER  MOUNTPOINT
zroot                 6.90G  29.7G    88K  /zroot
zroot/ROOT             627M  29.7G    88K  none
zroot/ROOT/default     627M  29.7G   627M  /
zroot/fat16            260M  29.9G    68K  -
zroot/jails           4.76G  29.7G   112K  /usr/jails
zroot/jails/basejail  1003M  29.7G   979M  /usr/jails/basejail
zroot/jails/database  1.95G  29.7G  1.95G  /usr/jails/database
zroot/jails/httpd     1.83G  29.7G  1.83G  /usr/jails/httpd
zroot/jails/newjail   4.66M  29.7G  4.66M  /usr/jails/newjail
zroot/jails/www       4.75M  29.7G  4.75M  /usr/jails/www
zroot/tmp               88K  29.7G    88K  /tmp
zroot/usr             1.27G  29.7G    88K  /usr
zroot/usr/home          88K  29.7G    88K  /usr/home
zroot/usr/ports        665M  29.7G   665M  /usr/ports
zroot/usr/src          633M  29.7G   633M  /usr/src
zroot/var              604K  29.7G    88K  /var
zroot/var/audit         88K  29.7G    88K  /var/audit
zroot/var/crash         88K  29.7G    88K  /var/crash
zroot/var/log          164K  29.7G   164K  /var/log
zroot/var/mail          88K  29.7G    88K  /var/mail
zroot/var/tmp           88K  29.7G    88K  /var/tmp
root@bsd11:~ #

 

스냅 샷은 위와 같은 방법으로 이름을 바꿀수 없으며 스냅샷의 특성으로 인하여
다른 상위 데이터 세트로 이름 변경이 불가 합니다.
재귀된 스냅샷의 이름을 변경 할려면 -r 옵셔을 지정 하고 하위 데이터 세트의 이름 같은 모든 스냅샷의 이름을 변경 해야 합니다.

root@bsd11:~ # zfs rename zroot/var/test@2018-03-15 new_test@2018-03-16
root@bsd11:~ # zfs list -t snapshot

 

데이터 세트 속성 설정

root@bsd11:~ # zfs set custom:costcenter=1234 zroot
root@bsd11:~ # zfs get custom:costcenter zroot
NAME   PROPERTY           VALUE              SOURCE
zroot  custom:costcenter  1234               local
root@bsd11:~ #

 

사용자정의 등록 정보를 제거 할려면 zfs -r 옵션을 사용합니다.

root@bsd11:~ # zfs get custom:costcenter zroot
NAME   PROPERTY           VALUE              SOURCE
zroot  custom:costcenter  1234               local
root@bsd11:~ # zfs inherit -r custom:costconter zroot
root@bsd11:~ # zfs get custom:costconter
NAME                                    PROPERTY           VALUE              SOURCE
zroot                                   custom:costconter  -                  -
zroot/ROOT                              custom:costconter  -                  -
zroot/ROOT/default                      custom:costconter  -                  -
zroot/fat16                             custom:costconter  -                  -
zroot/jails                             custom:costconter  -                  -
zroot/jails/basejail                    custom:costconter  -                  -
zroot/jails/basejail@20180306_19:50:50  custom:costconter  -                  -
zroot/jails/basejail@20180306_20:02:39  custom:costconter  -                  -
zroot/jails/database                    custom:costconter  -                  -
zroot/jails/httpd                       custom:costconter  -                  -
zroot/jails/newjail                     custom:costconter  -                  -
zroot/jails/www                         custom:costconter  -                  -
zroot/test                              custom:costconter  -                  -
zroot/tmp                               custom:costconter  -                  -
zroot/usr                               custom:costconter  -                  -
zroot/usr/home                          custom:costconter  -                  -
zroot/usr/ports                         custom:costconter  -                  -
zroot/usr/src                           custom:costconter  -                  -
zroot/var                               custom:costconter  -                  -
zroot/var/audit                         custom:costconter  -                  -
zroot/var/crash                         custom:costconter  -                  -
zroot/var/log                           custom:costconter  -                  -
zroot/var/mail                          custom:costconter  -                  -
zroot/var/tmp                           custom:costconter  -                  -
root@bsd11:~ # zfs get custom:costconter zroot
NAME   PROPERTY           VALUE              SOURCE
zroot  custom:costconter  -                  -
root@bsd11:~ #

 

공유속성 및 설정

NFS / SMB 공유 옵션 입니다.
ZFS 데이터 세트를 네트워크에서 공유 할수 있는 방법을 정의 할수 있습니다.
둘다 off 로 되어 있습니다.

root@bsd11:~ # zfs get sharenfs zroot/usr/home
NAME            PROPERTY  VALUE     SOURCE
zroot/usr/home  sharenfs  off       default
root@bsd11:~ # zfs get sharesmb zroot/usr/home
NAME            PROPERTY  VALUE     SOURCE
zroot/usr/home  sharesmb  off       default
root@bsd11:~ #

 

/usr/home nfs 공유 설정

root@bsd11:~ # zfs set sharenfs=on zroot/usr/home
root@bsd11:~ # zfs get sharenfs zroot/usr/home
NAME            PROPERTY  VALUE     SOURCE
zroot/usr/home  sharenfs  on        local
root@bsd11:~ #

 

zfs set sharenfs 사용 예)

다음과 같이 nfs 연결 정보를 설정 할수 있습니다.

root@bsd11:~ # zfs set sharenfs="-alldirs,=maproot=root,-network=192.168.0.0/24" zroot/usr/home
root@bsd11:~ # zfs get sharenfs zroot/usr/home
NAME            PROPERTY  VALUE                                           SOURCE
zroot/usr/home  sharenfs  -alldirs,=maproot=root,-network=192.168.0.0/24  local
root@bsd11:~ #

 

스냅 샷 관리

-작성중

 

 

FreeBSD VirtIO

virtio 참고 : https://wiki.libvirt.org/page/Virtio

So-called “full virtualization” is a nice feature because it allows you to run any operating system virtualized. However, it’s slow because the hypervisor has to emulate actual physical devices such as RTL8139 network cards . This emulation is both complicated and inefficient.

Virtio is a virtualization standard for network and disk device drivers where just the guest’s device driver “knows” it is running in a virtual environment, and cooperates with the hypervisor. This enables guests to get high performance network and disk operations, and gives most of the performance benefits of paravirtualization.

Note that virtio is different, but architecturally similar to, Xen paravirtualized device drivers (such as the ones that you can install in a Windows guest to make it go faster under Xen). Also similar is VMWare’s Guest Tools.

This page describes how to configure libvirt to use virtio with KVM guests.

kvm 사용시 virtio Driver 를 사용할 일이 종종 있습니다.

과거에는 virtio-kmod 를 ports 에서 설치 하고  /boot/loader.conf 에 virtio_load 등을 추가 하였지만

 

BSD 11 에서는 바로 Disk 를 추가 하여 사용 할수 있습니다.

 

VirtIO Driver load

Driver load 확인을 위한것임으로 별도로 확인할 필요는 없습니다.

 

root@bsd11:~ # kldload virtio
kldload: can't load virtio: module already loaded or in kernel
root@bsd11:~ #

이미 kernel 에서 load 되어 있다고 나옵니다.

 

차후 make world 도 해봐야 겠네요. 🙂

root@bsd11:~ # cat /usr/src/sys/amd64/conf/GENERIC | grep vir
device          virtio                  # Generic VirtIO bus (required)
device          virtio_pci              # VirtIO PCI device
device          virtio_blk              # VirtIO Block device
device          virtio_scsi             # VirtIO SCSI device
device          virtio_balloon          # VirtIO Memory Balloon device
root@bsd11:~ #

 

 

VirtIO Device 확인

Disk name 은 vtbdX 형식으로 추가 됩니다.

root@bsd11:~ # ls -al /dev/vtb*
crw-r-----  1 root  operator  0x48 Mar 11 21:49 /dev/vtbd0
root@bsd11:~ #

 

VirtIO Disk Test

root@bsd11:~ # gpart create -s GPT vtbd0
vtbd0 created
root@bsd11:~ # gpart add -t freebsd-ufs vtbd0
vtbd0p1 added
root@bsd11:~ # newfs -U /dev/vtbd0p1
/dev/vtbd0p1: 10240.0MB (20971440 sectors) block size 32768, fragment size 4096
        using 17 cylinder groups of 626.09MB, 20035 blks, 80256 inodes.
        with soft updates
super-block backups (for fsck_ffs -b #) at:
 192, 1282432, 2564672, 3846912, 5129152, 6411392, 7693632, 8975872, 10258112,
 11540352, 12822592, 14104832, 15387072, 16669312, 17951552, 19233792, 20516032
root@bsd11:~ # mkdir /data
root@bsd11:~ # mount /dev/vtbd0p1 /data/
root@bsd11:~ # df -h | grep -i data
/dev/vtbd0p1            9.7G    8.0K    8.9G     0%    /data
root@bsd11:~ #