2019年11月4日 星期一

HAPorxy Install for mysql

PART1 Install the ha pxoy

simple

https://www.haproxy.com/blog/hitless-reloads-with-haproxy-howto/


https://galeracluster.com/library/documentation/ha-proxy.html
https://computingforgeeks.com/galera-cluster-high-availability-with-haproxy-on-ubuntu-18-04-centos-7/

http://benjr.tw/95644


http://random168.blogspot.com/2018/11/linux-haproxy-mariadbmysql.html

https://iter01.com/59486.html

scl

https://pario.no/2018/07/17/install-haproxy-1-8-on-centos-7/

large

https://www.fromdual.com/making-haproxy-high-available-for-mysql-galera-cluster
https://www.jonespaulr.net/ha-mariadbgalera-cluster-w-haproxy-and-keepalived.html

Part2  install the  haproxy log


https://ruilung-notes.blogspot.com/2016/12/haproxylog.html

https://ops.tips/gists/haproxy-docker-container-logs/


part3  install the view


https://www.datadoghq.com/blog/how-to-collect-haproxy-metrics/

https://www.haproxy.com/blog/dynamic-configuration-haproxy-runtime-api/

REF document

ch:

https://www.cnblogs.com/dkblog/archive/2012/03/13/2393321.html

en

https://www.haproxy.org/download/1.4/doc/configuration.txt

https://www.haproxy.com/blog/the-four-essential-sections-of-an-haproxy-configuration/



https://stackshare.io/stackups/haproxy-vs-keepalived

https://codertw.com/%E4%BC%BA%E6%9C%8D%E5%99%A8/382202/

https://ssorc.tw/5937

strange parameter

https://stackoverflow.com/questions/34840176/when-to-use-httpclose-or-http-server-close-in-haproxy
https://ops.tips/gists/making-haproxy-respond-200ok-to-health-checks/
http://wsfdl.com/openstack/2014/12/24/Haproxy%E4%B8%8EOpenStack-API%E5%AE%89%E5%85%A8.html

2019年10月22日 星期二

docker Mariadb

1. install

https://linoxide.com/containers/setup-use-mariadb-docker-container/


2. docker network setting in container
https://philipzheng.gitbooks.io/docker_practice/content/network/linking.html

3. mariadb explain
https://mariadb.com/kb/en/library/installing-and-using-mariadb-via-docker/
https://mariadb.com/kb/en/library/configuring-mariadb-for-remote-client-access/
https://tableplus.com/blog/2018/09/mariadb-how-to-create-new-user-and-grant-privileges.html


4. db with network
http://arder-note.blogspot.com/2018/05/docker-container-link-network.html


5.
http://benjr.tw/95284

https://mariadb.org/get-involved/getting-started-for-developers/get-code-build-test/


6. download data
https://relational.fit.cvut.cz/dataset/NBA


7. testing
sqlslap:
https://www.digitalocean.com/community/tutorials/how-to-measure-mysql-query-performance-with-mysqlslap
https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/187279/

https://dev.mysql.com/doc/refman/8.0/en/mysqlslap.html

https://www.techrepublic.com/blog/how-do-i/how-do-i-stress-test-mysql-with-mysqlslap/


sysbech:
https://github.com/akopytov/sysbench
https://severalnines.com/database-blog/how-benchmark-performance-mysql-mariadb-using-sysbench
https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/187279/


linkbech:
https://mariadb.org/performance-evaluation-of-mariadb-10-1-and-mysql-5-7-4-labs-tplc/


8. cluster:
http://benjr.tw/95381

http://benjr.tw/12461

https://abcg5.pixnet.net/blog/post/113914391

http://akuma1.pixnet.net/blog/post/172611248-mariadb-cluster-%E6%9E%B6%E8%A8%AD%EF%BC%8D%EF%BC%8D%EF%BC%88%E4%B8%89%EF%BC%89%E8%A8%AD%E5%AE%9Amariadb-cluster


https://kknews.cc/zh-tw/code/nv8jxaq.html

https://mariadb.com/kb/en/library/what-is-mariadb-galera-cluster/

https://linuxize.com/post/how-to-install-mariadb-on-ubuntu-18-04/

# replicate
https://noter.tw/4508/mariadb-replication-%E8%A8%AD%E5%AE%9A/

https://allen-fjl.blogspot.com/2018/02/centos-7-mysqlmariadb-replication.html

https://www.ithome.com.tw/tech/87416

9.  replicate
https://kknews.cc/zh-tw/code/l3b3eeb.html

https://www.itread01.com/content/1548326306.html

https://www.itread01.com/p/1136578.html

https://abcg5.pixnet.net/blog/post/117473364-%E5%AF%A6%E4%BD%9C%E7%B0%A1%E5%96%AE%E7%9A%84mariadb-replication

https://blog.toright.com/posts/5062/mysql-replication-%E4%B8%BB%E5%BE%9E%E5%BC%8F%E6%9E%B6%E6%A7%8B%E8%A8%AD%E5%AE%9A%E6%95%99%E5%AD%B8.html

https://www.itread01.com/content/1525956033.html

10.
http://benjr.tw/95644

http://benjr.tw/95473

https://mariadb.com/kb/en/library/installing-galera-from-source/

http://random168.blogspot.com/2018/11/mariadbmysql-galera-cluster.html

https://blog.wu-boy.com/2012/11/innodb-as-the-default-mysql-storage-engine/

http://hank20.blogspot.com/2018/04/centos7mariadb103galera-cluster.html

https://www.itread01.com/articles/1494275901.html

http://benjr.tw/95381

https://galeracluster.com/library/documentation/galera-parameters.html

https://galeracluster.com/library/documentation/mysql-wsrep-options.html#wsrep-node-name

https://severalnines.com/database-blog/running-mariadb-galera-cluster-without-container-orchestration-tools-part-one

https://galeracluster.com/library/documentation/quorum-reset.html

https://www.cnblogs.com/nulige/articles/8470001.html

https://galeracluster.com/library/documentation/docker.html

https://codertw.com/%E8%B3%87%E6%96%99%E5%BA%AB/11036/

https://severalnines.com/database-blog/galera-cluster-recovery-101-deep-dive-network-partitioning


11. Galera ok
A. install : 
B. usigin safe start  , start2
C. cluster container
D.  other
E. other 2
F.other 3


12. Other pameter
https://galeracluster.com/library/documentation/mysql-wsrep-options.html#wsrep-cluster-address


https://www.dreamvps.com/tutorials/install-mysql-galera-cluster-centos-7/

http://hank20.blogspot.com/2018/04/centos7mariadb103galera-cluster.html

http://it2record.blogspot.com/2014/07/centos65-mariadb-55-galera-server.html

https://blog.wu-boy.com/2013/03/galera-cluster-for-mysql-multi-master-replication/

https://galeracluster.com/library/documentation/notification-cmd.html

good

https://www.centos.bz/2017/07/centos-7-2-install-mariadb-galera-cluster10-1-21-mariadb-3-master-cluster/


2019年10月20日 星期日

EMC api for isilon

1. login
https://community.emc.com/community/products/isilon/blog/2015/10/29/onefs-api-tutorial-insightiq-performance-metrics

2.  api
http://doc.isilon.com/onefs/8.1.0/api/02-ifs-br-intro-to-onefs-api.htm

3. system api
http://doc.isilon.com/onefs/8.1.0/api/04-ifs-br-file-system-access-apis.htm

2019年10月16日 星期三

unicode and utf8

https://pjchender.blogspot.com/2018/06/guide-unicode-javascript.html


PHP to character


print_r(json_decode('{"t":"\u00ed"}'));

$str = "\u9060\u50b3\u96fb\u4fe1";
echo unicode2utf8($str);

function unicode2utf8($str){
        if(!$str) return $str;
       
        $decode = json_decode($str);
        if($decode) return $decode;

        $str = '["' . $str . '"]';
        $decode = json_decode($str);
        if(count($decode) == 1){
                return $decode[0];
        }
        return $str;
}


ref  1

2019年9月26日 星期四

Docker Concept

1. Example 1
Docker 不是虚拟机,容器中的应用都应该以前台执行,而不是像虚拟机、物理机里面那样,用 systemd去启动后台服务,容器内没有后台服务的概念。
一些初学者将 CMD 写为:
CMD service nginx start
然后发现容器执行后就立即退出了。甚至在容器内去使用 systemctl 命令结果却发现根本执行不了。这就是因为没有搞明白前台、后台的概念,没有区分容器和虚拟机的差异,依旧在以传统虚拟机的角度去理解容器。
正确的做法是直接执行 nginx 可执行文件,并且要求以前台形式运行。比如:
CMD ["nginx", "-g", "daemon off;"]


2.  EXPOSE

EXPOSE
 指令是声明运行时容器提供服务端口,这只是一个声明,
在运行时并不会因为这个声明应用就会开启这个端口的服务。在 Dockerfile 中写入这样的声明有两个好处,一个是帮助镜像使用者理解这个镜像服务的守护端口,以方便配置映射;另一个用处则是在运行时使用随机端口映射时,也就是 docker run -P时,会自动随机映射 EXPOSE 的端口。
要将 EXPOSE 和在运行时使用 -p <宿主端口>:<容器端口> 区分开来。-p,是映射宿主端口和容器端口,换句话说,就是将容器的对应端口服务公开给外界访问,而 EXPOSE 仅仅是声明容器打算使用什么端口而已,并不会自动在宿主进行端口映射



3. WORKDIR 
格式为 WORKDIR <工作目录路径>
使用 WORKDIR 指令可以来指定工作目录(或者称为当前目录),以后各层的当前目录就被改为指定的目录,如该目录不存在,WORKDIR 会帮你建立目录。
之前提到一些初学者常犯的错误是把 Dockerfile 等同于 Shell 脚本来书写,这种错误的理解还可能会导致出现下面这样的错误:
RUN cd /app
RUN echo "hello" > world.txt
如果将这个 Dockerfile 进行构建镜像运行后,会发现找不到 /app/world.txt 文件,或者其内容不是 hello。原因其实很简单,在 Shell 中,连续两行是同一个进程执行环境,因此前一个命令修改的内存状态,会直接影响后一个命令;而在 Dockerfile 中,这两行 RUN 命令的执行环境根本不同,是两个完全不同的容器。这就是对 Dockerfile 构建分层存储的概念不了解所导致的错误。
之前说过每一个 RUN 都是启动一个容器、执行命令、然后提交存储层文件变更。第一层 RUN cd /app 的执行仅仅是当前进程的工作目录变更,一个内存上的变化而已,其结果不会造成任何文件变更。而到第二层的时候,启动的是一个全新的容器,跟第一层的容器更完全没关系,自然不可能继承前一层构建过程中的内存变化。
因此如果需要改变以后各层的工作目录的位置,那么应该使用 WORKDIR 指令



4.  study
https://jeffreyfritz.com/2018/09/deploying-asp-net-core-with-net-framework-using-docker/

https://www.jinnsblog.com/2018/12/docker-dockerfile-guide.html

https://blog.alexellis.io/run-iis-asp-net-on-windows-10-with-docker/

http://www.codedata.com.tw/social-coding/docker-layman-abc/

https://columns.chicken-house.net/2018/05/12/msa-labs2-selfhost/


https://skychang.github.io/2015/07/30/%E8%AE%93-ASP-NET-MVC-%E5%9F%B7%E8%A1%8C%E6%96%BC-Docker/

2019年9月25日 星期三

apache redis guidline



https://blog.gxxsite.com/laravel-redis-cache-clear-session-queue/

https://matomo.org/faq/how-to/faq_20521/


https://github.com/MISP/misp-book/issues/36

https://www.cloudways.com/blog/redis-for-queuing-in-laravel-5/


https://www.objectrocket.com/blog/how-to/top-5-redis-use-cases/


# apache mpm_prefork
https://serverfault.com/questions/269674/why-is-apache-running-so-many-processes-excessive-ram-here

https://stackoverflow.com/questions/15922194/problems-with-apache-servers-and-a-lot-of-httpd-processes

https://serverfault.com/questions/823121/why-is-apache-spawning-so-many-processes

https://serverfault.com/questions/365205/why-are-there-many-httpd-process-on-the-machine-while-i-only-started-one-apache

https://stackoverflow.com/questions/36924952/ah00161-server-reached-maxrequestworkers-setting-consider-raising-the-maxreque

https://serverfault.com/questions/684424/how-to-tune-apache-on-ubuntu-14-04-server

docker apache notice the tmpfs



1.  Problem

Apache 2.4 AH01762 & AH01760: failed to initialize shm (Shared Memory Segment)




2. solution
$ mkdir /run/httpd



3. reason
为了让容器能够访问数据而不需要永久地写入数据,可以使用 tmpfs 挂载,该挂载仅存储在主机的内存中(如果内存不足,则为 swap)。当容器停止时,tmpfs 挂载会被移除。如果提交容器,则不会保存 tmpfs 挂载



4. ref

https://ma.ttias.be/apache-2-4-ah01762-ah01760-failed-to-initialize-shm-shared-memory-segment/
https://bugzilla.redhat.com/show_bug.cgi?id=1215667

# tmpfs
https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html
https://zh.wikipedia.org/zh-tw/Tmpfs
https://adon988.logdown.com/posts/7801999-docker-tmpfs

https://blog.csdn.net/kikajack/article/details/79475168
https://unix.stackexchange.com/questions/13972/what-is-this-new-run-filesystem