Skip to main content

米斯特周

Tag: Mysql

MYSQL在1G VPS上的性能优化配置

今天不小心把数据给删除了,好在有备份,唉,烦死了。然后,各种装,装好后,在优化数据库这块,看到螃蟹氪的这篇优化笔记1,顺手拿来用了,目前感觉好使。 [mysql] # CLIENT # port = 3306 socket = /var/lib/mysql/mysql.sock [mysqld] # GENERAL # user = mysql default-storage-engine = InnoDB socket = /var/lib/mysql/mysql.sock pid-file = /var/lib/mysql/mysql.pid # MyISAM # key-buffer-size = 32M myisam-recover = FORCE,BACKUP # SAFETY # max-allowed-packet = 16M max-connect-errors = 1000000 skip-name-resolve innodb = FORCE # DATA STORAGE # datadir = /var/lib/mysql/ # CACHES AND LIMITS # tmp-table-size = 32M max-heap-table-size = 32M query-cache-type = 0 query-cache-size = 0 max-connections = 500 thread-cache-size = 50 open-files-limit = 65535 table-definition-cache = 1024 table-open-cache = 2048 # INNODB # innodb-flush-method = O_DIRECT innodb-log-files-in-group = 2 innodb-log-file-size = 64M innodb-flush-log-at-trx-commit = 1 innodb-file-per-table = 1 innodb-buffer-pool-size = 512M # LOGGING # log-error = /var/lib/mysql/mysql-error.

TCMalloc

TCMalloc (google-perftools) 是用于优化C++写的多线程应用,比glibc 2.3的malloc快。这个模块可以用来让MySQL在高并发下内存占用更加稳定。

安装步骤:

The glibc built-in stack-unwinder on 64-bit systems has some problems with the perftools libraries. (In particular, the cpu/heap profiler may be in the middle of malloc, holding some malloc-related locks when they invoke the stack unwinder. The built-in stack unwinder may call malloc recursively, which may require the thread to acquire a lock it already holds: deadlock.)

For that reason, if you use a 64-bit system, we strongly recommend you install libunwind before trying to configure or install gperftools. libunwind can be found at here

Even if you already have libunwind installed, you should check the version. Versions older than this will not work properly; too-new versions introduce new code that does not work well with perftools (because libunwind can call malloc, which will lead to deadlock).

在CentOS 6.2上安装Nginx+PHP5(PHP-FPM)+MySQL

## 1.使用非官方软件源

[root@localhost /]# rpm --import https://fedoraproject.org/static/0608B895.txt
[root@localhost /]# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
[root@localhost /]# rpm –import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
[root@localhost /]# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
[root@localhost /]# yum install yum-priorities

编辑/etc/yum.repos.d/epel.repo文件,启用这个源,使其优先级最高

[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1 p
riority=10
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
[...]

Ubuntu 9.04 Nginx+php+mysql

由于Ubuntu 9.04已经包含了nginx,所以根本不要编译,安装超简单!

修改/etc/apt/sources.list文件内容为国内镜像,然后运行:

apt-get update apt-get install nginx

即可完成安装。启动nginx:

/etc/init.d/nginx start

然后就可以访问http://localhost/了,一切正常!如果不能访问,先不要继续,看看是什么原因,解决之后再继续。

Virtual Hosting With Proftpd And MySQL (Incl. Quota) On Ubuntu 9.10

This document describes how to install a Proftpd server that uses virtual users from a MySQL database instead of real system users. This is much more performant and allows to have thousands of ftp users on a single machine. In addition to that I will show the use of quota with this setup.

For the administration of the MySQL database you can use web based tools like phpMyAdmin which will also be installed in this howto. phpMyAdmin is a comfortable graphical interface which means you do not have to mess around with the command line.

This tutorial is based on Ubuntu 9.10. You should already have set up a basic Ubuntu 9.10 server system.

This howto is meant as a practical guide; it does not cover the theoretical backgrounds. They are treated in a lot of other documents in the web.

This document comes without warranty of any kind! I want to say that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!

Ubuntu Pure-FTPd服务安装配置+虚拟用户

Pure-FTPd FTP server:

Pure-FTPd is a fast, production-quality, standards-conformant FTP server based upon Troll-FTPd. Features include chrooted home directories, virtual domains, built-in ‘ls’, anti-warez system, configurable ports for passive downloads, FXP protocol, bandwidth throttling, ratios, fortune files, Apache-like log files, fast standalone mode, atomic uploads, text / HTML / XML real-time status report, virtual users, virtual quotas, privilege separation, SSL/TLS and more.

## 一、安装Pure-FTPd

$ sudo apt-get install pure-ftpd
$ sudo apt-get install pure-ftpd-mysql