Primary server public IP: 211.100.1.1 集群服务器的外网ip Primary server private IP::为空 本例中采用LVS NAT模式的集群,以下是集群的不同模式区别: 1. Virtual Server via Network Address Translation(VS/NAT) 通过网络地址转换,调度器重写请求报文的目标地址,根据预设的调度算法,将请求分派给后端的真实服务器;真实服务器的响应报文通过调度器时,报文的源地址被重写,再返回给客户,完成整个负载调度过程。 2. Virtual Server via IP Tunneling(VS/TUN) 采用NAT时,由于请求和响应报文都必须经过调度器地址重写,当客户请求越来越多时,调度器的处理能力将成为瓶颈。为了解决这个问题,调度器把请求报文通过IP隧道转发至真实服务器,而真实服务器将响应直接返回给客户,所以调度器只处理请求报文。由于一般网络服务应答比请求报文大许多,采用VS/TUN技术后,集群系统的最大吞吐量可以提高10倍。 3. Virtual Server via Direct Routing(VS/DR) VS/DR通过改写请求报文的MAC地址,将请求发送到真实服务器,而真实服务器将响应直接返回给客户。同VS/TUN技术一样,VS/DR技术可极大地提高集群系统的伸缩性。这种方法没有IP隧道的开销,对集群中的真实服务器也没有必须支持IP隧道协议的要求,但是要求调度器与真实服务器都有一块网卡连在同一物理网段上。 点击NAT按钮,出现NAT网络设置: NAT Router IP:192.168.1.2 NAT路径名称 NAT Router netmask:255.255.255.0 NAT掩码 NAT Router device:eth1 NAT 路径装置
mysql数据库Master-Slave实现 ①Slave数据库服务器要拥有访问Master资源的权限,因此首先要在Master上为Slave创建访问帐号并赋予文档复制权限。 #mysql -h192.168.1.4 –uroot –p –D hello mysql>;GRANT REPLICATION SLAVE ON *.* TO 'testbak'@'%' IDENTIFIED BY 'testbak'; ②根据mysql数据库的Master-Slave机制,Slave数据库实施数据同步操作的依据是Master数据库的日志文件及该日志文件的日志位置。因此,在为Master新增一台Slave服务器的时候要确保为Slave配置的参数(master_log_file及master_log_pos)就是Master当前使用的日志文件及当前的操作节点。如果Master数据库的数据一直处于运营状态(即有插入、修改、删除等操作),将不能满足上述要求。所以目前的维护操作是:系统扩容为Master增加一台Slave的时候,要停止整个业务系统,以停止对Master数据库数据的读写操作,然后查看Master当前的日志文件及日志位置。 #mysql -h192.168.1.4 –uroot –p –D hello mysql>; show master status; 有个改进的操作,可以将Master数据库锁住为只读,防止数据的更新。此时不用停止业务系统,但用户将不能进行信息修改、注册等操作。(待测试验证) ③将与当前Master数据库master_log_file、master_log_pos的值匹配的数据从Master拷贝到Slave上。可以采用mysqldump方法,也可以直接拷贝数据文件。注意,拷贝数据之前要用 # mysqladmin –u root –p shutdown 关闭主数据库。这里我们直接把数据文件压缩为mysql.tar.gz ④修改Master数据库的配置文件 一般在/etc/my.cnf 以192.168.1.4 Master数据库的配置文件为例: 修改/etc/my.cnf ,在[mysqld]区段内加入参数 # vi /etc/my.cnf log-bin server-id=1 sql-bin-update-same binlog-do-db=hello ****************************************************************************** # Example mysql config file for very large systems. # # This is for large system with memory of 1G-2G where the system runs mainly # My. # # 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/var) or # ~/.my.cnf to set user-specific options. # # One can in this file use all long options that the program supports. # If you want to know which options a program support, run the program # with --help option.
# The following options will be passed to all MySQL clients [client] #password = your_password port = 3306 socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server [mysqld] port = 3306 socket = /tmp/mysql.sock skip-locking set-variable = key_buffer=384M set-variable = max_allowed_packet=1M set-variable = table_cache=512 set-variable = sort_buffer=2M set-variable = record_buffer=2M set-variable = thread_cache=8 # Try number of CPU's*2 for thread_concurrency set-variable = thread_concurrency=8 set-variable = myisam_sort_buffer_size=64M
# Replication Master Server (default) #log-bin # required for replication #server-id = 1 # required unique id between 1 and 2^32 - 1 # defaults to 1 if master-host is not set # but will not function as a master if omitted
# Replication Slave Server (comment out master section to use this) #master-host = # MUST BE SET #master-user = # MUST BE SET #master-password = # MUST BE SET #master-port = # optional--defaults to 3306 #log-bin # not required for slaves, but recommended #server-id = 2 # required unique id between 2 and 2^32 - 1 # (and different from the master) # defaults to 2 if master-host is set # but will not function as a slave if omitted
# Point the following paths to different dedicated disks #tmpdir = /tmp/ #log-update = /path-to-dedicated-directory/hostname
# Uncomment the following if you are using BDB tables #set-variable = bdb_cache_size=384M #set-variable = bdb_max_lock=100000
# Uncomment the following if you are using InnoDB tables #innodb_data_home_dir = /usr/local/mysql/var/ #innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend #innodb_log_group_home_dir = /usr/local/mysql/var/ #innodb_log_arch_dir = /usr/local/mysql/var/ # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high #set-variable = innodb_buffer_pool_size=384M #set-variable = innodb_additional_mem_pool_size=20M # Set .._log_file_size to 25 % of buffer pool size #set-variable = innodb_log_file_size=100M #set-variable = innodb_log_buffer_size=8M #innodb_flush_log_at_trx_commit=1 #set-variable = innodb_lock_wait_timeout=50
******************************************************************************* # Example mysql config file for very large systems. # # This is for large system with memory of 1G-2G where the system runs mainly # MySQL. # # 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/var) or # ~/.my.cnf to set user-specific options. # # One can in this file use all long options that the program supports. # If you want to know which options a program support, run the program # with --help option.
# The following options will be passed to all MySQL clients [client] #password = your_password port = 3306 socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server [mysqld] port = 3306 socket = /tmp/mysql.sock skip-locking set-variable = key_buffer=384M set-variable = max_allowed_packet=1M set-variable = table_cache=512 set-variable = sort_buffer=2M set-variable = record_buffer=2M set-variable = thread_cache=8 # Try number of CPU's*2 for thread_concurrency set-variable = thread_concurrency=8 set-variable = myisam_sort_buffer_size=64M master-host=192.168.1.3 master-user=testbak master-password=testbak master-port=3306 server-id=2 master-connect-retry=60 replicate-do-db=hello log-slave-updates
# Point the following paths to different dedicated disks #tmpdir = /tmp/ #log-update = /path-to-dedicated-directory/hostname
# Uncomment the following if you are using BDB tables #set-variable = bdb_cache_size=384M #set-variable = bdb_max_lock=100000
# Uncomment the following if you are using InnoDB tables #innodb_data_home_dir = /usr/local/mysql/var/ #innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend #innodb_log_group_home_dir = /usr/local/mysql/var/ #innodb_log_arch_dir = /usr/local/mysql/var/ # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high #set-variable = innodb_buffer_pool_size=384M #set-variable = innodb_additional_mem_pool_size=20M # Set .._log_file_size to 25 % of buffer pool size #set-variable = innodb_log_file_size=100M #set-variable = innodb_log_buffer_size=8M #innodb_flush_log_at_trx_commit=1 #set-variable = innodb_lock_wait_timeout=50