‫So, yeah, how about you guys jump into a demo, so are we going to do here again?
‫We're going to open up just to Posterous in instances with one mass that on stand by for simplicity.
‫And we're going to make one a.m. and we're going to make the other as a standby.
‫We're going to connect the standby to the mass, are going to show you how to do that.
‫And then I'm going to make the master aware of the standby because we have to do this two way configuration
‫to get this right.
‫I found it.
‫I found difficult to actually find a walking example on Bosco's 13 because it's brand new.
‫Even the one on Falconer's just not clear enough.
‫So I had to go through the dark again and make the simplest possible configuration for you.
‫So you get this working right by any by any chance.
‫This is not a best practice.
‫I'm not I'm not showing you best practice here.
‫I'm showing you how it works.
‫And I'm going to tell you that, oh, don't do this.
‫I'm going to slap you in the head or don't use the polls, because as an application, obviously, this
‫goes without saying.
‫But if I if I started doing the creative as an application, this is this kind of pollute the the goal
‫of what I'm trying to show you.
‫Right.
‫I'm trying to give you what exactly how it works.
‫The simplest way to get a story up and running so you can just test and paste this thing.
‫OK, I've always jump into it.
‫All right, guys, how about we jump into the demo?
‫So I have DOCA installed on this machine and I am going to spin up to Docker and instances that are
‫each, for instance, and I'm going to use Puskás 13 because I.
‫I like the risk.
‫I like to I live in the edge Beebs.
‫I live in the edge.
‫So here's what I'm going to do.
‫So are we going to create we're going to document instances.
‫We're going to name the first one, PJI p.m. and the second one is P standby.
‫Right.
‫And based on those each, we're going to have its own port and he's going to have its own volume that
‫I'm going to mount on my.
‫Hosts here.
‫So let's create a folder.
‫How about we do that?
‫I'm going to create a folder called For Applications that's for application.
‫I'm going to throw my my data for both master and standby here.
‫Why?
‫Because we're going to muck with the data a lot to get this right.
‫Right.
‫First of all, we need to spin up the master and that will get us to understand why these are completely
‫distinct Oscars and instances, obviously.
‫Then we're going to copy the entire data from master to the standby.
‫That's a requirement for to get the application right.
‫It has to be exactly identical to start with and then you stop building on top of it.
‫If if those are different, you're going to get a lot of errors.
‫And I got this all the time.
‫So how about we do that?
‫We're going to do Docker Run.
‫That's the name.
‫I'm going to call it the Postgres instance master.
‫I'm going to expose it to five, four, three, two.
‫That's the default ball.
‫Five, four, three, two.
‫Right.
‫So it's exposed to the host.
‫That's very important as well.
‫And so the master is on a five, four, three, two.
‫This is always the same because it's the same as the same instance that we're running on.
‫Right.
‫It's the same instance.
‫And then we're going to do the volume.
‫And the volume here is essentially just inside the application folder.
‫I'm going to create a folder called Data.
‫Right.
‫This will create a folder called Data inside this.
‫And I want to map this to that postscripts data folder, which is in and which is essentially in the
‫in the document, which is VAR Hleb, I believe PostgreSQL slash data that almost it almost as though
‫now we do EPOs Chris the environment variable password.
‫I'm going to call the postscripts user Postgres.
‫That's the same password, that idea obviously.
‫But we, you guys know what I'm doing here.
‫This is not this practice practices.
‫This is just showing you how to do things.
‫And then if you want to build something massive, this if you want to make this into production, you
‫actually sit down and think how to do this right.
‫You build an architecture.
‫It's not it's not like that at all.
‫You cannot do it in five minutes.
‫So now the final thing is just do Posterous.
‫And I'm going to detach this so that I'm going to use the same terminal to do other things.
‫How about we run this?
‫All right.
‫Looks like you have to specify the whole that.
‫So I'm going to do users who say.
‫Announcer While Chris and then.
‫Replication and then data, let's review the whole thing again.
‫So.
‫Dr. Ron P..
‫M..
‫That's the name of the Docker container, that's the port, and that's the path of the volume, what
‫I'm going to do here is I am going to change this to master data underscored data.
‫So I know that is actually that the master data.
‫Right.
‫We want to we want to differentiate between the master data and the standby data.
‫So I'm going to rename this folders to be Master Data.
‫That's the folder is going to get created.
‫And then this is what we map to.
‫Looks good.
‫And finally, once we get this right, we run and.
‫Dr. LOG's, the master looks like we're running.
‫Looks like his good looks like a good creating files, configuration files.
‫Good.
‫So let's test this thing.
‫P.M. So we have now a folder called Pimsleur Data, awesome.
‫OK, so.
‫How about we create the standby replica?
‫All we have to do is just change some variables here, so I'm going to be standby.
‫It's not running off by four, three, two, because that's used now going to five, four, three,
‫three.
‫And then I'm going to match this instead of the master data.
‫No, no.
‫It's going to be a standby data, its own folder.
‫And that said, just like that, we have to focus instances.
‫Right there are not identical right now.
‫But if we go to the standby data, we can see all the data right here, the postscript data, very critical.
‫And then if I go to B.M. data, you can see it's all there.
‫The next step is I'm going to stop both instances P.M. and the standby.
‫Why?
‫Because I need to actually copy the content of the master to the standby.
‫And it's very simple to do this because now it's everything is in my folder right here.
‫So all I have to do is just do move the standby data to be standby data backup.
‫Right.
‫And then I'm going to copy Dash R, which is a recursive I.M. data to please stand by data.
‫Exactly.
‫Copy the whole thing as is and then paste it.
‫And just like that, we now have the same folder, but we tricked the other instance so that it reads
‫almost the same content.
‫That's very critical for application.
‫Another processes to do PBG back up.
‫A lot of people do that.
‫I like to do this.
‫That's another example.
‫Just because it's easier, I don't want to deal with backups and all that stuff.
‫So this is way easier.
‫Now we have two databases now to start this up, make sure they are working Eastend then he starts Docker's
‫start p.m. Pashtun by OSM.
‫We're almost there.
‫We just barely created this thing, so the next step here is we need to go to M..
‫All right.
‫So what we need to do next is update some file only in the master.
‫Right.
‫So just let's go to the master data here.
‫And then that's when the PJI it should be a configuration, very, very critical file.
‫And what we need to do to this file is doing insert.
‫And at the end I'm going to add host replication.
‫I want to enable the application for the user.
‫Posterous, that idea.
‫Everybody says you don't use Postgres as an application.
‫Yeah.
‫Also don't use the password name password.
‫Right.
‫For your passwords.
‫Obviously everybody knows that.
‫But for simplest, the reason I'm going to use the same postscripts user which is an admin, don't use
‫an admin, use a proper credit user and only create so that it only allows to do an application.
‫So, you know, you want a user that is allowed to do certain things, not everything.
‫That's a bad idea, but.
‫More testing, so what's the harm?
‫So and then we've got to do all and then finally in five, and that will allow the master to town stand
‫by to connect to the master in their application mode.
‫Awesome.
‫So now the next thing we're going to do is we need you're going to need to jump into the standby replica.
‫So let's go to the standby replica and very easy, because I'm just going through different folders,
‫which is awesome.
‫This is now a moment in a standby data, right?
‫So now I'm Dadu Postscripts Config, and now this is the critical part.
‫We want to edit one configuration in the Postgres dotcom file in the standby, and that is called,
‫I think, primary connection info.
‫There you go.
‫We're going to enable that that will allow us to connect to the master note and here is the connection
‫is trying to do this.
‫Application name the first important thing, why this is I this is a unique identifier for each.
‫Back up or stand by not, you have to give it a name, so I'm going to stand by one, right?
‫That's the first that's first name that came to mind my name.
‫And then you use the same application name has to be case sensitive, by the way, and then you reference
‫it on the master so that the master are aware of what nodes it wants to connect to.
‫Right.
‫Otherwise, if you allow anyone to it from any database, that's just a security flaw.
‫Right.
‫That's why we have this factor authentication here.
‫We had a space and we do host equal.
‫What's the host name on my master?
‫It's Hosain Mac, which is the same.
‫They are all in the same machine.
‫And since I expose them to the port, I can safely use this name.
‫Right.
‫And then what's the port?
‫It's five, four, three, two.
‫Remember, that's the master.
‫Awesome.
‫And then finally there was a name Allscripts.
‫Well, you can use, replicate, replicate as a replicator or whatever user you want.
‫But for me it's it's Postgres as just testing.
‫And what's the password.
‫It is also Allscripts because we ran remember we ran this thing was Bosco's.
‫And hopefully we don't have any errors because I ran into error sometimes here, and that's the only
‫change that we do in the configuration on the stand, why you can change some other configuration.
‫But I'm not going to go with this in this video.
‫Right.
‫There are some so many knobs to turn here.
‫So we say, see, it says the standby server.
‫This thing are only in the standby.
‫They are ignored, the master server.
‫So we save and write.
‫On some.
‫Guys.
‫Did I mention that I have to stop the both stand by and the replication, if not, just make sure they
‫are stopped?
‫Well, I don't remember if I stopped them or not.
‫So now the other thing you need to do, which is weird, is.
‫In the stand by, which is this you have to create in the same folder, you have to create a file called
‫Stand by dot signal.
‫This makes this instance a read only instance and a stand by instance.
‫Right.
‫So now we have finished with the work in the stand.
‫Now we need to jump back onto the master.
‫Right.
‫Which is what what is the master P Master?
‫And now we need to change one slight thing in the configuration, and it's called.
‫I believe Synchronoss.
‫That's search for a Synchronoss comment by defaults on that's that's what we discussed the Internet
‫versus asynchronous, right?
‫What else?
‫Synchronoss, stand by.
‫That's what we want, so the Synchronoss stand by name because we were going to do a Synchronoss operations,
‫right?
‫All we have to do is just literally reference here, and that's the tricky part, guys.
‫You have this is a Syntex thing here, so you do, for example, first one and then you specify the
‫application names, right?
‫So if you have like a standby list, spill it.
‫Right, hopefully.
‫Stand by.
‫So this means give me a allow the comment as long as one at least one of these servers commit.
‫And obviously this is a little bit silly because there is only one server.
‫But if you have like another standby several stand by two application names.
‫Remember here, guys, that you put the application in, standby three.
‫Then you say, OK, I want the first two or I want any two, for example.
‫Right.
‫This means like this.
‫Has these two had more priority on the third.
‫Right.
‫And so on.
‫But my configuration is only this.
‫So it's very simple.
‫I have all I have to do is just change this thing.
‫And then hopefully we don't have any errors, right?
‫And that said, so now about who we don't have any problem, let's start the master and peace.
‫Stand by and let's hope for the best.
‫So let's look at the logs as well.
‫There is another way to look at the logs by doing DOCA logs, right?
‫Darker logs, E.M..
‫Stand by, one is now a Synchronoss stand by with priority one, look at the beautiful thing.
‫So now the master is aware, was this a master?
‫Yes, it is a master.
‫And the master is now aware of the stand by one replica.
‫Right.
‫And now if I go to stand by.
‫It is also aware.
‫Says database really starts streaming wall from the primary, right?
‫So was the writer had logs because that's what actually changed.
‫Right, right.
‫Had is essentially is it's a very small file that records the transactions.
‫So any transaction on any table or goes to this file first or it's usually in memory and then goes to
‫disk and this is what, what, what, what the database is exchange essentially all the walls.
‫Awesome.
‫Looks like what good guys.
‫So now what do we need to do?
‫Can we trust this thing?
‫So far we didn't actually enter any database or how about we actually.
‫Get into one of them, and so what I'm going to do here is I'm going to use this terminal, right.
‫And.
‫Execute.
‫P.M..
‫And let's call it the sequel, that Shupe Oscars means enter the Postgres mode here, and then I'm going
‫to show you that things are working by doing a select statement.
‫Select star from PG Stat Replication.
‫And that tells you that, hey, by the way, if this is empty, that means you don't have any application.
‫But look at this.
‫We have one of the streaming and I am streaming and it's a synchronous mode and all this detail and
‫it's called Stand By One.
‫And this is the user that idea.
‫But who cares for testing?
‫So that's the master.
‫I'm going to create another tab here.
‫And this will be my standby, so Dr. Exec, let it be standby and.
‫Physical as you focus now, I am in this is the standby.
‫Yes, this is a stand by and this one is the master.
‫So now if I create a table here, here, table test, I'd integer and let's say, gee, there's a tea
‫bar or two.
‫This is not a virtual.
‫I just grabbed a table.
‫If I go to this instance and do describe test, look at this, the table magically appeared on the other
‫instance.
‫Why?
‫Because we are writing to this.
‫However, if I go here and do create table test one, I'd, I don't know, integer and then I do a T
‫voiture two hundred.
‫Look at this.
‫We're getting yelled at.
‫You cannot write to a replica, you cannot write to a standby backup.
‫It's only to read only.
‫So now if I do select count star from this one, it's zero.
‫Right.
‫And if I do insert into test.
‫And I say, I don't know the and yet it's just the idea and then do select random times thousand from
‫generate serial, he's won 10000.
‫So I'm sort of inserting random number here, as I query here, still zero.
‫Well, all of a sudden appeared.
‫That is extremely fast, guys, because it's in the same instance.
‫Right.
‫But now I am seeing my queries appear here and obviously they are also here.
‫So this is pretty neat.
‫That's exactly what I wanted to show.
‫Right.
‫If I drop the table.
‫There was a little bit harsh, but if I, Ilter, change anything here, that change is going to be
‫so.
‫Let's do an alter table test and call them of I get the syntax right.
‫I made a sequel when it comes to alter their, I don't know, g var char or just the integer.
‫Is that how you do it.
‫Oh how about that.
‫I did it.
‫I got it right.
‫I'll get that shows up immediately here in the second instance.
‫So that's essentially what we want to show guys.
‫I can delete throws, I can truncate table truncate table test.
‫Right.
‫And the moment you truncated obviously all the rows are gone from the replica as well.
‫So that's essentially replication in a nutshell.
‫How about we jump back into the slides and complete this video?
‫Guys, anything all the resources and stuff like that will be available below.
‫Let's jump back onto it.