2014年5月9日 星期五

OpenVZ VPS 增加 Postgresql shared_buffers

修改 VPS $VEID 中 /etc/sysctl.conf 內容如下
# Controls the default maxmimum size of a mesage queue
 kernel.msgmnb = 65536
# Controls the maximum size of a message, in bytes
 kernel.msgmax = 65536
# Controls the maximum shared segment size, in bytes
 kernel.shmmax = 68719476736
# Controls the maximum number of shared memory segments, in pages
 kernel.shmall = 4294967296

修改 VPS $VEID 中 /var/lib/pgsql/data/postgresql.conf 內容
shared_buffers = 512MB

重新啟動 VPS
vzctl restart $VEID

OpenVZ VPS(CentOS 6) 安裝 Glusterfs 摘要

RedHat已將 Glusterfs 加入官方 RPM中,以下 repo 相關指令可不執行
vzctl exec $VEID wget -P /etc/yum.repos.d http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/glusterfs-epel.repo

vzctl exec $VEID yum install glusterfs-{,fuse,server}

vzctl stop $VEID
vzctl set $VEID --devices c:10:229:rw --save
vzctl exec $VEID mknod /dev/fuse c 10 229 
vzctl set $VEID --capability sys_admin:on --save

vzctl restart $VEID

PROXMOX(version 3.21) Open VZ VPS 使用 iptables 作 PORT 轉向

proxmox 載入相關 modules
modprobe xt_state
modprobe xt_tcpudp
modprobe ip_conntrack

編輯 /etc/vz/conf/$VEID.conf 加入
IPTABLES="ipt_REJECT ipt_tos ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat"

VPS重新啟動
vzctl restart $VEID

iptables 範例  port 888 轉向 port 80
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 888 -j DNAT --to  $(ip addr show eth0 |grep "inet "|cut -d "/" -f 1|cut -d \t -f 2):80

iptables -L -n 
iptables -t nat -L -n 

OpenVZ 更改 VPS hostname

vzctl set $VEID --hostname "new-hostname" --save

OPenVZ VPS 使用特定分割區 (Bind mounts)

CTID=777   # VPS container ID
 
echo '#!/bin/bash
. /etc/vz/vz.conf
. ${VE_CONFFILE}
SRC=/mnt/disk    #  HN 掛載目錄
DST=/mnt/disk    #  VPS 中要掛載目錄
if [ ! -e ${VE_ROOT}${DST} ]; then mkdir -p ${VE_ROOT}${DST}; fi
mount -n -t simfs ${SRC} ${VE_ROOT}${DST} -o ${SRC}
' > /etc/vz/conf/${CTID}.mount
 
chmod +x /etc/vz/conf/${CTID}.mount

>參考 http://wiki.openvz.org/Bind_mounts