dubbo mysql源码编译

部署环境 操作系统:CentOS-6.6-x86_64-bin-DVD1.iso MySQL 版本:mysql-5.6.26.tar.gz  操作用户:root 系统 IP:

一、服务器配置:
1、配置网络 #
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet
HWADDR=00:50:56:a1:12:53
IPADDR=192.168.1.205
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=223.5.5.5
DNS2=223.6.6.6


[root@master1 ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=master1
[root@master1 ~]#
[root@master1 ~]# cat /etc/hosts
192.168.229.204 master1
127.0.0.1 master1
[root@master1 ~]#

3关闭selinux
# vi /etc/selinux/config
SELINUX=disabled

reboot

3、新增 mysql 用户组:
groupadd mysql

4、新增 mysql 用户,并添加到 mysql 用户组:
useradd -r -g mysql mysql

5、新建 MySQL 执行文件目录(后面会把编译好的 mysql 程序安装到这个目录):
mkdir -p /usr/local/mysql

6、新建 MySQL 数据库数据文件目录:
mkdir -p /home/mysql/data
mkdir -p /home/mysql/logs
mkdir -p /home/mysql/temp

[root@master1 ~]# cat /etc/profile
PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
export PATH

[root@master1 ~]# yum install make cmake gcc gcc-c++ bison bison-devel ncurses ncurses-devel autoconf automake -y
[root@master1 ~]# cp mysql-5.6.26.tar.gz /usr/local/src/
[root@master1 ~]# cd /usr/local/src/
[root@master1 src]# tar -zxvf mysql-5.6.26.tar.gz

[root@master1 mysql-5.6.26]# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/home/mysql/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DENABLE_DOWNLOADS=1

配置解释:
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql 设置安装目录
-DMYSQL_DATADIR=/home/mysql/data 设置数据库存放目录
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock 设置 UNIX socket 目录
-DMYSQL_USER=mysql 设置运行用户
-DDEFAULT_CHARSET=utf8 设置默认字符集,默认 latin1
-DEFAULT_COLLATION=utf8_general_ci 设置默认校对规则,默认 latin1_general_ci
-DWITH_INNOBASE_STORAGE_ENGINE=1 添加 InnoDB 引擎支持
-DENABLE_DOWNLOADS=1 自动下载可选文件,比如自动下载谷歌的测试包
-DMYSQL_TCP_PORT=3306 设置服务器监听端口,默认 3306
-DSYSCONFDIR=/etc 设置 my.cnf 所在目录,默认为安装目录

# make
# make install
(注意:如果需要重装 mysql,在 /usr/local/src/mysql-5.6.26 在执行下 make install 就可以了,
不需要再 cmake 和 make)

清除安装临时文件
#make clean
修改mysql目录拥有者为mysql用户
[root@master1 mysql-5.6.26]# chown -Rf mysql:mysql /usr/local/mysql
[root@master1 mysql-5.6.26]#  chown -Rf mysql:mysql /home/mysql

[root@master1 ~]# cd /usr/local/mysql/
[root@master1 mysql]# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/home/mysql/data

17、初始化脚本在/usr/local/mysql/下生成了配置文件 my.cnf,需要更改该配置文件的所有者:
[root@master1 mysql]# chown -Rf mysql:mysql /usr/local/mysql/my.cnf

在启动 MySQL 服务时,会按照一定次序搜索 my.cnf,先在/etc 目录下找,找不 到则会搜索 mysql 程序目录下是否有 my.cnf (
[root@master1 ~]# mv /etc/my.cnf /etc/my.cnf.bak
或者
[root@master1 ~]# vi /etc/my.cnf
[root@master1 ~]# cat /etc/my.cnf
[client]
port = 3306
socket = /usr/local/mysql/mysql.sock

[mysqld]
character-set-server = utf8
collation-server = utf8_general_ci

skip-external-locking
skip-name-resolve

user = mysql
port = 3306
basedir = /usr/local/mysql
datadir = /home/mysql/data
tmpdir = /home/mysql/temp
# server_id = .....
socket = /usr/local/mysql/mysql.sock
log-error = /home/mysql/logs/mysql_error.log
pid-file = /home/mysql/mysql.pid

open_files_limit = 10240

back_log = 600
max_connections=500
max_connect_errors = 6000
wait_timeout=605800

#open_tables = 600
#table_cache = 650
#opened_tables = 630

max_allowed_packet = 32M

sort_buffer_size = 4M
join_buffer_size = 4M
thread_cache_size = 300


query_cache_type = 1
query_cache_size = 256M
query_cache_limit = 2M
query_cache_min_res_unit = 16k

tmp_table_size = 256M
max_heap_table_size = 256M

key_buffer_size = 256M
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M

lower_case_table_names=1

default-storage-engine = INNODB

innodb_buffer_pool_size = 2G
innodb_log_buffer_size = 32M
innodb_log_file_size = 128M
innodb_flush_method = O_DIRECT

#####################
thread_concurrency = 32
long_query_time= 2
slow-query-log = on
slow-query-log-file = /home/mysql/logs/mysql-slow.log

[mysqldump]
quick
max_allowed_packet = 32M

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[root@master1 ~]#

复制服务启动脚本
[root@master1 ~]#  cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

服务启动脚本
[root@master1 ~]# service mysql start
Starting MySQL.. SUCCESS!
[root@master1 ~]#
[root@master1 ~]# chkconfig mysql on

设置 MySQL 数据库 root 用户的本地登录密码(初始用户没有密码)
[root@master1 usr]# /usr/local/mysql/bin/mysqladmin  -u root password 'roncoo'

root@master1 usr]# /usr/local/mysql/bin/mysql -uroot -p
Enter password: roncoo
mysql> show databases;

修改mysql密码
mysql> use mysql;
mysql> update user set Password = password('www.roncoo.com') where User='root';
mysql> flush privileges;

允许 root 远程登录,设置远程登录密码

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'www.roncoo.com' WITH GRANT OPTION;
mysql> flush privileges;


生产环境建议如下配置
[root@master1 usr]# /usr/local/mysql/bin/mysql_secure_installation

你可能感兴趣的:(dubbo)