月度归档:2018年08月

SSH from A through B to C, using private key on B



https://serverfault.com/questions/337274/ssh-from-a-through-b-to-c-using-private-key-on-b/701884#701884?tdsourcetag=s_pctim_aiomsg

Host jumpServer
        HostName x.y.z.h
        Port 22
        User abc
        IdentityFile ~/.ssh/id_rsa

Host A74
    HostName 10.1.0.1
    Port 22
    User zyx
    IdentityFile ~/.ssh/a73.id_rsa
    ProxyJump jumpServer    #ProxyJump是从ssh7.3开始支持。#ProxyCommand需要nc支持
    #ProxyCommand ssh -o 'ForwardAgent yes' jumpServer 'ssh-add && nc %h %p'

MySQL的主从配置

https://github.com/getwingm/mysql-replica

version: '2'
services:
    master:
        image: twang2218/mysql:5.7-replica
        restart: unless-stopped
        ports:
            - 3306:3306
        environment:
            - MYSQL_ROOT_PASSWORD=master_passw0rd
            - MYSQL_REPLICA_USER=replica
            - MYSQL_REPLICA_PASS=replica_Passw0rd
        command: ["mysqld", "--log-bin=mysql-bin", "--server-id=1"]
    slave:
        image: twang2218/mysql:5.7-replica
        restart: unless-stopped
        ports:
            - 3307:3306
        environment:
            - MYSQL_ROOT_PASSWORD=slave_passw0rd
            - MYSQL_REPLICA_USER=replica
            - MYSQL_REPLICA_PASS=replica_Passw0rd
            - MYSQL_MASTER_SERVER=master
            - MYSQL_MASTER_WAIT_TIME=10
        command: ["mysqld", "--log-bin=mysql-bin", "--server-id=2"]

PHP中安装主从插件

1. wget http://pecl.php.net/get/mysqlnd_ms-1.5.2.tgz 
2. tar xzvf mysqlnd_ms-1.5.2.tgz
3. cd mysqlnd_ms-1.5.2
4. /path/to/phpize
5. ./configure --enable-mysqlnd-ms --with-php-config=/usr/local/php/bin/php-config
6. make
7. make install
8. sudo /etc/init.d/php-fpm restart
9. php -m | grep mysql #看到"mysqlnd_ms"扩展表示安装成功

执行代码
      if (function_exists('mysqlnd_ms_set_qos')) {
            try {
                $db = $this->db;
                $mysqli = $db->conn_id;
                mysqlnd_ms_set_qos($mysqli, MYSQLND_MS_QOS_CONSISTENCY_SESSION);
            }catch (Exception $e) {

            }

        }

优秀的GoLang库

日志类
https://github.com/sirupsen/logrus
ORM类
https://github.com/jinzhu/gorm #最强,包括数据库迁移。
https://github.com/go-xorm/xorm #最少依赖