一、系统准备
centos6.4选择base server安装
附加包
yum install gcc gcc-c++ zlib-devel pcre-devel readline readline-devel bzip2-devel rpm-build kernel-devel libaio-devel elfutils-libelf-devel compat-libstdc++-33 compat-libcap1-1.10-1.x86_64 cmake bison automake libtool* ncurses-devel cmake
yum install compat-libcap1-1.10-1.x86_64
#nagios依赖包
yum install xinetd-2.3.14-38.el6.x86_64
yum install openssl-devel-1.0.0-27.el6.x86_64
yum install bison-devel ncurses-devel
二、准备安装Mysql
创建mysql用户
useradd mysql
创建mysql安装目录
mkdir /app/mysql
给目录授权
chown mysql /app/mysql
准备配置文件
cat /etc/my.cnf
[client]
socket = /app/mysql/run/mysql.sock
[mysqld]
user=mysql
port = 3306
bind-address = 0.0.0.0
max_connections = 3000
max_connect_errors = 30
back_log = 600
socket = /app/mysql/run/mysql.sock
pid-file = /app/mysql/run/mysql.pid
basedir = /app/mysql
datadir = /app/mysql/data
log-error = /app/mysql/log/mysql_err.log
log-warnings = 1
log-bin=/app/mysql/data/log-bin
expire_logs_days=5
max_binlog_size = 512M
binlog_format=mixed
long_query_time=2
slow-query-log-file = /app/mysql/log/mysql_slowquery.log
explicit_defaults_for_timestamp=true
open_files_limit = 10240
table_open_cache = 4096
max_allowed_packet = 32M
binlog_cache_size = 256M
max_heap_table_size = 128M
sort_buffer_size = 16M
join_buffer_size = 16M
thread_cache_size = 120
query_cache_limit = 4M
ft_min_word_len = 8
character-set-server = utf8
thread_stack = 512K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 128M
sync_binlog=1
innodb_thread_concurrency=24
innodb_buffer_pool_size = 12G
innodb_buffer_pool_instances = 12
innodb_flush_method = O_DIRECT
innodb_sync_spin_loops=11
innodb_spin_wait_delay=12
innodb_page_size=8192
query_cache_type = 0
query_cache_size=0
innodb_data_home_dir = /app/mysql/data
innodb_data_file_path = ibdata1:128M:autoextend
innodb_write_io_threads = 12
innodb_read_io_threads = 12
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 16M
innodb_log_file_size = 512M
innodb_log_files_in_group = 3
innodb_flush_method = O_DIRECT
innodb_log_group_home_dir = /app/mysql/data/
innodb_max_dirty_pages_pct = 77
innodb_lock_wait_timeout = 100
innodb_flush_neighbors = 0
innodb_io_capacity=240
innodb_io_capacity_max=600.
三、进行mysql编译安装
su - mysql
tar -zxvf mysql-5.6.20.tar.gz
cd mysql-5.6.20
cmake -DCMAKE_INSTALL_PREFIX=/app/mysql -DMYSQL_DATADIR=/app/mysql/data -DSYSCONFDIR=/app/mysql/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/app/mysql/run/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
make && make install
安装完成后创建日志目录
mkdir /app/mysql/log
四、mysql初始化
/app/mysql/scripts/mysql_install_db --datadir=/app/mysql/data --basedir=/app/mysql --user=mysql
修改增加环境变量
[mysql@mdb-165 ~]$ cat .bashrc
# .bashrc
# Source global definitions
export PATH=/app/mysql/bin:$PATH
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
使环境变量生效
source ~/.bashrc
启动mysql
mysqld_safe &
设置mysql的root密码
[mysql@mdb-165 ~]$ mysqladmin -u root password
New password:
Confirm new password:
登录测试mysql
[mysql@mdb-165 ~]$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.20-log Source distribution
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
最后检查mysql的错误日志看是否有错误告警
[root@mdb-165 log]# more /app/mysql/log/mysql_err.log
150125 10:44:16 mysqld_safe Starting mysqld daemon with databases fro..............
25 10:44:19 6405 [Note] /app/mysql/bin/mysqld: ready for connections.
Version: '5.6.20-log' socket: '/app/mysql/run/mysql.sock' port: 3306 Source distribution
You have mail in /var/spool/mail/root
One Response