顯示具有 ubuntu 標籤的文章。 顯示所有文章
顯示具有 ubuntu 標籤的文章。 顯示所有文章

2016年6月2日 星期四

使用sysbench 對MySQL進行壓力測試



安裝


https://launchpad.net/sysbench
trunk的版本是 0.4

虛擬機為ubuntu 14.04,檢查apt-get可以安裝的sysbench版本
# apt-cache madison sysbench
  sysbench | 0.4.12-1.1 | http://tw.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
或由 http://tw.archive.ubuntu.com/ubuntu/pool/universe/s/sysbench/ 得知我設的倉庫只提供到sysbench 0.4.12
Universe - Community-maintained, i.e. not officially supported software.
universe是社群維護的套件. 如:非官方支援的軟體
註:CentOS 7 用yum裝的可以直接裝0.5
# yum info sysbench
...
Version     : 0.5

在網上的一些範例中,sysbench的 --test會設為 /usr/share/doc/sysbench/tests/db/select.lua ,但是我的  /usr/share/doc/sysbench/ 下沒有tests/db/select.lua
原因,我用apt-get安裝了 0.4.12版,在 github上
https://github.com/akopytov/sysbench/tree/0.4/sysbench/tests
0.4版本沒有db 資料夾
https://github.com/akopytov/sysbench/tree/0.5/sysbench/tests/db
0.5版本有db資料夾


安裝 0.4.12 版
# apt-get install sysbench
移除 0.4.12 版
# aptitude purge sysbench

安裝 0.5版

# cd ~
# git clone https://github.com/akopytov/sysbench.git
# cd sysbench/
這時候如果想直接安裝,通常會失敗
# ./autogen.sh
automake 1.10.x (aclocal) wasn't found, exiting
1. 先安裝一些相依套件
# apt-get install -y gcc autoconf automake make libtool libssl-dev libcrypto++9

2. 安裝mysql_config(在 Percona repository 中可用)

安裝 Percona apt repository

# wget https://repo.percona.com/apt/percona-release_0.1-3.$(lsb_release -sc)_all.deb
安裝percona庫
# dpkg -i percona-release_0.1-3.$(lsb_release -sc)_all.deb
檢查 /etc/apt/sources.list.d/percona-release.list ,有多這隻檔案代表安裝成功
記得更新本地緩存
# apt-get update

最後安裝mysql_config
# apt-get install -y libperconaserverclient18-dev
3. 編譯和安裝sysbench
# ./autogen.sh
# ./configure
# make
安裝
# make install
4. 產生LUA資料夾(當初就是因為0.4版本沒有這個,直接拿0.5的LUA跑0.4的sysbench怕有問題,才手動編譯安裝)
# mkdir /usr/share/sysbench/tests/db -p
# cp sysbench/tests/db/* /usr/share/sysbench/tests/db
5. 檢查sysbench 0.5是否安裝成功
# sysbench --version
sysbench 0.5
移除sysbench
先看  Makefile 怎麼寫的,有看到 uninstall: uninstall-recursive ,所以嘗試移除sysbench
# make uninstall
檢查... 移除成功
# sysbench --version
-su: /usr/local/bin/sysbench: No such file or directory

 vim /usr/local/bin/sysbench 是二進位檔,應該是c寫的,或用 file  /usr/local/bin/sysbench去看,有些會告訴你那是什麼檔案。ex. python, shell... etc.

Benchmark

測試的benchmark是:你每次調試my.cnf後,重啟mysql,然後用sysbench測,看qps


參考資料:
http://askubuntu.com/questions/447/how-can-i-see-all-versions-of-a-package-that-are-available-in-the-archive  How can I see all versions of a package that are available in the archive?
http://blog.secaserver.com/2014/07/sysbench-0-5-ubuntu-14-04-trusty-percona-server-xtradb-cluster/  SYSBENCH 0.5 + UBUNTU 14.04 (TRUSTY) + PERCONA SERVER OR XTRADB CLUSTER
https://www.percona.com/doc/percona-server/5.5/installation/apt_repo.html  Installing Percona Server on Debian and Ubuntu
Rellik



2015年12月15日 星期二

VirtualBox 虛擬機跑MySQL

寫下我最近用VirtualBox跑測試環境過慢的問題

虛擬機
ubuntu 14.04
mysql  Ver 14.14 Distrib 5.5.41, for debian-linux-gnu (x86_64) using readline 6.3

問題一
靜態網頁phpinfo()跑很慢
因為我的虛擬機測試環境已經很髒了,之前在這篇 haproxy使用心得 設定了load balance,所以
先用telnet xxx 80 查連不連得到 => 連不到
用kill把nginx進程(process)全殺了
# killall nginx
再重啟
# /etc/init.d/nginx start
robert:可能是進程被咬死,用service nginx restart 是起不了作用的

問題二
開有連虛擬機上資料庫的網頁非常慢,但設定改為連其他機器時,速度正常
在mysql用show processlist檢查後發現
mysql> show processlist;
...
| 10 | unauthenticated user | 192.168.169.147:51391 | NULL | Connect | NULL | login          | NULL

這個連線在卡
解法:
http://stackoverflow.com/questions/8034706/access-mysql-server-on-linux-throu-virtualbox-windows7-laggs
在 /etc/mysql/my.cnf 的 [mysqld] 中新增
skip-name-resolve

然後重啟mysql
# service mysql restart

問題三
phpmyadmin 編輯欄位速度過慢
mysql> show processlist;
...
| 19 | root | 192.168.169.140:51359 | progmate_test | Query   |   39 | NULL  | SELECT `column_name`, `table_name`, `table_schema`, `referenced_column_name` FROM `information_schem |
卡在SELECT information_schema這個表

簡單的測試
https://www.percona.com/blog/2011/12/23/solving-information_schema-slowness/  Solving INFORMATION_SCHEMA slowness
mysql> select count(*),sum(data_length) from information_schema.tables;
+----------+------------------+
| count(*) | sum(data_length) |
+----------+------------------+
|      769 |       5880654489 |
+----------+------------------+
1 row in set (24.77 sec)

mysql> set global innodb_stats_on_metadata=0;
Query OK, 0 rows affected (0.00 sec)

mysql> select count(*),sum(data_length) from information_schema.tables;
+----------+------------------+
| count(*) | sum(data_length) |
+----------+------------------+
|      769 |       5880654489 |
+----------+------------------+
1 row in set (0.07 sec)

解法:
http://stackoverflow.com/questions/7283915/poor-performance-of-information-schema-key-column-usage-in-mysql  Poor performance of INFORMATION_SCHEMA.key_column_usage in MySQL
在 /etc/mysql/my.cnf 的 [mysqld] 中新增
innodb_stats_on_metadata=0

然後重啟mysql
# service mysql restart

什麼是innodb_stats_on_metadata?
https://www.percona.com/blog/2013/12/03/innodb_stats_on_metadata-slow-queries-information_schema/  innodb_stats_on_metadata and slow queries on INFORMATION_SCHEMA
When the option is set to ON, InnoDB index statistics are updated when running SHOW TABLE STATUS, SHOW INDEX or when querying INFORMATION_SCHEMA.TABLES or INFORMATION_SCHEMA.STATISTICS. These statistics include the cardinality and the number of entries, they are used by the optimizer to find an optimal execution plan.
當這個選項被設置為ON時。當執行 SHOW TABLE STATUS、SHOW INDEX、操作INFORMATION_SCHEMA.TABLES或INFORMATION_SCHEMA.STATISTICS表時, InnoDB的索引統計正被更新。這個統計包括基數( cardinality ) 和 entry數,他們用於優化找到一個最佳的執行計畫
So even if SELECT statements cannot change the real statistics, MySQL updates the statistics for InnoDB tables. This is counterintuitive.
因此,如果SELECT語句不能改變真正的統計(MySQL更新InnoDB表的統計)。這是違反直覺的。
Is it useful? Not really, because InnoDB will always compute statistics when you open a table for the first time and when significant portions of the table have been modified (and when you run ANALYZE TABLE).
它有用嗎?不是,因為InnoDB總是計算統計當你第一次打開一個表和當一個表顯著的部分被修改了(和當你運行ANALYZE TABLE)
The problem was magnified in the example because the whole dataset was not fitting in memory, the number of tables was high and the I/O subsystem was not very powerful.
該問題是被放大的例子,因為整個dataset未嵌合在記憶體中,表的數量很大而子系統的I/O不夠強

值得提出來的是,這個值在 MySQL 5.6 內的 InnoDB 預設是關閉的,在 5.1 與 5.5 則是開啟的。

參考資料:
http://sourceforge.net/p/phpmyadmin/bugs/4592/  #4592 (ok 4.4) Editing columns (tbl_structure.php) is incredibly slow
https://blog.gslin.org/archives/2013/12/09/3918/innodb_stats_on_metadata-%E5%B0%8D%E6%95%88%E8%83%BD%E7%9A%84%E5%BD%B1%E9%9F%BF/  innodb_stats_on_metadata 對效能的影響...








2015年9月2日 星期三

haproxy使用心得

系統:ubuntu14.04

安裝:
$ sudo apt-get install haproxy

檢查haproxy版本
$ haproxy -v

檢查haproxy設定檔 ( /etc/haproxy/haproxy.cfg )
$ haproxy -V -c -f haproxy.cfg

設定:
1. 編輯 /etc/default/haproxy ,將 ENABLED=0 改為 1
ENABLED=0 => ENABLED=1

2. 避免 [ALERT] 243/175711 (2715) : Starting proxy http_proxy: cannot bind socket 錯誤
# sysctl -e net.ipv4.ip_nonlocal_bind=1

3. 解決 [ALERT] 243/175711 (2715) : Starting proxy http_proxy: cannot bind socket 錯誤
原來是nginx把 80 port 佔用了,要把nginx 換成其他port
把 /etc/nginx/sites-available 中vhost設定檔中server{}中的 listen 換成其他port
ex.
listen 80; => listen 81;
listen [::]:80; => listen [::]:81;
然後重啟nginx

4. 編輯haproxy.cfg (因為我的haproxy版本是1.4,所以照 http://cbonte.github.io/haproxy-dconv/configuration-1.4.html#2.3 上面改的)
global
    daemon
    maxconn 256

defaults
    mode http
    timeout connect 5000ms
    timeout client 50000ms
    timeout server 50000ms

frontend http-in
    bind *:80
    default_backend servers2

frontend http-in2
    bind *:88
    default_backend servers

backend servers
    server server1 192.168.1.140:80 maxconn 32
backend servers2
    server server2 192.168.1.147:81 maxconn 32

架構
我的VM( 192.168.1.147 ):
haproxy 80
nginx  81

我電腦(win 7, 192.168.1.140):
apache 80

結果
http://192.168.1.147:88/ 開windows apache 80 程式
http://192.168.1.147/ 開VM nginx 81 程式

http://192.168.1.147:81/ 開VM nginx 81 程式

註:
如果只設一組 frontend 兩組backend
frontend http-in
    bind *:80
    default_backend servers

backend servers
    server server1 192.168.1.140:80 maxconn 32
    server server2 192.168.1.147:81 maxconn 32
這樣打開 http://192.168.1.147 在firefox用 ctrl+f5 刷頁,會在 192.168.1.140:80 和 192.168.1.147:81 兩台主機切換



參考資料:
http://blog.longwin.com.tw/2009/03/haproxy-ha-load-balance-2009/  使用 HAProxy 完成 網站分流, 平衡負載
http://cbonte.github.io/haproxy-dconv/configuration-1.4.html#2.3  HAProxy Configuration Manual ( 1.4 example )



2015年9月1日 星期二

nginx vhost配置

系統:ubuntu 14.04

1. 建立資料夾
# mkdir /var/www/html/test.vm  # 程式資料夾
# mkdir /var/www/html/test.vm/logs # log資料夾

# chmod 755 -R /var/www/html/test.vm
# chown www-data:www-data -R /var/www/html/test.vm  # 我沒做,依然用bear:bear

2. 建立設定檔
# touch /etc/nginx/sites-available/test.vm
編輯設定檔test.vm內容:
server {
    listen 80;
    listen [::]:80;

    root /var/www/html/test.vm;  # 設定你程式的路徑
    index index.html index.htm; 

    server_name test.vm; # 虛擬主機的完整名稱

    location / {
        try_files $uri $uri/ =404;
    }

    access_log /var/www/html/test.vm/logs/access.log; # access_log 的位置
    error_log /var/www/html/test.vm/logs/error.log;
}

3. 啟用虛擬主機
nginx沒有像Apache 有a2ensite的指令來啟用虛擬主機,所以要用ln 去做
# ln -s /etc/nginx/sites-available/test.vm /etc/nginx/sites-enabled/test.vm

4. 重新啟動nginx
# service nginx restart

5. php頁面打不開(連結變成下載php檔案)
在你的test.vm加入下面這一段
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_index  index.php;
        include        fastcgi_params;
}

完整的test.vm檔:
server {
    listen 80;
    listen [::]:80;

    root /var/www/html/test.vm;
    index index.html index.htm;

    server_name test.vm;

    location / {
        try_files $uri $uri/ =404;
    }
    location ~ .php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_index  index.php;
        include        fastcgi_params;
    }

    access_log /var/www/html/test.vm/logs/access.log;
    error_log /var/www/html/test.vm/logs/error.log;

}

5.2 Nginx $document_root$fastcgi_script_name 與 $request_filename 的區別
http://serverfault.com/questions/465607/nginx-document-rootfastcgi-script-name-vs-request-filename  Nginx $document_root$fastcgi_script_name vs $request_filename
http://serverfault.com/questions/502776/what-is-the-correct-setting-of-nginxs-fastcgi-param-script-filename  What is the correct setting of Nginx's fastcgi_param SCRIPT_FILENAME?
$request_filename
This variable is equal to path to the file for the current request, formed from directives root or alias and URI request;
這個變數等於當前請求檔案的路徑,從指向的根或alias和URI請求所形成
$document_root
This variable is equal to the value of directive root for the current request;
這個變數等於當前請求的指向的根
$fastcgi_script_name
This variable is equal to the URI request or, if if the URI concludes with a forward slash, then the URI request plus the name of the index file given by fastcgi_index. It is possible to use this variable in place of both SCRIPT_FILENAME and PATH_TRANSLATED, utilized, in particular, for determining the name of the script in PHP.
這個變數等於URI請求,如果URI的結尾是斜線( ex. http:xxx/xx/ ),則該URI請求會加上fastcgi_index所設的索引名字。
$request_filename is just a nicer way of writing it.
$request_filename 只是更好的寫法

6.1 將入口檔改為a.do( 其內容一樣是php )
index 新增 a.do
index index.html index.htm a.do;
在 location / {} 中加入這段
location ~ .*\.(do|php)?$ {
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_param  SCRIPT_FILENAME  /your_a.do_path/$fastcgi_script_name;
    include        fastcgi_params;
}

6.1.1 (AWS nginx編譯安裝)出現錯誤:
2016/xx/xx XX:XX:XX [error] 8866#0: *41 open() "/root/project/test.html" failed (13: Permission denied), client: x.x.x.x, server: user.domain.net, request: "GET /test.html HTTP/1.1", host: "user.domain.net"
原因,nginx編譯安裝只能把程式放在 安裝的路徑下 /usr/local/webserver/nginx/html/ 

6.1.2 出現錯誤:
2016/xx/xx XX:XX:XX [error] 8924#0: *42 FastCGI sent in stderr: "Access to the script '/usr/local/webserver/nginx/html/project/a.do' has been denied (see security.limit_extensions)" while reading response header from upstream, client: 1
6.1.2.2 出現錯誤:(CentOS 7)
頁面顯示 Access Denied.
access log 有記錄,error log 無記錄,一樣用下面的解法解。security.limit_extensions那行註解記得拿掉
解法:
http://stackoverflow.com/questions/23390531/access-denied-403-for-php-files-with-nginx-php-fpm
php-fpm的 /etc/php-fpm.d/www.conf 的security.limit_extensions新增.do
security.limit_extensions = .php .php3 .php4 .php5 .do

6.2 如果網頁伺服器是Apache2, 使a.do可以視為php網頁訪問
http://stackoverflow.com/questions/3555681/why-are-my-php-files-showing-as-plain-text
在 apache/conf/httpd.conf
修改 <IfModule mime_module> 中的
AddType application/x-httpd-php .php => AddType application/x-httpd-php .php .do

7. 設定url rewrite
在 location / {} 中加入這段
rewrite ^/(.+)-(.+).html$ /a.do?controller=$1&action=$2 last;

7.2 apache2
http://stackoverflow.com/questions/13867543/htaccess-rewrite-shtml-and-html-as-php
在網頁根目錄加入.htaccess,內容為
RewriteEngine On
RewriteRule ^(.+)_(.+)\.shtml$ /a.do?controllers=$1&actions=$2 [L,QSA]

8. 設定alias 資料夾
在 server {} 中加入
location /phpmyadmin {
    alias /var/www/phpmyadmin/$1;
}
這樣 http://your_domain/phpmyadmin 就能直接訪問 /var/www/phpmyadmin/ 的phpmyadmin

9. 設定多個網址指到同一隻程式(同Apache的ServerAlias)
在server {} 中的server_name加入
server_name test.vm m.test.vm; # 虛擬主機的完整名稱

參考資料:
http://www.arthurtoday.com/2010/09/ubuntu-nginx-virtual-host.html Ubuntu 設定 Nginx 虛擬主機 ( Virtual Host )
http://stackoverflow.com/questions/5687938/nginx-trouble-loading-index-file nginx trouble loading index file



2015年8月10日 星期一

解決php5-fpm ( nginx ) "Call to undefined function json_encode" 錯誤

系統:
ubuntu 14.04

用nginx跑php時找不到json_encode()函數報錯:
Call to undefined function json_encode ... 

但使用apache2跑則正常

檢查:
# dpkg --get-selections | grep php5-json
有安裝php5-json

# apt-get install php5-json
Reading package lists... Done
Building dependency tree
Reading state information... Done
php5-json is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
已安裝,所以沒新東西被裝

但是
# php5-fpm -m | grep json
(無結果)

root@ubuntu:/etc/php5/fpm/conf.d# ls -l
total 0
lrwxrwxrwx 1 root root 32 Jul  3 11:11 05-opcache.ini -> ../../mods-available/opcache.ini
lrwxrwxrwx 1 root root 28 Jul  3 11:11 10-pdo.ini -> ../../mods-available/pdo.ini
lrwxrwxrwx 1 root root 29 Jul  3 11:11 20-curl.ini -> ../../mods-available/curl.ini
lrwxrwxrwx 1 root root 27 Jul  3 11:11 20-gd.ini -> ../../mods-available/gd.ini
lrwxrwxrwx 1 root root 31 Jul  3 11:11 20-mcrypt.ini -> ../../mods-available/mcrypt.ini
lrwxrwxrwx 1 root root 31 Jul  3 11:11 20-mysqli.ini -> ../../mods-available/mysqli.ini
lrwxrwxrwx 1 root root 30 Jul  3 11:11 20-mysql.ini -> ../../mods-available/mysql.ini
lrwxrwxrwx 1 root root 34 Jul  3 11:11 20-pdo_mysql.ini -> ../../mods-available/pdo_mysql.ini
lrwxrwxrwx 1 root root 33 Jul  3 11:11 20-readline.ini -> ../../mods-available/readline.ini
原來json.ini不在php5-fpm的設定裡面

把php5-fpm的conf.d備份,然後重建
root@ubuntu:/etc/php5/fpm# mv conf.d/ conf-old.d
root@ubuntu:/etc/php5/fpm# ln -s /etc/php5/mods-available /etc/php5/fpm/conf.d

然後重啟
# service nginx restart
# service php5-fpm restart  // 注意:重啟nginx是無效的,要重啟動php5-fpm

檢查:
# php5-fpm -m | grep json
json

最後打開網頁,json_encode()可以正常使用






2015年7月8日 星期三

ubuntu 安裝docker

系統 ubuntu 14.04

透過系統內建套件安裝
$ sudo apt-get update
$ sudo apt-get install -y docker.io
$ sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker
$ sudo sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker.io

透過Docker 套件庫安裝最新版本
$ sudo apt-get install apt-transport-https
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
$ sudo bash -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
$ sudo apt-get update
$ sudo apt-get install -y lxc-docker

快速安裝法(建議使用)
$ curl -sSL https://get.docker.com/ubuntu/ | sudo sh

ps. 我是使用上面比較麻煩的方法安裝的

參考資料:
http://philipzheng.gitbooks.io/docker_practice/content/install/ubuntu.html

2015年3月24日 星期二

阿里雲和網站備案實戰

在中國只要開80 port就需要備案,以下以企業網站備案為實例

買網址
http://www.net.cn/ 萬網
在首頁可以搜尋網址,用支付寶(淘寶)登錄,然後用支付寶付費
买域名时需要填的资料:
域名所有者单位名称:*
域名管理联系人:*
所属区域:*
通讯地址:*
邮编:*
联系电话:*
手机:*
电子邮箱:*
企业管理人:
所属行业:
之後要填《网站备案信息真实性核验单》(需負責人簽名蓋公章)


設定網址聯繫人,以便即時提醒通知(如網址快過期了)
登錄 http://www.net.cn/ 萬網後
上方 "产品管理/续费" => 我的域名 => 在你買的網址後面點"管理" => 進入"域名控制台"頁面
裡面有"基本信息"、"域名信息修改"、"域名所有者实名认证" 、"域名证书打印(備案時需要打印出來寄送)" ...等,可以修改聯繫信箱電話、查詢網址实名认证结果

網址綁定IP
在 "域名控制台" 中 點上方的"域名解析" 裡面可以"設置解析"

買虛擬主機
http://www.net.cn/hosting/basic/
基础版
网页空间: 2G
单月流量: 20GB
并发连接数: 150个
价格:288元/年

進入虛擬主機管理控制台
登錄 http://www.net.cn/ 萬網後
上方 "产品管理/续费" => "我的主机" =>  在你買的主機後面點"管理"( 在這個列表頁可以看到我們買的虛擬主機IP ) => 進入"主機管理控制台"頁面
站点信息 => 基础环境设置 => 域名绑定 - 可以綁定網址,但基本上還是要在你"域名控制台"上設定才對
站点信息 => 高级环境设置 => PHP版本设置 - 可以把PHP設成4, 5.2, 5.3,但要"停止站点"後重啟才會生效
站点信息 => 高级环境设置 => PHP.ini设置 - 可以弱弱的設定一點點PHP設定,
数据库管理 => 管理 - 進入phpmyadmin( 版本有點舊 )管理你虛擬主機的資料庫

發票索取
http://help.www.net.cn/knowledge_detail.htm?knowledgeId=5867323

缺點:
無法ssh,不能修改php.ini設定,云虚拟主机仅支持1个站点。

因為Joomla 3 在PHP5.3以下php.ini需要關閉 magic_quotes_gpc這設定,但虛擬主機沒辦法設定,所以買了阿里雲ECS

買阿里雲ECS (類似Linode的VPS,可以ssh)
進入阿里雲網頁 http://www.aliyun.com/ ,可用淘寶(支付寶)帳號登錄
产品 => 弹性计算 => 云服务器ECS http://www.aliyun.com/product/ecs/ 這邊有介紹阿里 雲ECS => 點"立即购买"後可以配置你要買的ECS
我選
包年包月 ( 買10個月送兩個月 ) 的青島主機
CPU: 1核 内存: 1GB 数据盘: 0G 带宽: 1Mbps(不限流量)
"镜像类型"選"市场镜像"然後可以選人家配置好的主機環境(有點類似docker的image)
並在此步驟設定ssh時root的密碼
以下是我選的鏡像:
PHP运行环境(Ubuntu 64位 | PHP5.4 | Apache)
Ubuntu12.04 64位 来源:上海驻云信息科技有限公司
集成软件:PHP5.4.27、Apache2.4.9、MySQL5.5.37 ... etc

進入阿里雲ECS後台
進入阿里雲網頁 http://www.aliyun.com/ => "管理控制台" => 已开通的产品与服务: "云服务器ECS" => "实例" (列表中可以看到你買的ECS的IP,啟動後可以ssh登錄) => "管理"
可以用網頁的ssh ,只是要設網頁的登錄密碼,而且不好用,還是建議用putty連線
停機後可以更改作業系統,如CentOS改Ubuntu (資料會不見)

新增雲主機聯繫人
会员中心 => 会员信息 => 联系人管理

找查阿里雲ECS的MySQL密碼(以我上面選的市場鏡像為例)
重設密碼
$ bash /alidata/init/initPasswd.sh # 重設mysql和ftp密碼
MySQL和FTP密碼放在
/alidata/account.log

備案
http://beian.aliyun.com/ 備案流程圖
1. 登录备案系统 - 
https://beian.gein.cn 阿里雲ICP 代備案管理系統
這邊帳號和淘寶是分開的,需重新申請,
注意:這邊必須寫業主的資料,如手機、email..等。如果將來要改資料,還要重新跑一次備案流程。如檢核點拍照、重新郵寄資料...
2. 填写备案信息 - 
企业备案请提前准备好企业证件及负责人证件扫描件或照片,例如营业执照、组织机构代码证等
3. 提交初审 - 
阿里云审核时长为1个工作日结果将以短信和邮件形式通知
4. 邮寄资料和办理拍照 - 
http://help.aliyun.com/knowledge_detail.htm?knowledgeId=5974581 办理拍照流程说明
邮寄资料 - 
a. 网站备案信息真实性核验单 请打印3份,按照样例分别填写并全部邮寄(前面签名盖公章的那份) - 必須打印三份後分別簽名蓋章,不能簽名蓋章後打印三份,否則會被退
b. 域名证书 - 在"域名控制台" 中打印出來一份
c. 邮寄地址 - 略,備案網頁流程上會跟你說
办理拍照 - 前往拍照核验点免费办理拍照
a. 请 網站負責人 本人携带 身份证原件 和 记录备案订单号(你將會知道) 前往核验点(你將會知道)
5. 等待管局审核 - 大概要等兩個禮拜(實測約16天)
6. 备案成功


參考資料:
http://beian.aliyun.com/ 備案流程
http://www.net.cn/ 萬網,阿里雲的,買網址、租虛擬主機
https://beian.gein.cn 阿里雲ICP 代備案管理系統
http://cp.hichina.com/ 萬網 - (虛擬主機)主机管理控制台
http://www.aliyun.com/ 阿里雲 - 租雲服務器ECS ( 可ssh )

2015年2月15日 星期日

ubuntu 安裝 php-pear

環境:docker ubuntu 14.04

# apt-get install libssl-doc libssl-dev php-pear php5-dev
報錯:
...
The following packages have unmet dependencies:
 libssl-dev : Depends: libssl1.0.0 (= 1.0.1f-1ubuntu2) but 1.0.1f-1ubuntu2.4 is to be installed
E: Unable to correct problems, you have held broken packages.

解法:
移除libssl1.0.0 重裝( apt-get upgrade 無效 )
# dpkg --purge --force-all libssl1.0.0
# apt-get install -f libssl1.0.0



2015年1月29日 星期四

apt-get 安裝出現 fork failed: Cannot allocate memory錯誤

在安裝git-ftp時出現下面這個錯誤

# apt-get -f install git-ftp
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  git-ftp
0 upgraded, 1 newly installed, 0 to remove and 42 not upgraded.
Need to get 0 B/14.6 kB of archives.
After this operation, 77.8 kB of additional disk space will be used.
dpkg: unrecoverable fatal error, aborting:
 fork failed: Cannot allocate memory
E: Sub-process /usr/bin/dpkg returned an error code (2)

原因:
用 free -m 或 top 看,發現所剩的記憶體太少了

解法:
把apache或gitlab關掉 再裝
# service apache2 stop
or
# gitlab-ctl stop

# apt-get -f install git-ftp
... 安裝成功