MySQL服务器的配置安装:
[root@jie4 ~]# ls
anaconda-ks.cfg install.log.syslog
install.log mysql-5.5.33-linux2.6-x86_64.tar.gz
###1、解压下载的mysql的通用二进制软件包
[root@jie4 ~]#tar xf mysql-5.5.33-linux2.6-x86_64.tar.gz -C /usr/local/
[root@jie4 ~]# cd /usr/local/
[root@jie4 local]# mv mysql-5.5.33-linux2.6-x86_64/ mysql
###2、创建存放数据库的文件,生产环境数据库存放在独立的建LVM的硬盘上面
[root@jie4 local]# mkdir -pv /mysql/data
mkdir: created directory `/mysql'
mkdir: created directory `/mysql/data'
###3、创建用户,和设置文件的属主和权限
[root@jie4 local]# useradd -r mysql
[root@jie4 local]# chown -R mysql:mysql /mysql/data
[root@jie4 local]# chmod -R 755 /mysql/data/
[root@jie4 local]# cd /usr/local/mysql/
[root@jie4 mysql]# cd support-files/
###4、建立mysql的配置文件
[root@jie4 support-files]# cp my-large.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y
###5、建立mysql的systemV服务脚本
[root@jie4 support-files]# cp mysql.server /etc/rc.d/init.d/mysqld
[root@jie4 ~]# vim /etc/my.cnf
###6、修改mysql的配置文件,修改或添加这两行
#############vim /etc/my.cnf###############
thread_concurrency = 4
datadir = /mysql/data
###########################################
###7、初始化mysql的脚本
[root@jie4 support-files]# cd /usr/local/mysql/scripts/
[root@jie4 scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/data
###8、开启mysql服务和把mysql的服务加入到开机自启的列表中
[root@jie4 scripts]# service mysqld start
Starting MySQL........... [ OK ]
[root@jie4 local]# chkconfig --add mysqld
[root@jie4 local]# chkconfig --level 35 mysqld on
[root@jie4 scripts]# cd /usr/local/mysql/
###9、使系统能识别源码包安装的软件############
####1)修改环境变量PATH的路径
####2)链接头文件的路径
####3)连接库文件
####4)提供man帮助文档
[root@jie4 mysql]# echo "PATH=/usr/local/mysql/bin:$PATH" >/etc/profile.d/mysqld.sh
[root@jie4 mysql]# source /etc/profile.d/mysqld.sh
[root@jie4 mysql]# ln -sv /usr/local/mysql/include/ /usr/include/mysqld
`/usr/include/mysqld' -> `/usr/local/mysql/include/'
[root@jie4 mysql]# echo "/usr/local/mysql/lib/" >/etc/ld.so.conf.d/mysqld.conf
[root@jie4 mysql]# ldconfig -v | grep mysql
####10、创建登录数据库的用户的密码
[root@jie4 local]# mysqladmin -u root password RedHat
[root@jie4 local]# mysql -u root -p
mysql> select user,password,host from mysql.user;
#查询mysql数据库中user表的用户,密码和host
+------+-------------------------------------------+-----------+
| user | password | host |
+------+-------------------------------------------+-----------+
| root | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 | localhost |
| root | | jie4.com |
| root | | 127.0.0.1 |
| root | | ::1 |
| | | localhost |
| | | jie4.com |
+------+-------------------------------------------+-----------+
6 rows in set (0.00 sec)
#删除数据库的安全隐患的用户
mysql> drop user root@'::1';
Query OK, 0 rows affected (0.00 sec)
mysql> drop user root@'jie4.com';
Query OK, 0 rows affected (0.00 sec)
mysql> drop user ''@'jie4.com';
Query OK, 0 rows affected (0.00 sec)
mysql> drop user ''@'localhost';
Query OK, 0 rows affected (0.00 sec)
#创建指定网段能访问数据库的用户名和密码
mysql> create user root@'172.16.%.%' identified by 'mypass';
Query OK, 0 rows affected (0.00 sec)
mysql> select user,password,host from mysql.user;
+------+-------------------------------------------+------------+
| user | password | host |
+------+-------------------------------------------+------------+
| root | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 | localhost |
| root | | 127.0.0.1 |
| root | *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4 | 172.16.%.% |
+------+-------------------------------------------+------------+
3 rows in set (0.01 sec)
mysql> flush privileges; #重读授权表,及时生效
Query OK, 0 rows affected (0.00 sec)
mysql> \q
到此为止每个服务器独立提供的服务已经安装搭建完成,现在需要让他们协同一起工作,用户的体验就好像是工作在一台机器上面