Gentoo2008升级portage过程中的一个小问题

Standard

正准备装cassandra,当然先要安装jre.
可当我安装jre时提示我说当前portage只支持EAPI 1,需要我升级portage以支持EAPI 2.于是我照做,但很奇怪,升级过程中需要安装的eselect-python-20090824.tar.bz2在官方的自带的那些portage库mirror中没有.
只好google了一下手工把它下载下来放在/usr/portage/distfiles/目录中,然后直接ebuild.
接下去python-gentoo-patches-2.5.4-r2.tar.bz2也遇到同样问题,仍旧手工下载.

ps:
下回记得一定要先emerge portage 再emerge –sync -_-

gentoo下的ssh key认证rsync同步

Standard

A:191.168.0.10
B:191.168.0.11
采用推送方式,由A将文件推送到B

A:

emerge rsync
 
cd
ssh-keygen -t dsa -b 1024 -f /root/this-host-rsync-key
cp this-host-rsync-* ~/.ssh
scp this-host-rsync-key.pub root@191.168.0.11:/root/.ssh/

B:

emerge rsync
 
cd
cd ~/.ssh/
cat this-host-rsync-key.pub > authorized_keys
 
vi /etc/rsyncd.conf
  uid = root
  gid = root
  max connections = 10
  pid file = /var/run/rsyncd.pid
  use chroot = yes
  read only = yes
  [rsynctest]
  path = /root/rsync_B
  comment = test
  ignore errors
  read only = no
 
/etc/init.d/rsyncd start

A:

rsync -vzrtopg --delete /root/rsync_A/ 172.28.201.102::rsynctest

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

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;看下

xen server安装gentoo2008后启动报错

Standard

xen server安装gentoo2008启动报错
报错提示:
Unable to mount root fs via NF,trying floppy.
Cannot open root device “hda3” or unknow-block(2,0)

报错截图:

解决方式:
经查发现原因是在光盘引导安装阶段,gentoo将xen的虚拟盘认做IDE设备.而我直接以IDE的hda开头进行相应配置,最终硬盘引导导动时内核以SATA方式将硬盘驱动起来,结果就造成找不到sda的报错.
也就是说,虽然你在cfdisk时看到的明明是写hda,但你在配grub及fstab时还是要写sda.

gentoo上面的nagios + nginx配置

Standard
#基础支持 gcc glibc glibc-common gd gd-devel
useradd -m nagios #添加一个名为nagios的用户用以专门跑nagios           
passwd nagios   #设置密码
groupadd nagcmd #添加nagcmd用户组,用以通过web页面提交外部控制命令
usermod -a -G nagcmd nagios #将nagios用户加入nagcmd组
usermod -a -G nagcmd nginx #将nginx用户加入nagcmd组
 
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.0.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
wget http://nagios.manubulon.com/nagios-snmp-plugins.1.1.1.tgz
tar zxvf nagios-3.2.0.tar.gz
tar zxvf nagios-plugins-1.4.13.tar.gz
tar zxvf nagios-snmp-plugins.1.1.1.tgz
 
cd nagios-3.2.0
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
这时nagios本身已基本安装完成
vi /usr/local/nagios/etc/objects/contacts.cfg #修改nagiosadmin这行其中的邮件地址为你的email地址,以将报警邮件发到你的邮箱
#make install-webconf #安装nagios的web接口
#htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
#设置登陆web界面时HTTP验证的账号密码
#因为我是用nginx,所以上面三行不执行,自己手工改nginx配置
 
cd ..
cd nagios-plugins-1.4.13
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
 
cd ..
cd nagios_plugins
#安装perl所用组件
perl -MCPAN -e shell
cpan> install Net::SNMP
./install.sh #一路回车
 
#nagios全套安装完毕
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg #检测nagios的配置是否正确
 
/etc/init.d/nagios start
/etc/init.d/nginx start

nagios要用cgi-bin,关于nginx上的cgi-bin配置可参考 nginx配置cgi-bin运行perl

转载请注明出处: 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

Gentoo常用工具

Standard

emerge syslog-ng (系统日志)
rc-update add syslog-ng default
emerge vixie-cron (Cron守护进程)
rc-update add vixie-cron default

emerge iproute2 (支持ip命令需要内核支持)
emerge sysstat (支持iostat、sar等系统工具)
emerge ftp (ftp命令)
emerge netkit-telnetd (telnet命令)
emerge bind-tool (调试网络的工具nslookup)
emerge gentoolkit (看名字就应该装上)
emerge vim (gentoo默认装了nano,但我还是比较习惯用vi)

vi /etc/bash/bashrc 加上下面这此alias
alias ll=’ls -all’
alias vi=’vim’
alias rm=’rm -i’

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