percona,源码编译安装Percona Server 5.5

Percona Server(http://www.percona.com/)是MySQL的衍生版,其对MySQL进行了改进,在功能、性能和稳定性上有着显著的提高。下面介绍一下如何用源码自行编译安装目前最新版本的Percona Server 5.5。
服务器系统版本为Centos 6。
从地址http://www.percona.com/redir/downloads/Percona-Server-5.5/Percona-Server-5.5.15-21.0/source/Percona-Server-5.5.15-rel21.0.tar.gz 下载最新源码包,并拷贝到/home/software/percona下。在控制台执行以下命令:
# cd /home/software/percona
# tar zxvf Percona-Server-5.5.15-rel21.0.tar.gz
# cd Percona-Server-5.5.15-rel21.0
# CC=gcc CFLAGS="-DBIG_JOINS=1 -DHAVE_DLOPEN=1 -O3" CXX=g++ CXXFLAGS="-DBIG_JOINS=1 -DHAVE_DLOPEN=1 -felide-constructors -fno-rtti -O3"
# cmake . \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DSYSCONFDIR:PATH=/usr/local/mysql \
-DCMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql \
-DENABLED_PROFILING:BOOL=ON \
-DENABLE_DEBUG_SYNC:BOOL=OFF \
-DMYSQL_DATADIR:PATH=/usr/local/mysql/data \
-DMYSQL_MAINTAINER_MODE:BOOL=OFF \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk,gb2312 \
-DWITH_BIG_TABLES:BOOL=ON \
-DWITH_FAST_MUTEXES:BOOL=ON \
-DENABLE-PROFILING:BOOL=ON \
-DWITH_SSL:STRING=bundled \
-DWITH_UNIT_TESTS:BOOL=OFF \
-DWITH_ZLIB:STRING=bundled \
-DWITH_PARTITION_STORAGE_ENGINE:BOOL=ON \
-DWITH_SERVER_SUFFIX=hxsw \
-DWITH_PLUGINS=heap,csv,partition,innodb_plugin,myisam \
-DEFAULT_COLLATION=utf8_general_ci \
-DEFAULT_CHARSET=utf8 \
-DENABLED_ASSEMBLER:BOOL=ON \
-DENABLED_LOCAL_INFILE:BOOL=ON \
-DENABLED_THREAD_SAFE_CLIENT:BOOL=ON \
-DENABLED_EMBEDDED_SERVER:BOOL=OFF \
-DWITH_CLIENT_LDFLAGS:STRING=all-static \
-DINSTALL_LAYOUT:STRING=STANDALONE \
-DCOMMUNITY_BUILD:BOOL=ON;
# make
# make install
修改/etc/my.cnf,如如下内容:
# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /usr/local/mysql/data) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
character_set_server = utf8
connect_timeout = 20
basedir = /usr/local/mysql/
datadir = /usr/local/mysql/data
user = mysql
port = 3306
socket = /tmp/mysql.sock
pid-file = /usr/local/mysql/data/mysql.pid
back_log = 500
event_scheduler = OFF
expire_logs_days= 7
skip-name-resolve
#default_table_type = Innodb
innodb_file_format=Barracuda
max_connections = 1100
max_connect_errors = 1000
table_cache = 2048
table_open_cache = 6144
table_definition_cache = 4096
wait_timeout=100
interactive_timeout = 100
tmpdir = /usr/local/mysql/tmp
tmp_table_size = 64M
max_heap_table_size = 64M
thread_cache_size = 64
thread_concurrency = 32
thread_stack = 192K
max_allowed_packet = 1G
sort_buffer_size = 512K
join_buffer_size = 1M
query_cache_size = 0
#query_cache_limit = 2M
key_buffer_size = 64M
read_buffer_size = 512k
read_rnd_buffer_size = 512k
bulk_insert_buffer_size = 32M
loose_handlersocket_port = 9998
# the port number to bind to (for read requests)
loose_handlersocket_port_wr = 9999
# the port number to bind to (for write requests)
loose_handlersocket_threads = 16
# the number of worker threads (for read requests)
loose_handlersocket_threads_wr = 1
# the number of worker threads (for write requests)
open_files_limit = 65535
# to allow handlersocket accept many concurrent
# connections, make open_files_limit as large as
# possible.
# Don't listen _disibledevent=>binlog_cache_size = 1M
log-bin = /usr/local/mysql/logs/mysql-bin
max_binlog_size = 128M
#log_long_format
#slow_query_log_file = mysql.slow
#log_queries_not_using_indexes = 0
long_query_time = 1
#log-slow-queries=/usr/local/mysql/logs/slowquery.log
slow_query_log_file=/usr/local/mysql/logs/slowquery.log
#myisam_sort_buffer_size = 32M
#myisam_max_sort_file_size = 512M
#myisam_max_extra_sort_file_size = 512M
#myisam_repair_threads = 1
#myisam_recover
#SLAVE
#server-id = 60133
#master-host = 172.21.32.129
#master-user = repl
#master-password = repl
#master-port = 3306
#replicate-do-db=mydb
#replicate-ignore-table=mysql.inventory
#replicate-ignore-db=mysql
#replicate-ignore-table=mysql.user
#slave-net-timeout=35
#master-connect-retry=30
#relay-log = relay-bin
#max-relay-log-size = 128M
#log_slave_updates
#replicate-same-server-id=0
skip-slave-start
#slave_skip_errors =1032
##slave_skip_errors = all
#read-only
#transaction_isolation = READ-COMMITTED
innodb_flush_method = O_DIRECT
innodb_buffer_pool_size = 2G
innodb_additional_mem_pool_size = 16M
innodb_data_home_dir = /usr/local/mysql/data
innodb_data_file_path = ibdata1:2G:autoextend
innodb_file_per_table = 1
innodb_log_group_home_dir = /usr/local/mysql/logs
innodb_log_buffer_size = 64M
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
innodb_thread_concurrency = 288
innodb_thread_sleep_delay = 500
innodb_file_io_threads = 4
innodb_concurrency_tickets = 1000
innodb_adaptive_hash_index = 1
innodb_adaptive_flushing = 1
innodb_doublewrite = 1
innodb_sync_spin_loops = 40
innodb_io_capacity = 200
innodb_flush_log_at_trx_commit = 0
innodb_max_dirty_pages_pct = 80
#innodb_lock_wait_timeout = 120
innodb_lock_wait_timeout = 10
innodb_support_xa = 0
log_bin_trust_function_creators = 1
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
注意:在标红处,可以设置字符集为utf8,缓冲区大小根据实际情况来调整。
在/usr/local/mysql目录下,创建目录:logs、tmp,并且赋予读写权限。
添加到启动项:
# cd /usr/local/mysql
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# chmod 700 /etc/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --level 345 mysqld _disibledevent=># make
# make install
初始化话数据库我就不写了,网上资料很多。完成后登录到mysql可以安装handlersocket插件了:
# mysql> INSTALL PLUGIN handlersocket SONAME 'handlersocket.so';
# mysql> SHOW PLUGINS;


Tags:  percona

延伸阅读

最新评论

发表评论