逝者如斯夫

          靜而思之

          導(dǎo)航

          留言簿(61)

          隨筆分類(lèi)

          最新隨筆

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          2018年8月3日

          Docker Registry 安裝和運(yùn)行

          使用場(chǎng)景

          • 內(nèi)部網(wǎng)絡(luò),無(wú)法訪(fǎng)問(wèn) Docker Hub
          • 控制 image 的存儲(chǔ)方式和存儲(chǔ)位置
          • 控制 image 的部署流程
          • 內(nèi)部開(kāi)發(fā)流程需要集成控制 image 的部署和存儲(chǔ)

          應(yīng)用邏輯示意圖:

          ?

          安裝 Registry 服務(wù)

          概要

          Docker Registry 在 docker hub 的名稱(chēng)是 registry。v1 版本的源碼地址 github.com/docker/docker-registry 已經(jīng)廢棄,v2 版本源碼地址在 github.com/docker/distribution,對(duì)應(yīng)的 API 是 Docker Registry HTTP API V2

          以下安裝沒(méi)有使用 HTTPS 方式,啟用 HTTPS 相關(guān)的證書(shū)配置參考這個(gè)文檔:

          官方文檔參考:

          最簡(jiǎn)安裝(啟動(dòng))

          docker run -d -p 5000:5000 --name registry registry:2
          

          以上命令未使用用戶(hù)名密碼登錄策略。

          啟用登錄密碼

          生成密碼

          登錄密碼可以通過(guò) host 的文件傳入,以下命令調(diào)用容器的 htpasswd 命令生成密碼文件:

          mkdir auth
          docker run --entrypoint htpasswd registry:2 \
              -Bbn <USER_NAME> <PASSWORD> > auth/auth.htpasswd
          

          啟用密碼

          通過(guò) –volume 參數(shù)傳入密碼文件:

          docker run -d -p 5000:5000 --restart=always --name registry \
            --volume `PWD`/auth:/auth \
            --env "REGISTRY_AUTH=htpasswd" \
            --env "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
            --env REGISTRY_AUTH_HTPASSWD_PATH=/auth/auth.htpasswd \
            registry:2
          

          修改鏡像存儲(chǔ)

          默認(rèn)鏡像數(shù)據(jù)存儲(chǔ)在 Docker Volume 中,可以通過(guò) bind mount 進(jìn)行修改,參數(shù)信息參考 Volume文檔。下面的例子將本機(jī)目錄 PWD/images 綁定到容器的 /var/lib/registry

          docker run -d -p 5000:5000 \
              --name auth-registry \
              -v `PWD`/images:/var/lib/registry \
              -e SQLALCHEMY_INDEX_DATABASE=sqlite:////opt/docker-image/docker-registry.db \
              -e STORAGE_PATH=/opt/docker-image \
              --restart=always \
              docker.onestch.com:5000/admin/registry:0.1
          

          默認(rèn)的存儲(chǔ)引擎為本地文件系統(tǒng),可以修改文件的存儲(chǔ)引擎為 Amazon S3 bucket、Google Cloud Platform 或其他引擎,可以通過(guò)配置 config.yml 的方式修改存儲(chǔ)配置,更多信息參考 Docker Registry 存儲(chǔ)配置文檔

          停止服務(wù)

          停止 registry 容器并清理運(yùn)行數(shù)據(jù)

          docker stop registry && \
          docker rm -v registry
          

          驗(yàn)證

          查看容器信息

          docker ps --no-trunc
          

          查看全部配置信息或部分信息

          docker inspect <CONTAINER_ID> 
          
          docker inspect <CONTAINER_ID> | grep -C3 -e "Volumes\":"
          docker inspect <CONTAINER_ID> | grep -C2 Binds
          docker inspect -f '{{ .Mounts }}' <CONTAINER_ID>
          

          查看映射的詳細(xì)信息

          docker volume inspect 4496b0a257b966052ef8d0743014a4f63fc9924251c8de0df0e9c70fde4c45e6
          

          發(fā)布鏡像

          登錄服務(wù)

          如果安裝(啟動(dòng))的 registry 服務(wù)需要登錄訪(fǎng)問(wèn)時(shí),執(zhí)行:

          docker login <REGISTRY_HOST>:<REGISTRY_PORT>
          

          輸入安裝時(shí)設(shè)定的用戶(hù)名密碼。

          目標(biāo)地址

          使用 docker tag 設(shè)定鏡像的目標(biāo)地址,鏡像的目標(biāo)地址包括三部分

          <HOST_NAME>[:<HOST_PORT>]/<IMAGE_NAME>:<IMAGE_VERSION>
          
          • HOST_NAME : HOST_PORT

            目標(biāo) registry 服務(wù)地址,缺省時(shí)使用官方 docker hub 的地址 registry-1.docker.io,且不允許包含下劃線(xiàn)

          • IMAGE_NAME 發(fā)布目標(biāo)鏡像名稱(chēng)

          • IMAGE_VERSION 發(fā)布目標(biāo)鏡像版本

          例如:repo.company.com:3456/myapp:0.1

          發(fā)布鏡像

          發(fā)布的鏡像文件可以從 docker hub 中 Pull 或者本地使用 Dockerfile build 獲得

          Pull

          docker pull registry
          

          Build

          docker build -t docker.onestch.com:5000/admin/registry:0.1 .
          

          首先需要對(duì)鏡像 tag 設(shè)定目標(biāo)倉(cāng)庫(kù),如果 build 的時(shí)候已經(jīng)設(shè)置了目標(biāo)地址,可以不用進(jìn)行 tag 操作

          docker tag registry:latest docker.onestch.com:5000/admin/registry:0.1
          

          然后 Push

          docker push docker.onestch.com:5000/admin/registry:0.1
          

          驗(yàn)證

          重新從私有倉(cāng)庫(kù)中獲取鏡像

          docker pull localhost:5000/admin/registry:0.1
          
          0.1: Pulling from admin/registry
          Digest: sha256:d738e358b6910d3a53c9c7ff7bbb5eac490ab7a9b12ffb4c1c27f2c53aae9275
          Status: Image is up to date for localhost:5000/admin/registry:0.1
          

          安裝 Registry UI

          選擇 registry ui,可選的有 atcol/docker-registry-uihyper/docker-registry-webkonradkleine/docker-registry-frontend

          安裝運(yùn)行

          針對(duì) hyper/docker-registry-web,使用 BASIC 認(rèn)證,未使用 HTTPS的情況

          docker run -it -p 8080:8080 \
              --rm \
              --name registry-web \
              --link auth-registry \
              -e REGISTRY_URL=http://auth-registry:5000/v2 \
              -e REGISTRY_AUTH_ENABLED=false \
              -e REGISTRY_BASIC_AUTH=YWRtaW46MTIzNDU2 \
              -e REGISTRY_NAME=docker.onestch.com:5000 hyper/docker-registry-web
          

          命令中 auth-registry 是自定的 registry 鏡像。

          使用 HTTPS 時(shí)需要傳入 /config/auth.key 文件,或自定義 config.xml 配置,例如:
          docker run -it -p 8080:8080 –name registry-web \
          –link auth-registry \
          -v $(pwd)/config.yml:/conf/config.yml:ro \
          hyper/docker-registry-web

          管理界面

          建立了 registry 服務(wù)后,對(duì) registry 的管理界面在本機(jī)的訪(fǎng)問(wèn)地址是http://localhost:8080,一般 ui 服務(wù)會(huì)和 registry 服務(wù)同樣運(yùn)行在私有網(wǎng)絡(luò),所以我們可以發(fā)布 registry ui 到 registry 服務(wù)器再運(yùn)行。

          docker tag docker.io/hyper/docker-registry-web docker.onestch.com:5000/admin/docker-registry-web
          
          docker push docker.onestch.com:5000/admin/docker-registry-web
          

          查看 UI 界面如下圖

          ?

          posted @ 2018-08-03 11:49 ideame 閱讀(1306) | 評(píng)論 (0)編輯 收藏

          2016年10月10日

          Zookeeper Cli 常用命令

          服務(wù)管理

          • 啟動(dòng)ZK服務(wù): zkServer.sh start
          • 查看ZK狀態(tài): zkServer.sh status
          • 停止ZK服務(wù): zkServer.sh stop
          • 重啟ZK服務(wù): zkServer.sh restart

          終端操作

          使用 zkCli 可以簡(jiǎn)單的對(duì) ZooKeeper 進(jìn)行訪(fǎng)問(wèn),數(shù)據(jù)創(chuàng)建,數(shù)據(jù)修改等操作. 連接命令行如下:

          zkCli.sh -server 127.0.0.1:2181
          

          命令行工具常用操作:

          • 顯示根目錄下文件

            ls /              //查看當(dāng)前節(jié)點(diǎn)數(shù)據(jù)
            ls2 /             //查看當(dāng)前節(jié)點(diǎn)數(shù)據(jù)并能看到更新次數(shù)等數(shù)據(jù)
            
          • 創(chuàng)建文件, 并設(shè)置初始內(nèi)容:

            create /config "test" //創(chuàng)建一個(gè)新的節(jié)點(diǎn)并設(shè)置關(guān)聯(lián)值
            create /config “”     //創(chuàng)建一個(gè)新的空節(jié)點(diǎn)
            
          • 獲取文件內(nèi)容

            get /brokers      //獲取節(jié)點(diǎn)內(nèi)容
            
          • 修改文件內(nèi)容

            set /zk "zkbak"   //對(duì) zk 所關(guān)聯(lián)的字符串進(jìn)行設(shè)置
            
          • 刪除文件

            delete /brokers  //刪除節(jié)點(diǎn)
            rmr    /brokers  //刪除節(jié)點(diǎn)及子節(jié)點(diǎn)
            

          四字命令

          ZooKeeper 支持某些特定的四字命令字母與其的交互,用來(lái)獲取服務(wù)的當(dāng)前狀態(tài)及相關(guān)信息。在客戶(hù)端可以通過(guò) telnet 或 nc 向 ZooKeeper 提交相應(yīng)的命令。命令行如下:

          echo conf | nc 132.37.3.26 26181
          

          ZooKeeper 常用四字命令:

          • conf

            輸出相關(guān)服務(wù)配置的詳細(xì)信息

          • cons

            列出所有連接到服務(wù)器的客戶(hù)端的完全的連接 / 會(huì)話(huà)的詳細(xì)信息。包括“接受 / 發(fā)送”的包數(shù)量、會(huì)話(huà) id 、操作延遲、最后的操作執(zhí)行等等信息

          • dump

            列出未經(jīng)處理的會(huì)話(huà)和臨時(shí)節(jié)點(diǎn)。

          • envi

            輸出關(guān)于服務(wù)環(huán)境的詳細(xì)信息(區(qū)別于 conf 命令)。

          • reqs

            列出未經(jīng)處理的請(qǐng)求

          • ruok

            測(cè)試服務(wù)是否處于正確狀態(tài)。如果確實(shí)如此,那么服務(wù)返回“ imok ”,否則不做任何相應(yīng)

          • stat

            輸出關(guān)于性能和連接的客戶(hù)端的列表。

          • wchs

            列出服務(wù)器 watch 的詳細(xì)信息

          • wchc

            通過(guò) session 列出服務(wù)器 watch 的詳細(xì)信息,它的輸出是一個(gè)與 watch 相關(guān)的會(huì)話(huà)的列表

          • wchp

            通過(guò)路徑列出服務(wù)器 watch 的詳細(xì)信息。它輸出一個(gè)與 session 相關(guān)的路徑

          posted @ 2016-10-10 17:54 ideame 閱讀(5552) | 評(píng)論 (0)編輯 收藏

          2016年8月1日

          JMH(Java Micro Benchmark) 簡(jiǎn)介

               摘要: JMH簡(jiǎn)介本文由 ImportNew - hejiani 翻譯自 java-performance。JMH是新的microbenchmark(微基準(zhǔn)測(cè)試)框架(2013年首次發(fā)布)。與其他眾多框架相比它的特色優(yōu)勢(shì)在于,它是由Oracle實(shí)現(xiàn)JIT的相同人員開(kāi)發(fā)的。特別是我想提一下Aleksey Shipilev和他優(yōu)秀的博客文章。JMH可能與最新的Oracle JRE同步,其結(jié)果可信度很高。JMH...  閱讀全文

          posted @ 2016-08-01 17:12 ideame 閱讀(3265) | 評(píng)論 (0)編輯 收藏

          2014年2月28日

          如何將 SVN 源碼庫(kù)轉(zhuǎn)換為 Mercurial

          如何將 SVN 源碼庫(kù)轉(zhuǎn)換為 Mercurial [1]

          首先得安裝 Subversion 庫(kù)函數(shù)

          				    wget http://mirrors.hust.edu.cn/apache/subversion/subversion-1.8.8.tar.gz
          
              tar xzf subversion-1.8.8.tar.bz2 
          
              cd subversion-1.8.8
          
              subversion-1.8.8 aliang$ ./autogen.sh 
                  buildcheck: checking installation...
                  buildcheck: autoconf not found.
                              You need autoconf version 2.59 or newer installed.
          
              brew install autoconf
                  ==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/autoconf-2.69.mavericks.bottle.tar.gz
                  #################################################### 100.0%
                  ==> Pouring autoconf-2.69.mavericks.bottle.tar.gz
                  ?? /usr/local/Cellar/autoconf/2.69: 69 files, 2.0M
          
              ./autogen.sh 
                  buildcheck: checking installation...
                  buildcheck: autoconf version 2.69 (ok)
                  buildcheck: autoheader version 2.69 (ok)
                  buildcheck: libtool not found.
                  You need libtool version 1.4 or newer installed
          
              brew install libtool
                  Warning: A newer Command Line Tools release is available
                  Update them from Software Update in the App Store.
                  ==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libtool-2.4.2.mavericks.bottle.2.tar.gz
                  ##################################################### 100.0%
                  ==> Pouring libtool-2.4.2.mavericks.bottle.2.tar.gz
                  ==> Caveats
                  In order to prevent conflicts with Apple''s own libtool we have prepended a "g"
                  so, you have instead: glibtool and glibtoolize.
                  ==> Summary
                  ??  /usr/local/Cellar/libtool/2.4.2: 66 files, 2.2M
          
              ./autogen.sh 
                  buildcheck: checking installation...
                  buildcheck: autoconf version 2.69 (ok)
                  buildcheck: autoheader version 2.69 (ok)
                  buildcheck: libtool version 2.4.2 (ok)
                  Copying libtool helper: /usr/local/share/aclocal/libtool.m4
                  Copying libtool helper: /usr/local/share/aclocal/ltoptions.m4
                  Copying libtool helper: /usr/local/share/aclocal/ltsugar.m4
                  Copying libtool helper: /usr/local/share/aclocal/ltversion.m4
                  Copying libtool helper: /usr/local/share/aclocal/lt~obsolete.m4
                  Creating build-outputs.mk...
                  Creating svn_private_config.h.in...
                  Creating configure...
          
                  You can run ./configure now.
          
                  Running autogen.sh implies you are a maintainer.  You may prefer
                  to run configure in one of the following ways:
          
                  ./configure --enable-maintainer-mode
                  ./configure --disable-shared
                  ./configure --enable-maintainer-mode --disable-shared
                  ./configure --disable-optimize --enable-debug
                  ./configure CUSERFLAGS='--flags-for-C' CXXUSERFLAGS='--flags-for-C++'
          
                  Note:  If you wish to run a Subversion HTTP server, you will need
                  Apache 2.x.  See the INSTALL file for details.
          
              brew install swig
                  ==> Downloading http://downloads.sourceforge.net/project/swig/swig/swig-2.0.11/swig-2.0.11.tar.gz
                  ######################################################################## 100.0%
                  ==> ./configure --prefix=/usr/local/Cellar/swig/2.0.11
                  ==> make
                  ==> make install
                  ??  /usr/local/Cellar/swig/2.0.11: 597 files, 6.2M, built in 10.1 minutes 
          
              ./configure --with-swig=/usr/local/bin/swig
                  configure: Configuring Subversion 1.8.8
                  ... ...
                  ==================================================================
                  WARNING: You have chosen to compile Subversion with a different
                           compiler than the one used to compile Apache.
          
                      Current compiler:  gcc
                     Apache's compiler:  /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc
          
                  This could cause some problems.
                  ==================================================================
                  ... ...
          
              make swig-py
              make install
              make check-swig-py        
              sudo make install-swig-py
          
              sudo cp -r /usr/local/lib/svn-python/ /Library/Python/2.7/site-packages/
          
          		

          執(zhí)行轉(zhuǎn)換命令

          				    mkdir hgpath
          
              cd hgpath
          
              hg init
          
              hg convert -s svn -d hg ${local_path} ./hgpath
          
          		

          注意,這里轉(zhuǎn)換的 SVN 目錄只能是倉(cāng)庫(kù)目錄而不是工作目錄

          posted @ 2014-02-28 11:25 ideame 閱讀(591) | 評(píng)論 (0)編輯 收藏

          2013年11月3日

          ditaa

          ?

          ditaa is a small command-line utility written in Java, that can
          convert diagrams drawn using ascii art ('drawings' that contain
          characters that resemble lines like | / - ), into proper
          bitmap graphics. This is best illustrated by the following
          example -- which also illustrates the benefits of using ditaa in
          comparison to other methods :)

              +--------+   +-------+    +-------+
              |        | --+ ditaa +--> |       |
              |  Text  |   +-------+    |diagram|
              |Document|   |!magic!|    |       |
              |     wmqeeuq|   |       |    |       |
              +---+----+   +-------+    +-------+
                  :                         ^
                  |       Lots of work      |
                  +-------------------------+
          
          After conversion using ditaa, the above
          file becomes:
          round 		corner demo

          ditaa interprets ascci art as a series of open and closed
          shapes, but it also uses special markup syntax to increase the
          possibilities of shapes and symbols that can be rendered.

          ditaa is open source and free software (free as in free
          speech), since it is released under the GPL license.

          BUT WHY? Does this thing have any real use?

          There are several reasons why I did this:

          1. Simply for hack value. I wanted to know if/how it could be
            done and how easily.
          2. Aesthetic reasons and legacy formats: there are
            several old FAQs with ascii diagrams lying out there. At this
            time and age ascii diagrams make my eyes hurt due to their
            ugliness. ditaa can be used to convert them to something
            nicer. Although ditaa would not be able to convert all of them
            (due to differences in drawing 'style' in each case), it could
            prove useful in the effort of modernising some of those
            documents without too much effort. I also know a lot of people
            that can make an ascii diagram easily, but when it gets to using
            a diagram program, they don't do very well. Maybe this utility
            could help them make good-looking diagrams easily/quickly.
          3. Embedding diagrams to text-only formats: There is a
            number of formats that are text-based (html, docbook, LaTeX,
            programming language comments), but when rendered by other
            software (browsers, interpreters, the javadoc tool etc), they
            can contain images as part of their content. If ditaa was
            intergrated with those tools (and I'm planning to do the javadoc
            bit myself soon), then you would have readable/editable diagrams
            within the text format itself, something that would make things
            much easier. ditaa syntax can currently be embedded to HTML.
          4. Reusability of "code": Suppose you make a diagram in
            ascii art and you render it with version 0.6b of ditaa. You keep
            the ascii diagram, and then version 0.8 comes out, which
            features some new cool effects. You re-render your old diagram
            with the new version of ditaa, and it looks better, with zero
            effort! In that sense ditaa is a diagram markup language, with
            very loose syntax.


          Download

          (((-intro-))) (((-download-))) (((-usage and syntax-))) (((-friends-))) (((-contact-)))

          The latest version of ditaa can be obtained from its SourceForge project page.

          You can checkout the code using:

          ???svn co https://ditaa.svn.sourceforge.net/svnroot/ditaa ditaa

          You can also browse the code online.


          Usage and syntax

          (((-intro-))) (((-download-))) (((-usage and syntax-))) (((-friends-))) (((-contact-)))

          Command line

          You need the latest Java runtimes (JRE) to use ditaa. The best
          anti-aliasing can be achieved using Java 1.5 or higher.

          To start from the command line, type (where XXX is the version number):

          java -jar ditaaXXX.jar

          You will be presented with the command-line options help:

           -A,--no-antialias          Turns anti-aliasing off.
           -d,--debug                 Renders the debug grid over the resulting
                                      image.
           -E,--no-separation         Prevents the separation of common edges of
                                      shapes. You can see the difference below:
          
          +---------+
          | cBLU    |
          |         |
          |    +----+
          |    |cPNK|
          |    |    |
          +----+----+
          			
          Before processingCommon edge
          separation (default)
          No separation
          (with the -E option)
           -e,--encoding <ENCODING>   The encoding of the input file.
           -h,--html                  In this case the input is an HTML file. The
                                      contents of the <pre class="textdiagram"> tags
                                      are rendered as diagrams and saved in the
                                      images directory and a new HTML file is
                                      produced with the appropriate <img> tags.
                                      See the HTML section.
              --help                  Prints usage help.
           -o,--overwrite             If the filename of the destination image
                                      already exists, an alternative name is chosen.
                                      If the overwrite option is selected, the image
                                      file is instead overwriten.
           -r,--round-corners         Causes all corners to be rendered as round
                                      corners.
           -s,--scale <SCALE>         A natural number that determines the size of
                                      the rendered image. The units are fractions of
                                      the default size (2.5 renders 1.5 times bigger
                                      than the default).
           -S,--no-shadows            Turns off the drop-shadow effect.
           -t,--tabs <TABS>           Tabs are normally interpreted as 8 spaces but
                                      it is possible to change that using this
                                      option. It is not advisable to use tabs in
                                      your diagrams.
           -v,--verbose               Makes ditaa more verbose.
          

          Syntax

          Round corners

          If you use / and \ to connect corners, they are rendered as
          round corners:

          /--+
          |  |
          +--/
          		  
          round corner demo
          Before processingRendered

          Color

          Color codes can be used to add color to the diagrams. The
          syntax of color codes is

          cXXX

          where XXX is a hex number. The first digit of the number
          represents the red compoment of the color, the second digit
          represents green and the third blue (good ol' RGB). See below for
          an example of use of color codes:

          /----\ /----\
          |c33F| |cC02|
          |    | |    |
          \----/ \----/
          
          /----\ /----\
          |c1FF| |c1AB|
          |    | |    |
          \----/ \----/
          		  
          color demo
          Before processingRendered

          This can become a bit tedious after a while, so there are (only
          some for now) human readable color codes provided:

          Color codes
          /-------------+-------------\
          |cRED RED     |cBLU BLU     |
          +-------------+-------------+
          |cGRE GRE     |cPNK PNK     |
          +-------------+-------------+
          |cBLK BLK     |cYEL YEL     |
          \-------------+-------------/
          
          color code
          Before processingRendered

          As you can see above, if a colored shape contains any text, the
          color of the text is adjusted according to the underlying
          color. If the undelying color is dark, the text color is changed
          to white (from the default black).

          Note that color codes only apply if they are within closed
          shapes, and they have no effect anywhere outside.

          Tags

          ditaa recognises some tags that change the way a rectangular
          shape is rendered. All tags are between { and }. See the table below:

          NameOriginalRenderedComment
          Document
          +-----+
          |wmqeeuq  |
          |     |
          |     |
          +-----+
          		  
          Symbol representing a document.
          Storage
          +-----+
          |{s}  |
          |     |
          |     |
          +-----+
          		  
          Symbol representing a form of storage,
          like a
          database or a hard disk.
          Input/Output
          +-----+
          |{io} |
          |     |
          |     |
          +-----+
          		  
          Symbol representing input/output.

          Dashed lines

          Any lines that contain either at least one = (for horizontal
          lines) or at least one : (for vertical lines) are rendered as
          dashed lines. Only one of those characters can make a whole line
          dashed, so this feature "spreads". The rationale behind that is
          that you only have to change one character to switch from normal
          to dashed (and vice versa), rather than redrawing the whole
          line/shape. Special symbols (like document or storage symbols) can
          also be dashed. See below:

          ----+  /----\  +----+
              :  |    |  :    |
              |  |    |  |{s} |
              v  \-=--+  +----+
          
          Before processingRendered

          Point markers

          If * is encountered on a line (but not at the end of the
          line), it is rendered as a special marker, called the point
          marker (this feature is still experimental). See below:

          *----*
          |    |      /--*
          *    *      |
          |    |  -*--+
          *----*
          
          point marker demo
          Before processingRendered

          Text handling

          (This section is still being written)

          If the pattern ' o XXXXX' is encountered, where XXXXX is any
          text, the 'o' is interpreted and rendered as a bullet point. Note
          that there must be a space before the 'o' as well as after it. See
          below:

          /-----------------\
          | Things to do    |
          | cGRE            |
          | o Cut the grass |
          | o Buy jam       |
          | o Fix car       |
          | o Make website  |
          \-----------------/
          
          bullet point demo
          Before processingRendered

          ?

          HTML mode

          When ditaa is run using the --html option, the input
          is an HTML file. The contents of the <pre
          class="textdiagram">
          tags are rendered as diagrams and
          saved in the images directory and a new HTML file is
          produced with the appropriate <img> tags.

          If the id parameter is present in the
          <pre> tag, its value is used as the filename of the
          rendered png. Otherwise a filename of the form
          ditaa_diagram_X.png is used, where X is a
          number. Similarly, if there is no output filename specified, the
          converted html file is named in the form of
          xxxx_processed.html, where xxxx is the filename of the
          original file.

          In this mode, files that exist are not generated again, they
          are just skipped. You can force overwrite of the files using the
          --overwrite option.

          posted @ 2013-11-03 15:21 ideame 閱讀(529) | 評(píng)論 (0)編輯 收藏

          How to install ZXing in Xcode 4

          • April 2011
          • Posted By Yannick Loriot
          • 81 Comments

          After an upgrading to Xcode 4, I have been having trouble compiling my own ZXing iOS project. That’s why I decided to explain you how to install easily ZXing with Xcode 4.

          First of all (for those who don’t know), ZXing is an open-source library to read the 1D/2D barcodes. This library is available on many platforms such as the iOS, Android, Blackberry, ect. You can find it here: http://code.google.com/p/zxing/.

          Before to start, be sure that you have the latest version of ZXing on your computer. If you don’t, you must download it via a SVN client here: http://zxing.googlecode.com/svn/trunk/.

          ?

          To use ZXing into your project in Xcode 4 follow these steps:

          1. Firstly go to the “zxing/iphone/ZXingWidget/” and drag and drop the ZXingWidget.xcodeproj file onto your Xcode “Project navigator” sidebar. If a dialog appears uncheck the “Copy items” and verify that the “Reference Type” is “Relative to Project” before clicking “Add”.

          2. Now we are going to add ZXingWidget as a dependency of your project to allow Xcode to compile it whenever you compile the main project:
            1. First select your project file in the “Project navigator”.
            2. Then select the corresponding target.
            3. After choose the “Build Phases” tab and expand the “Target Dependencies” section.
            4. Click the “+” (add) button to display a dialog.
            5. To finish add the “ZXingWidget” target as shown above.

          3. Now we are going to link the ZXingWidget static library (libZXingWidget.a) to the project:
            1. Firstly choose the “Build Phases” tab and expand the “Link Binary With Libraries” section.
            2. Then click the “+” (add) button to display a dialog.
            3. To finish add the “libZXingWidget.a” which is located in the “Workspace” category as shown above.
            4. By the way add the following iOS frameworks too:
              • AddressBook
              • AddressBookUI
              • AudioToolbox
              • AVFoundation
              • CoreMedia
              • CoreVideo
              • libiconv.dylib

          4. Then you must configure the header search path of your project to allow Xcode to find the ZXingWidget headers. To do that:
            1. In the “Project navigator” select the main project (not the target).
            2. Go to the “Build Settings” tab and search the “Header Search Paths“.
            3. Double-click on it and add:
              • The full path of the “zxing/iphone/ZXingWidget/Classes” directory. Check the “recursive path“.
              • The full path of the “zxing/cpp/core/src/” directory. Uncheck the “recursive path“.

          Now you just have to import the “ZXingWidgetController.h” and the “QRCodeReader.h” to your project and use them.
          Attention: Make sure that the files in which you are using the ZXing headers have the .mm extension because they use c++ library files.

          Voilà! Now all should be ok. I hope it’ll help you!

          1 Star 2 Stars 3 Stars 4 Stars 5 Stars (33 votes, average: 4.55 out of 5)

          http://yannickloriot.com/2011/04/how-to-install-zxing-in-xcode-4/

          posted @ 2013-11-03 14:45 ideame 閱讀(395) | 評(píng)論 (0)編輯 收藏

          2013年7月22日

          MySQL-python 安裝的問(wèn)題

          在Mac下安裝MySQL-python一直有問(wèn)題,不管是用pip還是用setup.py,都是返回如下錯(cuò)誤:


          sudo python setup.py install

          running install
          running bdist_egg
          running egg_info
          writing MySQL_python.egg-info/PKG-INFO
          writing top-level names to MySQL_python.egg-info/top_level.txt
          writing dependency_links to MySQL_python.egg-info/dependency_links.txt
          reading manifest file 'MySQL_python.egg-info/SOURCES.txt'
          reading manifest template 'MANIFEST.in'
          writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
          installing library code to build/bdist.macosx-10.7-x86_64/egg
          running install_lib
          running build_py
          copying MySQLdb/release.py -> build/lib.macosx-10.7-x86_64-2.7/MySQLdb
          running build_ext
          building '_mysql' extension
          / A p p l i c a t i o n s / X c o d e . a p p / C o n t e n t s / D e v e l o p e r / T o o l c h a i n s / X c o d e D e f a u l t . x c t o o l c h a i n / u s r / b i n / c l a n g?? - f n o - s t r i c t - a l i a s i n g?? - f n o - c o m m o n?? - d y n a m i c?? - I / u s r / l o c a l / i n c l u d e?? - I / u s r / l o c a l / o p t / s q l i t e / i n c l u d e?? - i s y s r o o t?? / A p p l i c a t i o n s / X c o d e . a p p / C o n t e n t s / D e v e l o p e r / P l a t f o r m s / M a c O S X . p l a t f o r m / D e v e l o p e r / S D K s / M a c O S X 1 0 . 7 . s d k?? - I / A p p l i c a t i o n s / X c o d e . a p p / C o n t e n t s / D e v e l o p e r / P l a t f o r m s / M a c O S X . p l a t f o r m / D e v e l o p e r / S D K s / M a c O S X 1 0 . 7 . s d k / S y s t e m / L i b r a r y / F r a m e w o r k s / T k . f r a m e w o r k / V e r s i o n s / 8 . 5 / H e a d e r s?? - D N D E B U G?? - g?? - f w r a p v?? - O 3?? - W a l l?? - W s t r i c t - p r o t o t y p e s?? -Dversion_info=(1,2,4,'final',1) -D__version__=1.2.4 -I/usr/local/Cellar/mysql/5.6.10/include -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.7-x86_64-2.7/_mysql.o -Os -g -fno-strict-aliasing
          unable to execute /: Permission denied
          error: command '/' failed with exit status 1


          經(jīng)過(guò)Google,發(fā)現(xiàn)原來(lái)是XCode沒(méi)有安裝Command line Tools的問(wèn)題,參考:http://sourceforge.net/p/mysql-python/bugs/333/

          posted @ 2013-07-22 01:59 ideame 閱讀(557) | 評(píng)論 (0)編輯 收藏

          2013年7月16日

          軟件級(jí)負(fù)載均衡器(LVS/HAProxy/Nginx)的特點(diǎn)和對(duì)比

          LVS的特點(diǎn)是:

          1. 抗負(fù)載能力強(qiáng)、是工作在網(wǎng)絡(luò)4層之上僅作分發(fā)之用,沒(méi)有流量的產(chǎn)生,這個(gè)特點(diǎn)也決定了它在負(fù)載均衡軟件里的性能最強(qiáng)的;
          2. 配置性比較低,這是一個(gè)缺點(diǎn)也是一個(gè)優(yōu)點(diǎn),因?yàn)闆](méi)有可太多配置的東西,所以并不需要太多接觸,大大減少了人為出錯(cuò)的幾率;
          3. 工作穩(wěn)定,自身有完整的雙機(jī)熱備方案,如LVS+Keepalived和LVS+Heartbeat,不過(guò)我們?cè)陧?xiàng)目實(shí)施中用得最多的還是LVS/DR+Keepalived;
          4. 無(wú)流量,保證了均衡器IO的性能不會(huì)收到大流量的影響;
          5. 應(yīng)用范圍比較廣,可以對(duì)所有應(yīng)用做負(fù)載均衡;
          6. 軟件本身不支持正則處理,不能做動(dòng)靜分離,這個(gè)就比較遺憾了;其實(shí)現(xiàn)在許多網(wǎng)站在這方面都有較強(qiáng)的需求,這個(gè)是Nginx/HAProxy+Keepalived的優(yōu)勢(shì)所在。
          7. 如果是網(wǎng)站應(yīng)用比較龐大的話(huà),實(shí)施LVS/DR+Keepalived起來(lái)就比較復(fù)雜了,特別后面有Windows Server應(yīng)用的機(jī)器的話(huà),如果實(shí)施及配置還有維護(hù)過(guò)程就比較復(fù)雜了,相對(duì)而言,Nginx/HAProxy+Keepalived就簡(jiǎn)單多了。

          Nginx的特點(diǎn)是:

          1. 工作在網(wǎng)絡(luò)的7層之上,可以針對(duì)http應(yīng)用做一些分流的策略,比如針對(duì)域名、目錄結(jié)構(gòu),它的正則規(guī)則比HAProxy更為強(qiáng)大和靈活,這也是許多朋友喜歡它的原因之一;
          2. Nginx對(duì)網(wǎng)絡(luò)的依賴(lài)非常小,理論上能ping通就就能進(jìn)行負(fù)載功能,這個(gè)也是它的優(yōu)勢(shì)所在;
          3. Nginx安裝和配置比較簡(jiǎn)單,測(cè)試起來(lái)比較方便;
          4. 也可以承擔(dān)高的負(fù)載壓力且穩(wěn)定,一般能支撐超過(guò)幾萬(wàn)次的并發(fā)量;
          5. Nginx可以通過(guò)端口檢測(cè)到服務(wù)器內(nèi)部的故障,比如根據(jù)服務(wù)器處理網(wǎng)頁(yè)返回的狀態(tài)碼、超時(shí)等等,并且會(huì)把返回錯(cuò)誤的請(qǐng)求重新提交到另一個(gè)節(jié)點(diǎn),不過(guò)其中缺點(diǎn)就是不支持url來(lái)檢測(cè);
          6. N1.ginx僅能支持http和Email,這樣就在適用范圍上面小很多,這個(gè)它的弱勢(shì);
          7. N1.ginx不僅僅是一款優(yōu)秀的負(fù)載均衡器/反向代理軟件,它同時(shí)也是功能強(qiáng)大的Web應(yīng)用服務(wù)器。LNMP現(xiàn)在也是非常流行的web架構(gòu),大有和以前最流行的LAMP架構(gòu)分庭抗?fàn)幹畡?shì),在高流量的環(huán)境中也有很好的效果。
          8. Nginx現(xiàn)在作為Web反向加速緩存越來(lái)越成熟了,很多朋友都已在生產(chǎn)環(huán)境下投入生產(chǎn)了,而且反映效果不錯(cuò),速度比傳統(tǒng)的Squid服務(wù)器更快,有興趣的朋友可以考慮用其作為反向代理加速器。

          HAProxy的特點(diǎn)是:

          1. HAProxy是支持虛擬主機(jī)的,以前有朋友說(shuō)這個(gè)不支持虛擬主機(jī),我這里特此更正一下。
          2. 能夠補(bǔ)充N(xiāo)ginx的一些缺點(diǎn)比如Session的保持,Cookie的引導(dǎo)等工作
          3. 支持url檢測(cè)后端的服務(wù)器出問(wèn)題的檢測(cè)會(huì)有很好的幫助。
          4. 它跟LVS一樣,本身僅僅就只是一款負(fù)載均衡軟件;單純從效率上來(lái)講HAProxy更會(huì)比Nginx有更出色的負(fù)載均衡速度,在并發(fā)處理上也是優(yōu)于Nginx的。
          5. HAProxy可以對(duì)Mysql讀進(jìn)行負(fù)載均衡,對(duì)后端的MySQL節(jié)點(diǎn)進(jìn)行檢測(cè)和負(fù)載均衡,不過(guò)在后端的MySQL slaves數(shù)量超過(guò)10臺(tái)時(shí)性能不如LVS,所以我向大家推薦LVS+Keepalived。

          HAProxy的算法現(xiàn)在也越來(lái)越多了,具體有如下8種:

          1. roundrobin,表示簡(jiǎn)單的輪詢(xún),這個(gè)不多說(shuō),這個(gè)是負(fù)載均衡基本都具備的;
          2. static-rr,表示根據(jù)權(quán)重,建議關(guān)注;
          3. leastconn,表示最少連接者先處理,建議關(guān)注;
          4. source,表示根據(jù)請(qǐng)求源IP,這個(gè)跟Nginx的IP_hash機(jī)制類(lèi)似,我們用其作為解決session問(wèn)題的一種方法,建議關(guān)注;
          5. ri,表示根據(jù)請(qǐng)求的URI;
          6. rlparam,表示根據(jù)請(qǐng)求的URl參數(shù)'balance urlparam' requires an URL parameter name;
          7. hdr(name),表示根據(jù)HTTP請(qǐng)求頭來(lái)鎖定每一次HTTP請(qǐng)求;
          8. rdp-cookie(name),表示根據(jù)據(jù)cookie(name)來(lái)鎖定并哈希每一次TCP請(qǐng)求。

          posted @ 2013-07-16 15:52 ideame 閱讀(1223) | 評(píng)論 (0)編輯 收藏

          2011年11月12日

          Git on Windows

          下載文件 http://msysgit.googlecode.com/files/PortableGit-1.7.7.1-preview20111027.7z

          解壓至 D:\JavaSoft\git-1.7.7.1

          增加系統(tǒng)環(huán)境路徑:D:\JavaSoft\git-1.7.7.1\bin;D:\JavaSoft\git-1.7.7.1\cmd;

          設(shè)置系統(tǒng)屬性:
          git config --global user.name "your.name" git config --global user.email git.mail.name@gmail.com

          創(chuàng)建密鑰:

          mkdir /.ssh

          ssh-keygen -f D:\JavaSoft\git-1.7.7.1\.ssh\id_rsa -t rsa -C 'git.mail.name@gmail.com' -t rsa

          復(fù)制 id_rsa.pub 的內(nèi)容,到github.com增加公鑰,然后粘貼保存。

          測(cè)試:git -v -T git@github.com

          Hi your.name! You've successfully authenticated, but GitHub does not provide shell access.

          posted @ 2011-11-12 11:27 ideame 閱讀(357) | 評(píng)論 (0)編輯 收藏

          2011年5月18日

          yum 上海交通大學(xué) Repository

          /etc/yum.repos.d/CentOS-Base.repo

          [base]
          name
          =CentOS-5?-?Base
          repo
          =os
          baseurl
          =http://ftp.sjtu.edu.cn/centos/5/os/$basearch/
          gpgcheck
          =1
          gpgkey
          =http://ftp.sjtu.edu.cn/centos/RPM-GPG-KEY-CentOS-5

          #released?updates
          [update]
          name
          =CentOS-5?-?Updates
          baseurl
          =http://ftp.sjtu.edu.cn/centos/5/updates/$basearch/
          gpgcheck
          =1
          gpgkey
          =http://ftp.sjtu.edu.cn/centos/RPM-GPG-KEY-CentOS-5

          #packages?used/produced?in?the?build?but?not?released
          [addons]
          name
          =CentOS-5?-?Addons
          baseurl
          =http://ftp.sjtu.edu.cn/centos/5/addons/$basearch/
          gpgcheck
          =1
          gpgkey
          =http://ftp.sjtu.edu.cn/centos/RPM-GPG-KEY-CentOS-5

          #additional?packages?that?may?be?useful
          [extras]
          name
          =CentOS-5?-?Extras
          baseurl
          =http://ftp.sjtu.edu.cn/centos/5/extras/$basearch/
          gpgcheck
          =1
          gpgkey
          =http://ftp.sjtu.edu.cn/centos/RPM-GPG-KEY-CentOS-5

          #additional?packages?that?extend?functionality?of?existing?packages
          [centosplus]
          name
          =CentOS-5?-?Plus
          baseurl
          =http://ftp.sjtu.edu.cn/centos/5/centosplus/$basearch/
          gpgcheck
          =1
          enabled
          =0
          gpgkey
          =http://ftp.sjtu.edu.cn/centos/RPM-GPG-KEY-CentOS-5

          #contrib?-?packages?by?Centos?Users
          [contrib]
          name
          =CentOS-5?-?Contrib
          baseurl
          =http://ftp.sjtu.edu.cn/centos/5/contrib/$basearch/
          gpgcheck
          =1
          enabled
          =0
          gpgkey
          =http://ftp.sjtu.edu.cn/centos/RPM-GPG-KEY-CentOS-5

          posted @ 2011-05-18 17:36 ideame 閱讀(531) | 評(píng)論 (0)編輯 收藏

          主站蜘蛛池模板: 双牌县| 富裕县| 永州市| 元氏县| 阳谷县| 贞丰县| 棋牌| 福泉市| 德令哈市| 临西县| 筠连县| 屯门区| 固镇县| 宜宾县| 岚皋县| 新竹市| 曲阳县| 岢岚县| 伊金霍洛旗| 孝感市| 遂川县| 江北区| 大埔县| 莱州市| 奉化市| 高碑店市| 闵行区| 都安| 荣昌县| 长垣县| 扎兰屯市| 鄂伦春自治旗| 泗阳县| 晋宁县| 晋江市| 县级市| 乌拉特后旗| 蕲春县| 措美县| 陈巴尔虎旗| 凤山县|