블로그 이미지
너덜

calendar

1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

Notice

Tag

'분류 전체보기'에 해당되는 글 5

  1. 2012.04.04 mysql
  2. 2012.04.04 node 설치 및 nowjs 로 쳇팅 바로 테스트해보기.
  3. 2012.04.04 apache 설치.
  4. 2012.04.04 ./mongo
  5. 2012.04.04 몽고DB 시작하기.
2012. 4. 4. 17:45 db/mysql
posted by 너덜
2012. 4. 4. 16:47 dev/node.js

node

yum install g++ curl libssl-dev apa

wget http://nodejs.org/dist/v0.6.14/node-v0.6.14.tar.gz

./configure
make
make install

./configure --prefix=/usr/local/node


hellowowrld.js
console.log('hello world');

node helloworld

 


require()
module.exports

[root@db02 src]# npm install nodemon -g
npm http GET https://registry.npmjs.org/nodemon
npm http 200 https://registry.npmjs.org/nodemon
npm http GET https://registry.npmjs.org/nodemon/-/nodemon-0.6.12.tgz
npm http 200 https://registry.npmjs.org/nodemon/-/nodemon-0.6.12.tgz
/usr/local/bin/nodemon -> /usr/local/lib/node_modules/nodemon/nodemon.js
nodemon@0.6.12 /usr/local/lib/node_modules/nodemon


[root@db02 src]# npm search twitter


익스프레스
expressjs.com

npm install -g express
npm install express jade


[root@db02 simpleweb]# pwd
/data/chapter-06/simpleweb
node app.js

 

 

nowjs
NowJS is a Node.js module. The client javascript (now.js) is served by the NowJS server.

http://nowjs.com/

NowJS 의 비밀은 두 개의 마술 주머니에서 비롯됩니다. 바로 now 와 everyone.now 입니다. now 객체는 클라이언트와 서버 사이에서 공유되는 마술 주머니입니다. 클라이언트는 now 객체에 변수와 함수들을 자유롭게 넣을 수 있고, 서버 또한 자유롭게 그것들에 접근할 수 있습니다. 물론 반대로도 가능합니다.
서버는 한 번에 수많은 클라이언트 연결을 가질 수 있습니다. 이는  바꿔 말하면 한 번에 수많은 마술주머니를 관리해야 한다는 뜻입니다. 그것이 바로 everyone.now 라는 또다른 마술 주머니를 서버가 가지고 있는 이유입니다. 서버가 everyone.now 에 어떤 변수를 추가하거나 변경하게 되면 모든 클라이언트 각각의 now 가 함께 변경됩니다.

설치
npm install -g now

간단한 테스트.
[root@db02 data]# node /data/node_modules/now/examples/helloworld_example/helloworld_server.js

http://localhost:8080/


아래의 내용을 보면 더 좋다.
http://nowjs.com/guide

체팅 예제.
https://github.com/downloads/Flotype/now/chat-example.tgz

 

Calipso
http://calip.so/quickstart-install-calipso.html
https://github.com/cliftonc/calipso


nowjs-chat
https://github.com/liamcurry/nowjs-chat

nodeChat
https://github.com/ztaccardi/nodeChat

 

posted by 너덜
2012. 4. 4. 14:04 server/apache

apache 설정

#### 1. directory make & install & download

mkdir /app/src
cd /app/src


yum install wget make sendmail

yum -y install gcc gcc-c++ compat-gcc-34-g77 flex openssl* termcap libtermcap libtermcap-devel gdbm-devel gd* php-gd zlib* pam* curl* pid* libiconv libmcrypt* libmhash libxml* freetype* ncurses* libpng* libjpeg* bzip2-devel openldap-devel libc-client-devel php5-dev bison libtool

wget http://192.168.0.1/src/httpd-2.2.17.tar.gz
wget http://192.168.0.1/src/php-5.2.14.tar.gz
wget http://192.168.0.1/src/mysql-5.1.51.tar.gz
wget http://192.168.0.1/src/cronolog-1.6.2.tar.gz
wget http://192.168.0.1/src/ZendOptimizer-3.3.3-linux-glibc23-x86_64.tar.gz
wget http://caos.kldp.net/frs/download.php/4855/mod_url-apache2-1.15.tar.gz2

wget http://www.sqlite.org/cvstrac/getfile/sqlite/tool/lemon.c
gcc -o lemon lemon.c
mv lemon /usr/loca/bin/


#### 2. httpd-2.2.17

cd /app/src
tar xvzf httpd-2.2.17.tar.gz

cd /app/src/httpd-2.2.17
./configure --prefix=/app/apache --enable-rule=SHARED_CORE --enable-modules=all --enable-mods-shared=most --enable-so --enable-ssl --with-mpm=worker
make
make install

cp -f /app/apache/bin/apachectl /etc/rc.d/init.d/httpd
ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S99httpd


#### mod_url설치.

cd /app/src
tar xvf mod_url-apache2-1.15.tar.gz2
/app/apache/bin/apxs -aic mod_url-apache2/mod_url.c

echo '<IfModule mod_url.c>' >> /app/apache/conf/httpd.conf
echo 'CheckURL On' >> /app/apache/conf/httpd.conf
echo '</IfModule>' >> /app/apache/conf/httpd.conf


#### cronolog 설치.
cd /app/src
tar xvzf cronolog-1.6.2.tar.gz
cd cronolog-1.6.2
./configure --prefix=/app/cronolog
make
make install


#### 3. mysql client 설치.
cd /app/src/
tar xvzf mysql-5.1.51.tar.gz
cd mysql-5.1.51
./configure --prefix=/app/mysql --enable-thread-safe-client --with-charset=utf8 --without-server --without-docs --without-man
make
make install

 

#### 4. PHP 설치.
cd /app/src
tar xvzf php-5.2.14.tar.gz
cd php-5.2.14
./configure --prefix=/app/php --with-apxs2=/app/apache/bin/apxs --with-mysql=/app/mysql --with-mysqli=/app/mysql/bin/mysql_config --with-config-file-path=/app/apache/conf --with-gd --enable-magic-quotes --enable-ftp --enable-sockets --with-zlib --with-png-dir --with-jpeg-dir --with-freetype-dir --disable-debug --with-freetype-dir --with-libxml-dir=/usr/lib --with-curl --enable-mbstring --enable-exif --with-iconv --with-openssl --enable-soap --with-mcrypt
make
make install

cp /app/src/php-5.2.14/php.ini-dist /app/apache/conf/php.ini


vi /app/apache/conf/httpd.conf

## 1.   DirectoryIndex index.html 옆에 index.php 추가.
## 2. #AddOutputFilter INCLUDES .shtml 밑에 아래 추가.
    AddType application/x-httpd-php .php .htm .html
    AddType application/x-httpd-php-source .phps

echo '<?phpinfo();?>' > /app/apache/htdocs/index.php

 

#### 4.1 Zend 설치.
cd /app/src
tar xvzf ZendOptimizer-3.3.3-linux-glibc23-x86_64.tar.gz
sh /app/src/ZendOptimizer-3.3.3-linux-glibc23-x86_64/install.sh

# /app/Zend
# /app/apache/conf
# /app/apache/bin/apachectl

 

 

#### 압축 설정

vi /app/apache/conf/httpd.conf

<IfModule mod_deflate.c>
        AddOutputFilterByType DEFLATE text/plain text/html text/xml
        AddOutputFilterByType DEFLATE application/xhtml+xml application/xml application/rss+xml
        AddOutputFilterByType DEFLATE text/css application/javascript application/x-javascript
        AddOutputFilterByType DEFLATE audio/midi

        DeflateCompressionLevel 1

        BrowserMatch ^Mozilla/4 gzip-only-text/html
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</ifModule>

 

#### vhost 아래 내용은 test.com으로 오는 놈을 www.test.com으로 변경하는 작업이다.

<VirtualHost *:80>
    ServerAdmin nerd@naver.com
    DocumentRoot "/data/apache/www/"
    ServerName test.com
    RedirectMatch /(.*)$ http://www.test.com/$1
    ErrorLog "|/app/cronolog/sbin/cronolog /data/logs/www-redirect-error_%Y%m%d.log"
    CustomLog "|/app/cronolog/sbin/cronolog /data/logs/www-redirect-access_%Y%m%d.log" common
    <Directory />
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
 
<VirtualHost *:80>
    ServerAdmin nerd@freebee.kr
    DocumentRoot "/data/apache/www/"
    ServerName www.azubu.com
    ErrorLog "|/app/cronolog/sbin/cronolog /data/logs/www-error_%Y%m%d.log"
    CustomLog "|/app/cronolog/sbin/cronolog /data/logs/www-access_%Y%m%d.log" common
    <Directory />
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

# vi 아파치 경로/server/mpm/worker/worker.c
[EDITOR]#define DEFAULT_SERVER_LIMIT 16 을
[EDITOR]#define DEFAULT_SERVER_LIMIT 20 으로 수정
저장하고 아웃 하셔야 합니다.


KeepAlive On
KeepAliveTimeout 2
Timeout 30


ServerLimit 20 --> 서버 갯수를 설정합니다.
StartServers 20 --> 아파치를 처음 시작할때 생성하는 서버 갯수입니다.
MaxClients 1280 --> ThreadsPerChild * StartServers 값입니다.
ThreadsPerChild 64 --> 서버 하나가 만들어 낼수 있는 쓰레드 갯수입니다. 최대 64개 입니다.
MinSpareThreads 64 -->  서버 하나가 만들어 낼수 있는 쓰레드의 최소 갯수입니다. 보통은 ThreadsPerChild 와 맞추어 줍니다.
MaxSpareThreads 1280 --> 시스템 전체에서 만들어 낼수 있는 쓰레드 갯수의 최대치 입니다.
                    ThreadsPerChild(64) * StartServers(20) 값이며, 보통 MaxClients 와 맞추어 줍니다.
MaxRequestsPerChild 0 --> 서버 하나가 만들어 내는 접속의 최대치 입니다. 0 일경우 무한대 이며, 숫자를 적으면 그 숫자만큼 접속되고 나면 서버를 죽였다 살립니다.

 

ServerLimit          20
StartServers         20
MaxClients         1280
MinSpareThreads      64
MaxSpareThreads    1280
ThreadsPerChild      64
MaxRequestsPerChild   0

posted by 너덜
2012. 4. 4. 13:57 db/mongoDB

[root@db02 bin]# ./mongo
MongoDB shell version: 2.0.4
connecting to: test
> help
db.help() help on db methods
db.mycoll.help() help on collection methods
rs.help() help on replica set methods
help admin administrative help
help connect connecting to a db help
help keys key shortcuts
help misc misc things to know
help mr mapreduce

show dbs show database names
show collections show collections in current database
show users show users in current database
show profile show most recent system.profile entries with time >= 1ms
show logs show the accessible logger names
show log [name] prints out the last segment of log in memory, 'global' is default
use <db_name> set current database
db.foo.find() list objects in collection foo
db.foo.find( { a : 1 } ) list objects in foo where a == 1
it result of the last line evaluated; use to further iterate
DBQuery.shellBatchSize = x set default number of items to display on shell
exit quit the mongo shell
>

> db.help()
DB methods:
db.addUser(username, password[, readOnly=false])
db.auth(username, password)
db.cloneDatabase(fromhost)
db.commandHelp(name) returns the help for the command
db.copyDatabase(fromdb, todb, fromhost)
db.createCollection(name, { size : ..., capped : ..., max : ... } )
db.currentOp() displays the current operation in the db
db.dropDatabase()
db.eval(func, args) run code server-side
db.getCollection(cname) same as db['cname'] or db.cname
db.getCollectionNames()
db.getLastError() - just returns the err msg string
db.getLastErrorObj() - return full status object
db.getMongo() get the server connection object
db.getMongo().setSlaveOk() allow this connection to read from the nonmaster member of a replica pair
db.getName()
db.getPrevError()
db.getProfilingLevel() - deprecated
db.getProfilingStatus() - returns if profiling is on and slow threshold
db.getReplicationInfo()
db.getSiblingDB(name) get the db at the same server as this one
db.isMaster() check replica primary status
db.killOp(opid) kills the current operation in the db
db.listCommands() lists all the db commands
db.logout()
db.printCollectionStats()
db.printReplicationInfo()
db.printSlaveReplicationInfo()
db.printShardingStatus()
db.removeUser(username)
db.repairDatabase()
db.resetError()
db.runCommand(cmdObj) run a database command. if cmdObj is a string, turns it into { cmdObj : 1 }
db.serverStatus()
db.setProfilingLevel(level,<slowms>) 0=off 1=slow 2=all
db.shutdownServer()
db.stats()
db.version() current version of the server
db.getMongo().setSlaveOk() allow queries on a replication slave server
db.fsyncLock() flush data to disk and lock server for backups
db.fsyncUnock() unlocks server following a db.fsyncLock()
>

> db.mycoll.help()
DBCollection help
db.mycoll.find().help() - show DBCursor help
db.mycoll.count()
db.mycoll.dataSize()
db.mycoll.distinct( key ) - eg. db.mycoll.distinct( 'x' )
db.mycoll.drop() drop the collection
db.mycoll.dropIndex(name)
db.mycoll.dropIndexes()
db.mycoll.ensureIndex(keypattern[,options]) - options is an object with these possible fields: name, unique, dropDups
db.mycoll.reIndex()
db.mycoll.find([query],[fields]) - query is an optional query filter. fields is optional set of fields to return.
e.g. db.mycoll.find( {x:77} , {name:1, x:1} )
db.mycoll.find(...).count()
db.mycoll.find(...).limit(n)
db.mycoll.find(...).skip(n)
db.mycoll.find(...).sort(...)
db.mycoll.findOne([query])
db.mycoll.findAndModify( { update : ... , remove : bool [, query: {}, sort: {}, 'new': false] } )
db.mycoll.getDB() get DB object associated with collection
db.mycoll.getIndexes()
db.mycoll.group( { key : ..., initial: ..., reduce : ...[, cond: ...] } )
db.mycoll.mapReduce( mapFunction , reduceFunction , <optional params> )
db.mycoll.remove(query)
db.mycoll.renameCollection( newName , <dropTarget> ) renames the collection.
db.mycoll.runCommand( name , <options> ) runs a db command with the given name where the first param is the collection name
db.mycoll.save(obj)
db.mycoll.stats()
db.mycoll.storageSize() - includes free space allocated to this collection
db.mycoll.totalIndexSize() - size in bytes of all the indexes
db.mycoll.totalSize() - storage allocated for all data and indexes
db.mycoll.update(query, object[, upsert_bool, multi_bool])
db.mycoll.validate( <full> ) - SLOW
db.mycoll.getShardVersion() - only for use with sharding
db.mycoll.getShardDistribution() - prints statistics about data distribution in the cluster
>

'db > mongoDB' 카테고리의 다른 글

몽고DB 시작하기.  (0) 2012.04.04
posted by 너덜
2012. 4. 4. 13:56 db/mongoDB

몽고DB

mkdir -p /data/db
http://www.mongodb.org

http://www.mongodb.org/display/DOCS/SQL+to+Mongo+Mapping+Chart
http://www.mongodb.org/display/DOCS/SQL+to+Aggregation+Framework+Mapping+Chart
http://bsonspec.org/
http://json.org/json-ko.html


wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.4.tgz

tar xvzf mongodb-linux-x86_64-2.0.4.tgz
mv mongodb-linux-x86_64-2.0.4 /usr/local/mongodb

[root@db02 ~]# vi .bash_profile

PATH=$PATH:/usr/local/mongodb/bin


[root@db02 bin]# mkdir /data/db
[root@db02 bin]# ./mongod
./mongod --help for help and startup options
Tue Apr 3 22:56:29 [initandlisten] MongoDB starting : pid=17303 port=27017 dbpath=/data/db/ 64-bit host=db02
Tue Apr 3 22:56:29 [initandlisten] db version v2.0.4, pdfile version 4.5
Tue Apr 3 22:56:29 [initandlisten] git version: 329f3c47fe8136c03392c8f0e548506cb21f8ebf
Tue Apr 3 22:56:29 [initandlisten] build info: Linux ip-10-110-9-236 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41
Tue Apr 3 22:56:29 [initandlisten] options: {}
Tue Apr 3 22:56:29 [initandlisten] journal dir=/data/db/journal
Tue Apr 3 22:56:29 [initandlisten] recover : no journal files present, no recovery needed
Tue Apr 3 22:56:29 [initandlisten] waiting for connections on port 27017
Tue Apr 3 22:56:29 [websvr] admin web console waiting for connections on port 28017


http://ip:28017/

[root@db02 bin]# ./mongostat
connected to: 127.0.0.1
insert query update delete getmore command flushes mapped vsize res faults locked % idx miss % qr|qw ar|aw netIn netOut conn time
0 0 0 0 0 1 0 0m 180m 15m 0 0 0 0|0 0|0 62b 1k 1 23:00:45
0 0 0 0 0 1 0 0m 180m 15m 0 0 0 0|0 0|0 62b 1k 1 23:00:46
0 0 0 0 0 1 0 0m 180m 15m 0 0 0 0|0 0|0 62b 1k 1 23:00:47
0 0 0 0 0 1 0 0m 180m 15m 0 0 0 0|0 0|0 62b 1k 1 23:00:48

[root@db02 bin]# ./mongotop
connected to: 127.0.0.1

ns total read write 2012-04-03T23:00:54
local.system.namespaces 0ms 0ms 0ms
admin.system.users 0ms 0ms 0ms

ns total read write 2012-04-03T23:00:55
local.system.namespaces 0ms 0ms 0ms
admin.system.users 0ms 0ms 0ms

ns total read write 2012-04-03T23:00:56
local.system.namespaces 0ms 0ms 0ms
admin.system.users 0ms 0ms 0ms

[root@db02 bin]#


[root@db02 bin]# ./mongod --rest --nohttpinterface &
[1] 17395
[root@db02 bin]# Tue Apr 3 23:10:12 [initandlisten] MongoDB starting : pid=17395 port=27017 dbpath=/data/db/ 64-bit host=db02
Tue Apr 3 23:10:12 [initandlisten] db version v2.0.4, pdfile version 4.5
Tue Apr 3 23:10:12 [initandlisten] git version: 329f3c47fe8136c03392c8f0e548506cb21f8ebf
Tue Apr 3 23:10:12 [initandlisten] build info: Linux ip-10-110-9-236 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41
Tue Apr 3 23:10:12 [initandlisten] options: { nohttpinterface: true, rest: true }
Tue Apr 3 23:10:12 [initandlisten] journal dir=/data/db/journal
Tue Apr 3 23:10:12 [initandlisten] recover : no journal files present, no recovery needed


http://ip:28017/_status


[root@db02 bin]# mongodump -d test -o /data/db/backup
connected to: 127.0.0.1
DATABASE: test to /data/db/backup/test
[root@db02 bin]# mongorestore -d foo --drop /data/db/backup/test
connected to: 127.0.0.1

'db > mongoDB' 카테고리의 다른 글

./mongo  (0) 2012.04.04
posted by 너덜
prev 1 next