优化LNMP架构采用“Website Baker”为小型公司创建高性能网站方案
?
Intel嵌入式設計開發者秘笈(精品)[上海央邦]學一送一,超值!
必讀版《十一攻破RHCE6.0、OCP》安博亞威】CCIE考試通過率第一!
Cisco網絡技術系列講座
試聽一個月,高端IT技術,五大項目3年經驗 中國IT實驗室收集整理 佚名 2011-11-24 9:07:51 保存本文 推薦給好友 收藏本頁 歡迎進入Linux社區論壇,與200萬技術人員互動交流? >>進入
??? 優化LNMP架構采用“Website Baker”為小型公司創建高性能網站方案參考圖片1.
??? 一、安裝部署各種軟件:
??? 1.系統環境:
??? 硬件:HP 360G4/2G
??? System:Centos 5.4
??? Web:nginx-1.1.6.tar.gz
??? FastCGI:php-5.3.8.tar.gz
??? DB:mysql-5.5.3-m3.tar.gz
??? 2. 安裝編譯環境
??? #yum -y install gcc gcc-c++ autoconf automake openssl-devel zlib-devel pcre-devel?? //pcre讓nginx支持正則
??? #yum -yt groupinstall "Developement Tools" "Development Libraries" 1.編譯安裝mysql
??? //a.編譯安裝mysql的優點:源碼包的默認編譯參數默認以dubgu模式)給mysql的性能帶來很大的損失,
??? // 此處使用 --without-debug參數禁用debug模式
??? //b.以靜態方式編譯(比動態方式提高5%-10%的性能)
??? // 此處使用 --with-mysqld-ldflgs=--all-staic 和 --with-client-ldflds=--all-staic參數
??? //c.使用unix套接字鏈接提高7.5%性能
??? // 此處使用--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
??? //d.允許使用匯編模式
??? // 此處使用 --enable-assembler? (優化性能)
??? //e.至于 --pgcc 目前沒有在生產上使用過(據說可以提高1%)
??? //f.編譯安裝,可以在同一臺服務器上安裝多個mysql(前提要保證存放位置、sock不同)
??? #groupadd mysql???????????????????????????? //為mysql創建用戶組
??? #useradd -g mysql mysql???????????????????? //將mysql用戶添加到mysql組中
??? #tar zxvf mysql-5.5.3-m3.tar.gz
??? #cd mysql-5.5.3-m3
??? ./configure \
??? --prefix=/usr/local/mysql \
??? --without-debug \?????????????????????????? //取消debug模式編譯
??? --enable-assembler \
??? --with-mysqld-ldflags=-all-static \
??? --with-client-ldflags=-all-static \
??? --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \
??? --with-extra-charsets=utf8,gbk //如果沒有問題則會顯示
??? // Thank you for choosing MySQL!
??? // 以下時間將為很長,請為mysql創建配置文件或數據目錄
??? #make && make install?????????????????????????? //如果編譯安裝沒有問題則NEXT
??? #chmod 755 /usr/local/mysql
??? #chown -R mysql:mysql /usr/local/mysql????????? //修改安裝目錄的用戶和用戶組為mysql
??? #mkdir -pv /mysql_data/{data,binlog,relaylog}?? //為mysql提供數據存放目錄
??? #/usr/local/mysql/bin/mysql_install_db \??????? //推薦是用其它新分區,避免IO重讀/分區
??? --basedir=/usr/local/mysql \
??? --datadir=/mysql_data --user=mysql
??? ----------------------------------------------
??? //創建并優化my.cnf文件
??? #vi /mysql_data/my.cnf??????????????????????????? //創建后保存
??? [client]
??? character-set-server = utf8
??? port??? = 3306
??? socket? = /usr/local/mysql/tmp/mysql.sock
??? [mysqld]
??? character-set-server = utf8
??? replicate-ignore-db = mysql
??? replicate-ignore-db = test
??? replicate-ignore-db = information_schema
??? user??? = mysql
??? port??? = 3306
??? socket? = /usr/local/mysql/tmp/mysql.sock
??? basedir = /usr/local/mysql
??? datadir = /mysql_data/data
??? log-error = /mysql_data/mysql.error.log
??? pid-file = /mysql_data/mysql.pid
??? skip-locking??????????????????????????????????? //避免mysql外部鎖定
??? open_files_limit = 10240
??? back_log = 384????????????????????????????????? //推薦小于512
??? max_connections = 5000
??? max_connect_errors = 6000
??? table_cache = 614
??? external-locking = FALSE
??? max_allowed_packet = 32M
??? sort_buffer_size = 1M
??? join_buffer_size = 1M
??? thread_cache_size = 300
??? query_cache_size = 512M
??? query_cache_limit = 2M
??? query_cache_min_res_unit = 2k
??? default-storage-engine = MyISAM
??? thread_stack = 192K
??? transaction_isolation = READ-COMMITTED
??? tmp_table_size = 246M
??? max_heap_table_size = 246M
??? long_query_time = 3
??? log-slave-updates
??? log-bin = /mysql_data/binlog/binlog
??? binlog_cache_size = 4M
??? binlog_format = MIXED
??? max_binlog_cache_size = 8M
??? max_binlog_size = 1G
??? relay-log-index = /mysql_data/relaylog/relaylog
??? relay-log-info-file = /mysql_data/relaylog/relaylog
??? relay-log = /mysql_data/relaylog/relaylog
??? expire_logs_days = 30
??? key_buffer_size = 256M??????????? //索引緩沖區為256M 或(4G內存可512M)
??? read_buffer_size = 1M
??? read_rnd_buffer_size = 16M
??? bulk_insert_buffer_size = 64M
??? myisam_sort_buffer_size = 128M
??? myisam_max_sort_file_size = 10G
??? myisam_repair_threads = 1
??? myisam_recover interactive_timeout = 120
??? wait_timeout = 120
??? skip-name-resolve??????????????? //避免做DNS 解析,提供IP地址連接 slave-skip-errors = 1032,1062,126,1114,1146,1048,1396
總結
以上是生活随笔為你收集整理的优化LNMP架构采用“Website Baker”为小型公司创建高性能网站方案的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: IOT Core-设备接入网关
- 下一篇: 【财经期刊FM-Radio|2020年1