2020年9月22日 星期二

openssl 1.1.1g

wget https://www.cpan.org/src/5.0/perl-5.28.0.tar.gz
tar -zxvf perl-5.28.0.tar.gz
cd perl-5.28.0
./Configure -des -Dprefix=$HOME/localperl
make test
make install

wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_1g.tar.gz
tar -xzf OpenSSL_1_1_1g.tar.gz
cd openssl-OpenSSL_1_1_1g
./config --prefix=/usr
make && make install
ldconfig
openssl version

2020年8月3日 星期一

Redis Cluster docker-compose.yml

run.sh
docker-compose down
docker-compose up -d

#設定 cluster
docker exec -it redis1 redis-cli --cluster create 10.123.123.11:7001 10.123.123.11:7002 10.123.123.11:7003 10.123.123.11:7004 10.123.123.11:7005 10.123.123.11:7006 --cluster-replicas 1
docker exec -it redis1 redis-cli -h 10.123.123.11 -p 7001 -c
docker-compose.yml
version: '2'
services:
  redis1:
    image: redis
    hostname: redis1
    container_name: redis1
    restart: always
    network_mode: host
    entrypoint:  
      - redis-server
      - --port 7001
      - --appendonly yes
      - --cluster-enabled yes
      - --protected-mode no
    ports:
      - 7001

  redis2:
    image: redis
    hostname: redis2
    container_name: redis2
    restart: always
    network_mode: host
#    volumes:
#      - ./vol/opt/:/opt/
    ports:
      - 7002
    entrypoint:  
      - redis-server
      - --port 7002
      - --appendonly yes
      - --cluster-enabled yes
      - --protected-mode no

  redis3:
    image: redis
    hostname: redis3
    container_name: redis3
    restart: always
    network_mode: host
    ports:
      - 7003
    entrypoint:  
      - redis-server
      - --port 7003
      - --appendonly yes
      - --cluster-enabled yes
      - --protected-mode no

  redis4:
    image: redis
    hostname: redis4
    container_name: redis4
    restart: always
    network_mode: host
    ports:
      - 7004
    entrypoint:  
      - redis-server
      - --port 7004
      - --appendonly yes
      - --cluster-enabled yes
      - --protected-mode no

  redis5:
    image: redis
    hostname: redis5
    container_name: redis5
    restart: always
    network_mode: host
    ports:
      - 7005
    entrypoint:  
      - redis-server
      - --port 7005
      - --appendonly yes
      - --cluster-enabled yes
      - --protected-mode no

  redis6:
    image: redis
    hostname: redis6
    container_name: redis6
    restart: always
    network_mode: host
    ports:
      - 7006
    entrypoint:  
      - redis-server
      - --port 7006
      - --appendonly yes
      - --cluster-enabled yes
      - --protected-mode no

2020年6月26日 星期五

CentOS 安裝 redis

yum -y --enablerepo=remi,remi-test install redis
設定 Redis 為背景服務
sudo systemctl daemon-reload
sudo systemctl enable redis.service
開啟防火牆 6379 埠號
# Add allow port 6379
firewall-cmd --permanent --add-port=6379/tcp
firewall-cmd --reload
啟動 Redis
# Start Redis service
sudo systemctl start redis.service
Ping Redis
redis-cli ping
yum -y remove redis

nginx /var/log/nginx/error.log failed (13: Permission denied), SELinux Problem

2020/06/26 00:59:59 [error] 9825#0: *52 open() "/home/user/www/index.html" failed (13: Permission denied),
解決方式,SELinux
chcon -R -u system_u -t httpd_sys_content_t /home/user/www

CentOS 安裝nginx

安裝能夠選擇指定 yum 的套件:
yum install yum-utils -y
vim /etc/yum.repos.d/nginx.repo
# 穩定版
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
module_hotfixes=true

# 最新版
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=0
enabled=0
module_hotfixes=true
yum-config-manager --enable nginx-stable
切換使用 nginx-stable 穩定版:
yum-config-manager --enable nginx-stable
查看欲安裝的 NGINX 版本資訊:
yum info nginx
安裝 NGINX:
yum install nginx -y
查看安裝的 NGINX 版本:
nginx -v
移除nginx
yum remove nginx -y

CentOS 7.x 安裝 OpenJDK 1.8

yum -y install java-1.8.0-openjdk
[root@localhost ~]# java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
[root@localhost ~]# 
yum -y remove java-1.8.0-openjdk

2020年2月28日 星期五

pytorch gpu (Cuda 9.2) python 3.8.1

cuda_9.2.148_win10.exe
cuda_9.2.148.1_windows.exe
cudnn-9.2-windows10-x64-v7.6.5.32.zip

(base) C:\Users\me> conda create --name pytorch-gpu
(base) C:\Users\me> conda create --name pytorch-gpu python=3.7

(pytorch-gpu) C:\Users\me>pip install numpy
Collecting numpy
  Downloading numpy-1.18.1-cp38-cp38-win_amd64.whl (12.8 MB)
     |████████████████████████████████| 12.8 MB 1.6 MB/s
Installing collected packages: numpy
Successfully installed numpy-1.18.1

(pytorch-gpu) C:\Users\me>pip install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cu92/torch_nightly.html
Looking in links: https://download.pytorch.org/whl/nightly/cu92/torch_nightly.html
Collecting torch
  Downloading https://download.pytorch.org/whl/nightly/cu92/torch-1.5.0.dev20200227%2Bcu92-cp38-cp38-win_amd64.whl (690.3 MB)
     |████████████████████████████████| 690.3 MB 15 kB/s
Collecting torchvision
  Downloading https://download.pytorch.org/whl/nightly/cu92/torchvision-0.6.0.dev20200228%2Bcu92-cp38-cp38-win_amd64.whl (1.4 MB)
     |████████████████████████████████| 1.4 MB 284 kB/s
Collecting pillow>=4.1.1
  Downloading Pillow-7.0.0-cp38-cp38-win_amd64.whl (2.0 MB)
     |████████████████████████████████| 2.0 MB 930 kB/s
Requirement already satisfied: numpy in c:\users\me\anaconda3\envs\pytorch-gpu\lib\site-packages (from torchvision) (1.18.1)
Collecting six
  Using cached six-1.14.0-py2.py3-none-any.whl (10 kB)
Installing collected packages: torch, pillow, six, torchvision
Successfully installed pillow-7.0.0 six-1.14.0 torch-1.5.0.dev20200227+cu92 torchvision-0.6.0.dev20200228+cu92

(pytorch-gpu) C:\Users\me>python
Python 3.8.1 (default, Feb 27 2020, 14:41:12) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
True
>>>

(pytorch-gpu) C:\Users\me>nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Tue_Jun_12_23:08:12_Central_Daylight_Time_2018
Cuda compilation tools, release 9.2, V9.2.148