Ubuntu 18.04 LEMP Stack

https://www.ubuntu.com/about/release-cycle

 

 

Mariadb 10.3 설치

mariadb 10.1 –> 10.3 으로 변경 10.1 repo 에서 정상적으로 설치 되지 않음

https://downloads.mariadb.org/mariadb/repositories/#mirror=harukasan&distro=Ubuntu&distro_release=bionic–ubuntu_bionic&version=10.1

mariadb 레포지터리를 추가 합니다. 

test@ubuntu1804:~$ sudo apt-get install software-properties-common
test@ubuntu1804:~$ sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
test@ubuntu1804:~$ sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://ftp.kaist.ac.kr/mariadb/repo/10.3/ubuntu bionic main'

 

mariadb-server , mariadb-client 패키지를 설치 합니다.

test@ubuntu1804:~$ sudo apt update
test@ubuntu1804:~$ sudo apt -y install mariadb-server mariadb-client

# 패스워드를 설정 합니다.

 

mariadb 서비스를 실행 및 활성화 합니다.

test@ubuntu1804:~$ sudo systemctl start mariadb.service
test@ubuntu1804:~$ sudo systemctl enable mariadb.service

 

mysql_secure_installation 을 실행 합니다.

test@ubuntu1804:~$ sudo mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n
 ... skipping.

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
test@ubuntu1804:~$

 

mariadb character set 을 utf8mb4 로 변경 합니다.

test@ubuntu1804:~$ sudo vi /etc/mysql/mariadb.cnf
# MariaDB-specific config file.
# Read by /etc/mysql/my.cnf

[client]
default-character-set = utf8mb4
# Default is Latin1, if you need UTF-8 set this (also in server section)
#default-character-set = utf8

[mysqld]

character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

 

mariadb.service 재시작후 character set 확인 합니다.

test@ubuntu1804:~$ sudo systemctl restart mariadb.service
test@ubuntu1804:~$ sudo mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 37
Server version: 10.3.10-MariaDB-1:10.3.10+maria~bionic-log mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> status;
--------------
mysql  Ver 15.1 Distrib 10.3.10-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Connection id:          37
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server:                 MariaDB
Server version:         10.3.10-MariaDB-1:10.3.10+maria~bionic-log mariadb.org binary distribution
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
UNIX socket:            /var/run/mysqld/mysqld.sock
Uptime:                 11 sec

Threads: 8  Questions: 61  Slow queries: 0  Opens: 32  Flush tables: 1  Open tables: 26  Queries per second avg: 5.545
--------------

MariaDB [(none)]> quit;
Bye
test@ubuntu1804:~$

 

Nginx 설치

test@ubuntu1804:~$ sudo apt install -y nginx

 

nginx 서비스를 실행 및 활성화 합니다.

test@ubuntu1804:~$ sudo systemctl start nginx
test@ubuntu1804:~$ sudo systemctl enable nginx

 

nginx.conf 를 설정 합니다.

test@ubuntu1804:~$ sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.org
test@ubuntu1804:~$ sudo vi /etc/nginx/nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 1024;
}

http {
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

 

/etc/nginx/sites-enabled/default 설정

server {
    listen 80;
    listen [::]:80;
    root /var/www/html;
    index  index.php index.html index.htm;
    server_name  example.com www.example.com;

    location / {
        try_files $uri $uri/ =404;
    }


     # pass PHP scripts to FastCGI server
        #
        location ~ \.php$ {
               include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
               fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        }
}

 

nginx config 를 확인 합니다.

test@ubuntu1804:~$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
test@ubuntu1804:~$

 

php 7.1 0설치

test@ubuntu1804:~$ sudo add-apt-repository ppa:ondrej/php
test@ubuntu1804:~$ sudo apt-get install -y php7.1
test@ubuntu1804:~$ sudo add-apt-repository universe
test@ubuntu1804:~$ sudo apt install -y php7.1-fpm php7.1-mcrypt php7.1-cli php7.1-xml php7.1-mysql php7.1-gd php7.1-imagick php7.1-recode php7.1-tidy php7.1-xmlrpc

 

php.ini 설정

test@ubuntu1804:~$ sudo vi /etc/php/7.1/fpm/php.ini
display_errors = On
display_startup_errors = On
date.timezone = Asia/Seoul
cgi.fix_pathinfo=0

 

php-fpm 설정 www.conf

test@ubuntu1804:~$ sudo vi /etc/php/7.1/fpm/pool.d/www.conf
listen.owner = www-data
listen.group = www-data
listen.mode = 0660

 

php7.1-fpm.service 재시작

test@ubuntu1804:~$ sudo systemctl restart php7.1-fpm.service

 

phpinfo 확인

test@ubuntu1804:~$ sudo vi /var/www/html/test.php
<?php phpinfo(); ?>

 

 http://192.168.0.18/test.php 로 접속하여 확인 합니다. 

 

 

Ubuntu sphinx-doc install

sphinx 의 경우 Python 문서를 위해 만들어졌으며 소프트웨어 문서화를 위한 좋은 기능을 가지고 있습니다.

sphinx-doc : http://www.sphinx-doc.org/en/1.6/index.html

설치참고: https://docs-korean-sphinx.readthedocs.io/ko/docs-korean/tutorial_ko.html

 

ubuntu sphinx-doc 설치

test@ubuntu-docs:~$ sudo apt-get install python-sphinx python-pip make

 

apt-get 으로 인스톨 했다면 pip install sphinx 를 하실 필요가 없습니다.

pip list 명령어로 확인가능

Python 이 설치 되어 있으면  pip 명령어로 손쉽게 설치를 진행 할수 있습니다.

pip 는 파이썬 으로 작성된 패키지 소프트웨어를 설치 , 관리 하는 패키지 관리 시스템 입니다.

자세한 내용은 https://pypi.org/project/pip/ 에서 확인 가능합니다.

test@ubuntu-docs:~$ pip install sphinx

 

sphinx 문서 환경설정

문서 작성시 해당 디렉토리에 설정 파일을 생성 합니다.

shinx-quickstart 명령어를 통하여 환경을 설정 할수 있습니다.

대략적으로 필요 한 부분만 y를 입력 하여 설정을 진행 합니다.

test@ubuntu-docs:~$ mkdir -p Workspace/docs
test@ubuntu-docs:~$ sphinx-quickstart
test@ubuntu-docs:~$ sphinx-quickstart
Welcome to the Sphinx 1.3.6 quickstart utility.

Please enter values for the following settings (just press Enter to
accept a default value, if one is given in brackets).

Enter the root path for documentation.
> Root path for the documentation [.]: /home/test/Workspace/docs

You have two options for placing the build directory for Sphinx output.
Either, you use a directory "_build" within the root path, or you separate
"source" and "build" directories within the root path.
> Separate source and build directories (y/n) [n]:

Inside the root directory, two more directories will be created; "_templates"
for custom HTML templates and "_static" for custom stylesheets and other static
files. You can enter another prefix (such as ".") to replace the underscore.
> Name prefix for templates and static dir [_]:

The project name will occur in several places in the built documentation.
> Project name: opensource docs
> Author name(s): user01

Sphinx has the notion of a "version" and a "release" for the
software. Each version can have multiple releases. For example, for
Python the version is something like 2.5 or 3.0, while the release is
something like 2.5.1 or 3.0a1.  If you don't need this dual structure,
just set both to the same value.
> Project version: 1.0
> Project release [1.0]:

If the documents are to be written in a language other than English,
you can select a language here by its language code. Sphinx will then
translate text that it generates into that language.

For a list of supported codes, see
http://sphinx-doc.org/config.html#confval-language.
> Project language [en]: ko

The file name suffix for source files. Commonly, this is either ".txt"
or ".rst".  Only files with this suffix are considered documents.
> Source file suffix [.rst]:

One document is special in that it is considered the top node of the
"contents tree", that is, it is the root of the hierarchical structure
of the documents. Normally, this is "index", but if your "index"
document is a custom template, you can also set this to another filename.
> Name of your master document (without suffix) [index]:

Sphinx can also add configuration for epub output:
> Do you want to use the epub builder (y/n) [n]:

Please indicate if you want to use one of the following Sphinx extensions:
> autodoc: automatically insert docstrings from modules (y/n) [n]: y
> doctest: automatically test code snippets in doctest blocks (y/n) [n]:
> intersphinx: link between Sphinx documentation of different projects (y/n) [n]: y
> todo: write "todo" entries that can be shown or hidden on build (y/n) [n]:
> coverage: checks for documentation coverage (y/n) [n]:
> pngmath: include math, rendered as PNG images (y/n) [n]:
> mathjax: include math, rendered in the browser by MathJax (y/n) [n]:
> ifconfig: conditional inclusion of content based on config values (y/n) [n]:
> viewcode: include links to the source code of documented Python objects (y/n) [n]: y

A Makefile and a Windows command file can be generated for you so that you
only have to run e.g. `make html' instead of invoking sphinx-build
directly.
> Create Makefile? (y/n) [y]:
> Create Windows command file? (y/n) [y]: n

Creating file /home/test/Workspace/docs/conf.py.
Creating file /home/test/Workspace/docs/index.rst.
Creating file /home/test/Workspace/docs/Makefile.

Finished: An initial directory structure has been created.

You should now populate your master file /home/test/Workspace/docs/index.rst and create other documentation
source files. Use the Makefile to build the docs, like so:
   make builder
where "builder" is one of the supported builders, e.g. html, latex or linkcheck.

test@ubuntu-docs:~$

 

shinx-quickstart 에서 설정한 문서 위치로 이동 합니다.

test@ubuntu-docs:~$ cd Workspace/docs/
test@ubuntu-docs:~/Workspace/docs$ ls -al
total 44
drwxrwxr-x 5 test test 4096 Sep 30 19:56 .
drwxrwxr-x 3 test test 4096 Sep 30 19:44 ..
drwxrwxr-x 2 test test 4096 Sep 30 19:56 _build
-rw-rw-r-- 1 test test 9445 Sep 30 19:56 conf.py
-rw-rw-r-- 1 test test  450 Sep 30 19:56 index.rst
-rw-rw-r-- 1 test test 7688 Sep 30 19:56 Makefile
drwxrwxr-x 2 test test 4096 Sep 30 19:56 _static
drwxrwxr-x 2 test test 4096 Sep 30 19:56 _templates
test@ubuntu-docs:~/Workspace/docs$

 

make html

test@ubuntu-docs:~/Workspace/docs$ make html
sphinx-build -b html -d _build/doctrees   . _build/html
Running Sphinx v1.3.6
making output directory...
loading translations [ko]... done
loading pickled environment... not yet created
loading intersphinx inventory from https://docs.python.org/objects.inv...
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: 1 added, 0 changed, 0 removed
reading sources... [100%] index
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
generating indices... genindex
writing additional pages... search
copying static files... done
copying extra files... done
dumping search index in English (code: en) ... done
dumping object inventory... done
build succeeded.

Build finished. The HTML pages are in _build/html.
test@ubuntu-docs:~/Workspace/docs$

 

make html 동작 확인

리눅스 Desktop 을 사용한다면 /home/test/Workspace/docs/_build/html/index.html 을 확인 하시면 됩니다.

</html>test@ubuntu-docs:~/Workspace/docs$ cat _build/html/index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>Welcome to opensource docs’s documentation! &mdash; opensource docs 1.0 documentation</title>

    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />

    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '1.0',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <script type="text/javascript" src="_static/translations.js"></script>
    <link rel="top" title="opensource docs 1.0 documentation" href="#" />


  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
~중략

 

설치는 위에 까지 하여 마무리 되었습니다.

간략하게 정리해본 sphinx-doc 설치법 이며 Nginx or Apache Web Site 와 같이 사용하면 좋을것으로 보입니다.

sphinx-autobuild 패키지 설치시 http://127.0.0.1:8000 접속으로도 확인 가능합니다.

sphinx-autobuild 패키지 설치 

test@ubuntu-docs:~/Workspace/web-docs/docs$ pip install sphinx sphinx-autobuild --user 
test@ubuntu-docs:~/Workspace/web-docs$ sphinx-autobuild . _build/html

+--------- manually triggered build ---------------------------------------------
Error: Config directory doesn't contain a conf.py file.
+--------------------------------------------------------------------------------

[I 181001 00:22:43 server:292] Serving on http://127.0.0.1:8000
[I 181001 00:22:43 handlers:59] Start watching changes
[I 181001 00:22:43 handlers:61] Start detecting changes

 

 

ubuntu locale 변경

 

locale 확인

test@docker-test:~$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
test@docker-test:~$

 

language-pack-ko pkg 설치

test@docker-test:~$ sudo apt-get install language-pack-ko

 

locale 변경 및 SSH 재접속후 locale 확인

test@docker-test:~$ locale -a |grep -i ko
ko_KR.utf8


test@docker-test:~$ sudo vi /etc/default/locale
#  File generated by update-locale
LANG="ko_KR.utf8"


## SSH 재접속후 확인

test@docker-test:~$ locale
LANG=ko_KR.utf8
LANGUAGE=
LC_CTYPE="ko_KR.utf8"
LC_NUMERIC="ko_KR.utf8"
LC_TIME="ko_KR.utf8"
LC_COLLATE="ko_KR.utf8"
LC_MONETARY="ko_KR.utf8"
LC_MESSAGES="ko_KR.utf8"
LC_PAPER="ko_KR.utf8"
LC_NAME="ko_KR.utf8"
LC_ADDRESS="ko_KR.utf8"
LC_TELEPHONE="ko_KR.utf8"
LC_MEASUREMENT="ko_KR.utf8"
LC_IDENTIFICATION="ko_KR.utf8"
LC_ALL=
test@docker-test:~$

 

 

Ubuntu 1604 + GitLab install

 

 

Site: https://about.gitlab.com/installation/#ubuntu

참고Site: https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-gitlab-on-ubuntu-16-04

Test환경 : vmware /  ubuntu 16.04

cpu : 2core

memory : 4G

GitLab omnibus 설치내용을 테스트 합니다.

Source 설치의 경우 하단 링크를 통하여 확인 할수 있습니다. Source 설치 라고 하여도 Source compile 설치는 아닙니다. 🙂

https://docs.gitlab.com/ee/install/installation.html

 

 pkg update 및 의존성 pkg 설치

test@docker-test:~$ sudo apt-get update
test@docker-test:~$ sudo apt-get install -y curl openssh-server ca-certificates

 

postfix 설치

test@docker-test:~$ sudo apt-get install -y postfix

 

GitLab 설치

test@docker-test:~$ cd /tmp/
test@docker-test:/tmp$ curl -LO https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh
test@docker-test:/tmp$ sudo bash /tmp/script.deb.sh
test@docker-test:/tmp$ sudo apt-get install gitlab-ce
It looks like GitLab has not been configured yet; skipping the upgrade script.

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.



     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/


Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
  sudo gitlab-ctl reconfigure

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

test@docker-test:/tmp$

 

GitLab 설정

test@docker-test:~$ sudo vi /etc/gitlab/gitlab.rb
## 도메인 설정을 합니다. 
external_url 'http://gitlab.example.com'

## 도메인 설정시 letsencrypt [ 'enable'] 을 설정합니다. 
# letsencrypt['enable'] = nil
# letsencrypt['contact_emails'] = [] # This should be an array of email addresses to add as contacts


## ==> 

letsencrypt['enable'] = true
letsencrypt['contact_emails'] = ['sammy@yourdomain.com']

 

GitLab 설정을 저장 합니다.

test@docker-test:~$ sudo gitlab-ctl reconfigure

 

Web 접속을 합니다.

 

Password 를 설정합니다.

 

설정한 password 로 로그인을 합니다.

Username : root

password : 설정한 password

 

 

사용법의 경우 추후 테스트 하도록 합니다. 🙂

FreeBSD 에서는 nginx + postgreSQL + Redis 를 별도로 설치 했지만 process 를 확인시 동작 하는걸로 확인 할수 있습니다.

test@docker-test:~$ sudo ps -aux |grep -i nginx
root      25277  0.0  0.0   4244   628 ?        Ss   21:30   0:00 runsv nginx
root      25279  0.0  0.1  42304  5036 ?        Ss   21:30   0:00 nginx: master process /opt/gitlab/embedded/sbin/nginx -p /var/opt/gitlab/nginx
gitlab-+  25280  0.0  0.0  46916  3868 ?        S    21:30   0:00 nginx: worker process
gitlab-+  25281  0.0  0.1  46916  7352 ?        S    21:30   0:00 nginx: worker process
gitlab-+  25282  0.0  0.0  42512  2680 ?        S    21:30   0:00 nginx: cache manager process
root      25748  0.0  0.0   4388   716 ?        S    21:31   0:00 svlogd -tt /var/log/gitlab/nginx
test      27713  0.0  0.0  14224  1016 pts/0    R+   21:42   0:00 grep --color=auto -i nginx
test@docker-test:~$ sudo ps -aux |grep -i redis
root      24914  0.0  0.0   4244   584 ?        Ss   21:29   0:00 runsv redis
gitlab-+  24916  0.6  0.2  41648 10272 ?        Ssl  21:29   0:05 /opt/gitlab/embedded/bin/redis-server 127.0.0.1:0
root      25565  0.0  0.0   4244   668 ?        Ss   21:31   0:00 runsv redis-exporter
gitlab-+  25567  0.1  0.3 170548 13628 ?        Ssl  21:31   0:00 /opt/gitlab/embedded/bin/redis_exporter -web.listen-address=localhost:9121 -redis.addr=unix:///var/opt/gitlab/redis/redis.socket
root      25730  0.0  0.0   4388   668 ?        S    21:31   0:00 svlogd -tt /var/log/gitlab/redis
root      25791  0.0  0.0   4388   768 ?        S    21:31   0:00 svlogd -tt /var/log/gitlab/redis-exporter
test      27741  0.0  0.0  14224   940 pts/0    S+   21:43   0:00 grep --color=auto -i redis
test@docker-test:~$ sudo ps -aux |grep -i postgres
root      24977  0.0  0.0   4244   764 ?        Ss   21:29   0:00 runsv postgresql
gitlab-+  24979  0.0  1.1 1096720 45964 ?       Ss   21:29   0:00 /opt/gitlab/embedded/bin/postgres -D /var/opt/gitlab/postgresql/data
gitlab-+  24981  0.0  0.6 1096988 24680 ?       Ss   21:29   0:00 postgres: checkpointer process
gitlab-+  24982  0.0  0.2 1096720 10904 ?       Ss   21:29   0:00 postgres: writer process
gitlab-+  24983  0.0  0.4 1096720 18256 ?       Ss   21:29   0:00 postgres: wal writer process
gitlab-+  24984  0.0  0.1 1097264 7092 ?        Ss   21:29   0:00 postgres: autovacuum launcher process
gitlab-+  24985  0.0  0.1  33268  4772 ?        Ss   21:29   0:00 postgres: stats collector process
root      25664  0.0  0.0   4244   704 ?        Ss   21:31   0:00 runsv postgres-exporter
gitlab-+  25682  0.0  0.7 1110084 28912 ?       Ss   21:31   0:00 postgres: gitlab gitlabhq_production [local] idle
gitlab-+  25729  0.0  0.7 1111600 30760 ?       Ss   21:31   0:00 postgres: gitlab gitlabhq_production [local] idle
root      25731  0.0  0.0   4388   656 ?        S    21:31   0:00 svlogd -tt /var/log/gitlab/postgresql
gitlab-+  25836  0.1  0.3 148416 15260 ?        Ssl  21:31   0:00 /opt/gitlab/embedded/bin/postgres_exporter --web.listen-address=localhost:9187 --extend.query-path=/var/opt/gitlab/postgres-exporter/queries.yaml
gitlab-+  25841  0.1  0.5 1108380 22272 ?       Ss   21:31   0:00 postgres: gitlab-psql postgres [local] idle
root      25918  0.0  0.0   4388   684 ?        S    21:31   0:00 svlogd -tt /var/log/gitlab/postgres-exporter
gitlab-+  25955  0.0  0.6 1108532 27868 ?       Ss   21:32   0:00 postgres: gitlab gitlabhq_production [local] idle
gitlab-+  25956  0.0  0.5 1107520 22768 ?       Ss   21:32   0:00 postgres: gitlab gitlabhq_production [local] idle
gitlab-+  25957  0.0  0.6 1107808 25468 ?       Ss   21:32   0:00 postgres: gitlab gitlabhq_production [local] idle
gitlab-+  25981  0.0  0.7 1107964 28428 ?       Ss   21:32   0:00 postgres: gitlab gitlabhq_production [local] idle
gitlab-+  27183  0.0  0.6 1107864 25600 ?       Ss   21:39   0:00 postgres: gitlab gitlabhq_production [local] idle
test      27765  0.0  0.0  14224   980 pts/0    S+   21:43   0:00 grep --color=auto -i postgres
test@docker-test:~$

 

 

 

 

Ubuntu mkdocs 설치

 

python , python-pip mkdocs 설치

https://www.mkdocs.org Site 에 설치법이 있지만 ubuntu에서 할때는 apt 로 패키지 관리가 좀더 편합니다. 🙂

test@docker-test:~$ sudo apt install python python-pip mkdocs

 

 

mkdocs Test

test@docker-test:~$ mkdocs new my-project
INFO    -  Creating project directory: my-project
INFO    -  Writing config file: my-project/mkdocs.yml
INFO    -  Writing initial docs: my-project/docs/index.md
test@docker-test:~$ cd my-project/
test@docker-test:~/my-project$ mkdocs build

test@docker-test:~/my-project$ mkdocs --help
Usage: mkdocs [OPTIONS] COMMAND [ARGS]...

  MkDocs - Project documentation with Markdown.

Options:
  -V, --version  Show the version and exit.
  -q, --quiet    Silence warnings
  -v, --verbose  Enable verbose output
  -h, --help     Show this message and exit.

Commands:
  build      Build the MkDocs documentation
  gh-deploy  Deploy your documentation to GitHub Pages
  new        Create a new MkDocs project
  serve      Run the builtin development server
test@docker-test:~/my-project$

 

mkdocs serve 로 할때는 일반 유저로도 상관이 없지만 –dev-addr 로 실행할때는 sudo 를 사용해야 합니다.

mkdocs serve 로 Site 를 운영하지 않으며 Github 및 nignx Site 와 연동하여 사용하시면 됩니다. 🙂

test@docker-test:~/my-project$ mkdocs serve
INFO    -  Building documentation...
[I 180909 20:03:45 server:271] Serving on http://127.0.0.1:8000
[I 180909 20:03:45 handlers:58] Start watching changes
^C[I 180909 20:03:46 server:291] Shutting down...
test@docker-test:~/my-project$ sudo mkdocs serve --dev-addr 192.168.101.135:80
INFO    -  Building documentation...
[I 180909 20:03:47 server:271] Serving on http://192.168.101.135:80
[I 180909 20:03:47 handlers:58] Start watching changes
^C[I 180909 20:03:50 server:291] Shutting down...
test@docker-test:~/my-project$

 

 

 

pip upgrade

test@docker-test:~/Workspace/mkdocs$ pip list
pip (8.1.1)
setuptools (20.7.0)
wheel (0.29.0)
You are using pip version 8.1.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
test@docker-test:~/Workspace/mkdocs$

test@docker-test:~/Workspace/mkdocs$ pip list
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
test@docker-test:~/Workspace/mkdocs$

ssh 재접속후 확인 
test@docker-test:~$ pip list
Package    Version
---------- -------
pip        18.0
setuptools 20.7.0
wheel      0.29.0
test@docker-test:~$

 

 

pip 패키지 설치시 –user 를 사용해야 합니다.

Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/futures-3.2.0.dist-info'
Consider using the `--user` option or check the permissions.

test@docker-test:~/Workspace/mkdocs/wiki/wiki$ pip install mkdocs-rtd-dropdown --user
Successfully installed Jinja2-2.10 Markdown-2.6.11 MarkupSafe-1.0 PyYAML-3.13 backports-abc-0.5 click-6.7 futures-3.2.0 livereload-2.5.2 mkdocs-1.0.4 mkdocs-rtd-dropdown-1.0.2 singledispatch-3.4.0.3 six-1.11.0 tornado-5.1

 

 

pip 패키지 설치후 ssh 재접속을 통하여 정상적인 적용이 가능 합니다. 

pip 패키지 설치후 바로 mkdocs build 시 아래와 같은 메시지를 확인 할수 있습니다.

test@docker-test:~/Workspace/mkdocs/wiki/wiki$ mkdocs build
WARNING -  Config value: 'nav'. Warning: Unrecognised configuration name: nav
ERROR   -  Config value: 'theme'. Error: Unrecognised theme.

Aborted with 1 Configuration Errors!
test@docker-test:~/Workspace/mkdocs/wiki/wiki$

 

 

ssh 재접속후 mkdocs build

test@docker-test:~/Workspace/mkdocs/wiki/wiki$ mkdocs build
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /home/test/Workspace/mkdocs/wiki/wiki/site
test@docker-test:~/Workspace/mkdocs/wiki/wiki$

 

 

material theme 사용시

site : https://squidfunk.github.io/mkdocs-material/

$ vi mkdocs.yml
theme:
name: 'material'
language: 'kr'

$ pip install mkdocs-material --user
$ mkdocs build

 

 

 

 

ubuntu WiKi.js install

 

Git install

test@docker-test:~$ sudo add-apt-repository -y ppa:git-core/ppa
test@docker-test:~$ sudo apt update && sudo apt upgrade
test@docker-test:~$ sudo apt install git

 

Nodejs install

test@docker-test:~$ sudo apt install curl
test@docker-test:~$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
test@docker-test:~$ sudo apt install -y nodejs
test@docker-test:~$ sudo apt install mongodb

 

Wiki-js install

test@docker-test:~$ sudo mkdir -p /var/www/wikijs
test@docker-test:~$ cd /var/www/wikijs/
test@docker-test:/var/www/wikijs$ curl -sSo- https://wiki.js.org/install.sh | sudo bash
 __    __ _ _    _    _
/ / /\ \ (_) | _(_)  (_)___
\ \/  \/ / | |/ / |  | / __|
 \  /\  /| |   <| |_ | \__ \
  \/  \/ |_|_|\_\_(_)/ |___/
                   |__/
   < INSTALL >

[1/3] Fetching latest build...
[2/3] Fetching dependencies...
[3/3] Creating config file...
-> Installation Complete

Thank you for installing Wiki.js!
Please consider donating to our open collective to help maintain this project:
https://opencollective.com/wikijs/donate

- Launch configuration wizard: node wiki configure
- Start Wiki.js server: node wiki start

test@docker-test:/var/www/wikijs$

test@docker-test:/var/www/wikijs$ sudo node wiki configure

 

 

 

 

 

 

 

 

SKIP THIS STEP 으로 Git 설정 부분은 넘어갑니다.

 

 

 

 

Configure 가 끝나면 자동적으로 wiki js 가 정지 합니다.

test@docker-test:/var/www/wikijs$ sudo node wiki configure
⠴ Browse to http://localhost:3000 to configure Wiki.js!
✔ Wiki.js is now running in normal mode!
test@docker-test:/var/www/wikijs$

 

WiKi.js config 파일 수정및 WiKi.js 실행

test@docker-test:/var/www/wikijs$ pwd
/var/www/wikijs
test@docker-test:/var/www/wikijs$ vi config.yml
title: Wiki
#host: 'http://localhost'
host: 'http://192.168.0.100'
port: 80
test@docker-test:/var/www/wikijs$ sudo node wiki start
✔ Wiki.js has started successfully.
test@docker-test:/var/www/wikijs$

 

 

 

 

ubuntu upgrade 16.04 -> 18.04

 

/etc/lsb-release 확인

login as: test
test@192.168.0.10's password:
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-62-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

206 packages can be updated.
114 updates are security updates.

New release '18.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Mon Sep  3 14:59:41 2018
test@docker-test:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"

 

16.04 모든 패키지 업데이트

test@docker-test:~$ sudo apt update && sudo apt dist-upgrade && sudo apt autoremove

 

update-manager-core 패키지 설치

test@docker-test:~$ sudo apt-get install update-manager-core

 

Prompt=lts 확인

test@docker-test:~$ cat /etc/update-manager/release-upgrades |grep -i prompt
# Default prompting behavior, valid options:
Prompt=lts
test@docker-test:~$

 

18.04 upgrade

test@docker-test:~$ sudo do-release-upgrade -d

Reading cache

Checking package manager

Continue running under SSH?

This session appears to be running under ssh. It is not recommended
to perform a upgrade over ssh currently because in case of failure it
is harder to recover.

If you continue, an additional ssh daemon will be started at port
'1022'.
Do you want to continue?

Continue [yN] y

To make recovery in case of failure easier, an additional sshd will
be started on port '1022'. If anything goes wrong with the running
ssh you can still connect to the additional one.
If you run a firewall, you may need to temporarily open this port. As
this is potentially dangerous it's not done automatically. You can
open the port with e.g.:
'iptables -I INPUT -p tcp --dport 1022 -j ACCEPT'

To continue please press [ENTER]

 

keep the local version currently installed 을 선택 합니다.

 

System Rebooting 후 lsb-release 확인시 18.04 로 update 된것을 확인할수 있습니다.

To finish the upgrade, a restart is required.
If you select 'y' the system will be restarted.

Continue [yN] y

test@docker-test:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS"
test@docker-test:~$

 

처음 mysql 을 설치하였을때는 euckr charset 을 사용했었습니다.

그후 얼마가 있다가 utf8로 설정 하였고 다시 요즘에는 utf8mb4 로 설정 하고 있습니다.

utf8mb4 는 간략하게 정리 하면 utf8 charset 보다 다양한 문자들을 지정하기 위하여 생겨난 charset 입니다.

스마트폰의 발전으로 emoticon을 상당히 많이 사용합니다.  저도 포스팅에 사용 합니다. 🙂 <–

UTF-8 인코딩 의 경우 문자당 최대 4바이트 가  필요 합니다.

Mysql utf8 인코딩의 경우 3바이트만 지정 하며 utf8mb4 charset 에서 4바이트를 지원 하게 됩니다.

이제부터 mysql / mariadb 설치시  utf8mb4 charset 으로 설정 하세요!

https://stackoverflow.com/questions/30074492/what-is-the-difference-between-utf8mb4-and-utf8-charsets-in-mysql

rsyslog logserver

 

rsyslog server 구성

rsyslog(Log-Server) , server1(Log-Client) , server2(Log-Client)

 

rsyslog 설치 확인

[root@rsyslog ~]# rpm -aq |grep -i rsyslog
rsyslog-8.24.0-12.el7.x86_64

 

rsyslog 설정

(UDP / TCP 중 선택 하여 설정 할수 있으며 514 Port 를 사용합니다.)

[root@rsyslog ~]# vi /etc/rsyslog.conf
# Provides UDP syslog reception
#$ModLoad imudp
#$UDPServerRun 514

## TCP 를 사용하여 테스트 하기 위하여 아래 내용의 주석을 제거 합니다.
# Provides TCP syslog reception
$ModLoad imtcp                     
$InputTCPServerRun 514

 

rsyslog Rule 설정

[root@rsyslog ~]# vi /etc/rsyslog.conf
#### RULES ####

# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.*                                                 /dev/console

# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none                /var/log/messages

# The authpriv file has restricted access.
authpriv.*                                              /var/log/secure

# Log all the mail messages in one place.
mail.*                                                  -/var/log/maillog


# Log cron stuff
cron.*                                                  /var/log/cron

# Everybody gets emergency messages
*.emerg                                                 :omusrmsg:*

# Save news errors of level crit and higher in a special file.
uucp,news.crit                                          /var/log/spooler

# Save boot messages also to boot.log
local7.*                                                /var/log/boot.log

## 아래 내용을 추가 합니다.
# Rsyslog Server Rules
$template TmplAuth, "/var/log/rsyslog/%HOSTNAME%/%PROGRAMNAME%.log"
$template TmplMsg, "/var/log/rsyslog/%HOSTNAME%/%PROGRAMNAME%.log"
authpriv.*   ?TmplAuth
*.info,mail.none,authpriv.none,cron.none   ?TmplMsg

 

rsyslog 재시작 

[root@rsyslog ~]# systemctl restart rsyslog

 

rsyslog 재시작후 /var/log/rsyslog 디렉토리가 생성 되며 hostname 별로 디렉토리가 생성 됩니다.

[root@rsyslog ~]# ls -al /var/log/rsyslog/
total 4
drwx------  3 root root   21 Feb  2 10:07 .
drwxr-xr-x. 7 root root 4096 Feb  2 10:07 ..
drwx------  2 root root   64 Feb  2 10:07 rsyslog
[root@rsyslog ~]#

 

rsyslog client 설정

[root@server1 ~]# vi /etc/rsyslog.conf
*.* @@192.168.192.100:514
[root@server2 ~]# vi /etc/rsyslog.conf
*.* @@192.168.192.100:514

( rsyslog server ip 설정 @=UDP @@=TCP 입니다.)

 

Client rsyslog 재시작

[root@server1 ~]# systemctl restart rsyslog

[root@server2 ~]# systemctl restart rsyslog

 

Test 를 위하여 server1, server2 에서 ssh login 을 진행 한후 rsyslog server 에서 /var/log/rsyslog 디렉토리를 확인 합니다.

[root@rsyslog rsyslog]# ls -al
total 4
drwx------  5 root root   51 Feb  2 10:24 .
drwxr-xr-x. 7 root root 4096 Feb  2 10:22 ..
drwx------  2 root root   80 Feb  2 10:09 rsyslog
drwx------  2 root root   87 Feb  2 10:24 server1
drwx------  2 root root   87 Feb  2 10:24 server2
[root@rsyslog rsyslog]# cd server1
[root@rsyslog server1]# ll
total 8
-rw------- 1 root root   0 Feb  2 10:24 rsyslogd.log
-rw------- 1 root root 198 Feb  2 10:24 sshd.log
-rw------- 1 root root 131 Feb  2 10:24 systemd.log
-rw------- 1 root root   0 Feb  2 10:24 systemd-logind.log
[root@rsyslog server1]#

(Client 에서 사용하는 서비스별로 log 가 취합 됩니다.)

 

log rotate 설정

(rsyslog 파일을 생성 합니다. )

[root@rsyslog ~]# vi /etc/logrotate.d/rsyslog
/var/log/rsyslog/*/*log {
    weekly
    size 100M
    create 0600 root root
    rotate 4
}

(일주일 로그 4주 보관 24일치를 보관 합니다. Size 의 경우 100k , 100M , 100G 단위로 설정할수 있습니다.)

 

firewalld 사용시 permanent 514 Port 추가

[root@rsyslog ~]# firewall-cmd --permanent --add-port=514/udp
[root@rsyslog ~]# firewall-cmd --permanent --add-port=514/tcp
[root@rsyslog ~]# firewall-cmd --reload

 

 

 

cacti realtime plugin

1.x Version 부터는 별도의 설치가 필요 하지 않습니다.

자세한 내용은 아래 사이트 참고 부탁 드립니다.

https://docs.cacti.net/plugin:realtime

Please note that this plugin has been merged into the base of Cacti 1.x on GitHub. Older versions of this plugin are maintained here for reference only.

Provides a method to view Cacti graphs with a resolution of upto 5 seconds.

추가 플러그인https://github.com/Cacti

 

 

Console -> Configuration -> Users -> Admin -> Permissions

Realtime Graphs 체크

 

Console -> Configuration -> Settings -> Visual

Real-time Graphs 항목

Graph Timespan : 30 Seconds

Refresh Interval : 5 Seconds

 

Graphs -> 이동후 모니터링 항목의 Time Graph View 버튼 클릭

Time Graph View 아래 버튼의 경우 Realtime 버튼 입니다. 

 

Real-time 버튼 클릭