Nginx entry and persistence redis clusters

Recommended song: Prodigal Son

mariadb 

1.yum install
yum install mariadb-server mariadb -y
after 2.yum installed, start the server, only the software installed by yum can use systemctl
systemctl Start MariaDB
3. database initialization
4.mysql -uroot -p

redis
1. source package install redis
2. specify the / opt / redis / working directory
3. Start the server redis
redis-server redis.conf
profile role 4.redis.conf software?
For this software, specify the open / close function of some
change redis port
change redis Password
Safe Mode redis of
bind parameters to specify redis start ip address


Way to kill redis services
1.kill pid
2.pkill redis-server based on the service name to kill the process, you can kill all relevant redis-server


1. Install the software on linux server
several points:
-yum install
- configure yum source configuration 163, Tsinghua University, Ali cloud yum source
- Empty cache yum
- yum generate new cache
- Source Installation
- Download the software source code compression package
- unzip, change directory
- release makefile, compile, build and install
-rpm package installation

Remote connectivity tools Xshell (ssh root @ ip)
mac students ssh root @ ip

The school year

 

redis publish and subscribe

Three roles, redis provide command
1. publishers
publish news channel message to channel
2. subscribers
SUBSCRIBE channel subscribe
PSUBSCRIBE channels * Support Subscription fuzzy matching
3. channel
channel channel name custom

redis persistence of RDB
1. add the parameter in the configuration file, open rdb function
redis.conf write
Port 6379
to daemonize Yes
logfile /data/6379/redis.log
the dir / Data / 6379
dbfilename s15.rdb
Save #rdb mechanism 900 every 900 seconds. 1 has a repair > change recording
save 300 10 # 10 every 300 seconds modifying
records
save 60 10000 # 10000 revised every 60 seconds> modified records
2. On redis server, rdb test function
redis-server redis.conf


redis persistence of aof
1. Open aof function, add the parameter redis.conf
Port 6379
to daemonize Yes
logfile /data/6379/redis.log
the dir / Data / 6379
appendOnly Yes
appendfsync everysec
2. Start redis server, the function specified aof test persistent data

 


The switch does not restart redis rdb data to the data aof
1. Preparation of rdb redis server
redis-server s15-redis.conf (which is indicated in the persistent mode rdb)

2. Switch to rdb aof
Redis-cli login redis, then the command to activate the aof persistence
127.0.0.1:6379> CONFIG set appendonly yes # with the command to activate the aof persistence (provisional entry into force, pay attention to write to the configuration file)
the OK
127.0 .0.1: 6379>
127.0.0.1:6379>
127.0.0.1:6379> the Save the SET CONFIG "" # close rdb persistence

2.5 aof the operation, a write to the configuration file, permanent, effective after the next reboot
Port 6379
to daemonize Yes
logfile /data/6379/redis.log
the dir / Data / 6379

#dbfilename s15.rdb
#save 900 1
#save 300 10
#save 60 10000
appendonly yes
appendfsync everysec

 


3. Test aof data persistence, kill redis, restart
the kill
Redis-Server-S15 redis.conf

4. The write data, checks the file aof

 

The master-slave synchronization redis

1. Check redis database information from the command master state
redis-cli -p 6379 info database information check
redis-cli -p 6379 info replication checks the information from the master database

 

1. Prepare three redis profile, distinguished by the port, starting three redis database instance, and then configure the master copy from
redis-6379.conf
Port 6379
to daemonize Yes
PidFile /data/6379/redis.pid
LogLevel Notice
logfile "/ Data /6379/redis.log "
dbfilename dump.rdb
the dir / Data / 6379

Redis-6380.conf
# quickly generate command profile
Sed" S / 6379/6380 / G "Redis-6379.conf> Redis-6380.conf
slaveof 127.0.0.1 6379 # indicates the primary repository of identity ip and port

6381.conf-Redis
# quickly generate command profile
Sed "S / 6379/6381 / G" Redis-6379.conf> Redis-6381.conf
slaveof 127.0.0.1 6379

2. Start the database instance three, from the detected primary synchronization scheme redis


3.redis main switch assignment, a manual fault from
1. 6379 of killing the master database instance
kill the main library

2. manually switch from the main identity
1. Log redis-6380, by order, remove from the library's own identity, waiting for a connection
slaoveof One NO
2. Log redis-6381, by order, to generate a new director
slaveof 127.0.0.1 6380

3. test the new master data synchronization from


redis Sentinel
1. What is the sentry it? Protection redis Lord, when the main library hang up automatically in the selection of a new main library from the library from the cluster, the normal operation, synchronization

2.redis Sentinel installation configuration
1. Prepare three redis database instance (three profiles, distinguished by the port)
[the root @ localhost redis-4.0.10] # redis redis-Server-6379.conf
[the root @ localhost redis- 4.0.10] # Redis Redis-Server-6380.conf
[root @ localhost Redis-4.0.10] # Redis Redis-Server-6381.conf
2. prepare three guards, three sentries ready configuration file (just port different 26379,26380,26381)
-rw-R & lt - r--. 1 the root Redis the root 227 18:44 2-Jan-26379.conf Sentinel
Port 26379
the dir / var / Redis / Data /
logfile "26379.log"

sentinel monitor s15master 127.0.0.1 6379 2

sentinel down-after-milliseconds s15master 30000

sentinel parallel-syncs s15master 1

sentinel failover-timeout s15master 180000
daemonize yes


-rw-r--r-- 1 root root 227 Jan 2 18:45 redis-sentinel-26380.conf
快速生成配置文件
sed "s/26379/26380/g" redis-sentinel-26379.conf > redis-sentinel-26380.conf
-rw-r--r-- 1 root root 227 Jan 2 18:46 redis-sentinel-26381.conf
sed "s/26379/26381/g" redis-sentinel-26379.conf > redis-sentinel-26381.conf

3. Add background parameters, such that the three Sentinel processes running in the background
[root @ localhost Redis-4.0.10] # echo "daemonize yes" >> Redis-Sentinel-26379.conf
[root @ localhost Redis-4.0.10] echo # "daemonize yes" >> Redis-Sentinel-26380.conf
[root @ localhost Redis-4.0.10] # echo "daemonize yes" >> Redis-Sentinel-26381.conf

4. Start Sentinel three
1003-Redis Redis Sentinel Sentinel-26379.conf-
1007-Redis Redis Sentinel Sentinel-26380.conf-
1008-Redis Redis-Sentinel Sentinel-26381.conf

5. The sentinel check the communication state
redis-cli - p 26379 info sentinel
after viewing the results were as follows, expressed Sentinel normal
[@ localhost Redis the root-4.0.10] -p # 26379 CLI-info Redis Sentinel
# the Sentinel
sentinel_masters:. 1
sentinel_tilt: 0
sentinel_running_scripts: 0
sentinel_scripts_queue_length: 0
sentinel_simulate_failure_flags: 0
master0: name = s15master, status = ok, address = 127.0.0.1: 6381, slaves = 2, sentinels = 3

6. redis kill a master repository, the node 6379, waits within 30s, check status 6381 of the node 6380, and
the kill the master node 6379
redis CLI -p-info 6380 Replication
redis CLI -p-info 6381 Replication
If, after switching from the master identity , (redis principle is to change the configuration file, the switchover from the identity)

7. 6379 to restore the database node, see if 6379 will add a new slave identity

 

 

redis-cluster Installation Configuration
1. Preparation Example 6 redis database, prepare 6 profiles redis- {7000 .... 7005} profiles
-rw-r - r-- 1 root root 151 Jan 2 19:26 redis -7000.conf
-rw-R & lt - r--. 1 2 19:27 Jan the root 151 Redis the root-7001.conf
-rw-R & lt - r--. 1 2 19:27 Jan the root 151 Redis the root-7002.conf
-R & lt -rw - r--. 1 2 19:27 Jan the root 151 Redis the root-7003.conf
-rw-R & lt - r--. 1 2 19:27 Jan the root 151 Redis the root-7004.conf
-rw-R & lt --r-- 1 root root 151 Jan 2 19:27 redis-7005.conf

2.启动6个redis数据库实例
[root@localhost s15rediscluster]# redis-server redis-7000.conf
[root@localhost s15rediscluster]# redis-server redis-7001.conf
[root@localhost s15rediscluster]# redis-server redis-7002.conf
[root@localhost s15rediscluster]# redis-server redis-7003.conf
[root@localhost s15rediscluster]# redis-server redis-7004.conf
[root@localhost s15rediscluster]# redis-server redis-7005.conf

3. Configure the ruby language environment, a key to start the script redis-cluster
source package 1. Download the ruby language, compile and install
wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1. the tar.gz
2. decompression
./configure --prefix = / opt / ruby / release Makefile
the make && the make and install the install the compiler
3. download and install the module package ruby operation redis
wget http://rubygems.org/downloads/redis -3.3.0.gem

4. configuration ruby environment variable
echo the PATH $

Vim / etc / Profile
writing bottom row
PATH = $ PATH: / opt / ruby / bin /
read files
Source / etc / Profile

5. the through ruby package management tool to install redis package, the installation will generate a redis-trib.rb this command
a key to create redis-cluster is actually assigned master-slave relationship and slot allocation slot slot allocation
/opt/redis-4.0.10/ src / redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005

6. Check the master node from the state
redis CLI -p-info 7000 Replication

7. The data is written to the cluster redis, view data flow
redis-cli -p 7000 # key will automatically redirect herein, a node into a slot slot in
the SET name S15
the SET addr Shahe




 

 


nginx learning portal

web server software

Windows
IIS server
Linux
nginx

the Apache charges

lighthttp


company's technology stack
paid version technology stack
apache web server application server + java + tomcat + oracle + memcached + redhat enterprise version of linux + svn (code management tool)

Open source technology stack (Luffy Xuecheng)
nginx (load balancing) + Python (virtualenv) +
uwsgi (Python application server, start the 10 process to handle django drf request)
+ MySQL (Ali cloud rds master-slave replication)
+ redis master-slave assignment
+ git
+ VUE server front-end code
+ linux (Ali cloud centos7)


curl the -I can view the site's domain response headers to view the site with what server


1.yum resolve dependencies needed to compile nginx, nginx will not be after you being given

yum install gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel openssl openssl-devel -y

2. nginx installation configuration software, download the source code
wget -C https://nginx.org/download/nginx-1.12.0.tar.gz
3. decompression source, compiled and installed
tar -zxvf nginx-1.12.0. tar.gz
handover source directory
./configure --prefix = / opt / nginx112 /
the make the make the install &&
4. enter nginx working directory
cd / opt / ngin112 /

5. Review gninx working directory
[root @ localhost nginx112] # LS
conf configuration file directory
html web root directory, your index.html put here, then access by domain pythonav.cn/index.html html / index.html
logs log
sbin store nginx executable commands


6. customize their nginx web site
modified /opt/nginx112/html/index.html This is nginx web root files, empty the contents of their written html tags

7. Start nginx server
/ opt / nginx112 / sbin / nginx just press Enter to perform

8. Check nginx service port
ps -ef | grep nginx

9. Access nginx web service through the windows
browser to access http://192.168.13.79


 

Guess you like

Origin www.cnblogs.com/duhong0520/p/11687517.html