今天尝试使用 oh-my-zsh,按照 github 上的说明:
curl -L http://install.ohmyz.sh | sh
进行安装完成后,运行 ls 发现中文文件名是乱码。搜索了一番,在 ~/.zshrc 文件末尾加入下面两行:
export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8
重启终端,或者运行
source ~/.zshrc
就 OK 了。
今天尝试使用 oh-my-zsh,按照 github 上的说明:
curl -L http://install.ohmyz.sh | sh
进行安装完成后,运行 ls 发现中文文件名是乱码。搜索了一番,在 ~/.zshrc 文件末尾加入下面两行:
export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8
重启终端,或者运行
source ~/.zshrc
就 OK 了。
git push {远程仓库名}:{远程分支名} # 本地分支和远程分支使用冒号:分隔 git push origin :feature/add_email_support # 使用实例
更详细的关于远程分支的介绍看这里:http://git-scm.com/book/zh/v1/Git-%E5%88%86%E6%94%AF-%E8%BF%9C%E7%A8%8B%E5%88%86%E6%94%AF
1. 安装 Samba
# apt-get install samba
2. 编辑配置文件
# vim /etc/samba/smb.conf
在最后面插入以下几行
[liubuntu-share] # 这个是你要共享的名字,可以在链接到这台机器的上看到,名字可以随便取 path=/data # 你要共享的目录,设置你自己的目录就好了 public=yes # 访问权限设置为 public writable=yes # 可写 security=share
3. 重启
# service samba restart
vim /etc/network/interfaces
原内容有如下4行:
auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp
以上表示默认使用DHCP分配IP,修改为如下:
auto lo iface lo inet loopback auto eth0 #iface eth0 inet dhcp iface eth0 inet static address 192.168.1.110 netmask 255.255.255.0 gateway 192.168.1.1
保存退出。
注意:只需要设置address(IP地址)、netmask(子网掩码)、gateway(网关)这三项就OK,network和broadcast这两项参数是可以不写的。
vim /etc/resolvconf/resolv.conf.d/base
添加如下内容(这点所有Linux发行版都通用):
nameserver 8.8.8.8 nameserver 8.8.4.4
ifdown eth0 # 如果你的网卡名不是这个,请更改为对应的 ifup eth0 # service networking restart 这个命令是不会成功的
大部分来自:http://www.ha97.com/4895.html,本文有修改。
This chapter will introduce several sophisticated techniques for maximizing the effi‐ ciency and value of replication, but as a first step, we will set up the simple replication shown in Figure 3-1—a single instance of replication from a master to a slave. This does not require any knowledge of the internal architecture or execution details of the rep‐ lication process (we’ll explore these before we take on more complicated scenarios).
Setting up basic replication can be summarized in three easy steps:
Unless you plan replication from the start and include the right configuration options in the my.cnf files, you will have to restart each server to carry out steps 1 and 2.
To follow the procedures in this section, it is easiest if you have a shell account on the machine with privileges to change the my.cnf file as well as an account on the server with ALL privileges granted.1
You should be very restrictive in granting privileges in a production environment. For precise guidelines, consult “Privileges for the User Configuring Replication” on page 27.
To configure a server so that it can act as master, ensure the server has an active binary log and a unique server ID. We will examine the binary log in greater detail later, but for now it is sufficient to say that it keeps a record of all the changes the master has made so that they can be repeated on the slave. The server ID is used to distinguish two servers from each other. To set up the binary log and server ID, you have to take the server down and add the log-bin, log-bin-index, and server-id options to the my.cnf configuration file as shown in Example 3-1. The added options are in boldface.
Example 3-1. Options added to my.cnf to configure a master
[mysqld] user = mysql pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock port = 3306 basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp log-bin = master-bin log-bin-index = master-bin.index server-id = 1
The log-bin option gives the base name for all the files created by the binary log (as you will see later, the binary log consists of several files). If you create a filename with an extension to log-bin, the extension will be ignored and only the file’s base name will be used (i.e., the name without the extension).
1. On Windows, the command-line prompt (CMD) or PowerShell can be used in place of the Unix “shell.” Basic Steps in Replication | 25
The log-bin-index option gives the name of the binary log index file, which keeps a list of all binlog files.
Strictly speaking, it is not necessary to give a name in the log-bin option. The default value is hostname-bin. The value for hostname is taken from the option for pid-file, which by default is the name of the host (as given by the gethostname(2) system call). If an administrator later changes the machine’s hostname, the binlog files will change names as well, but they will be tracked correctly in the index file. However, it is a good idea to create a name that is unique for the MySQL server and not tied to the machine the server is running on because it can be confusing to work with a series of binlog files that suddenly change name midstream.
If no value is provided for log-bin-index, the default value will be the same base name as for the binlog files (hostname-bin if you don’t give a default for log-bin). This means that if you do not provide a value for log-bin-index, the index file will change its name when you change the name of the host. So if you change the name of the host and start the server, it will not find the index file and therefore assume that it does not exist, and this will give you an empty binary log.
Each server is identified by a unique server ID, so if a slave connects to the master and has the same server-id as the master, an error will be generated indicating that the master and the slave have the same server ID.
Once you have added the options to the configuration file, start the server again and finish its configuration by adding a replication user.
After you make the change to the master’s configuration file, restart the master for the changes to take effect.
The slave initiates a normal client connection to the master and requests the master to send all changes to it. For the slave to connect, a user with special replication privileges is required on the master. Example 3-2 shows a standard mysql client session on the master server, with commands that add a new user account and give it the proper privilege.
Example 3-2. Creating a replication user on the master
GRANT REPLICATION SLAVE ON *.* TO repl_user IDENTIFIED BY 'xyzzy';
There is nothing special about the REPLICATION SLAVE privilege except that the user can retrieve the binary log from the master. It is perfectly viable to have a normal user account and grant that user the REPLICATION SLAVE privilege. It is, however, a good idea to keep the replication slave user separate from the other users. If you do that, you can remove the user if you need to disallow certain slaves from connecting later.
After configuring the master, you must configure the slave. As with the master server, you need to assign each slave a unique server ID. You may also want to consider adding the names of the relay log and the relay log index files to the my.cnf file (we will discuss the relay log in more detail in “Replication Architecture Basics” on page 228) using the options relay-log and relay-log-index. The recommended configuration options are given in Example 3-3, with the added options highlighted.
Example 3-3. Options added to my.cnf to configure a slave
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
server-id = 2
relay-log-index = slave-relay-bin.index relay-log = slave-relay-bin
Like the log-bin and log-bin-index options, the defaults for the relay-log and relay-log-index options depend on the hostname. The default for relay-log is host name-relay-bin and the default for relay-log-index is hostname-relay-bin.index. Using the default introduces a problem in that if the hostname of the server changes, it will not find the relay log index file and will assume there is nothing in the relay logfiles.
After editing the my.cnf file, restart the slave server for the changes to take effect.
Now you can perform the final step in setting up basic replication: directing the slave to the master so that it knows where to replicate from. To do this, you need four pieces of information about the master:
You already created a user account with the right privileges and a password when con‐ figuring the master. The hostname is given by the operating system and can’t be con‐ figured in the my.cnf file, but the port number can be assigned in my.cnf (if you do not supply a port number, the default value of 3306 will be used). The final two steps nec‐ essary to get replication up and running are to direct the slave to the master using the CHANGE MASTER TO command and then start replication using START SLAVE:
CHANGE MASTER TO MASTER_HOST = 'master-1', MASTER_PORT = 3306, MASTER_USER = 'repl_user', MASTER_PASSWORD = 'xyzzy'; -- Query OK, 0 rows affected (0.00 sec) START SLAVE; -- Query OK, 0 rows affected (0.15 sec)
Congratulations! You have now set up your first replication between a master and a slave! If you make some changes to the database on the master, such as adding new tables and filling them in, you will find that they are replicated to the slave. Try it out! Create a test database (if you do not already have one), create some tables, and add some data to the tables to see that the changes replicate over to the slave.
Observe that either a hostname or an IP address can be given to the MASTER_HOST parameter. If a hostname is given, the IP address for the hostname is retrieved by calling gethostname(3), which, depending on your configuration, could mean resolving the hostname using a DNS lookup. The steps for configuring such lookups are beyond the scope of this book.
摘选自:《MySQL High Availability》 p25-p29