Jenkins安装配置

Standard

详细参考:http://jenkins-php.org

apt-get install default-jdk
wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | apt-key add -
sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
apt-get update
apt-get install jenkins
 
java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin git phing checkstyle cloverphp crap4j dry htmlpublisher jdepend plot pmd violations warnings xunit
java -jar jenkins-cli.jar -s http://localhost:8080 safe-restart
 
apt-get install phpunit phpcodesniffer phploc pdepen phpmd phpcpd phpdox php5-xdebug libxml2-utils
1.
curl -L https://raw.githubusercontent.com/sebastianbergmann/php-jenkins-template/master/config.xml | java -jar jenkins-cli.jar -s http://localhost:8080 create-job php-template
 
Or add the template manually:
 
cd $JENKINS_HOME/jobs
mkdir php-template
cd php-template
wget https://raw.github.com/sebastianbergmann/php-jenkins-template/master/config.xml
cd ..
chown -R jenkins:jenkins php-template/
Reload Jenkins configuration, for instance using the Jenkins CLI:
java -jar jenkins-cli.jar -s http://localhost:8080 reload-configuration
 
2.Click on "New Job".
3.Enter a "Job name".
4.Select "Copy existing job" and enter "php-template" into the "Copy from" field.
5.Click "OK".
6.Uncheck the "Disable Build" option.
7.Fill in your "Source Code Management" information.
8.Configure a "Build Trigger", for instance "Poll SCM".
9.Click "Save".

Alpine Linux LNMP安装配置

Standard

看到说Docker官方Image将会开始要使用它,所以装个看看呗。
下载地址:www.alpinelinux.org

apk add nginx memcached mysql mysql-client php php-dev php-cli php-pear php-phar php-fpm php-gd php-memcache php-json php-mysql php-pdo php-pdo_mysql php-mysqli php-zip php-zlib php-bz2 php-ctype php-mcrypt bash git;
apk add gcc g++ make autoconf;
 
#first running php -m on the command
#then compare the output to php -n -m
vi /usr/bin/pecl;  # 'exec $PHP -C -q $INCARG ... '
pecl install xdebug
 
vi /etc/php/php.ini;
...
zend_extension=/usr/lib/php/modules/xdebug.so
xdebug.remote_enable=1
xdebug.remote_port=9090
xdebug.remote_connect_back=1
xdebug.auto_trace=1
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.profiler_enable=1
xdebug.var_display_max_data=10000
xdebug.var_display_max_depth=20
...
 
vi /etc/nginx/nginx.conf;
    ...
    location ~ \.php$ {                                                     
        root           html;                                                
        fastcgi_pass   127.0.0.1:9000;                                      
        fastcgi_index  index.php;                                           
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; 
        include        fastcgi_params;                                      
    }    
    ...
 
vi /usr/share/nginx/html/index.php;
<?php
    phpinfo();
?>
 
apk add curl openssl php-openssl;
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer;
 
/etc/init.d/php-fpm start;
/etc/init.d/nginx start;
 
/etc/init.d/mariadb setup;
/etc/init.d/mariadb start;
/etc/init.d/memcached start;
 
apk add phpmyadmin;
cd /usr/share/nginx/html/;
cp -rf /usr/share/webapps/phpmyadmin ./;
cp /etc/phpmyadmin/config.inc.php ./phpmyadmin;
apk del phpmyadmin;
 
cd /usr/share/nginx/html;
wget https://github.com/jokkedk/webgrind/archive/master.zip;
unzip master.zip;
mv webgrind-master webgrind;
apk add python graphviz font-misc-misc;
 
cd /etc/profile.d;
cat color_prompt;
  # Setup a red prompt for root and a green one for users.
  # rename this file to color_prompt.sh to actually enable it
  NORMAL="\[\e[0m\]"
  RED="\[\e[1;31m\]"
  GREEN="\[\e[1;32m\]"
  if [ "$USER" = root ]; then
        PS1="$RED\h [$NORMAL\w$RED]# $NORMAL"
  else
        PS1="$GREEN\h [$NORMAL\w$GREEN]\$ $NORMAL"
  fi
 
mv color_prompt color_prompt.sh;
vi alias.sh;
  alias ll="ls -al"
  alias rm="rm -i"
 
#yemaosheng.com

Puppet安装配置使用

Standard

记得以前看过,貌似感觉cfengin比较好,不过既然老外那边已经用了这个,那花些时间再看看熟熟手。

vi /etc/hosts
192.168.0.10 puppetserver
192.168.0.11 puppetclient1
#yemaosheng.com
yum -y install ruby ruby-libs ruby-rdoc
wget http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-7.noarch.rpm
yum install puppetlabs-release-6-7.noarch.rpm
[server] yum -y install puppet-server
[server] service puppetmaster start
 
[client] yum -y install puppet
[client] puppet agent --no-daemonize --onetime --verbose --debug --server=puppetserver
 
[server] puppet cert list --all #会看到一个前面没有+号的client key
[server] puppet cert --sign puppetclient1 #确认client的key

在puppetclient1上新建一个helloworld.txt文件

[server] vi /etc/puppet/manifests/site.pp
node default {
  file {
    "/tmp/helloworld.txt": content => "hello, world";
  }
}
[client] puppet agent --test --server=puppetserver

在puppetclient1上安装tree

[server] vi /etc/puppet/manifests/site.pp
import 'nodes.pp'
[server] vi /etc/puppet/manifests/nodes.pp
node 'puppetclient1' {
      include tree
}
[server] vi /etc/puppet/puppet.conf
modulepath=/etc/puppet/modules:/var/lib/puppet/modules:/opt/modules
[server] mkdir -p /etc/puppet/modules/tree/{files,manifests,templates}
[server] vi /etc/puppet/modules/tree/manifests/init.pp
class tree {
  package { tree:
    ensure => present,
  }
  #类型 { 标题:
  #  属性 => 值,
  #  }
  #}
}
[client] puppet agent --no-daemonize --verbose --debug --server=puppetserver

在puppetclient1上安装memcached并同步配置文件

[server] mkdir -p /etc/puppet/modules/memcached/{files,manifests,templates}
[server] cp /etc/sysconfig/memcached /etc/puppet/modules/memcached/files/
[server] vi /etc/puppet/modules/memcached/manifests/init.pp
class memcached {
  package { memcached:
    ensure => present,
  }
  file { '/etc/sysconfig/memcached':
    notify => Service['memcached']
    mode => '644',
    owner => 'root',
    group => 'root',
    source => 'puppet:///modules/memcached/memcached',
  }
  service { 'memcached':
    ensure => 'running',
    enable => 'true',
  }
}
[client] puppet agent --server=puppetserver

从master主动发指命让agent同步

[client] vi /etc/puppet/auth.conf
path /
auth any
allow *
 
[client] vi /etc/puppet/puppet.conf
...
listen = true
...
 
[server] puppet kick --host puppetclient1

安装配置Mcollective

[server] yum -y install activemq mcollective mcollective-client
[server] vi /etc/activemq/activemq.xml #修改默认用户名及密码
[server] service atcivemq start
[server] vi /etc/mcollective/server.cfg #修改plugin.stomp.*默认值连接到activemq
[server] service mcollective start
 
[server] mkdir -p /etc/puppet/modules/mcollective/{files,manifests,templates}
[server] cp /etc/mcollective/server.cfg /etc/puppet/modules/mcollective/files/
[server] chmod 644 /etc/puppet/modules/mcollective/files/server.cfg
[server] vi /etc/puppet/modules/mcollective/manifests/init.pp
class mcollective {
  package { mcollective:
    ensure => present,
  }
  file { '/etc/mcollective/server.cfg':
    notify => Service['mcollective']
    mode => '640',
    owner => 'root',
    group => 'root',
    source => 'puppet:///modules/mcollective/server.cfg',
  }
  service { 'mcollective':
    ensure => 'running',
    enable => 'true',
  }
}
 
[server] mco find
puppetserver
puppetclient1
 
[client] yum -y install mcollective-service-agent
[client] service mcollective restart
[server] yum -y install mcollective-service-client
[server] mco rpc service start service=httpd -v #启动puppetclient1机上的httpd服务
[server] mco rpc service stop service=httpd -v #停止puppetclient1机上的httpd服务
 
[client] yum -y install mcollective-puppet-agent
[client] service mcollective restart
[server] yum -y install mcollective-puppet-client
[server] mco puppet status

安装Dashboard

[server] yum -y install puppet-dashboard
mysql> create database dashboard default charset utf8;
mysql> use dashboard;
mysql> grant all on dashboard.* to dashboard@localhost identified by 'dashboard' ;
mysql> flush privileges;
[server] vi /usr/share/puppet-dashboard/config/database.yml
production:
  database: dashboard
  username: dashboard
  password: dashboard
  encoding: utf8
  adapter: mysql
  #用ruby的rake命令创建数据库和创建表
[server] cd /usr/share/puppet-dashboard/
[server] rake RAILS_ENV=production db:create
[server] rake RAILS_ENV=production db:migrate
 
#运行puppet-dashboard
[server] /usr/share/puppet-dashboard/script/server -e production
#或是
[server] /etc/init.d/puppet-dashboard start
#这样将用3000端口运行自带的webrick服务器。

官方文档:http://docs.puppetlabs.com/puppet/3/reference/
中文wiki:http://puppet.wikidot.com

Redis安装配置操作

Standard

Redis和Memcached类似,但其断电后数据仍然能得到保存,功能也更丰富.

#安装
cd /usr/local/
wget http://redis.googlecode.com/files/redis-1.2.6.tar.gz
tar zxvf redis-1.2.6.tar.gz 
mv redis-1.2.6 redis
cd redis
./make
#make命令执行完成后,会在当前目录下生成本个可执行文件,如下:
#redis-server:Redis服务器的daemon启动程序
#redis-cli:Redis命令行操作工具。当然,你也可以用telnet根据其纯文本协议来操作
#redis-benchmark:Redis性能测试工具,测试Redis在你的系统及你的配置下的读写性能
#redis-stat:Redis状态检测工具,可以检测Redis当前状态参数及延迟状况 
 
#修改配置
vi redis.conf
daemonize yes #默认是no,改为yes让其后台运行.
 
#配置的一些基本说明
daemonize:#是否以后台daemon方式运行
pidfile:#pid文件位置
port:#监听的端口号
timeout:#请求超时时间
loglevel:#log信息级别
logfile:#log文件位置
databases:#开启数据库的数量
save * *#保存快照的频率,第一个*表示多长时间,第三个*表示执行多少次写操作。在一定时间内执行一定数量的写操作时,自动保存快照。可设置多个条件。
rdbcompression:#是否使用压缩
dbfilename:#数据快照文件名(只是文件名,不包括目录)
dir#数据快照的保存目录(这个是目录)
appendonly:#是否开启appendonlylog,开启的话每次写操作会记一条log,这会提高数据抗风险能力,但影响效率。
appendfsync:#appendonlylog如何同步到磁盘(三个选项,分别是每次写都强制调用fsync、每秒启用一次fsync、不调用fsync等待系统自己同步)
 
#启动
./redis-server redis.conf
 
#操作
./redis-cli 
redis> set key1 value1
OK
redis> get key1
value1
redis> set site yemaosheng.com
OK
redis> get site
yemaosheng.com
redis> lpush city SH
OK
redis> lpush city BJ
OK
redis> lpush city SZ
OK
redis> lpush city HZ
OK
redis> lpush city GZ
OK
redis> lrange city 0 2
1. GZ
2. HZ
3. SZ
redis> lrange city 1 2
1. HZ
2. SZ
redis> lpop city
GZ
redis> lpop city
HZ
redis> lpop city
SZ
redis> lpop city
BJ
redis> lpop city
SH
redis> lpop city
(nil)

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

安装 tomcat + solr

Standard
##### wget tomcat #####
[tester@svr ~]$ wget  http://apache.freelamp.com/tomcat/tomcat-6/v6.0.29/bin/apache-tomcat-6.0.29.tar.gz
[tester@svr ~]$ ls
apache-tomcat-6.0.29.tar.gz
[tester@svr ~]$ tar xvf apache-tomcat-6.0.29.tar.gz 
[tester@svr ~]$ sudo mv apache-tomcat-6.0.29 /usr/local/
[tester@svr ~]$ wget http://www.xlpar.com/files/3/19tp60r2vu6nt6/jdk-6u21-linux-x64-rpm.bin
[tester@svr ~]$ ls
jdk-6u21-linux-x64-rpm.bin
[tester@svr ~]$ sudo mv jdk-6u21-linux-x64-rpm.bin /usr/java/
 
######## install jdk #########
[tester@svr ~]$ sudo mkdir /usr/java
[tester@svr ~]$ sudo mv jdk-6u21-linux-x64-rpm.bin /usr/java/
[tester@svr ~]$ cd /usr/java/
[tester@svr java]$ ls
jdk-6u21-linux-x64-rpm.bin
[tester@svr java]$ sudo chmod a+x jdk-6u21-linux-x64-rpm.bin 
[tester@svr java]$ sudo ./jdk-6u21-linux-x64-rpm.bin 
[tester@svr java]$ ls
default                   jdk-6u21-linux-x64-rpm.bin             sun-javadb-common-10.5.3-0.2.i386.rpm  sun-javadb-docs-10.5.3-0.2.i386.rpm
jdk1.6.0_21               latest                                 sun-javadb-core-10.5.3-0.2.i386.rpm    sun-javadb-javadoc-10.5.3-0.2.i386.rpm
jdk-6u21-linux-amd64.rpm  sun-javadb-client-10.5.3-0.2.i386.rpm  sun-javadb-demo-10.5.3-0.2.i386.rpm
[tester@svr java]$ cd jdk1.6.0_21/
[tester@svr jdk1.6.0_21]$ ls
bin        demo     jre  man          README_ja.html     register.html     register_zh_CN.html  src.zip
COPYRIGHT  include  lib  README.html  README_zh_CN.html  register_ja.html  sample               THIRDPARTYLICENSEREADME.txt
[tester@svr jdk1.6.0_21]$ ./bin/java -version
 
###### export java env #########
[tester@svr jdk1.6.0_21]$ sudo vi /etc/profile
[tester@svr jdk1.6.0_21]$ tail /etc/profile
    if [ -r "$i" ]; then
        . $i
    fi
done
 
unset i
unset pathmunge
export JAVA_HOME=/usr/java/jdk1.6.0_21
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
[tester@svr jdk1.6.0_21]$ source /etc/profile
[tester@svr jdk1.6.0_21]$ java -version
 
#### alternate open-java to jdk
[tester@svr sbin]$ sudo ./alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_21/bin/java 300
[tester@svr sbin]$ sudo ./alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_21/bin/javac 300
 
[tester@svr sbin]$ java --version
[tester@svr sbin]$ sudo ./alternatives --display java
 
[tester@svr sbin]$ sudo ./alternatives --config java
[tester@svr sbin]$ sudo ./alternatives --config javac
 
[tester@svr sbin]$ java -version
 
####### start tomcat ######
[tester@svr sbin]$ cd /usr/local/apache-tomcat-6.0.29/
[tester@svr apache-tomcat-6.0.29]$ ./bin/startup.sh 
Using CATALINA_BASE:   /usr/local/apache-tomcat-6.0.29
Using CATALINA_HOME:   /usr/local/apache-tomcat-6.0.29
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-6.0.29/temp
Using JRE_HOME:        /usr/java/jdk1.6.0_21
Using CLASSPATH:       /usr/local/apache-tomcat-6.0.29/bin/bootstrap.jar
 
[tester@svr apache-tomcat-6.0.29]$ sudo /sbin/service httpd restart
 
##### rename tomcat dir #####
[tester@svr local]$ sudo mv apache-tomcat-6.0.29 tomcat
[tester@svr local]$ sudo vi /etc/profile
export TOMCAT_HOME="/usr/local/tomcat"
[tester@svr local]$ source /etc/profile
 
##### install solr #####
[tester@svr local]$ cd
[tester@svr ~]$ wget http://labs.renren.com/apache-mirror/lucene/solr/1.4.1/apache-solr-1.4.1.tgz
 
[tester@svr ~]$ tar xvf apache-solr-1.4.1.tgz 
[tester@svr ~]$ ls
apache-solr-1.4.1  apache-solr-1.4.1.tgz
 
###### start solr example #####
[tester@svr ~]$ sudo mv apache-solr-1.4.1 /usr/solr
[tester@svr ~]$ cd /usr/solr/
[tester@svr solr]$ cd example/
[tester@svr example]$ java -jar start.jar 
 
[tester@svr example]$ sudo vi /etc/rc.local 
/usr/local/tomcat/bin/startup.sh
/usr/java/jdk1.6.0_21/bin/java -jar /usr/solr/example/start.jar
 
#now visit your web site http://localhost:8983/solr/admin/

Cassandra安装配置

Standard
wget http://labs.renren.com/apache-mirror/cassandra/0.6.2/apache-cassandra-0.6.2-bin.tar.gz
tar zxvf apache-cassandra-0.6.2-bin.tar.gz
mv ./apache-cassandra-0.6.2/ /opt/cassandra/
mkdir -p /var/log/cassandra/;
mkdir -p /var/lib/cassandra/;
cd /opt/cassandra/conf/;
 
vi /etc/hosts;
  172.20.0.11 cas1
  172.20.0.12 cas2
  172.20.0.13 cas3
 
vi storage-conf.xml;
  <Seeds>
      <Seed>cas1</Seed>
      <Seed>cas2</Seed>
      <Seed>cas3</Seed>
  </Seeds>
  ...
  <ListenAddress></ListenAddress>
  ...
  <ThriftAddress>0.0.0.0</ThriftAddress>
  ...
  <ReplicationFactor>2</ReplicationFactor>
 
 
#启动Cassandra
/opt/cassandra/bin/cassandra
#停止Cassandra
pgrep -u `whoami` -f cassandra | xargs kill -9
 
#查看状态
./nodetool -host 172.20.0.11 -port 8080 info
./nodetool -host 172.20.0.12 -port 8080 info
./nodetool -host 172.20.0.13 -port 8080 info
 
/opt/cassandra/bin/nodeprobe -host 172.20.0.11 -port 8080 ring
***************************************************************
WARNING: ./nodeprobe is obsolete, use ./nodetool instead
***************************************************************
Address       Status     Load          Range                                      Ring
                                       158255313114555862951163726015274498791    
172.20.0.11   Up         1.1 KB        76956859483693548579208375882609057366     |<--|
172.20.0.12   Up         1.1 KB        126662997939550187436807835701584364141    |   |
172.20.0.13   Up         760 bytes     158255313114555862951163726015274498791    |-->|
 
#客户端读写操作
./cassandra-cli -host 172.20.0.11 -port 9160
cassandra> set Keyspace1.Standard1['user']['name']='YeMaosheng'
cassandra> quit
 
./cassandra-cli -host 172.20.0.12 -port 9160
cassandra> get Keyspace1.Standard1['user']
=> (column=6e616d65, value=YeMaosheng, timestamp=1276750744566000)
Returned 1 results.
 
#调节使用的内存大小
vi /opt/cassandra/bin/cassandra in.sh
  -Xmx1G  #默认为1G,改成你实际所需要的大小运行即可
 
#转载请注明出处 http://yemaosheng.com

VPS下安装配置OpenVPN服务器

Standard

上周弄了个vps,3.5美元一个月最便宜的那种.
号称24X7在线服务即时响应,但实际效率很低.
光是开通就用了三天,后让其重装下系统又等了两天,汗呢…
但这价格比起20RMB一月买玩网游用的商业VPN来说还是满划算 ^_^

本来vps上准备装个pptpd,既简单方便又不需专门客户端.可装了才发现vps上面没有相应的内核模块.
发tickets过去询问对方回复只支持openvps和vtun,vtun没用过,所以就装openvpn了.

安装步骤如下:

升级并安装openssl

yum update #全部升一下级
yum install openssl openssl-devel #openssl也许系统已经装了

第三方yum库

cd /etc/yum.repos.d/
vi CentOS-Third.repo
	[dag]
	name=Dag RPM Repository for Red Hat Enterprise Linux
	baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
	gpgcheck=1
	enabled=1
	[kbs-CentOS-Extras]
	name=CentOS.Karan.Org-EL$releasever - Stable
	gpgcheck=1
	gpgkey=http://centos.karan.org/RPM-GPG-KEY-karan.org.txt
	enabled=1
	baseurl=http://centos.karan.org/el$releasever/extras/stable/$basearch/RPMS/
	[kbs-CentOS-Misc]
	name=CentOS.Karan.Org-EL$releasever - Stable
	gpgkey=http://centos.karan.org/RPM-GPG-KEY-karan.org.txt
	gpgcheck=1
	enabled=1
	baseurl=http://centos.karan.org/el$releasever/misc/stable/$basearch/RPMS/
	[kbs-CentOS-Misc-Testing]
	name=CentOS.Karan.Org-EL$releasever - Testing
	gpgkey=http://centos.karan.org/RPM-GPG-KEY-karan.org.txt
	gpgcheck=1
	enabled=1
	baseurl=http://centos.karan.org/el$releasever/misc/testing/i386/RPMS/
 
rpm --import http://centos.karan.org/RPM-GPG-KEY-karan.org.txt
rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

openvpn安装配置

yum install openvpn -y #安装openvpn
 
#找下easy-rsa在哪,将其cp到/etc/openvpn目录下
updatedb
locate easy-rsa
cp -R /../easy-rsa /etc/openvpn/
 
cd /etc/openvpn/easy-rsa
chmod 777 *
mkdir /etc/openvpn/keys
 
vi ./vars
#将export KEY_DIR=/etc/openvpn/keys改为export KEY_DIR=/etc/openvpn/keys
 
source ./vars
 
./clean-all
./build-ca
./build-key-server server
./build-key client1
./build-dh
 
cd /etc/openvpn
vi server.conf
	mode server
	duplicate-cn #多个用户使用同一帐号
	port 1194
	proto udp
	dev tun
	ca keys/ca.crt
	cert keys/server.crt
	key keys/server.key
	dh keys/dh1024.pem
	server 192.168.2.0 255.255.255.0
	client-config-dir ccd
	# Put your Public DNS Servers here
	push "dhcp-option DNS 208.67.222.222"
	push "route 192.168.2.0 255.255.255.0"
	ifconfig-pool-persist ipp.txt
	push "redirect-gateway"
	keepalive 10 120
	comp-lzo
	persist-key
	persist-tun
	status server-tcp.log
	verb 3
 
touch server-tcp.log
touch ipp.txt
vi /etc/init.d/openvpn 去掉119echo 1 > /proc/sys/net/ipv4/ip_forward 前的注释符
 
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j SNAT --to 123.123.123.123
 
/etc/init.d/openvpn start

Windows客户端安装配置
下载地址: http://openvpn.se/files/install_packages/openvpn-2.0.9-gui-1.0.3-install.exe

#my vps
cd /etc/openvpn/keys
tar zcvf clent1key.tar.gz c*
sz clientkey.tar.gz #将其sz下载下来并解压放到C:\Program Files\OpenVPN\config\
 
#windows client
C:\Program Files\OpenVPN\config\client1.ovpn
	client
	dev tun
	proto udp
	remote 174.36.56.242 1194
	resolv-retry infinite
	nobind
	persist-key
	persist-tun
	ca ca.crt
	cert client1.crt
	key client1.key
	ns-cert-type server
	#DNS Options here, CHANGE THESE !!
	push "dhcp-option DNS 208.67.222.222"
	comp-lzo
	verb 3
	status openvpn-status.log

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

cacti在gentoo上的安装步骤

Standard
cd /usr/portage/net-analyzer/rrdtool
emerge rrdtool-1.2.30.ebuild
 
emerge net-snmp
vi /etc/snmp/snmpd.conf
   com2sec local     127.0.0.1/32       public
   com2sec network   172.10.0.0/24       public
   group MyRWGroup v1         local
   group MyRWGroup v2c        local
   group MyRWGroup usm        local
   group MyROGroup v1         network
   group MyROGroup v2c        network
   group MyROGroup usm        network
   view all    included  .1                               80
   access MyROGroup ""      any       noauth    exact  all    all   none
   access MyRWGroup ""      any       noauth    exact  all    all    none
   syslocation MyLocation.
   syscontact Me 
 
emerge cacti  #安装过程中可能会因为在之前emerge php的时候USE没带上socket、xml、pcre而报错,加上它们重新emerge下php就行

cacti安装后默认路径在/usr/share/webapps/cacti/0.8.7b-r3/htdocs
因为我用nginx没装apache,没法用webapp-config命令来加cacti的虚拟主机,所以自己记着在nginx.conf里配一下.

配置cacti

cd /usr/share/webapps/cacti/0.8.7b-r3/htdocs
mysql -u root -p cacti < cacti.sql
vi include/config.php  #改mysql连接配置
crontab -e
*/1 * * * *       /usr/bin/php /usr/share/webapps/cacti/0.8.7b-r3/htdocs/poller.php > /dev/null 2>&1

安装cacti插件

cd /usr/share/webapps/cacti/0.8.7b-r3/htdocs
wget http://mirror.cactiusers.org/downloads/plugins/cacti-plugin-0.8.7e-PA-v2.5.zip
unzip cacti-plugin-0.8.7e-PA-v2.5.zip
patch -p1 -N --dry-run &lt; cacti-plugin-0.8.7e-PA-v2.5.diff #看下是否有报错,此步骤不会进行实际安装
patch -p1 -N &lt; cacti-plugin-0.8.7e-PA-v2.5.diff
mysql -u root -p cacti &lt; pa.sql
 
mkdir plugins
cd plugins
wget http://cactiusers.org/downloads/monitor.gzip
wget http://cactiusers.org/downloads/settings.gzip
wget http://cactiusers.org/downloads/thold.gzip
wget http://cactiusers.org/downloads/discovery.gzip

将上面下载的四个插件直接解开,记得把各插件里的*.sql文件导进数据库
所有插件的下载地址: http://cactiusers.org/downloads/ 注意要找版本号相同的

vi ../include/global.php  #在$plugins = array();一行后加上加上下面这些
$plugins[] = 'thold';
$plugins[] = 'monitor';
$plugins[] = 'settings';
$plugins[] = 'discovery';

问题来了,打完补丁后报error
Call to undefined function api_plugin_hook() in … /include/global_arrays.php on line 620
官网论坛里查了下发现不少人都有这问题
解决方法,查看*.rej文件,手工修改代码
到此安装完毕

Tips:
1.监控nginx mysql apache memcached的template和script可到下面这个网址下载:
http://code.google.com/p/mysql-cacti-templates/
2.要监控nginx记得把–with-http_stub_status_module加上,再配上location /status { … }
3.cacti的报警和实时性相对nagios和zabbix来说不算强项

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

Tokyo Tyrant安装

Standard
wget http://tokyocabinet.sourceforge.net/tokyocabinet-1.4.32.tar.gz
tar zxvf tokyocabinet-1.4.32.tar.gz
cd tokyocabinet-1.4.32
./configure
make
make install
 
wget http://tokyocabinet.sourceforge.net/tyrantpkg/tokyotyrant-1.1.33.tar.gz
tar zxvf tokyotyrant-1.1.33.tar.gz
cd tokyotyrant-1.1.33
./configure
make
make install
 
mkdir /ttserver
ttserver -host 127.0.0.1 -port 11211 -thnum 8 -dmn -pid /ttserver/ttserver.pid -log /ttserver /ttserver.log -le -ulog /ttserver/ -ulim 128m -sid 1 -rts /ttserver/ttserver.rts /ttserver/database.tch

备份及恢复

tcrmgr copy -port 11211 127.0.0.1 backup.tch
#kill ttserver
cp /backup.tch /ttserver/database.tch
ttserver -host 127.0.0.1 -port 11211 -thnum 8 -dmn -pid /ttserver/ttserver.pid -log /ttserver/ttserver.log -le -ulog /ttserver/ -ulim 128m -sid 1 -rts /ttserver/ttserver.rts /ttserver/database.tch

详细说明 http://tokyocabinet.sourceforge.net/tyrantdoc/

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

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 进行安装.