ページ

ラベル linux の投稿を表示しています。 すべての投稿を表示
ラベル linux の投稿を表示しています。 すべての投稿を表示

2014年7月21日月曜日

Cent OSでOpenGL 7 - 3Dプログラミング -

いよいよ、OpenGLで3Dプログラミングを開始。


以下サイトを参考
http://seesaawiki.jp/w/mikk_ni3_92/d/%B4%F0%CB%DC%CA%D403

・3D描画の流れ

  1. ビューポートの設定
  2. 視体積設定
  3. 視点の設定
これらの設定をウィンドウズ変更時のイベントで行う。

void glutReshapeFunc(void (*func)( int width, int height))
機能
GLUTのウィンドウの大きさが変ったときや、移動したときに呼び出されるコールバック関数を登録する。
この関数を使用しない場合、funcにNULLを設定した場合は、デフォルトの動作として、glViewport(0, 0, width, height)を呼び出す。
引数
funcウィンドウのサイズが変更されたときに呼び出されるコールバック関数。ウィンドウの幅と高さを表す2つのint型の引数をとる。
戻り値
なし

1. ビューポートの設定

glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
x, y ・・・左隅(左下)の座標
width・・・幅
height・・・高さ


2. 視体積(視野)の設定

どの範囲まで視野に入れるか?

glMatrixMode(GL_PROJECTION)
まずは視体積の設定を有効にする。

次に投影方法の設定
・透視投影
・並行投影


透視投影には「glFrustum」関数と「glPerspective」関数がある。
glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble znear, GLdoble zfar)
「left」、「right」:「左」、「右」の垂直座標を指定
「bottom」、「top」:「下」、「上」の水平座標を指定
「znear」、「zfar」:「手前」、「奥行き」を指定

gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
「fovy」:「y座標」、すなわち「縦方向の視野角」を指定
「sapect」:「視野角」に対する、「比率」で「水平方向の視野角」を決定
「zNear」、「zFar」:「手前」、「奥行き」を指定


並行投影
視点に影響されず、常に正しいサイズで表示される。2次元で画像表示等に使用される。
glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zbear, GLdoble zfar)
「引数」については、「glFrustum()関数」と同じ

3. 視点の設定

視点の位置設定には「gluLookAt」関数を使う
gluLookAt(GLdouble ex,GLdouble ey,GLdouble ez,
     GLdouble cx,GLdouble cy,GLdouble cz,
     GLdouble ux,GLdouble uy,GLdouble uz,)


「(ex,ey,ez)」:「視点の位置」
「(cx,cy,cz)」:「見たいもの位置」
「(ux,uy,uz)」:画像のどこが「上」なのかを指定(ベクトル)

void reshape(int w, int h)
{
  glViewport(0, 0, w, h);

  glMatrixMode(GL_PROJECTION); // モードの切り替え
  glLoadIdentity();
  gluPerspective(45.0, (double)w / (double)h, 0.1, 100.0);

  glMatrixMode(GL_MODELVIEW); // モードを元に戻す
  glLoadIdentity();
  gluLookAt(0.5, 1.5, 2.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
}

以下サイトのサンプルコードを実行

コンパイルgcc -o sample sample.c -lglut -lGLU -lGL -lm



2014年7月13日日曜日

Cent OSでOpenGL 6 - 線と矩形の描画 -

線をひく&矩形描画


今まで、GLUTを使用しない場合いかに大変かを見てきたので、
今回からはOpenGLの内容を見て行く為GLUTを使用。


#include <GL/glut.h>

void display(void)
{
  glClear(GL_COLOR_BUFFER_BIT);
  glColor3d(1.0, 0.0, 0.0); /* 赤色の線を指定 */

  glBegin(GL_LINES);
  glVertex2d(-0.9, -0.9);
  glVertex2d(0.9, 0.6);
  glEnd();

  glFlush();
}

void init(void)
{
  glClearColor(1.0, 1.0, 1.0, 1.0);
}

int main(int argc, char *argv[])
{
  glutInit(&argc, argv);
  glutInitDisplayMode(GLUT_RGBA);
  glutCreateWindow(argv[0]);
  glutDisplayFunc(display);
  init();
  glutMainLoop();
  return 0;
}

実行結果



今回は分かり易い様に、背景を白色に設定。
また線の色をglColor3d関数で赤に設定。

次はglBegin関数に「GL_LINE_LOOP」を指定。
void display(void)
{
  glClear(GL_COLOR_BUFFER_BIT);
  glColor3d(1.0, 0.0, 0.0); /* 赤色の線を指定 */

  glBegin(GL_LINE_LOOP);
  glVertex2d(-0.9, -0.9);
  glVertex2d(0.9, -0.9);
  glVertex2d(0.9, 0.9);
  glVertex2d(-0.9, 0.9);
  glEnd();

  glFlush();
}

実行結果



四角形を塗りつぶす為にglBeginに「GL_POLYGON」を指定
void display(void)
{
  glClear(GL_COLOR_BUFFER_BIT);
  glColor3d(1.0, 0.0, 0.0); /* 赤色の線を指定 */

  glBegin(GL_POLYGON);
  glVertex2d(-0.9, -0.9);
  glVertex2d(0.9, -0.9);
  glVertex2d(0.9, 0.9);
  glVertex2d(-0.9, 0.9);
  glEnd();

  glFlush();
}

実行結果


2014年6月21日土曜日

Cent OSでOpenGL 5 - 描画処理 -

今回でやっとOpenGLのメイン部分を解読。
全体像は以下。

void DrawAQuad() {
 glClearColor(1.0, 1.0, 1.0, 1.0);
 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 glOrtho(-1., 1., -1., 1., 1., 20.);

 glMatrixMode(GL_MODELVIEW);
 glLoadIdentity();
 gluLookAt(0., 0., 10., 0., 0., 0., 0., 1., 0.);

 glBegin(GL_QUADS);
  glColor3f(1., 0., 0.); glVertex3f(-.75, -.75, 0.);
  glColor3f(0., 1., 0.); glVertex3f( .75, -.75, 0.);
  glColor3f(0., 0., 1.); glVertex3f( .75.75, 0.);
  glColor3f(1., 1., 0.); glVertex3f(-.75.75, 0.);
 glEnd();
}

上から順に・・・
void glClearColor(
 GLclampf red , GLclampf green ,
 GLclampf blue , GLclampf alpha
);
バッファを初期化する色情報を設定する。
float型で0.0〜1.0で指定する。
void glClear(GLbitfield mask);
実際のバッファを初期化。
以下定数の組み合わせで初期化対称を設定。
定数解説
GL_COLOR_BUFFER_BITカラー バッファ
GL_DEPTH_BUFFER_BITデプス バッファ
GL_ACCUM_BUFFER_BITアキュムレーション バッファ
GL_STENCIL_BUFFER_BITステンシル バッファ
※ステンシルバッファ
 ・・・ステンシルは型板という意味。塗料を塗る時に型板で塗らない箇所を作る
    ように、OpenGLでも点を描画するかしないかのマスクを設定する
※アキュムレーションバッファ
void glMatrixMode(GLenum mode);
OpenGLには3つの変換行列があり、操作対称の行列を指定
定数解説
GL_MODEVIEWモデルビュー変換行列
GL_PROJECTION投影変換行列
GL_TEXTUREテクスチャ行列
void glLoadIdentity(void);
行列の初期化。
void glOrtho(GLdouble left, GLdouble right, GLdouble bottom
             GLdouble top, GLdouble near, GLdouble far);
現在の行列と正射影行列の乗算を行う。
void gluLookAt(///);
以下サイト参照。
void glBegin(GLenum mode);
頂点データの指定開始。モードは以下定数を指定。
定数解説
GL_POINTS各頂点を単独の点として扱う 頂点 n は、点 n を意味し n この点が描画される
GL_LINES2つの頂点をペアとし、それぞれのペアを独立した線分として扱う
GL_LINE_STRIP最初の頂点から最後の頂点まで、線分を連結して描画する
GL_LINE_LOOPすべての頂点を線分で連結する
GL_TRIANGLES3つの頂点をペアとし、それぞれ独立した三角形として扱う
GL_TRIANGLE_STRIP連結した三角形のグループを描画する
GL_TRIANGLE_FAN最初の頂点を軸に、連結した三角形のグループを描画する
GL_QUADS4つの頂点をペアとし、それぞれ独立した四角形として扱う
GL_QUAD_STRIP連結した四角形のグループを描画する
GL_POLYGON単独の凸ポリゴンを描画する
参考URL

2014年6月12日木曜日

Cent OSでOpenGL 4 - XLib調査2 -

前回の続き・・

 cmap = XCreateColormap(dpy, root, vi->visual, AllocNone);
これは一体何をしているのか?

概要:カラーマップと色構造体の生成
引数:Display *         ・・・    Xサーバの接続を指定
            Window           ・・・    カラーマップを作るスクリーンに属するウィンドウ
            Visual *           ・・・    スクリーンがサポートするVisual 
            int                    ・・・     割当られるカラーマップのエントリー

XSetWindowAttributes    swa;

 swa.colormap = cmap;
 swa.event_mask = ExposureMask | KeyPressMask;

 win = XCreateWindow(dpy, root, 0, 0, 600, 600, 0, vi->depth, InputOutput, vi->visual, CWColormap | CWEventMask, &swa);
XCreateWindow

概要:ウィンドウの生成

 XMapWindow(dpy, win);
 XStoreName(dpy, win, "VERY SIMPLE APPLICATION”);

XMapWindow
   Xサーバーとウィンドウとのマッピング

XStoreName
  Window名の設定

ここからOpenGLの初期化
 glc = glXCreateContext(dpy, vi, NULL, GL_TRUE);
 glXMakeCurrent(dpy, win, glc);


 glEnable(GL_DEPTH_TEST); 

glXCreateContext

概要:GLXレンダリングコンテキストの作成
引数:Display* Xサーバー
            XVisualInfo* コンテキストが利用可能なフレームバッファリソースの定義
            GLXContext 共有するコンテキスト
            Bool レンダリングをグラフィックシステムと直接接続で行う(GL_TRUE)か
                      サーバー経由で行うか(GL_FALSE)

glXMakeCurrent

概要:GLXコンテキストをウィンドウ又はGLXピックスマップ(Bitmap)に割り当てる
引数:Display* Xサーバー
            GLXDrawable XウィンドウIDかGLXピックスマップID
            GLXContext コンテキスト

glEnable
概要:有効な描画方法を設定
参考:http://www.westernvillage.co.jp/openglprogram.htm

 while(1) {
        XNextEvent(dpy, &xev);

        if(xev.type == Expose) {
                XGetWindowAttributes(dpy, win, &gwa);
                glViewport(0, 0, gwa.width, gwa.height);
                DrawAQuad();
                glXSwapBuffers(dpy, win);
        }

        else if(xev.type == KeyPress) {
                glXMakeCurrent(dpy, None, NULL);
                glXDestroyContext(dpy, glc);
                XDestroyWindow(dpy, win);
                XCloseDisplay(dpy);
                exit(0);
        }
    } /* this closes while(1) { */

} /* this is the } which closes int main(int argc, char *argv[]) { */

XNextEvent
概要:イベントを型によって選択
参考:http://xjman.dsl.gr.jp/man/man3/XNextEvent.3x.html

XGetWindowAttributes
概要:ウィンドウの現在の属性を取得
参考:http://xjman.dsl.gr.jp/man/man3/XGetWindowAttributes.3x.html

glViewport
概要:ビューポートの設定
参考:http://wisdom.sakura.ne.jp/system/opengl/gl13.html

glXSwapBuffers
概要:ブッファの入れ替え
参考:http://manpages.ubuntu.com/manpages/gutsy/ja/man3/glXSwapBuffers.3x.html

2014年6月2日月曜日

Cent OSでOpenGL 3 - XLib調査 -

前回のサンプルプログラムを紐解いてみる

まずはメイン関数で最初に呼び出される以下関数。
dpy = XOpenDisplay(NULL);

名前からしてXLibの関数だな。
詳細:Xサーバーへの接続。
引数:char *display_name
            ハードウェアのディスプレイ名を指定。
            NULLの場合は環境変数DISPLAYの値を使用。
戻り値:Display構造体(Xlib.hで定義)
typedef struct
#ifdef XLIB_ILLEGAL_ACCESS
_XDisplay
#endif
{
        XExtData *ext_data;     /* hook for extension to hang data */
        struct _XPrivate *private1;
        int fd;                 /* Network socket. */
        int private2;
        int proto_major_version;/* major version of server's X protocol */
        int proto_minor_version;/* minor version of servers X protocol */
        char *vendor;           /* vendor of the server hardware */
        XID private3;
        XID private4;
        XID private5;
        int private6;
        XID (*resource_alloc)(  /* allocator function */
                struct _XDisplay*
        );
        int byte_order;         /* screen byte order, LSBFirst, MSBFirst */
        int bitmap_unit;        /* padding and data requirements */
        int bitmap_pad;         /* padding requirements on bitmaps */
        int bitmap_bit_order;   /* LeastSignificant or MostSignificant */
        int nformats;           /* number of pixmap formats in list */
        ScreenFormat *pixmap_format;    /* pixmap format list */
        int private8;
        int release;            /* release of the server */
        struct _XPrivate *private9, *private10;
        int qlen;               /* Length of input event queue */
        unsigned long last_request_read; /* seq number of last event read */
        unsigned long request;  /* sequence number of last request. */
        XPointer private11;
        XPointer private12;
        XPointer private13;
        XPointer private14;
        unsigned max_request_size; /* maximum number 32 bit words in request*/
        struct _XrmHashBucketRec *db;
        int (*private15)(
                struct _XDisplay*
                );
        char *display_name;     /* "host:display" string used on this connect*/
        int default_screen;     /* default screen for operations */
        int nscreens;           /* number of screens on this server*/
        Screen *screens;        /* pointer to list of screens */
        unsigned long motion_buffer;    /* size of motion buffer */
        unsigned long private16;
        int min_keycode;        /* minimum defined keycode */
        int max_keycode;        /* maximum defined keycode */
        XPointer private17;
        XPointer private18;
        int private19;
        char *xdefaults;        /* contents of defaults from server */
        /* there is more to this structure, but it is private to Xlib */
}
#ifdef XLIB_ILLEGAL_ACCESS
Display,
#endif
*_XPrivDisplay;



次にXOpenDisplayで取得したDisplay構造体を使って何やら行っている模様。
 root = DefaultRootWindow(dpy);

Xlib.hに以下のマクロとして定義されていました。
#define DefaultRootWindow(dpy)  (ScreenOfDisplay(dpy,DefaultScreen(dpy))->root)
#define ScreenOfDisplay(dpy, scr)(&((_XPrivDisplay)dpy)->screens[scr])
#define DefaultScreen(dpy)      (((_XPrivDisplay)dpy)->default_screen)

Screen構造体定義
typedef struct {
        XExtData *ext_data;     /* hook for extension to hang data */
        struct _XDisplay *display;/* back pointer to display structure */
        Window root;            /* Root window id. */
        int width, height;      /* width and height of screen */
        int mwidth, mheight;    /* width and height of  in millimeters */
        int ndepths;            /* number of depths possible */
        Depth *depths;          /* list of allowable depths on the screen */
        int root_depth;         /* bits per pixel */
        Visual *root_visual;    /* root visual */
        GC default_gc;          /* GC for the root root visual */
        Colormap cmap;          /* default color map */
        unsigned long white_pixel;
        unsigned long black_pixel;      /* White and Black pixel values */
        int max_maps, min_maps; /* max and min color maps */
        int backing_store;      /* Never, WhenMapped, Always */
        Bool save_unders;
        long root_input_mask;   /* initial root input mask */
} Screen;


XサーバーのルートバックグラウンドのWindow(X.h内でXID(unsigned long)として定義されている)を返している。

次はGLっぽい。
 vi = glXChooseVisual(dpy, 0, att);
詳細:グラフィックに必要な能力を要求する。GLサーバーはこれによって必要な
             Visualを選定する。

以下が必要な要件。
GLint                   att[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None };
結構指定できるものが多数あるので詳しくは以下サイトを参照
http://lmb.informatik.uni-freiburg.de/people/reisert/opengl/doc/glXChooseVisual.html

typedef struct {
  Visual *visual;
  VisualID visualid;
  int screen;
  int depth;
#if defined(__cplusplus) || defined(c_plusplus)
  int c_class;                                  /* C++ */
#else
  int class;
#endif
  unsigned long red_mask;
  unsigned long green_mask;
  unsigned long blue_mask;
  int colormap_size;
  int bits_per_rgb;
} XVisualInfo;


2014年6月1日日曜日

Cent OSでOpenGL 2 - GLX拡張 -

前回はとりあえずウィンドウを表示してみたが、今回は真面目にOpenGLについて勉強。


まずは公式サイトを見てみる。
OpenGLの公式サイトはこちら

公式サイトのGetting Started 〜を見てみる。
主要なOSにはOpenGLが既に入っているが、ドライバーは最新に〜という内容が書かれてあるっぽい。
以下それぞれのプラットフォーム毎の説明

・Linux
Linuxのグラフィックスはほぼ "X Window”だ。LinuxでOpenGLをサポートするという事は
X WindowのGLX拡張を使用する事になる。
Direct Rendering Infrastructure(DRI)は簡単にハードウェアアクセラレーションを使える
ドライバーのフレームワーク。
DRIはXFree86の4.0からのサポートされているが、現在はXFree86からXorg
主流となっている。
コンパイル時にはOpenGLのライブラリをリンクする為に「-lGL」を指定する必要がある。

・Windows
コンパイルする際は「OpenGL32.lib」をリンクする必要がある。

実際のプログラミング

1. 初期化
    各プラットフォールで異なった書き方で初期化する必要がある。
 初期化には2つのフェースがある。
    1)  OpenGL Context の作成
    2)  OpenGLを使用する為に必要な機能をロード

2. LinuxでのOpenGL Contextの作成


GLXContext glXCreateContext(Display *  dpy,
XVisualInfo *  vis,
GLXContext  shareList,
Bool  direct);

上記関数を使用しContextを作成。

以下簡単なウィンドウ表示サンプル
// -- Written in C -- //

#include<stdio.h>
#include<stdlib.h>
#include<X11/X.h>
#include<X11/Xlib.h>
#include<GL/gl.h>
#include<GL/glx.h>
#include<GL/glu.h>

Display                 *dpy;
Window                  root;
GLint                   att[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None };
XVisualInfo             *vi;
Colormap                cmap;
XSetWindowAttributes    swa;
Window                  win;
GLXContext              glc;
XWindowAttributes       gwa;
XEvent                  xev;

void DrawAQuad() {
 glClearColor(1.0, 1.0, 1.0, 1.0);
 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 glOrtho(-1., 1., -1., 1., 1., 20.);

 glMatrixMode(GL_MODELVIEW);
 glLoadIdentity();
 gluLookAt(0., 0., 10., 0., 0., 0., 0., 1., 0.);

 glBegin(GL_QUADS);
  glColor3f(1., 0., 0.); glVertex3f(-.75, -.75, 0.);
  glColor3f(0., 1., 0.); glVertex3f( .75, -.75, 0.);
  glColor3f(0., 0., 1.); glVertex3f( .75,  .75, 0.);
  glColor3f(1., 1., 0.); glVertex3f(-.75,  .75, 0.);
 glEnd();
} 
 
int main(int argc, char *argv[]) {

 dpy = XOpenDisplay(NULL);
 
 if(dpy == NULL) {
        printf("\n\tcannot connect to X server\n\n");
        exit(0);
 }
        
 root = DefaultRootWindow(dpy);

 vi = glXChooseVisual(dpy, 0, att);

 if(vi == NULL) {
        printf("\n\tno appropriate visual found\n\n");
        exit(0);
 } 
 else {
        printf("\n\tvisual %p selected\n", (void *)vi->visualid); /* %p creates hexadecimal output like in glxinfo */
 }


 cmap = XCreateColormap(dpy, root, vi->visual, AllocNone);

 swa.colormap = cmap;
 swa.event_mask = ExposureMask | KeyPressMask;
 
 win = XCreateWindow(dpy, root, 0, 0, 600, 600, 0, vi->depth, InputOutput, vi->visual, CWColormap | CWEventMask, &swa);

 XMapWindow(dpy, win);
 XStoreName(dpy, win, "VERY SIMPLE APPLICATION");
 
 glc = glXCreateContext(dpy, vi, NULL, GL_TRUE);
 glXMakeCurrent(dpy, win, glc);
 
 glEnable(GL_DEPTH_TEST); 
 
 while(1) {
        XNextEvent(dpy, &xev);
        
        if(xev.type == Expose) {
                XGetWindowAttributes(dpy, win, &gwa);
                glViewport(0, 0, gwa.width, gwa.height);
                DrawAQuad(); 
                glXSwapBuffers(dpy, win);
        }
                
        else if(xev.type == KeyPress) {
                glXMakeCurrent(dpy, None, NULL);
                glXDestroyContext(dpy, glc);
                XDestroyWindow(dpy, win);
                XCloseDisplay(dpy);
                exit(0);
        }
    } /* this closes while(1) { */
} /* this is the } which closes int main(int argc, char *argv[]) { */

コンパイル
gcc -o test test.c -lX11 -lGL -lGLU
実行すると以下のグラフィックが表示される。

2014年5月31日土曜日

Cent OSでOpenGL 1 - GLUTを触る -

簡単にOpenGLが使えるGLUTを使用して開発&勉強。

以下サイトを参考
http://www.wakayama-u.ac.jp/~tokoi/opengl/libglut.html#3

とりあえず今日はインストールと簡単なウィンドウ表示くらいで。

・インストール
[root@localhost include]# yum install freeglut
[root@localhost include]# yum install freeglut-devel


サイトに書かれてあるウィンドウ実行するサンプルアプリを実行
・ソース
#include <GL/glut.h>

void display(void)
{
  glClear(GL_COLOR_BUFFER_BIT);
  glFlush();
}

void init(void)
{
  glClearColor(0.0, 0.0, 1.0, 1.0);
}

int main(int argc, char *argv[])
{
  glutInit(&argc, argv);
  glutInitDisplayMode(GLUT_RGBA);
  glutCreateWindow(argv[0]);
  glutDisplayFunc(display);
  init();
  glutMainLoop();
  return 0;
}
~    

・実行結果

2014年5月29日木曜日

Cent OS 6.5にpgadminをインストール

ポスグレをGUIで管理するツールpgadminが便利なので、CentOSにインストール


以下サイトを参考にインストール
http://d.hatena.ne.jp/replication/20110509/1304912031

ただ情報が古い為、wgetで取得できない。調べながらインストール。

まずはEPELを取得
[root@localhost ~]# wget http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm

インストール
[root@localhost ~]# rpm -ivh epel-release-6-8.noarch.rpm


rpmfusionをインストール
[root@localhost ~]# rpm -Uvh http://download1.rpmfusion.org/free/el/updates/6/x86_64/rpmfusion-free-release-6-1.noarch.rpm

[root@localhost ~]# rpm -Uvh http://download1.rpmfusion.org/nonfree/el/updates/6/x86_64/rpmfusion-nonfree-release-6-1.noarch.rpm


yumコマンドでpgadminをインストール
[root@localhost ~]# yum install pgadmin3

無事インストール完了!!
















ただ、DBに接続しようとするとident認証エラーが!!
という事で
http://jurakudai.blog92.fc2.com/blog-entry-4.html
を参考にしながら設定を変更。

vi /var/lib/pgsql/data/pg_hba.conf
# "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

サービスの再起動
service postgresql restart

無事、接続できました。

2014年5月26日月曜日

Cent OS 6.5 USBストレージのマウント

現在 A-TERMルータのプチNASとして活躍のUSBストレージをVM上のCent OS 6.5から
マウントして観覧可能にしたい。

という事で、マウント先のディレクトリを
/mnt/wd-2
として作成し、マウントを実行。

[root@localhost mnt]# sudo mount -t cifs //192.168.0.1/wd-2 /mnt/wd-2
mount: 間違ったファイルシステムタイプ、不正なオプション、
       //192.168.0.1/wd-2 のスーパーブロックが不正、コードページまたは
       ヘルパープログラムの未指定、或いは他のエラー
       (for several filesystems (e.g. nfs, cifs) you might
       need a /sbin/mount.<type> helper program)
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

何か分からないが怒られるorz
上記を参考にcifs関連のパッケージをインストール

[root@localhost mnt]# yum install cifs-utils
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package cifs-utils.x86_64 0:4.8.1-19.el6 will be installed
--> Processing Dependency: keyutils for package: cifs-utils-4.8.1-19.el6.x86_64
--> Running transaction check
---> Package keyutils.x86_64 0:1.4-4.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch            Version                Repository     Size
================================================================================
Installing:
 cifs-utils          x86_64          4.8.1-19.el6           base           65 k
Installing for dependencies:
 keyutils            x86_64          1.4-4.el6              base           39 k

Transaction Summary
================================================================================
Install       2 Package(s)

Total download size: 103 k
Installed size: 204 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): cifs-utils-4.8.1-19.el6.x86_64.rpm                |  65 kB     00:00     
(2/2): keyutils-1.4-4.el6.x86_64.rpm                     |  39 kB     00:00     
--------------------------------------------------------------------------------
Total                                           495 kB/s | 103 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : keyutils-1.4-4.el6.x86_64                                    1/2 
  Installing : cifs-utils-4.8.1-19.el6.x86_64                               2/2 
  Verifying  : cifs-utils-4.8.1-19.el6.x86_64                               1/2 
  Verifying  : keyutils-1.4-4.el6.x86_64                                    2/2 

Installed:
  cifs-utils.x86_64 0:4.8.1-19.el6                                              

Dependency Installed:
  keyutils.x86_64 0:1.4-4.el6                                                   

Complete!

再度マウントを実行してみる。
[root@localhost mnt]# sudo mount -t cifs //192.168.0.1/wd-2 /mnt/wd-2
Password: 
[root@localhost mnt]# ls /mnt/wd-2
$RECYCLE.BIN  20_document  40_picture  60_vm     90_backup
10_develop    30_music     50_video    70_books  readme.txt
[root@localhost mnt]# 
[root@localhost mnt]# df
Filesystem         1K-blocks      Used Available Use% Mounted on
/dev/sda2           18339256   2852416  14555256  17% /
tmpfs                 506176       232    505944   1% /dev/shm
/dev/sda1             297485     34634    247491  13% /boot
.host:/            244277768 159972844  84304924  66% /mnt/hgfs
//192.168.0.1/wd-2 976489632 166328384 810161248  18% /mnt/wd-2

無事マウントできました。

2014年5月25日日曜日

Cent OS 6.5にPostgresをインストール&設定

ポスグレをインストール

以下サイトを参考にインストール
http://lets.postgresql.jp/documents/tutorial/centos

パッケージマネージャーにてPostgresql-serverを検索し関連するものをインストール














インストールされており、Postgresユーザが作成されている事を確認








psqlコマンドやサービスに登録されているかを確認














OS起動時にサービスが自動起動するように設定
また、サービスを開始したところデータベースの初期化をしてからと怒られたので
service postgresql initdb
で初期化後、サービスを開始












ユーザ(ロール)を作成 ※今回はstoneoceanで作成





ユーザをstoneoceanに切り替えてDB作成



















2014年3月27日木曜日

Ubuntu 13.10でEclipseのメニューが表示されない

VM上にUbuntu13.10を入れて、テスト環境にしようとしたらEclipseのメニューが表示されない(--;)


↓サイトを参考に設定ファイルを修正。
http://qiita.com/ayihis@github/items/27d4c433ce162887c4b4

サイト通りに
/usr/share/applications/eclipse.desktopを修正しようとしたら若干内容が
異なっていました。

以下修正した内容

[Desktop Entry]
Type=Application
Name=Eclipse
Comment=Eclipse Integrated Development Environment
Icon=eclipse
Exec=env UBUNTU_MENUPROXY=0 eclipse
Terminal=false
Categories=Development;IDE;Java;

赤字で示した箇所をサイト通りにすると起動できないごたーです。
一応これでメニュー表示ができました。


2014年3月12日水曜日

Ubuntu 13.10 をVMにインストール

現在MBAでのVM上で使用しているCentOSがあまりパッとしないので、Ubuntuをインストールしてみた。
毎回色々問題があるので、今回はまとめ。。

まずはここからisoファイルをダウンロード。

VMからisoファイルを指定して新規インストール。日本語版をインストールしてみるが、全然日本語になっていないので、
http://kledgeb.blogspot.jp/2013/10/ubuntu-1310-7-ubuntu-japanese-team.html
ここを参考に設定、再起動で日本語になった。

















次はキーボードがMBAで使用するので、レイアウト上日本語入力ができないorz
なのでここを参考に設定。

まずは「設定」→「キーボード」→「レイアウトの設定」
















日本語(Anthy)を選択し設定マークをクリック。




















Key Bindingタブから、Latin_mode(英字), hiragana_mode(ひらがな)のショートかっとを設定する。
各項目を選択し編集ボタンをクリック。「...」ボタンをクリックして設定したいショートカットボタンをタイプする。


















キーボードの設定はこれでOK。
あとはターミナルの設定、日時の設定等を設定すればいい感じ。