cat > /etc/salt/roster << EOF
test:
host: 192.168.1.1
user: root
password: redhat
EOF
通过salt-ssh执行,第一次执行后会添加auth key
salt-ssh '*' cmd.run "uptime"
发布时间:January 27, 2014 // 分类:Puppet // No Comments
cat > /etc/salt/roster << EOF
test:
host: 192.168.1.1
user: root
password: redhat
EOF
通过salt-ssh执行,第一次执行后会添加auth key
salt-ssh '*' cmd.run "uptime"
发布时间:January 27, 2014 // 分类:Puppet // No Comments
Master:
curl -L http://bootstrap.saltstack.org | sudo sh -s -- -M -N
yum search salt-ssh
Slave:
wget -O - http://bootstrap.saltstack.org | sudo sh
yum install salt-minion
客户端配置:
Master: 192.168.1.1
#识别ID
id: test
启动客户端:
/etc/init.d/salt-minion start
服务器端确认:
salt-key -A
执行模块命令:
salt '*' test.ping
执行shell命令:
salt '*' cmd.run "uptime"
执行脚本命令:
mkdir -p /srv/salt/scripts/
cat > /srv/salt/scripts/test.sh << EOF
#!/bin/bash
echo "test" > /tmp/test.txt
echo $1
echo $2
echo $3
EOF
salt '*' cmd.script salt://scripts/test.sh "aa bb cc"
同步服务器状态,安装git:
cat >/srv/salt/git.sls << EOF
git:
pkg:
- installed
EOF
salt '*' state.sls git
查看节点信息:
salt '*' grains.ls 查看grains分类
salt '*' grains.items 查看grains所有信息
salt '*' grains.item osrelease 查看grains某个信息
发布时间:January 26, 2014 // 分类:CentOS // No Comments
remi:
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
CentOS5:
rpm -ivh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
CentOS7:
rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
安装后源默认禁用,如需启用可修改remi.repo或:
yum --enablerepo=remi-php55 install php
src:
http://rpms.famillecollet.com/SRPMS/
webtatic:
rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
src:
http://repo.webtatic.com/yum/el6/SRPMS/
发布时间:January 21, 2014 // 分类:PHP // No Comments
1.phpQuery
<?php
require("phpQuery-onefile.php");
phpQuery::newDocumentFile('https://www.haiyun.me/archives.html');
//foreach (pq('body .main li')->find('a') as $a) {
foreach (pq('body .main li a') as $a) {
$hrefs[] = pq($a)->attr('href');
$hrefs[] = pq($a)->text();
}
print_r($hrefs);
?>
记得释放内存:
phpQuery::$documents = array();
phpQuery::unloadDocuments();
2.基于tidy的HtmlParserModel,可解析不正规的HTML页面:
yum install php-tidy
git clone https://github.com/bupt1987/HtmlParserModel.git
<?php
include_once "HtmlParserModel.php";
$html = file_get_contents('http://www.amazon.com/s/node=3564986011');
$html_dom = new HtmlParserModel($html);
$p_array = $html_dom->find('a.title');
foreach ($p_array as $p){
echo $p->getPlainText();
}
?>
发布时间:January 18, 2014 // 分类:Nginx // No Comments
1.rewrite使用break结,使用last会对server标签重新发起请求
location /a/ {
rewrite ^/a/(.*)$ /b/$1 break;
proxy_pass https://www.haiyun.me;
}
2.proxy_pass结尾添加/会丢弃路径目录,如下访问/a/test.html会代理到/test.html
location /a/ {
rewrite ^/a/(.*)$ /b/$1 break;
proxy_pass https://www.haiyun.me/;
}
3.代理访问重定向的网址:
proxy_redirect https://www.haiyun.me/ http://$host/;