This post will explain how to set up multiple monitors with multiple graphic cards on Ubuntu 12.04

글쓴이가 근무하는 사무실에서, 글쓴이가 직접 쓸 워크스테이션이 지게차로 배송이 되어서 왔다 ㅎㅎ.


My workstation has two nVidia Quadro K4000 and six monitors.  My purpose was, 3 upper monitors(Graphic card #1) would be for monitoring only, and 3 lower monitors(Graphic card #2) would be for my use, such as terminal, web browser, note, and so on.  I work at College Of Education, University of Hawaii at Manoa as a Systems Administrator.

본 워크스테이션의 목적은 사실 오픈스택 클라우드의 시뮬레이션을 위해 구입했는데, 사양이 어마어마하게 빵빵하다.  구체적으로 나열하기는, 내것도 아닌데 자랑질하는 거 같아서 생략하고, 한국돈으로 천만원이 넘는다.  뭐 하여간,  모니터 위의 3대는 순전히 인프라 전체의 모니터링만을 하며, 아래 3대는 글쓴이의 작업용이다.


First time, I used Xinerama with nVidia control panel.  It worked good, but the only one left-side launcher existed on the left-top monitor, and log-out button existed only right-top monitor.  This was not what I wanted.  And also, I didn't want to unintentionally click monitoring windows on the upper monitors.  Yes, I wanted to block the mouse pointer moving toward upper monitors.  So, I needed two X-Windows managers working simultaneously with only one keyboard and one mouse for only lower monitors.  Actually, setting two independant window manager up is easy, but keyboard and mouse inputs work on both lower and upper desktop at the same time.

일단 첫째로 해본건 Xinerama였다.  nVidia 콘트롤 패널에서 클릭하면 아주 쉽게 잘되는데, 문제는 우분투 데스크탑의 런치패널이 왼쪽 상단 모니터에만 생기고, 상단 아이콘, 특히 로그아웃 버튼은 오른쪽 상단 모니터에만 생기니까 너무 불편했다.  게다가 중요한 건, 위의 모니터링 시스템들이 전부 웹브라우저이기 때문에, 컴퓨터 쓰다가 잘못해서 상단을 클릭하면 모니터링 페이지가 클릭된 페이지로 넘어가게 되서 이것 역시 불편했다.  무엇보다도 마우스 포인터가 위로 넘어가지 않길 바랬다.  따라서, 글쓴이가 원한건 두개의 독립된 윈도우매니저였으며, 키보드 하나와 마우스 하나로 아래 3대의 모니터만 컨트롤할 수 있어야만 했다.  윈도우 매니저 2개 설정하는 것 자체는 쉽지만, 문제는 두개의 서로다른 윈도우 매니져에서 키보드와 마우스는 같이 움직인다는게 문제였다.




I spent almost two days to figure out how to do this, and actually the configuration is very simple.  The configuration files we need are only two, /etc/lightdm/lightdm.conf and /etc/X11/xorg.conf.  I read this manual, https://help.ubuntu.com/community/MultiseatX

이것을 알아내기 위해서 대략 2일 정도를 소모했지만, 그에 비해 설정은 매우 간단하다.  여기서 우리가 필요한 파일은 /etc/lightdm/lightdm.conf 파일과 /etc/X11/xorg.conf 이다.  또한, 본 매뉴얼을 작성하기 위해 https://help.ubuntu.com/community/MultiseatX  이 글을 읽어봤었다.


For easy management multiple graphic cards and monitors, I split xorg.conf into two files, xorg_upper.conf and xorg_lower.conf.  It doesn't matter to merge or split it.  It's up to you. 

관리의 용이함을 위해, xorg.conf 파일을 둘로 나눴다.  윗모니터용 xorg_upper.conf, 아래 모니터용 xorg_lower.conf.  쪼개든 합치든 상관없다.


Let's see /etc/lightdm/lightdm.conf file.

[SeatDefaults]
user-session=true
greeter-session=unity-greeter
allow-guest=false
greeter-hide-users=true
greeter-show-manual-login=true

[Seat:0]
xserver-config=/etc/X11/xorg_lower.conf
xserver-command=/usr/bin/X -layout Layout0
user-session=ubuntu

[Seat:1]
xserver-config=/etc/X11/xorg_upper.conf -sharevts -allowMouseOpenFail -pointer Mouse1
xserver-command=/usr/bin/X -layout Layout1
user-session=ubuntu
autologin-user=monitor
autologin-user-timeout=0


Configuration is easy, right?  One thing we should know is, I'll block keyboard and mouse inputs on upper monitors, Seat:1 which means that I won't have a control.  Thus, upper desktop should enable "Auto-Login".  Don't worry.  We can control it through the VNC (Remmina).  If you confirm this works, then remove "-sharevts -allowMouseOpenFail -pointer Mouse1" and configure the remote desktop and automatic login on System Setting menu.  And then add "-sharevts -allowMouseOpenFail -pointer Mouse1" again.  Restart lightdm.

딱 봐도 설정이 어렵지는 않다.  한 가지 우리가 알고있어야할 점은, 윗 모니터들은 키보드와 마우스 입력을 막을 예정이고, 그렇다면 윗 모니터들을 제어할 방법이 없어지게 된다.  따라서, 자동 로그인을 키고 원격 데탑 설정만 해주면 된다.  위의 설정파일을 적용해보고 잘되는게 확인되면 마우스 입력을 막아주는 옵션인 "-sharevts -allowMouseOpenFail -pointer Mouse1" 부분을 잠시 지우고 로그인해서 자동로그인와 원격데탑 설정을 해준뒤 다시 로그아웃해서 옵션을 넣어주고 lightdm을 재시작해주면 된다.


The following is xorg_lower.conf.  Nothing different.  You can copy xorg.conf and rename it to xorg_lower.conf.

아래는 xorg_lower.conf 파일이다.  설정은 기본 xorg.conf와 다를게 없다.  그걸 그냥 복사해서 이름만 바꿔주면 된다.

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "Xinerama" "0"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "DELL E2313H"
    HorizSync       30.0 - 83.0
    VertRefresh     56.0 - 76.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Quadro K4000"
    BusID          "PCI:131:0:0"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "DFP-0"
    Option         "metamodes" "DVI-I-1: nvidia-auto-select +3840+0, DP-2: nvidia-auto-select +1920+0, DP-3: nvidia-auto-select +0+0"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection



Now, let's see the important file, xorg_upper.conf file.  It's almost same.  ServerFlags section is added on the top, and mouse#, keyboard# and screen# are not 0.

이제 중요한건, xorg_upper.conf 파일이다.  거의 다 비슷한데 맨 위 ServerFlags가 추가됐고, Mouse 넘버나 키보드 넘버, 스크린 넘버 등이 조금씩 다르다.  위의 파일과 비교해보자.

Section "ServerFlags"
    Option         "DefaultServerLayout" "Layout1"
    Option         "AllowMouseOpenFail" "True"
    Option         "AllowEmptyInput" "True"
    Option         "AutoAddDevices" "False"
    Option         "AutoEnableDevices" "False"
    Option         "DontVTSwitch" "False"
EndSection

Section "ServerLayout"
    Identifier     "Layout1"
    Screen      1  "Screen1" 0 0
    InputDevice    "Keyboard1" "CoreKeyboard"
    InputDevice    "Mouse1" "CorePointer"
    Option         "Xinerama" "0"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    Identifier     "Mouse1"
    Driver         "void"
EndSection

Section "InputDevice"
    Identifier     "Keyboard1"
    Driver         "void"
EndSection

Section "Monitor"
    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor1"
    VendorName     "Unknown"
    ModelName      "DELL E2313H"
    HorizSync       30.0 - 83.0
    VertRefresh     56.0 - 76.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device1"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Quadro K4000"
    BusID          "PCI:132:0:0"
EndSection

Section "Screen"
    Identifier     "Screen1"
    Device         "Device1"
    Monitor        "Monitor1"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "DFP-0"
    Option         "metamodes" "DVI-I-1: nvidia-auto-select +3840+0, DP-0: nvidia-auto-select +1920+0, DP-1: nvidia-auto-select +0+0"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection


I hope this helps!

블로그 이미지

jswlinux

Seowon Jung의 잡동사니 보관소

,

sudo add-apt-repository ppa:webupd8team/sublime-text-2

sudo apt-get update

sudo apt-get -y install sublime-text 


Sublime Text 2 실행한 뒤, 사이드 바에 고정시키면 끝.

블로그 이미지

jswlinux

Seowon Jung의 잡동사니 보관소

,

이것 때문에 무려 2시간이나 소비했다는 사실. 원인은 정말 쓸데없는 것이었는데...

방법을 공유하고자 한다. 이상하게 국내에는 장고 설치에 관한 블로그가 없다. 본 포스트는 장고를 설치하고 아파치의 mod_python 모듈로 운영하고자할 때 필요한 내용이다.

 

먼저 장고설치. 우분투 10.04 LTS 기준으로 아래의 명령어는 Django 1.1버전이 설치된다. 현재 최신버전은 1.3이며, 장고 홈페이지에서 직접 내려받아서 설치할 수 있다. 이 경우 설치되는 경로만 조금 다를 뿐, 작동은 정상적으로 한다.

sudo apt-get install -y libapache2-mod-python python-django python-django-doc

 

이제 장고가 정상적으로 작동되는지를 알아볼 차례.

sudo vi /etc/apache2/sites-available/django-example

<Location "/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    PythonDebug On
    PythonPath "['/usr/share/doc/python-django-doc'] + sys.path"
    SetEnv DJANGO_SETTINGS_MODULE examples.settings
</Location>

라고 작성해준 다음,

sudo a2dissite default

sudo a2ensite django-example

sudo service apache2 reload

(출처: https://wiki.ubuntu.com/Django)
 

이제 본인의 서버 혹은 컴퓨터로 접속을 해본다. 그러면 아래와 같은 화면을 볼 수 있다.

그러면 이제 나만의 페이지를 만들어볼 차례. 여기서부터 2시간 동안 삽질도 아닌 쌩쑈를 다 했다.

먼저 장고로 웹서비스를 할 디렉토리를 만든다. 예를 들기 위해, 필자의 유저네임은 jswlinux이며, 홈디렉토리는 /home/jswlinux 이다.

장고를 이용한 웹서비스는 /home/jswlinux/jswlinux.com에서 할 예정이라고 가정한다.

 

장고의 어드민 명령어로 초기화 파일을 생성해준다. 프로젝트의 이름은 myproject라고 가정한다.

$ mkdir ~/jswlinux.com

$ cd ~/jswlinux.com

$ django-admin startproject myproject

 

이제 ls를 해보면 myproject라는 폴더가 생성되어있는 것을 볼 수 있다. 그러면 아파치 설정파일을 작성해줄 차례다. /etc/apache2/apache.conf 파일에 작성하라고 되어있는데, 보통 일반적으로는 /etc/apache2/sites-available/ 밑에 작성하는 것이 관리도 수월하고 보기도 편하므로 그곳에 작성하기로 한다.

sudo vi /etc/apache2/sites-available/jswlinux.com

<VirtualHost *:80>

ServerName  seowonjung.com

ServerAlias www.seowonjung.com

DocumentRoot /home/jswlinux/seowonjung.com

<Directory />

Options FollowSymLinks Multiviews

AllowOverride all

</Directory>

 

LogLevel warn

ErrorLog /var/log/apache2/seowonjung.com-error.log

CustomLog /var/log/apache2/seowonjung.com-access.log combined

 

<Location "/django/">

SetHandler python-program

PythonHandler django.core.handlers.modpython

SetEnv DJANGO_SETTINGS_MODULE myproject.settings

PythonPath "['/home/jswlinux/jswlinux.com'] + sys.path"

PythonDebug On

</Location>

</VirtualHost>

 

위의 작성된 내용 중에서 글씨체가 굵게되어있는 곳을 주목해야하는데, 저 부분 때문에 2시간이나 삽질을 했던 거다.

먼저, 첫번째 <Location "/django/"> 라고 되어있는 부분은, 웹서버를 관리해보신 분이면 쉽게 아시겠지만, 웹사이트를 접속했을 때 최종경로를 지정하는 부분이다. 다시 말해, http://jswlinux.com/ 이라고 접속했을 때 장고로 서비스하는 페이지가 나오게 하고싶다면 <Location "/"> 라고 입력하면 되고, http://jswlinux.com/django/ 라고 입력해야 장고로 만들어진 페이지가 나오게 하고싶다면 위와 같이 하면 된다. 별것 아니지만, http://jswlinux.com/ 이라고 접속했을 때 바로 장고로 만들어진 페이지가 나오게 하고싶다면, 사실 상단의 VirtualHost에 해당하는 부분은 모두 삭제해도 상관없다.

두번째, 위의 django-admin startproejct myproject 라고 실행해서 만들어줬던 디렉토리를 넣으면 *절대로* 안된다. 프로젝트 폴더가 만들어진 상위 디렉토리를 넣어야한다. 다시 말해, django-admin 명령어로 만들어진 프로젝트 폴더의 경로가 /home/jswlinux/jswlinux.com/myproject라면, 위의 아파치 설정파일에는

PythonPath "['/home/jswlinux/jswlinux.com'] + sys.path"

까지만 넣어야한다는 사실이다. 여기서 myproject라는 장고 프로젝트의 이름은 그 윗 라인, SetEnv DJANGO_SETTINGS_MODULE myproject.settings 에서 판단한다는 사실을 추측해볼 수 있겠다. 저장하고 아파치를 reload 해준다.

이상 완료하면 다음과 같은 페이지를 볼 수 있다.

블로그 이미지

jswlinux

Seowon Jung의 잡동사니 보관소

,

우분투 포럼 채팅방에서 일어난 일이었다. 어느 분께서 아파치 서버의 세팅을 뭘 잘못 손대셨는지 뭐가 잘 안된다고 하신다. 그러면서 재설치와 동시에 PHPMyAdmin 설정을 모두 할려고 하는데, 어떤 순서대로 설치를 해야하냐고 물으셨다. 일반적으로 APM의 설치는 다음과 같다.

sudo apt-get install apache2 libapache2-mod-auth-mysql

sudo apt-get install mysql-server mysql-client

sudo apt-get install php5 php5-common libapache2-mod-php5 php5-mysql

sudo apt-get install phpmyadmin

 

그런데, 다른 분께서 위의 명령어를 한 방에 정리하셨다.

sudo apt-get install phpmyadmin

 

그런데 사실이다!!! 생각해보면 phpmyadmin과 의존관계에 있는 패키지들이 모두 연결되어있다. 따라서, 인터넷에 나와있는 리눅스에서의 APM 설치법은 이제 위의 명령어 단 한 줄로 정리가 된다.

sudo apt-get install phpmyadmin (데비안 계열일 경우)

 

실제로 해봤다. 새로 포맷하고 새로 설치하는 컴퓨터에 해봤는데, 우분투나 데비안에서는 위의 명령어를 치기 전에 하나를 해줘야한다.

sudo apt-get install mysql-server mysql-client

왜냐하면, phpmyadmin이 설치되면서 DB의 root 비밀번호를 설정하는 입력화면이 나오는데, mysql-server의 비밀번호가 먼저 설정되어있지 않으면 설치가 제대로 되지않는다. 물론 잘 아는 유저들한테서야 별거 아니지만, 리눅스를 배우기 시작한지 얼마 안되는 분들한테는 엄청 당황스러울 거다. 따라서 우분투/데비안 유저라면 아래의 방법으로 APM을 설치한다.

 

sudo apt-get install mysql-server mysql-client

sudo apt-get install phpmyadmin

 

쉽고 간단한 APM 설치~

블로그 이미지

jswlinux

Seowon Jung의 잡동사니 보관소

,