saltstack-grains

用来匹配minion的grains,是指那些关于minion主机的静态信息,比如OS,软件版本,虚拟化,CPU,内存等等。

查看grains

1
2
3
salt ‘*’ grains.items  #打印grains
salt ‘*’ grains.item [keyname] #打印指定的值

在minion 中配置grains

/etc/salt/grains 自定义 grains
/etc/salt/minion 自定义 grains

1
2
3
4
5
6
7
8
grains:
roles:
- webserver
- memcache
deployment: datacenter4
cabinet: 13
cab_u: 14-15

阅读更多

saltstack-自定义模块

创建 modules 目录

1
2
mkdir  /srv/salt/_modules  && cd /srv/salt/_modules

在 _modules 目录创建一个模块 test.py

代码如下

1
2
3
def foo():
return 'foo'

阅读更多

saltstack-安装

导入saltstack PPA key

Ubuntu下最新版本的包发布在saltstack PPA。如果你有 add-apt-repository 工具,你可以一键添加软件源仓库并导入PPA的key。

1
2
sudo add-apt-repository ppa:saltstack/salt

如果提示以下错误

1
2
add-apt-repository: command not found?

需要安装下面两个东西

1
2
3
sudo apt-get install python-software-properties
sudo apt-get install software-properties-common

阅读更多

mysql安装配置

命令行安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Install the database packages
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev

# Ensure you have MySQL version 5.5.14 or later
mysql --version


# Pick a MySQL root password (can be anything), type it and press enter
# Retype the MySQL root password and press enter

# Secure your installation
sudo mysql_secure_installation

# Login to MySQL
mysql -u root -p

# Ensure you can use the InnoDB engine which is necessary to support long indexes
# If this fails, check your MySQL config files (e.g. `/etc/mysql/*.cnf`, `/etc/mysql/conf.d/*`) for the setting "innodb = off"
mysql> SET storage_engine=INNODB;


阅读更多

tmux

会话

创建新会话

tmux new[-session] -s <会话名称> [初始命令]

结束会话

Ctrl+b 或 输入 exit

阅读更多

让homebrew 走代理

命令

1
2
$ http_proxy=http://IP:PORT https_proxy=http://IP:PORT brew install PACKAGE

1
2
$ ALL_PROXY=socks5://IP:PORT brew nstall PACKAGE

阅读更多

php和nginx使用x-accel-redirect做文件下载

1
2
3
4
5
6
7
8
9
10
11
12

$file_url= "g1/".$file_path;
$file_name=$title.'.'.$file_ext;

header("Content-Type:application/octet-stream;charset=utf-8");
header('Content-Disposition: attachment; filename='.$file_name);
header('X-Accel-Redirect: /filedfs/'.$file_url);
header("X-Accel-Buffering: yes");
header("X-Accel-Limit-Rate :102400"); //速度限制 Byte/s
header("Accept-Ranges: none");//单线程 限制多线程
header("X-Accel-Charset: utf-8");

阅读更多

centos下php编译安装

安装前准备

1
2
3
4
5
6
7
8
9
10
yum -y install gcc automake autoconf libtool make

yum -y install gcc gcc-c++ glibc

yum -y install libmcrypt-devel mhash-devel libxslt-devel \
libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \
zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel \
ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel \
krb5 krb5-devel libidn libidn-devel openssl openssl-devel

阅读更多

tesseract配置

Tesseract开源的OCR引擎,使用 Apache 2.0 license授权协议,可以直接使用或者使用API开发.并且支持多语言.

阅读更多