Tag Archives: create

Ubuntu: Create own deb package

I'll show you how to create own deb package using modified nginx
1) we download nginx sources
2) we download some external nginx modules
3) we run

1
2
3
4
5
6
7
./configure --with-cc-opt="-static -static-libgcc" --with-ld-opt="-Bstatic" --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid \
    --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
    --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx \
    --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Wp,-D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed' \
    --add-module=./modules/naxsi/naxsi_src \
    --add-module=./modules/nginx-goodies-nginx-sticky-module-ng-bd312d586752 \
    --add-module=./modules/headers-more-nginx-module-0.25

4) make
after make we have out/nginx file so we could create own package using it

$ mkdir -p /opt/nginx/deb/nginx-ng
$ cd /opt/nginx/deb/nginx-ng
$ ls -1

1
2
3
4
DEBIAN
etc
usr
var

I downloaded original nginx deb and unpack it, after that I took DEBIAN, usr, var and etc folders from it
Continue reading Ubuntu: Create own deb package

LVM: reduce partition size

# umount mountpoint with lvm partition
unmount /data

# check for errors and fix them
fsck -f /dev/sys/data

# resize filesystem to 80Gb
resize2fs /dev/sys/data 80G

# deactivate logical volume
lvchange -an /dev/sys/data

# change size of logical volume
lvreduce --size 191G /dev/sys/data

# create new volume «drbdmaster» in logical group «sys» with size 4Gb
lvcreate -n drbdmaster -L4G sys

# activate volumes
lvchange -ay  /dev/sys/data
lvchange -ay /dev/sys/drbdmaster

# mount data
mount /dev/sys/data

# create filesystem on drbdmaster
mkfs.ext4 /dev/sys/drbdmaster

# mount drbdmaster
mkdir -p /drbd/master
mount /dev/sys/drbdmaster /drbd/master

mongodb: replica master-slave + creating of db and collection

Replica master-slave

master
add to mongod.conf:
master = true
client
add to mongod.conf:
slave = true
source = $masterHost:$masterPort #(for example 127.0.0.1:27017)

stop master
rsync folder with db from master to slave
start master
start slave

Creating of db and collection

# open mongo shell
mongo --host 127.0.0.1:27017
# use db name which you'd like to create
use newDbName
# data which you'd like to add to collection
j = { name : «mongo» }
# insert previous data to collection
db.testData.insert ( j )

# check that db/collection/data were created
show dbs
show collections
db.testData.find ()

check replica

# open mongo shell on slave
mongo --host 10.0.0.2:27017
# check that db/collection/data were created
show dbs
show collections
db.testData.find ()