예를 들면
<test>
</test>
위에서 asdf아래 라인에 aaaa를 추가하고 싶을 경우에
%s/asdf\n/&aaaa/g
이렇게 할 수 있고
aaaa다음에 한 줄을 띄우고 싶을 때 \n으로 하면 실제 한 줄이 띄어지진 않고 개행 문자가 표시 되는데 \r로 해주면 된다.
%s/asdf\n/&aaaa\r/g
이렇게~
CFLAGS="-D_FILE_OFFSET_BITS=64" ./configure --with-each-optoins위와같은 방버으로 말이다.
function fsize($file) {
// filesize will only return the lower 32 bits of
// the file's size! Make it unsigned.
$fmod = filesize($file);
if ($fmod < 0) $fmod += 2.0 * (PHP_INT_MAX + 1);
// find the upper 32 bits
$i = 0;
$myfile = fopen($file, "r");
// feof has undefined behaviour for big files.
// after we hit the eof with fseek,
// fread may not be able to detect the eof,
// but it also can't read bytes, so use it as an
// indicator.
while (strlen(fread($myfile, 1)) === 1) {
fseek($myfile, PHP_INT_MAX, SEEK_CUR);
$i++;
}
fclose($myfile);
// $i is a multiplier for PHP_INT_MAX byte blocks.
// return to the last multiple of 4, as filesize has modulo of 4 GB (lower 32 bits)
if ($i % 2 == 1) $i--;
// add the lower 32 bit to our PHP_INT_MAX multiplier
return ((float)($i) * (PHP_INT_MAX + 1)) + $fmod;
}
Memcached 사용하기
(편의상 존칭은 생략했습니다. ^^)
Memcached 데몬
사이트 : http://www.danga.com/memcached/
다운로드 : http://memcached.googlecode.com/files/memcached-1.2.8.tar.gz
Memcached PHP Extension
사이트 : http://pecl.php.net/package/memcache
다운로드 : http://pecl.php.net/get/memcache-2.2.5.tgz
LibEvent
사이트 : http://monkey.org/~provos/libevent/
다운로드 : http://monkey.org/~provos/libevent-1.4.11-stable.tar.gz
Memcached 는 데이터를 메모리에 저장하여 이용할 수 있는 데몬이다. 분산처리가 가능하고 매우 빠른 성능을 지닌 캐시 이다.
(편의상 root로 작업)
1. Memcached 설치
우선 Memcached 를 적당한 디렉토리 (/usr/local/src) 등에 다운로드를 받는다.
# tar zxvf memcached-1.2.8.tar.gz
# cd memcached-1.2.8
# configure --prefix=/usr/local/memcached
* checking for libevent directory... configure: error: libevent is required 메세지가 나오면 libevent 라이블러리를 설치를 해줘야 한다.
# make
# make install
1-1 memcached 실행
# cd /usr/local/memcached (configure 에서 지정한 prefix로 이동)
# bin/memcached -u [실행될 사용자] &
* 실행될 사용자는 memcached 데몬이 -u 옵션으로 지정된 사용자로 실행이 된다 (root로 지정하면 안됨)
# netstat -na | grep 11211
->
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN
tcp 0 0 :::11211 :::* LISTEN
포트를 확인한다.
2. Memcache PHP Extension
# tar zxvf memcache-2.2.5.tgz
# cd memcache-2.2.5
# phpize
# ./configure
# make
# cp .libs/memcache.so /(php 익스텐션 디렉토리) php.ini에서 지정한 extension_dir 에서 설정한 디렉토리
# php -m | grep memcache 로 모듈 확인
# /etc/init.d/httpd restart 또는 /usr/local/apache/bin/apachectl restart 로 Apache 재시작
PHP info 확인

3. Libevent 설치 (옵션)
* Memcache Configure 중 libevent 가 필요하다는 메세지를 보내고 중단이 되었을때 설치를 한다.
libevent 를 다운로드 받는다.
# tar zxvf libevent-1.4.11-stable.tar.gz
# cd libevent-1.4.11-stable
# ./configure
# make
# make install (/usr/local/lib 에 libevent.so 파일이 존재하는지 확인한다.)
# ldconfig (vi /etc/ld.so.conf 에 /usr/local/lib 추가를 한다.
[출처] http://www.lovelgw.com/Blog/94
4. 추가옵션 - phpize실행 시 autoconf없다는 에러 나는 경우
# cd /usr/local/src (적당한 곳으로 이동)
m4설치
# wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz
# tar zxvf m4-1.4.9.tar.gz
# cd m4-1.4.9/
# ./configure && make && make install
# cd ../
autoconf 설치
# wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz
# tar zxvf autoconf-2.62.tar.gz
# cd autoconf-2.62/
# ./configure && make && make install
SELECT pg_get_serial_sequence('table_name', 'column_name')
이렇게하면 해당 테이블의 컬럼의 sequence이름을 알 수 있다.SELECT * FROM sequence_name해당 sequence의 정보를 볼 수 있다.
| sequence_name name |
last_value bigint |
start_value bigint |
increment_by bigint |
max_value bigint |
min_value bigint |
cache_value bigint |
log_cnt bigint |
is_cycled boolean |
is_called boolean |
| sequence_name | 10 | 1 | 1 | 92233123~~ | 1 | 1 | 31 | f | t |