Percona Monitoring Plugins for Zabbix3

Standard
#Install
apt-get install percona-zabbix-templates
cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.conf.d/
#Configure 
vi /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php
...
$mysql_user = 'uid';
$mysql_pass = 'pwd';
...
#Test
/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg

zbx_percona_mysql_template

A ton of data to import with a shell

Standard

schema_import.sh

#!/bin/bash
for f in *schema*.gz; do
  DBName=$(echo $f | cut -d - -f 5)
  echo "Create "${DBName}
  echo "create database if not exists ${DBName}" | /usr/bin/mysql -u root -pXXXXXX
  zcat ${f} | /usr/bin/mysql -u root -pXXXXXX ${DBName}
  echo "Created"
done

data_import.sh

#!/bin/bash
for f in *data*.gz; do
  DBName=$(echo $f | cut -d - -f 5)
  echo "Import "${DBName}
  zcat ${f} | /usr/bin/mysql -u root -pXXXXXX ${DBName}
  echo "Imported"
done

一大坨文件

/nfs/dbs/31/mysql-slave-31.lololololol.com-schema-user_cluster_1-11-27-16.sql.gz
/nfs/dbs/31/mysql-slave-31.lololololol.com-schema-user_cluster_2-11-27-16.sql.gz
...
 
/nfs/dbs/31/mysql-slave-31.lololololol.com-data-user_cluster_1-11-27-16.sql.gz
/nfs/dbs/31/mysql-slave-31.lololololol.com-data-user_cluster_2-11-27-16.sql.gz
...

ps:
公司收了一家美国的论坛服务商,那边留了个人交接.
放了个NFS,上去一看,好家伙.每台机器目录下有几千个小的备份文件.
问其why,答long story…
好吧…好在文件命名还算规律。

dump.sh

MYSQL_PORT=$1
FILE_NAME=$2
MYSQL_IP=x.x.x.x
MYSQL_USER=uid
MYSQL_PASS=pwd
MYSQL_CONN="-u${MYSQL_USER} -p${MYSQL_PASS} -h${MYSQL_IP} -P${MYSQL_PORT}"
#
# Collect all database names except for
# mysql, information_schema, and performance_schema
#
SQL="SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT IN"
SQL="${SQL} ('mysql','information_schema','performance_schema')"
 
DBLISTFILE=/tmp/DatabasesToDump-${FILE_NAME}.txt
mysql ${MYSQL_CONN} -ANe"${SQL}" > ${DBLISTFILE}
 
DBLIST=""
for DB in `cat ${DBLISTFILE}` ; do DBLIST="${DBLIST} ${DB}" ; done
 
MYSQLDUMP_OPTIONS="--routines --triggers --single-transaction"
mysqldump ${MYSQL_CONN} ${MYSQLDUMP_OPTIONS} --databases ${DBLIST} | pv | gzip > db-${FILE_NAME}.sql.gz
wget https://repo.percona.com/apt/percona-release_0.1-4.$(lsb_release -sc)_all.deb && dpkg -i percona-release_0.1-4.$(lsb_release -sc)_all.deb && apt-get update && apt-get -y upgrade && apt-get -y install lvm2 xfsprogs percona-server-server-5.7
 
# add 2 x 128 ssd and 1 x 256 hdd
# ssd n enter enter enter enter t enter 8e enter w enter
fdisk /dev/sdc
fdisk /dev/sdd
 
# hdd
fdisk /dev/sde
 
pvcreate /dev/sdc1 /dev/sdd1 /dev/sde1 && vgcreate mysql /dev/sdc1 /dev/sdd1 && vgcreate data /dev/sde1 && lvcreate --name data --size 240G mysql && lvcreate --name backups --size 240G data
 
mkfs.xfs /dev/mapper/mysql-data && mkfs.xfs /dev/mapper/data-backups
 
edit /etc/fstab
/dev/mapper/mysql-data /var/lib/mysql auto  defaults,nobarrier 0 2
/dev/mapper/data-backups /data auto  defaults,nobarrier 0 2
 
service mysql stop && cd /var/lib && mv mysql mysql.old && mkdir mysql && mkdir /data && mount -a && mv mysql.old/* mysql/  && chown mysql:mysql mysql
 
vi /etc/security/limits.d/91-mysql.conf
mysql   soft    nofile 400000
mysql   hard    nofile 400000 
 
/etc/sysctl.conf
fs.file-max = 20000000
net.ipv4.tcp_fin_timeout = 10
kernel.pid_max = 65535
kernel.randomize_va_space = 1
net.core.netdev_max_backlog=32768
net.core.rmem_max = 8388608
net.core.somaxconn = 16384
net.core.wmem_max = 8388608
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.all.log_martians = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.default.log_martians = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.secure_redirects = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv4.ip_forward=0
net.ipv4.ip_local_port_range = 2000 65000
net.ipv4.tcp_max_syn_backlog=8192
net.ipv4.tcp_rmem = 4096 87380 8388608
net.ipv4.tcp_syncookies=0
net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_tw_reuse = 0
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_wmem = 4096 87380 8388608
vm.overcommit_memory = 1
vm.swappiness = 0
fs.aio-max-nr = 500000
 
sysctl -p
 
echo session required pam_limits.so >> /etc/pam.d/common-session
 
vi /etc/mysql/percona-server.conf.d/mysqld.cnf 
[mysqld]
user   = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket   = /var/run/mysqld/mysqld.sock
port   = 3306
basedir    = /usr
datadir    = /var/lib/mysql
tmpdir   = /tmp
lc-messages-dir  = /usr/share/mysql
explicit_defaults_for_timestamp
innodb_use_native_aio=1
max_connections=4096
wait_timeout=5
interactive_timeout=120
myisam_sort_buffer_size=1024M
sort_buffer_size=1024M
innodb_file_per_table=ON
skip-name-resolve
default-storage-engine=InnoDB
max_allowed_packet=64M
# 48 hours
expire_logs_days = 3
server-id              = 108
innodb_data_file_path = ibdata1:10M:autoextend
#innodb_buffer_pool_size = 28000M
innodb_flush_method = O_DIRECT
innodb_file_per_table
bind-address = 0.0.0.0
log-error    = /var/log/mysql/error.log
#log-erorr = /dev/null
log_error_verbosity=3
# Recommended in standard MySQL setup
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_ALL_TABLES
sql_mode=""
symbolic-links=0
 
# Forum requires this
lower_case_table_names  = 1
master-info-repository=TABLE
relay-log-info-repository=TABLE
replicate-do-table              = account.identity_data
replicate-do-table              = account.signature_data
replicate-do-table              = account.account_usertypes
replicate-do-table              = account.banned_words
replicate-wild-do-table         = forum\_skeleton.%
replicate-wild-do-table = domain\_%.%
replicate-wild-do-table = user\_cluster\_%.%
slave-skip-errors               = 1062
open-files-limit=400000
myisam-recover-options=FORCE,BACKUP

Hive安装配置

Standard

Hadoop集群安装配置

wget http://mirrors.gigenet.com/apache/hive/stable-2/apache-hive-2.0.0-bin.tar.gz
 
tar zxf apache-hive-2.0.0-bin.tar.gz
mv apache-hive-2.0.0 /usr/local/
cd /usr/local
mv apache-hive-2.0.0 hive
 
cat /etc/profile
...
HIVE_HOME=/usr/local/hive
PATH=$PATH:$HIVE_HOME/bin
export HIVE_HOME PATH
...
 
cd /usr/local/hive/conf
cp hive-default.xml.template hive-default.xml
vi /usr/local/hive/conf/hive-site.xml
<configuration>
        <property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://Master:3306/hive?createDatabaseIfNotExist=true</value>
        <description>JDBC connect string for a JDBC metastore</description>
        </property>
        <property>
        <name>javax.jdo.option.ConnectionDriverName</name>
        <value>com.mysql.jdbc.Driver</value>
        <description>Driver class name for a JDBC metastore</description>
        </property>
        <property>
        <name>javax.jdo.option.ConnectionUserName</name>
        <value>hive<value>
        <description>username to use against metastore database</description>
        </property>
        <property>
        <name>javax.jdo.option.ConnectionPassword</name>
        <value>hive</value>
        <description>password to use against metastore database</description>
        </property>
</configuration>
mysql>CREATE USER 'hive' IDENTIFIED BY 'hive';
mysql>GRANT ALL PRIVILEGES ON *.* TO 'hive'@'hadoop-master' WITH GRANT OPTION;
mysql>FLUSH privileges;
mysql>CREATE DATABASE hive;
cd ~
wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.38.tar.gz
tar zxf mysql-connector-java-5.1.38.tar.gz
cd mysql-connector-java-5.1.38
cp mysql-connector-java-5.1.38-bin.jar /usr/local/hive/lib/
 
scp -r /usr/local/hive Slave1:/usr/local/
scp -r /usr/local/hive Slave2:/usr/local/
#create the schema
schematool -initSchema -dbType mysql
 
#for client on Slave1,2
hive --service metastore &
 
hive
hive> show databases;

#Slave1,2

cat /usr/local/hive/conf/hive-site.xml
<configuration>
    <property>  
        <name>hive.metastore.uris</name>  
        <value>thrift://Master:9083</value>
    </property>
</configuration>

CentOS+Postfix+Dovecot+PostfixAdmin + Amavisd+ClamAV+SpamAssassin

Standard

基础安装
[root@yemaosheng.com ~ ] yum install -y postfix dovecot
[root@yemaosheng.com ~ ] hostname
mail.example.com
[root@yemaosheng.com ~ ] vi /etc/hosts
127.0.0.1 mail.example.com
[root@yemaosheng.com ~ ] vi /etc/postfix;

#主机名系统
myhostname = mail.example.com
#域名
mydomain = example.com
#本地投递邮件显示的域名
myorigin = $mydomain
#设置接受邮件的网络接口IP, Listen 127.0.0.1
#inet_interfaces = $myhostname, localhost
#Listen *
inet_interfaces = all
#系统所有本地投递的域名列表
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#172.28.100.0 为内网IP段
mynetworks = 192.168.100.0/24, 127.0.0.0/8
#允许中继的域名
relay_domains =
#设置存放用户邮件的用户目录
home_mailbox = Maildir/

[root@yemaosheng.com ~ ] vi /etc/dovecot.conf;

protocols = imap imaps pop3 pop3s
mail_location = maildir:~/Maildir
pop3_uidl_format = %08Xu%08Xv

[root@yemaosheng.com ~ ] useradd test
[root@yemaosheng.com ~ ] useradd test2
[root@yemaosheng.com ~ ] mkdir /home/test/Maildir
[root@yemaosheng.com ~ ] chown test.test /home/test/Maildir
[root@yemaosheng.com ~ ] chmod -R 700 /home/test/Maildir
[root@yemaosheng.com ~ ] mkdir /home/test2/Maildir
[root@yemaosheng.com ~ ] chown test2.test2 /home/test2/Maildir
[root@yemaosheng.com ~ ] chmod -R 700 /home/test2/Maildir

至此,已经能用系统帐号收发邮件了.

================================================

下面,在之前基础上修改,使用虚拟用户帐号,安装Mysql和PostfixAdmin

安装配置POSTFIXADMIN

下载
cd /var/www/html/;
wget http://downloads.sourceforge.net/project/postfixadmin/postfixadmin/postfixadmin-2.3.3/postfixadmin-2.3.3.tar.gz;
tar zxvf postfixadmin-2.3.3.tar.gz;
mv postfixadmin-2.3.3.tar.gz postfixadmin;
cd postfixadmin;

修改config文件
vi config.inc.php;

$CONF['configured'] = true;
$CONF['default_language'] = 'cn';
$CONF['postfix_admin_url'] = '/postfixadmin';
$CONF['database_type'] = 'mysql';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfix';
$CONF['database_password'] = ‘postfix';
$CONF['database_name'] = 'postfix';
$CONF['domain_path'] = 'YES';
$CONF['domain_in_mailbox'] = 'NO';
$CONF['encrypt'] = 'md5';
$CONF['emailcheck_resolve_domain] = 'NO';

然后别忘了先建个postfix库
mysql -e ‘create database postfix’;

访问安装页面

1.访问http://IP/postfixadmin/setup.php
2.创建Setup password(如:123456)
  点击“Generate password hash”获取一段加密代码
  将该代码拷贝到配置文件config.inc.php中的以下配置中
  $CONF['setup_password'] = 'change';(用加密代码替换change)
  然后再次访问PostfixAdmin的设置页,创建管理员的账号和密码
  (需要正确输入之前创建的Setup password才能创建管理员账号)
3.访问PostfixAdmin的登录页http://IP/postfixadmin/
  使用管理员账号登录后,就可以进行相应的管理工作.

配置POSTFIX

vi /etc/postfix/main.cf

#在最后加入
#---------------------Virtual Mailbox settings----------
#89是postfix用户ID `id postfix`
virtual_minimum_uid = 89
virtual_mailbox_base = /var/spool/mail
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_alias_domains = $virtual_alias_maps
virtual_uid_maps = static:89
virtual_gid_maps = static:89
virtual_transport = virtual
maildrop_destination_recipient_limit = 1
maildrop_destination_concurrency_limit = 1
#---------------------Quota--------------------------
message_size_limit = 52428800
mailbox_size_limit = 209715200
virtual_mailbox_limit = 209715200
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_mailbox_limit_message = Sorry, The quota of mailbox has overdrawn.
virtual_overquota_bounce = yes
#---------------------SASL--------------------------
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions =  permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = /var/run/dovecot/auth-client #参照dovecot配置
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_sasl_application_name = smtpd
smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)

Postfix的mysql连接配置文件

echo -ne 'user = root\npassword = \nhosts = localhost\ndbname = postfix\ntable = alias\nselect_field = goto\nwhere_field = address' > /etc/postfix/mysql_virtual_alias_maps.cf;
echo -ne 'user = root\npassword = \nhosts = localhost\ndbname = postfix\ntable = domain\nselect_field = domain\nwhere_field = domain' > /etc/postfix/mysql_virtual_domains_maps.cf;
echo -ne 'user = root\npassword = \nhosts = localhost\ndbname = postfix\ntable = mailbox\nselect_field = quota\nwhere_field = username' > /etc/postfix/mysql_virtual_mailbox_limit_maps.cf;
echo -ne 'user = root\npassword = \nhosts = localhost\ndbname = postfix\ntable = mailbox\nselect_field = maildir\nwhere_field = username' > /etc/postfix/mysql_virtual_mailbox_maps.cf;

配置DOVECOT
vi /etc/dovecot.conf

base_dir = /var/run/dovecot
protocols = imap imaps pop3 pop3s
listen = *
disable_plaintext_auth = no
shutdown_clients = yes
log_path = /var/log/dovecot.log
ssl = no
mail_location = maildir:/var/spool/mail/%d/%n
auth default {
  mechanisms = plain login cram-md5
  passdb sql {
    args = /etc/dovecot-mysql.conf
  }
 
  userdb sql {
    args = /etc/dovecot-mysql.conf
  }
...
  socket listen {
    client {
      path = /var/run/dovecot/auth-client #postfix参照于此
      mode = 0660
      user = postfix
      group = postfix
    }
first_valid_uid=89

Dovecot的mysql连接配置文件

vi /etc/dovecot-mysql.conf
driver = mysql
connect = host=localhost dbname=postfix user=root password=
default_pass_scheme = MD5
password_query = SELECT password FROM mailbox WHERE username = '%u'
user_query = SELECT maildir, 89 AS uid, 89 AS gid FROM mailbox WHERE username = '%u'

启动
/etc/init.d/dovecot start
/etc/init.d/postfix start

================================================

打开outlook,在pop和smtp上填上IP地址试试吧.
怎么?不行?看看日志… 发现哪报错了吗?
因为之前CentOS默认安装的postfix是不支持的mysql的(你可以用`postconf -m`看一下是否有mysql支持),所以先卸掉,改yum配置再重装一下.
方法如下:
cp /etc/postfix/main.cf /tmp/
yum remove postfix
vi /etc/yum.repos.d/CentOS-Base.repo

[base]
exclude=postfix-*
[update]
exclude=postfix-*
[centosplus]
includepkgs=postfix-*

yum install postfix
cp /tmp/main.cf /etc/postfix/

================================================

为其加上防病毒及防垃圾邮件功能

安装Amavisd-new, ClamAV and SpamAssassin
因为默认yum下没有amavisd和clamav,所以要先新增rpmforge源
rpm –import http://apt.sw.be/RPM-GPG-KEY.dag.txt
vi /etc/yum.repos.d/CentOS-Base.repo

[rpmforge]
name = Red Hat Enterprise $releasever RPMforge
baseurl = http://apt.sw.be/redhat/el5/en/$basearch/rpmforge
mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1

安装配置amavisd和clamav
yum install amavisd-new clamav clamd spamassassin
vi /etc/amavisd.conf

$max_servers = 2;                # num of pre-forked children (2..30 is common), -m
$daemon_user  = "amavis";         # (no default;  customary: vscan or amavis), -u
$daemon_group = "amavis";        # (no default;  customary: vscan or amavis), -g
[...]
$inet_socket_port = 10024;       # listen on this local TCP port(s)
[...]
# $notify_method  = 'smtp:[127.0.0.1]:10025';
# $forward_method = 'smtp:[127.0.0.1]:10025';  # set to undef with milter!
[...]
$mydomain = 'example.com';        # Edit: a convenient default for other settings
$MYHOME = '/var/amavis';                # Uncomment: a convenient default for other settings, -H
$helpers_home = "$MYHOME/var";           # Uncomment: working directory for SpamAssassin, -S
$lock_file = "$MYHOME/var/amavisd.lock"; # Uncomment, -L
$pid_file  = "$MYHOME/var/amavisd.pid";    # Uncomment, -P
$myhostname = 'mail.example.com';         # Uncomment & Edit: must be a fully-qualified domain name!
[...]
$QUARANTINEDIR = "/var/virusmails";
[...]
#@local_domains_maps....  # Comment this line
[...]
$sa_tag_level_deflt  = -999;  # add spam info headers if at, or above that level
$sa_tag2_level_deflt = 5.0;  # add 'spam detected' headers at that level
$sa_kill_level_deflt = 5.0;  # triggers spam evasive actions (e.g. blocks mail)
$sa_dsn_cutoff_level = 17;   # spam level beyond which a DSN is not sent
$sa_quarantine_cutoff_level = 20; # spam level beyond which quarantine is off
$sa_spam_subject_tag = '[SPAM] ';
[...]
$final_virus_destiny      = D_PASS;   # Uncomment this line if you want to receive mails with tag $final_spam_destiny       = D_PASS;   # Uncomment this line if you want to receive mails with tag
# ### http://www.clamav.net/
['ClamAV-clamd',
  \&ask_daemon, ["CONTSCAN {}\n", "/var/run/clamav/clamd.sock"],
  qr/\bOK$/m, qr/\bFOUND$/m,
  qr/^.*?: (?!Infected Archive)(.*) FOUND$/m ],

vi /etc/postfix/master.cf

#增加如下内容:
smtp-amavis  unix    -    -    n    -    4    smtp
        -o smtp_data_done_timeout=1200
        -o smtp_send_xforward_command=yes
        -o disable_dns_lookups=yes
127.0.0.1:10025 inet    n    -    n    -    -    smtpd
        -o content_filter=
        -o local_recipient_maps=
        -o relay_recipient_maps=
        -o smtpd_restriction_classes=
        -o smtpd_helo_restrictions=
        -o smtpd_sender_restrictions=
        -o smtpd_recipient_restrictions=permit_mynetworks,reject
        -o mynetworks=127.0.0.0/8
        -o strict_rfc821_envelopes=yes
        -o smtpd_error_sleep_time=0
        -o smtpd_soft_error_limit=1001
        -o smtpd_hard_error_limit=1000
        -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks

/etc/init.d/clamd start;
/etc/init.d/spamassassin start;
/etc/init.d/amavisd start;
/etc/init.d/postfix reload;

转载请注明出处: http://yemaosheng.com

Facebook的OnlineSchemaChange.php备注

Standard
...
define('OSC_FLAGS_ACCEPT_VERSION',  0x0400); // bypasses version check
...
public function __construct($input_sock = '', $input_user, $input_password,
  $input_dbname, $input_tablename,
  $input_altercmd, $input_outfile_folder = null,
  $input_flags = 0,
  $input_batchsize_load = 500000,
  $input_batchsize_replay = 500,
  $input_long_xact_time = 30,
  $input_logfile_folder = "/var/tmp/") {
  ...
}
 
...
 
  private function validateVersion() {
    ...
    if ((!($this->flags & OSC_FLAGS_ACCEPT_VERSION)) &&
        ($this->version !== "5.0.84") &&
        ($this->version !== "5.1.47")) {
      $error = "OSC has only been tested on versions 5.0.84 and 5.1.47. ".
               "Running on ".$this->version." is not allowed unless ".
               "OSC_FLAGS_ACCEPT_VERSION flag is set.";
      $this->raiseException($error, false);
    }
    return $this->version;
  }
 
...
 
$user='root';
$pwd='';
$db = 'test';
$table = 't1';
$sock = '/var/lib/mysql/mysql.sock';
 
$alter = "ALTER TABLE `t1` ADD INDEX ( `intcol1` )";
 
$osc = new OnlineSchemaChange($sock, $user, $pwd, $db, $table, $alter, NULL, 0x0400);
$osc->execute();

mysql小工具openarkkit

Standard

下载地址 http://code.google.com/p/openarkkit/

oak-apply-ri: apply referential integrity on two columns with parent-child relationship.
oak-block-account: block or release MySQL users accounts, disabling them or enabling them to login.
oak-chunk-update: perform long, non-blocking UPDATE/DELETE operation in auto managed small chunks.
oak-get-slave-lag: print slave replication lag and terminate with respective exit code.
oak-hook-general-log: hook up and filter general log entries based on entry type or execution plan criteria.
oak-kill-slow-queries: terminate long running queries.
oak-modify-charset: change the character set (and collation) of a textual column.
oak-online-alter-table: perform a non-blocking ALTER TABLE operation.
oak-prepare-shutdown: make for a fast and safe MySQL shutdown.
oak-purge-master-logs: purge master logs, depending on the state of replicating slaves.
oak-repeat-query: repeat query execution until some condition holds.
oak-security-audit: audit accounts, passwords, privileges and other security settings.
oak-show-limits: show AUTO_INCREMENT “free space”.
oak-show-replication-status: show how far behind are replicating slaves on a given master.

记下备用.

gentoo编译安装mysql5.1.x

Standard
./configure \
	--prefix=/usr/local/mysql \
	--enable-assembler \
	--without-debug \
	--with-mysqld-ldflags=-all-static \
	--with-charset=utf8 \
	--with-extra-charsets=all \
	--with-unix-socket-path=/usr/local/mysql/mysql.sock \
	--enable-thread-safe-client \
	--with-mysqld-user=mysql \
	--with-plugins=partition,heap,innobase,myisam
make
make install

ps:
在my.cnf [mysqld]下加上default-storage-engine=INNODB 保存.
重启后show engines;看下

Gentoo emerge安装nginx+php+mysql

Standard
yemaosheng.com # nano /etc/portage/package.use
dev-lang/php cli cgi ctype mysql mysqli mssql pdo gd curl xml hash json soap sockets snmp
www-servers/nginx fastcgi ssl status
media-gfx/imagemagick jpeg png
yemaosheng.com # nano /etc/portage/package.keywords
www-servers/spawn-fcgi ~x86
dev-php5/pecl-memcache ~x86
 
yemaosheng.com # emerge php nginx spawn-fcgi
 
yemaosheng.com # nano /etc/nginx/nginx.conf
  http {
        ...
        ...
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        fastcgi_buffer_size 64k;
        fastcgi_buffers 4 64k;
        fastcgi_busy_buffers_size 128k;
        fastcgi_temp_file_write_size 128k;
        ...
        ...
        server {
                listen          80;
                server_name     localhost;
 
                #access_log     /var/log/nginx/localhost.access_log main;
                #error_log      /var/log/nginx/localhost.error_log info;
 
                root /var/www/localhost/htdocs;
                index index.php index.html;
 
                location ~\.php$ {
                        fastcgi_pass    127.0.0.1:9000;
                        fastcgi_index   index.php;
                        include fastcgi_params;
                        fastcgi_param SCRIPT_FILENAME /var/www/localhost/htdocs$fastcgi_script_name;
                }
        }
  }
 
yemaosheng.com # spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u nobody -g nobody -f /usr/bin/php-cgi
yemaosheng.com # /etc/init.d/nginx start
yemaosheng.com # emerge mysql
yemaosheng.com # ebuild /var/db/pkg/dev-db/mysql-5.0.70-r1/mysql-5.0.70-r1.ebuild config
yemaosheng.com # /etc/init.d/mysql start
yemaosheng.com # nano /etc/conf.d/local.start
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u nobody -g nobody -f /usr/bin/php-cgi
yemaosheng.com # rc-update add nginx default
yemaosheng.com # rc-update add mysql default

ps:
APC Memcache Imagick之类的PHP扩展存放在/usr/portage/dev-php5/目录下.
可直接 emerge pecl-apc pecl-imagick pecl-memcache 进行安装.

apache2.2.6+php5.2.9+mysql5.1.34编译安装

Standard
rpm -ivh gettext-devel-0.14.1-13.x86_64.rpm
 
# zlib
tar -zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=/usr/local/zlib
make
make install
cd ..
 
# openssl
tar -zxvf openssl-0.9.8g.tar.gz
cd openssl-0.9.8g
./config \
	--prefix=/usr/local/openssl \
	--openssldir=/usr/local/openssl \
	--with-zlib-lib=/usr/local/zlib/lib \
	--with-zlib-include=/usr/local/zlib/include \
	shared \
	zlib \
	threads 
make
make test
make install
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf.d/openssl.conf
ldconfig
cd ..
 
# http
tar jxvf httpd-2.2.6.tar.bz2
cd httpd-2.2.6
./configure \
	--prefix=/usr/local/apache \
	--enable-track-vars \
	--enable-rewrite \
	--enable-proxy \
	--enable-proxy-http  \
	--enable-cache \
	--enable-disk-cache \
	--enable-mem-cache \
	--enable-so \
	--enable-ssl \
	--enable-mods-shared="cache disk_cache mem_cache" \
	--enable-rewrite=shared \
	--enable-proxy=shared \
	--enable-proxy-http=shared \
	--with-mpm=worker \
	--sysconfdir=/usr/local/apache/conf \
	--with-ssl=/usr/local/openssl \
	--with-z-dir=/usr/local/zlib \
	--with-perl 
make 
make install
cd ..
 
# DirectoryIndex index.php
# AddType application/x-httpd-php .php
# LoadModule php5_module        modules/libphp5.so
 
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
chmod +x /etc/init.d/httpd
 
# icon
tar zxvf libiconv-1.12.tar.gz
cd libiconv-1.12
./configure --prefix=/usr/local/iconv
make
make install
cd ..
 
# libpng
tar jxvf libpng-1.2.23.tar.bz2   
cd libpng-1.2.23
env \
	CPPFLAGS="-I/usr/local/zlib/include" \
	LDFLAGS="-L/usr/local/zlib/lib" \
	./configure \
	--prefix=/usr/local/libpng
make
make check 
make install
cd ..
 
# freetype
tar jxvf freetype-2.3.5.tar.bz2 
cd freetype-2.3.5
env \
	CPPFLAGS="-I/usr/local/zlib/include" \
	LDFLAGS="-L/usr/local/zlib/lib" \
	./configure \
	--prefix=/usr/local/freetype2
make
make install
cd ..
 
# jpeg
mkdir -p \
	/usr/local/jpeg6/bin \
	/usr/local/jpeg6/lib \
	/usr/local/jpeg6/include \
	/usr/local/jpeg6/man1 \
	/usr/local/jpeg6/man/man1 
 
tar zxvf jpegsrc.v6b.tar.gz    
cd jpeg-6b
./configure \
	--prefix=/usr/local/jpeg6 \
	--enable-shared --enable-static
make
make install-lib  
make install
cd ..
 
# libxml
tar -zxf libxml2-2.6.30.tar.gz
cd libxml2-2.6.30
./configure \
	--prefix=/usr/local/libxml2 \
	--with-zlib=/usr/local/zlib
make
make install
cd ..
 
# gd
tar -jvxf gd-2.0.35.tar.bz2
cd gd-2.0.35 
./configure \
	--prefix=/usr/local/gd2 \
	--with-freetype=/usr/local/freetype2 \
	--with-png=/usr/local/libpng \
	--with-jpeg=/usr/local/jpeg6 \
	CPPFLAGS="-I/usr/local/zlib/include" \
	LDFLAGS="-L/usr/local/zlib/lib"
make
make install 
cd ..
 
#mysql
groupadd mysql
useradd -g mysql mysql
tar zxvf mysql-5.1.34.tar.gz
cd mysql-5.1.34
./configure \
	--prefix=/usr/local/mysql \
	--enable-assembler \
	--without-debug \
	--with-mysqld-ldflags=-all-static \
	--with-charset=utf8 \
	--with-extra-charsets=all \
	--with-innodb \
	--with-unix-socket-path=/usr/local/mysql/mysql.sock \
	--enable-thread-safe-client \
	--with-mysqld-user=mysql
make
make install
 
cd ..
if [ -f my.cnf.slave ]; then mv my.cnf.slave /etc/my.cnf; else mv my.cnf.mast /etc/my.cnf; fi; mkdir -p /data/mysqllog/binlog /data/mysqllog/relaylog ; chown mysql.0 /data/mysqllog/binlog /data/mysqllog/relaylog  /usr/local/mysql; cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld ; /usr/local/mysql/bin/mysql_install_db --user=mysql; /etc/init.d/mysqld start
 
# php
tar zxvf php-5.2.9.tar.gz
cd php-5.2.9
./configure \
	--prefix=/usr/local/php \
	--with-zlib=/usr/local/zlib \
	--with-zlib-dir=/usr/local/zlib \
	--with-apxs2=/usr/local/apache/bin/apxs \
	--with-mysql=/usr/local/mysql \
	--with-mysql-sock=/usr/local/mysql \
	--with-pdo-mysql=/usr/local/mysql \
	--with-libxml-dir=/usr/local/libxml2 \
	--with-gd=/usr/local/gd2 \
	--with-jpeg-dir=/usr/local/jpeg6 \
	--with-png-dir=/usr/local/libpng \
	--with-freetype-dir=/usr/local/freetype2 \
	--with-libxml-dir=/usr/local/libxml2 \
	--with-openssl=/usr/local/openssl \
	--with-iconv-dir=/usr/local/iconv \
	--with-ttf \
	--with-gettext \
	--enable-gd-native-ttf \
	--enable-mbstring \
	--enable-xml \
	--enable-pcntl \
	--enable-sockets \
	--enable-zip \
	--with-bz2 \
	--disable-debug 
make
make install
cp php.ini-dist /usr/local/php/lib/php.ini 
cd ..
 
# memcache
tar zxvf memcache-2.2.1.tgz
cd memcache-2.2.1
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcach
make 
make install
cd ..
 
sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20060613/"\n\nextension = "memcache.so"\n#' /usr/local/php/lib/php.ini
sed -i 's#expose_php = On#expose_php = Off#' /usr/local/php/lib/php.ini
 
# soap
cd php-5.2.9/ext/soap
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --enable-soap
make
make install
cd
 
sed -i 's#extension = "memcache.so"#extension = "memcache.so"\nextension = "soap.so"#' /usr/local/php/lib/php.ini

Pureftpd + Mysql

Standard
yum install -y mysql mysql-server
 
wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.22.tar.gz
tar zxvf pure-ftpd-1.0.22.tar.gz
cd pure-ftpd-1.0.22
./configure \
--prefix=/usr/local/pureftpd \
--with-probe-random-dev  \
--with-paranoidmsg \
--with-altlog \
--with-puredb \
--with-extauth \
--with-pam \
--with-cookie \
--with-throttling \
--with-ratios  \
--with-quotas \
--with-ftpwho \
--with-largefile \
--with-welcomemsg  \
--with-uploadscript \
--with-virtualhosts \
--with-diraliases \
--with-virtualchroot \
--with-peruserlimits \
--with-language=simplified-chinese \
--with-mysql \
--with-tls \
--with-rfc2640
 
#如遇到 configure: error: libmysqlclient is needed for MySQL support 的话就 cp /usr/lib/mysql/libmysqlclient.sq /usr/lib/
make
make install
 
mkdir –pv /usr/local/pureftpd/etc
cp pureftpd-mysql.conf /usr/local/pureftpd/etc
cp configuration-file/pure-config.pl /usr/local/pureftpd/sbin/
cp configuration-file/pure-ftpd.conf /usr/local/pureftpd/etc/
chmod 755 /usr/local/pureftpd/sbin/pure-config.pl
 
cd contrib
cp redhat.init /etc/init.d/pureftpd
chmod u+x /etc/init.d/pureftpd
chkconfig --add pureftpd
chkconfig pureftpd on
vi /etc/init.d/pureftpd #修改其相关默认路径到 /usr/local/pureftpd/
 
wget http://machiel.generaal.net/files/pureftpd/ftp_v2.1.tar.gz
tar zxvf ftp_v2.1.tar.gz
#为其配置web访问,运行 install.php,按提示操作
#http://yemaosheng.com

Pureftp web端管理软件 ftp_v2.1.tar.gz