从5.5版本以后,源码编译配置工具换成了cmake,所以要先装cmake

        # tar vxfz cmake-2.8...

        # cd cmake-2.8...

        # ./configure

        # make && make install


安装依赖包:

yum -y install gcc gcc-c++ cmake libaio libaio-devel lsof glibc glibc-devel zlib zlib-devel glib2 glib2-devel pcre pcre-devel ncurses ncurses-devel rsync telnet libtool automake screen iotop lrzsz wireshark perl-Time-HiRes perl-DBD-MySQL numactl bison bison-devel 

openssl openssl-devel libgcrypt-devel libgcrypt sysstat valgrind-devel libdb-devel xz-devel unzip


创建mysql用户:

        # groupadd mysql

        # useradd -g mysql mysql



解压安装包:

# tar zxvf Percona-Server-5.5.33-rel31.1.tar.gz 

# cd Percona-Server-5.5.33-rel31.1


编译安装

#cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all \

 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci \

  -DWITH_DEBUG=0 -DBUILD_CONFIG=mysql_release -DENABLE_DTRACE=0 -DFEATURE_SET=community \

  -DWITH_EMBEDDED_SERVER=OFF -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306  -DWITH_PARTITION_STORAGE_ENGINE=1 \

  -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1


# make  

# make install 


修改环境变量

 # vim ~/.bash_profile

    export PATH=/usr/local/mysql/bin:$PATH


创建目录为初始化做准备  

        # cd /data

        # mkdir -p /data/mysql/{data,tmp,logs} 注意不要空隔

        # chown -R mysql:mysql /usr/local/mysql/

        # vim /etc/my.cnf

[client]

port            = 3306

socket          = /tmp/mysql.sock

[mysql]

prompt="\\u@\\h:\p  \\R:\\m:\\s [\\d]>"

#tee=/data/mysql/data/query.log

no-auto-rehash

[mysqld]

#misc

user = mysql

basedir = /usr/local/mysql

datadir = /data/mysql/data

port = 3306

socket = /tmp/mysql.sock

event_scheduler = 0

#timeout

interactive_timeout = 300

wait_timeout = 300

#character set

character-set-server = utf8

open_files_limit = 65535

max_connections = 1000

max_connect_errors = 100000

skip-name-resolve = 1

#logs

log-output=file

slow_query_log = 1

slow_query_log_file = slow.log

log-error = error.log

log_warnings = 2

pid-file = mysql.pid

long_query_time = 1

#log-slow-admin-statements = 1

#log-queries-not-using-indexes = 1

log-slow-slave-statements = 1

#binlog

binlog_format = mixed

server-id = 203306

log-bin = mybinlog

binlog_cache_size = 4M

max_binlog_size = 1G

max_binlog_cache_size = 2G

sync_binlog = 0

expire_logs_days = 10

#relay log

skip_slave_start = 1

max_relay_log_size = 1G

relay_log_purge = 1

relay_log_recovery = 1

log_slave_updates

#slave-skip-errors=1032,1053,1062

#buffers & cache

table_open_cache = 2048

table_definition_cache = 2048

table_open_cache = 2048

max_heap_table_size = 96M

sort_buffer_size = 2M

join_buffer_size = 2M

thread_cache_size = 256

query_cache_size = 0

query_cache_type = 0

query_cache_limit = 256K

query_cache_min_res_unit = 512

thread_stack = 192K

tmp_table_size = 96M

key_buffer_size = 8M

read_buffer_size = 2M

read_rnd_buffer_size = 16M

bulk_insert_buffer_size = 32M

#myisam

myisam_sort_buffer_size = 128M

myisam_max_sort_file_size = 10G

myisam_repair_threads = 1

#innodb

innodb_buffer_pool_size = 100M

innodb_buffer_pool_instances = 1

innodb_data_file_path = ibdata1:1G:autoextend

innodb_flush_log_at_trx_commit = 2

innodb_log_buffer_size = 64M

innodb_log_file_size = 100M

innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 50

innodb_file_per_table = 1

innodb_rollback_on_timeout

innodb_status_file = 1

innodb_io_capacity = 2000

transaction_isolation = READ-COMMITTED

innodb_flush_method = O_DIRECT



初始化

# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/data/ --basedir=/usr/local/mysql


 出现下面两行即为初始化成功

        installing mysql system tables... OK

        filling help table... OK


启动数据库服务:

# mysqld_safe &

ps -ef | grep mysqld

# ps -ef | grep mysqld

root     30806  5218  0 15:30 pts/1    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe

mysql    31696 30806  0 15:30 pts/1    00:00:01 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql/data --plugin-dir=/usr/local/mysql/lib/mysql/plugin --user=mysql --log-error=/data/mysql/data/error.log --open-files-limit=65535 --pid-file=/data/mysql/data/mysql.pid --socket=/tmp/mysql.sock --port=3306

root     31760  5218  0 15:33 pts/1    00:00:00 grep mysqld


安装完成