实时警报通知:微信告警通知的重要性解析
654
2023-02-14
NginX and Riak
Problem of storage and delivering static content is quiet actual nowadays. Lots of people needs big and reliable storages for storing static images and many other static files and delivering it to end users. Most popular solution still is NFS mounted storage, which is accessible from all front-ends, but this solution has big bottlenecks.
Hard to backup.Everything relies on NAS.Statically mounted external storage is needed.
Now lets dig deeper:
Hard to Backup :Some of you will say that this is not so ! But lets imagine that you have 10TB of small images which your application regularly use and this images are very critical. Standard rsync and or tar could take lots of time and system resources, which is definitely not what we want.
Statically mounted external storage is needed: This means that all your system will rely on externally mounted device and regardless how reliable is that, it is some king of SPOF.
So for everyone else:
lets summarize what we need:
Reliable storage.Low latency to access file.Easy management and backup.Reliability and fault tolerance.Easy access and less programming overhead.
After spending lots of time for finding a solution for mentioned problems we found seems ideal solution:
Before starting let’s summarize what these two tools will give us:
Download and Install Riak:
Done! Riak is installed. Do not start it for now. Just in case:
1 | # /etc/init.d/riak restart |
edit /etc/riak/app.config and change:
Also make sure you have configured /etc/hosts file and system hostname. Correct /etc/hosts should look something like this:
Also make sure you have configured /etc/hosts file and system hostname. Correct /etc/hosts should look something like this:
Also if you do not have your own internal DNS, you will have to add other nodes to /etc/hosts as well, but better to have DNS.
Also make some changes for storage configuration:
format and mount your bid disk to /var/lib/riak:
1 2 3 4 5 6 | # mkfs.xfs /dev/sdb1 # mount /dev/sdb1 /mnt # mv /var/lib/riak/* /mnt/ # umount /mnt # mount /dev/sdb1 /var/lib/riak # chown -R riak.riak /var/lib/riak |
Or better just create another mount-point and reconfigure Riak to use it
1 2 3 4 | # mount /dev/sdb1 /opt # mkdir /opt/riak # chown riak.riak /opt/riak # mv /var/lib/riak/* /opt/riak |
Change paths in /etc/riak/app.config:
1 2 3 4 5 | {riak_core,[ {ring_state_dir,"/opt/riak/riak/ring"}, ...--------... {bitcask,[{data_root,"/opt/riak/bitcask"}]}, {eleveldb,[{data_root,"/opt/riak/leveldb"}]}, |
Also it would be nice to enable Riak console to have nice WUI
It is installed by default so all you need is to change userlist from {userlist, [{"user", "pass"} to actual values. and make sure {admin, true} exist.
also edit /etc.riak/vm.args and change
Now restart Riak:
1 | /etc/init.d/riak restart |
Nor we need to more nodes to have redundancy: lets imagine that we have 3 nodes cluster for now.
Now you have 3 separate nodes, now need to join them all to single cluster: Very nice guide to do this is here
Shortly you need yo do following: After making apropriate configs
on node 2 and 3
And only on riak1 node
Now you have fully clusterized and working Riak installation.
to test is do following:
apt-get install nginx
Now edit /etc/nginx/sites-enabled/default and replace content with this:
发表评论
暂时没有评论,来抢沙发吧~