042.CentOS装Tengine和Percona
Ucloud(CentOS6.5)安装Tengine2.1.0和Percona5.6,
过程比较简单,重点是mysql的配置文件。
@史荣久 / 2015-06-10 / CC-BY-SA-3.0
系统环境 Ucloud
$ uname -a
Linux 10-4-18-185 2.6.32-431.11.7.el6.ucloud.x86_64 #1
SMP Wed Jan 7 23:42:27 CST 2015 x86_64 x86_64 x86_64
GNU/Linux
$ cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m
$ free -m
total used free
Mem: 15887 14094 1792
-/+ buffers/cache: 9148 6738
Swap: 511 0 511
$ cat /proc/cpuinfo | grep 'model name' | cut -f2 -d: | uniq -c
# 4 Intel(R) Xeon(R) CPU E5-2640 0 @ 2.50GHz
8 QEMU Virtual CPU version (cpu64-rhel6)
安装 Tengine2.1.0
# http://tengine.taobao.org
wget http://tengine.taobao.org/download/tengine-2.1.0.tar.gz
tar -xzf tengine-2.1.0.tar.gz
cd tengine-2.1.0/
# requires the PCRE library
yum install -y pcre pcre-devel
# require the OpenSSL library
yum install openssl openssl-devel
#已经安装过了,所有此步骤不需要。
#yum install zlib zlib-devel
./configure
make
sudo make install
# 把以下加入环境变量
cat /etc/profile.d/nginx.sh
export PATH=$PATH:/usr/local/nginx/sbin/
# 查看安装模块
nginx -m
安装 Percona5.6
wget https://www.percona.com/downloads/Percona-Server-5.6/\
Percona-Server-5.6.24-72.2/binary/redhat/6/x86_64/\
Percona-Server-5.6.24-72.2-r8d0f85b-el6-x86_64-bundle.tar
tar -xf Percona-Server-*.tar
# 解包后有很多rpm,只需要安装以下3个即可。
rpm -ivh \
Percona-Server-client-56-5.6.24-rel72.2.el6.x86_64.rpm \
Percona-Server-shared-56-5.6.24-rel72.2.el6.x86_64.rpm \
Percona-Server-server-56-5.6.24-rel72.2.el6.x86_64.rpm
# 标准rpm安装,标准启动和配置,或通过以下命令查看。
# rpm -qa|grep Percona
# rpm -ql Percona-Server-server-56-5.6.24-rel72.2.el6.x86_64
service mysql start
/usr/bin/mysqladmin -u root password 'www.moilioncircle.com'
# 查看启动情况
chkconfig --list mysql
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
# 把数据库,装到200g的磁盘上
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 20G 2.2G 17G 12% /
tmpfs 7.8G 0 7.8G 0% /dev/shm
/dev/vdb 197G 188M 187G 1% /data
# 移动数据库和改权限
service mysql stop
mkdir -p /data/mysql/{tmp,log}
chown mysql.mysql -R /data/mysql
mv /var/lib/mysql /data/mysql/data
#配置文件在这里
cat /etc/my.cnf
看懂就牛了
[mysqld]
############ 创建function+view ############
log_bin_trust_function_creators=1
############ performance_schema ############
#performance_schema
############ common parameter ############
# 默认innodb存储引擎, 默认utf8字符集,默认不忽略大小写
default-storage-engine = INNODB
character-set-server=utf8
collation = utf8_bin
sql_mode="STRICT_TRANS_TABLES"
#old:loose_character_set_server = utf8
#### Baes dir ####
#basedir = /opt/mysql
datadir = /data/mysql/data
tmpdir = /data/mysql/tmp
#socket = /opt/mysql/run/mysql.sock
#### Base configure info ####
#default-character-set = gbk
port = 3306
#skip-locking
skip-name-resolve
old_passwords = 0
lower_case_table_names = 1
open_files_limit = 135582
read_rnd_buffer_size = 5M
max_allowed_packet = 12M
max_connect_errors = 65536
max_connections = 1500
max_user_connections = 450
thread_cache_size=256
table_definition_cache=65536
thread_stack=262144
wait_timeout=864000
table_open_cache=2000
#table_open_cache=65536
# 避免再次回表获得数据,使用优化过的排序算法
max_length_for_sort_data = 16k
#### Log info ####
log-error = /data/mysql/log/alert.log
#log_slow_queries = /data/mysql/log/slow.log
slow_query_log=1
slow_query_log_file= /data/mysql/log/slow.log
log-slow-admin-statements
#log-queries-not-using-indexes
long_query_time = 0.001
slow_launch_time=1
#### Binary log && Relay log ####
binlog_format='MIXED'
log-bin = /data/mysql/log/mysql-bin
log-slave-updates = 1
relay-log = /data/mysql/log/mysqld-relay-bin
relay-log-index = /data/mysql/log/mysqld-relay-bin.index
master-info-file = /data/mysql/log/master.info
relay-log-info-file = /data/mysql/log/relay-log.info
#expire_logs_days=1
max_binlog_size = 500M
max_binlog_cache_size = 1000M
sync_binlog=1000
####slow log输出格式
log_slow_verbosity='innodb'
# 取消query_cache
query_cache_type = 0
query_cache_size = 0
############ per thread memory ############
thread_stack = 512k
net_buffer_length = 8K
sort_buffer_size = 2M
join_buffer_size = 4M
read_buffer_size = 2M
read_rnd_buffer_size = 512k
# 最大内存临时表大小
tmp_table_size = 8M
binlog_cache_size = 2M
#myisam
concurrent_insert = 2
key_buffer = 50M
myisam_sort_buffer_size = 50M
#innodb plugin
#innodb
default-storage-engine = INNODB
innodb_flush_method = O_DIRECT
innodb_file_per_table = 1
innodb_open_files=60000
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 100
innodb_buffer_pool_size = 1G
innodb_log_buffer_size= 100M
innodb_log_file_size = 100M
innodb_log_files_in_group = 4
innodb_file_io_threads = 4
innodb_thread_concurrency = 32
innodb_max_dirty_pages_pct = 50
transaction-isolation = READ-COMMITTED
innodb_data_file_path = ibdata1:12M:autoextend
innodb_io_capacity=1000
innodb_read_io_threads=8
innodb_write_io_threads=8
innodb_buffer_pool_instances=4
innodb_thread_concurrency=32
# 在innodb lru list 先呆一秒再放到lru头
innodb_old_blocks_time=1000
# 取消二阶段事务
innodb_support_xa = OFF
### Server id ####
log_bin_trust_function_creators=1
read_only=0
server_id=239
题图:Percona为MySQL数据库服务器进行了改进,在功能和性能上较MySQL有着很显著的提升。