# 配置clush:# 在/etc/clustershell目录下,手动创建groups文件
eg:
shell>touch /etc/clustershell/groups
shell> vim /etc/clustershell/groups
all: a1 host1 host2
name:host3 host4
# 需要注意的是all 是必须配置的,clush 有 -a 这个参数,主机间用空格分离。
eg:
shell>touch /etc/clustershell/groups
shell> vim /etc/clustershell/groups
all: host-172-16-2-208
4. 配置免密登录
# 如果没有事先生成ssh密匙的话,需要先生成:
shell> ssh-keygen
# 可选操作:为了方便,我们可以给需要登录的服务器起一个可读性更好的别名,如果你做了类似的操作,那么后面的<USER>@<SERVER>都可以换成对应的<HOST>:
shell>cat ~/.ssh/config
Host db_1
Hostname <SERVER>
User <USER>
Port <PORT>
Host db_2
Hostname <SERVER>
User <USER>
Port <PORT>
Host db_3
Hostname <SERVER>
User <USER>
Port <PORT># 然后把生成的公钥添加到需要登录的服务器指定位置:
shell>cat ~/.ssh/id_rsa.pub |ssh<USER>@<SERVER>"cat - >> ~/.ssh/authorized_keys"# 如果你和我一样总记不清如何正确拼写authorized_keys,可以接着学一下ssh-copy-id的用法,这个命令可以让操作更简单点:
shell> ssh-copy-id -i ~/.ssh/id_rsa.pub "<USER>@<SERVER>"# 注:每配置好一台免密码登录的服务器,最好手动实际操作一下,因为第一次连接会要求手动确认是否保存信息到~/.ssh/known_hosts文件。
eg:
[root@host-172-16-2-207 ~]# ssh-copy-id host-172-16-2-208
The authenticity of host 'host-172-16-2-208 (192.168.10.214)' can't be established.
ECDSA key fingerprint is 16:2a:df:68:97:e0:2a:e1:c2:3c:d7:ac:99:d7:76:d0.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@host-172-16-2-208's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'host-172-16-2-208'"
and check to make sure that only the key(s) you wanted were added.
5. 利用clush管理命令进行远程机器集群管理
# ssh首次登陆的时候,会提示输入"yes/no",需要提前将这个执行。
shell>ssh'host-172-16-2-208'
eg:
shell> clush -g db uptime
shell> clush -a hostname
shell> clush -b -a hostname
shell> clush -a "echo asdfsdf > /tmp/test"
fastDFS 部署
1. 环境准备
1.1 使用的系统软件
名称
说明
centos
7.x
libfatscommon
FastDFS分离出的一些公用函数包
FastDFS
FastDFS本体
fastdfs-nginx-module
FastDFS和nginx的关联模块
nginx
nginx1.15.4
1.2 编译环境
yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y
1.3 磁盘目录
说明
位置
所有安装包
/usr/local/src
数据存储位置
/home/dfs/
#这里我为了方便把日志什么的都放到了dfs
mkdir /home/dfs #创建数据存储目录
cd /usr/local/src #切换到安装目录准备下载安装包
wget http://nginx.org/download/nginx-1.15.4.tar.gz #下载nginx压缩包
tar -zxvf nginx-1.15.4.tar.gz #解压
cd nginx-1.15.4/
#添加fastdfs-nginx-module模块
./configure --add-module=/usr/local/src/fastdfs-nginx-module/src/
make && make install #编译安装
2. rpm 安装
2.1 编译后的rpm 安装包
[root@host-172-16-2-207 ~]# ll fdfs/
total 512
-rw-r--r--. 1 root root 1924 Feb 12 01:04 fastdfs-5.0.12-1.el7.centos.x86_64.rpm
-rw-r--r--. 1 root root 170680 Feb 12 01:05 fastdfs-server-5.0.12-1.el7.centos.x86_64.rpm
-rw-r--r--. 1 root root 133872 Feb 12 01:05 fastdfs-tool-5.0.12-1.el7.centos.x86_64.rpm
-rw-r--r--. 1 root root 110888 Feb 12 01:05 libfastcommon-1.0.40-1.el7.centos.x86_64.rpm
-rw-r--r--. 1 root root 40664 Feb 12 01:05 libfastcommon-devel-1.0.40-1.el7.centos.x86_64.rpm
-rw-r--r--. 1 root root 36428 Feb 12 01:05 libfdfsclient-5.0.12-1.el7.centos.x86_64.rpm
-rw-r--r--. 1 root root 18284 Feb 12 01:05 libfdfsclient-devel-5.0.12-1.el7.centos.x86_64.rpm
[root@host-172-16-2-207 ~]# yum install -y ./fdfs/*.rpm
2.2 默认数据存储及日志位置
[root@host-172-16-2-207 ~]# mkdir -p /home/yuqing/fastdfs/# 服务正常启动后[root@host-172-16-2-207 ~]# ll /home/yuqing/fastdfs/
total 12
drwxr-xr-x. 259 root root 8192 Feb 12 03:17 data
drwxr-xr-x. 2 root root 46 Feb 12 01:13 logs