python升级后pip不能用解决方法

 

升级完python2.7后pip不可用,还是老的2.6下的,需要升级Pip到2.7下

按这个方式安装pip:

 

 

官网文档:

https://pip.pypa.io/en/stable/installing/

然后:

# whereis pip

pip: /usr/bin/pip /usr/bin/pip2.6 /usr/local/bin/pip2.7 /usr/local/bin/pip

直接用这个安装需要的包就是2.7的了:

/usr/local/bin/pip install requests

mongodb连接

 

  1. 下载mongodb压缩包

curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.6.tgz

mongodb-linux-x86_64-3.0.6.tgz

  1. 解压

$ tar zxvf mongodb-linux-x86_64-3.0.6.tgz

  1. 进入bin目录

$ cd mongodb-linux-x86_64-3.0.6/bin

  1. 连接远程数据库

$ mongo 192.168.1.200:27017/database  -u user  -p  password

kafka培训PPT

kafka-20180314

kafka常用操作:

查看topic列表:

1.kafka-topics.sh –list –zookeeper  10.1.14.39:2181,10.1.14.40:2181,10.1.14.41:2181

创建topic:

2.kafka-topics.sh –create –zookeeper 10.1.14.39:2181,10.1.14.40:2181,10.1.14.41:2181 –replication-factor 3 –partitions 1 –topic my-replicated-to

查看topic详细信息

3.kafka-topics.sh –describe –zookeeper  10.1.14.39:2181,10.1.14.40:2181,10.1.14.41:2181   –topic

生产消息:

./kafka-console-producer.sh –broker-list 10.1.14.39:9092,10.1.14.40:9092,10.1.14.41:9092 –topic nglogs

消费消息

./kafka-console-consumer.sh –bootstrap-server   10.1.14.39:9092,10.1.14.40:9092,10.1.14.41:9092    –from-beginning –topic nglogs

zookeeper相关命令:

bin/zkServer.sh stop

bin/zkServer.sh start

bin/zkServer.sh status

./zkCli.sh -server 10.1.14.41:2181

#see all topics
ls /brokers/topics
ls /

#broker info
ls /brokers/ids
get /brokers/ids/0

get /controller_epoch
#check partition
get /brokers/topics/my-replicated-topic
get /brokers/topics/nglogs/partitions/state

#add partions
ls /brokers/topics/nglogs/partitions

#修改分区

bin/kafka-topics.sh –alter –zookeeper 10.1.14.39:2181,10.1.14.40:2181,10.1.14.41:2181 –partitions 3 –topic nglogs

 

测试脚本:

consumer.py

producter.py

 

 

腾讯云cos挂载问题

挂载cos报错如下:

cosfs: /usr/lib64/libstdc++.so.6: version GLIBCXX_3.4.20' not found (required by cosfs)
cosfs: /usr/lib64/libstdc++.so.6: version 
GLIBCXX_3.4.15′ not found (required by cosfs)

解决如下:

strings /usr/lib64/libstdc++.so.6 | grep GLIBC

find / -name “libstdc++.so*”

cp /soft/gcc-4.9.4/gcc-bulild-4.9.4/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.20 /usr/lib64/

 

 

Fastdfa 详细部署

以前操作,补一下文档:

安装环境:

10.1.14.40

10.1.14.39

2台上都安装fast_dfs和nginx ,2台上都跑,看后面截图:

下载包:

wget http://jaist.dl.sourceforge.net/project/fastdfs/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz

wget http://nginx.org/download/nginx-1.12.2.tar.gz

git clone https://github.com/happyfish100/libfastcommon.git

cd libfastcommon

./make.sh

./make.sh install

wget https://github.com/happyfish100/fastdfs/archive/V5.09.tar.gz

cd   /usr/local/src/fastdfs-5.09/init.d/

./make.sh

./make.sh install

修改配置:

 

cp  tracker.conf.sample  tracker.conf

vi tracker.conf

disabled=false

base_path=/home/yuqing/fastdfs

vim storage.conf

disabled=false

group_name=group1

base_path=/home/yuqing/fastdfs

store_path0=/home/yuqing/fastdfs

tracker_server=10.1.14.39:22122

tracker_server=10.1.14.40:22122

启动:

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf  restart

 

/usr/bin/fdfs_storaged /etc/fdfs/storage.conf  restart

 

Nginx 安装:

./configure   –prefix=/usr/local/nginx –add-module=../fastdfs-nginx-module/src –with-pcre=../pcre-8.41

Make

make[1]: *** [objs/addon/src/ngx_http_fastdfs_module.o] Error 1

make[1]: Leaving directory `/usr/local/src/nginx-1.13.6′

make: *** [build] Error 2

修改:

/usr/local/src/fastdfs-nginx-module/src/config

如下:

ngx_addon_name=ngx_http_fastdfs_module

HTTP_MODULES=”$HTTP_MODULES ngx_http_fastdfs_module”

NGX_ADDON_SRCS=”$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c”

CORE_INCS=”$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/”

CORE_LIBS=”$CORE_LIBS -L/usr/local/lib -lfastcommon -lfdfsclient”

CFLAGS=”$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE=’256*1024′ -DFDFS_MOD_CONF_FILENAME=’\”/etc/fdfs/mod_fastdfs.conf\”‘”

 

Make

Make install

Cd

/usr/local/src/fastdfs-5.09/conf

  • cp anti-steal.jpg http.conf mime.types /etc/fdfs/
  • cd

/usr/local/src/fastdfs-nginx-module/src

cp mod_fastdfs.conf  /etc/fdfs/

vi mod_fastdfs.conf

增加一个tracker:

tracker_server=10.1.14.40:22122

tracker_server=10.1.14.39:22122

 

vim storage.conf

写入2个tracker:

tracker_server=10.1.14.39:22122

tracker_server=10.1.14.40:22122

 

vi client.conf

base_path=/home/yuqing/fastdfs

tracker_server=10.1.14.40:22122

tracker_server=10.1.14.39:22122

 

 

nginx.conf配置:

 

upstream fastdfs_tracker{

server 10.1.14.40:8080;

server 10.1.14.39:8080;

}

 

server {

listen       80;

server_name  10.1.14.40;

 

#charset koi8-r;

 

access_log  logs/host.access.log  main;

 

#location /group1/M00 {

#       root /home/yuqing/fastdfs/data/;

#       ngx_fastdfs_module;

#       }

 

location /group1/M00 {

proxy_next_upstream http_502 http_504 error timeout invalid_header;

#proxy_cache http-cache;

#proxy_cache_valid  200 304 12h;

#proxy_cache_key $uri$is_args$args;

proxy_pass  http://fastdfs_tracker;

#add_header Nginx-Cache “$upstream_cache_status”;

#expires 30d;

}

 

#error_page  404              /404.html;

 

# redirect server error pages to the static page /50x.html

#

error_page   500 502 503 504  /50x.html;

location = /50x.html {

root   html;

}

 

}

 

server {

listen 8080;

server_name 10.1.14.40;

 

location / {

root html;

index index.html index.htm;

}

 

location ~/group[0-9]/M00 {

ngx_fastdfs_module;

}

}

 

Tail  -f /home/yuqing/fastdfs/logs//home/yuqing/fastdfs/logs

2017-11-01 15:22:19] ERROR – file: tracker_mem.c, line: 3872, open file /home/yuqing/fastdfs/data/storage_groups_new.dat fail, errno: 2, error info: No such file or directory

[2017-11-01 15:22:19] INFO – file: tracker_mem.c, line: 4213, sys files loaded from tracker server 10.1.14.40:22122

[2017-11-01 15:22:20] ERROR – file: tracker_service.c, line: 2149, client ip: 10.1.14.39, sync src server: 10.1.14.40 not exists

[2017-11-01 15:22:20] INFO – file: tracker_service.c, line: 969, the tracker leader is 10.1.14.40:22122

发现有报错:

解决如下:

经过调试问题暂时解决了,是多个tracker   data数据不一致,没有自动同步。
删掉新加入节点的/data目录,拷贝当前Leader tracker目录下的 /data文件 过去即可(.pid不要拷贝)

Scp –r data 10.1.14.39:/home/xxxxx/

 

重启后加入的节点14.39

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

查看日志:

[2017-11-01 15:38:13] INFO – file: tracker_relationship.c, line: 383, selecting leader…

[2017-11-01 15:38:14] INFO – file: tracker_relationship.c, line: 422, the tracker leader 10.1.14.40:22122

 

没哟报错了。

 

14.39:

 

两台上都可以上传包:

/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /tmp/word.jpg

 

1.6老版本安装:

  • 先安装libvent-20.0.21-stable.tar.gz

yum install gcc-c++

yum -y install zlib zlib-devel openssl openssl–devel pcre pcre-devel

 

./configure –prefix=/usr/

Make

Make install

 

解压:FastDFS_v4.06.tar.gz  进入目录:

Vi  make.sh  去掉这行注释:WITH_LINUX_SERVICE=1

 

Make.sh

 

Make.sh install

 

Mkdir –p /home/yuqing/fastdfs

 

cd /usr/lib64/

ln -s /usr/lib/libevent-2.0.so.5 libevent-2.0.so.5

启动脚本:

service fdfs_trackerd start

service fdfs_storaged start

service fdfs_storaged status

service fdfs_trackerd status

/usr/local/nginx/sbin/nginx

tar -zxvf fastdfs-nginx-module_v1.15.tar.gz

tar -zxvf pcre-8.41.tar.gz

tar -zxvf nginx-1.6.1.tar.gz

 

./configure  –prefix=/usr/local/nginx –add-module=../fastdfs-nginx-module/src –with-pcre=../pcre-8.41

Make

Make install

Nginx.conf

#user  nobody;

worker_processes  1;

 

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

 

#pid        logs/nginx.pid;

events {

worker_connections  1024;

}

 

http {

include       mime.types;

default_type  application/octet-stream;

 

#log_format  main  ‘$remote_addr – $remote_user [$time_local] “$request” ‘

#                  ‘$status $body_bytes_sent “$http_referer” ‘

#                  ‘”$http_user_agent” “$http_x_forwarded_for”‘;

 

#access_log  logs/access.log  main;

 

sendfile        on;

#tcp_nopush     on;

 

#keepalive_timeout  0;

keepalive_timeout  65;

 

#gzip  on;

 

upstream fastdfs_tracker{

server 10.1.9.14:8080;

server 10.1.9.16:8080;

}

 

server {

listen       80;

server_name  10.1.9.16;

 

#charset koi8-r;

 

#access_log  logs/host.access.log  main;

 

location / {

root   html;

index  index.html index.htm;

}

 

location /group1/M00 {

proxy_next_upstream http_502 http_504 error timeout invalid_header;

#proxy_cache http-cache;

#proxy_cache_valid  200 304 12h;

#proxy_cache_key $uri$is_args$args;

proxy_pass  http://fastdfs_tracker;

#add_header Nginx-Cache “$upstream_cache_status”;

#expires 30d;

}

 

#error_page  404              /404.html;

 

# redirect server error pages to the static page /50x.html

#

error_page   500 502 503 504  /50x.html;

location = /50x.html {

root   html;

}

 

}

 

server {

listen 8080;

server_name 10.1.9.16;

 

location / {

root html;

index index.html index.htm;

}

 

location ~/group[0-9]/M00 {

ngx_fastdfs_module;

}

}

 

 

 

#error_page  404              /404.html;

 

# redirect server error pages to the static page /50x.html

#

#error_page   500 502 503 504  /50x.html;

#location = /50x.html {

#    root   html;

#}

 

 

}

 

以10.1.9.16为例,另一个是9.14,需要修改IP即可。

Nginx日志报:

ERROR – file: ../common/fdfs_global.c, line: 52, the format of filename “group1/M00/00/00/CgEJEFqhB6qABYBRABjk_e3WFFQ333.jpg” is invalid

解决办法:

vi /etc/fdfs/mod_fastdfs.conf

url_have_group_name=false

改为

url_have_group_name=true  

重启nginx : /usr/local/nginx/sbin/nginx –s reload

测试:

上传:/usr/local/src/FastDFS/client/fdfs_upload_file /etc/fdfs/client.conf   /tmp/word.jpg

 

访问:world