Documentos de Académico
Documentos de Profesional
Documentos de Cultura
187/26
Installation de postgres host 1,2 1. wget http://yum.postgresql.org/8.4/redhat/rhel-5-i386/pgdg-centos-8.4 -3.noarch.rpm 2. rpm -Uvh pgdg-centos-8.4-3.noarch.rpm 3. yum install postgresql postgresql-server postgresql-contrib 4. service postgresql initdb
Configuracion postgres conexiones remotas. 1. vi /var/lib/pgsql/data/postgresql.conf configuramos la linea de local host y le colocamos * #-----------------------------------------------------------------------------# CONNECTIONS AND AUTHENTICATION #-----------------------------------------------------------------------------# - Connection Settings listen_addresses = '*' # what IP address(es) to listen on; 2. vi /var/lib/pgsql/data/pg_hba.conf # TYPE DATABASE USER CIDR-ADDRESS METHOD ident ident md5 ident
# "local" is for Unix domain socket connections only local all all # IPv4 local connections: host all all 127.0.0.1/32 host all all 192.168.0.128/26 # IPv6 local connections: host all all ::1/128
3.
Configuracion de usuario de postgresql 1. su - postgres 2. su - postgres psql -d template1 -U postgres ALTER USER postgres WITH PASSWORD 'AMROEI2011';
Configuration de cluster en servidor maestro. DEFINIMOS VARIABLES DE ENTORNO EN SERVIDOR MASTER y slave export export export export export export export export CLUSTERNAME=clusterarchivo; MASTERDBNAME=archivoiceo; MASTERHOST=192.168.0.189; SLAVEHOST=192.168.0.187; REPLICATIONUSER=postgres; SLAVEDBNAME=archivoiceo; PGBENCHUSER=pgbench; REPLICATIONUSER=postgres;
para el slave export export export export export CLUSTERNAME=clusterarchivo; REPLICATIONUSER=postgres; SLAVEDBNAME=archivoiceo; PGBENCHUSER=pgbench; REPLICATIONUSER=postgres;
2.-Creamos un archivo slonik.sh en /etc/profile.d/ y le colocamos las variables de sesion. Esto con la finalidad de que las variables esten disponibles en todos los s hells y subshells tambien cuando 3.-su - postgres 4.-createuser -A -D $PGBENCHUSER 5.Aceptar la creacion de roles
Creamos las base de datos para el comando pgbeach desde el master server createdb -O postgres -h $MASTERHOST $MASTERDBNAME ; createdb -O postgres -h $SLAVEHOST $SLAVEDBNAME; pgbench -i -s 1 -U postgres -h $MASTERHOST $MASTERDBNAME Ahora creamos los primary key en las tablas creadas por el pgbeacn LO EJECUTAMOS DESDE EL MASTERDBHOST psql -U postgres -h $MASTERHOST -d $MASTERDBNAME -c "begin; alter table pgbench_history add column id serial;
update pgbench_history set id =nextval('pgbench_history_id_seq'); alter table pgbench_history add primary key(id); commit"
EJECUTAR DESDE EL SERVIDOR. Because Slony-I depends on the databases having the pl/pgSQL procedural language installed, we better install it now. It is possible that you have installed pl/ pgSQL into the template1 database in which case you can skip this step because i t's already installed into the $MASTERDBNAME. createlang -h $MASTERHOST plpgsql $MASTERDBNAME; createlang -h $SLAVEHOST plpgsql $SLAVEDBNAME; pgbench -s 1 -c 5 -t 1000 -U postgres -h $MASTERHOST $MASTERDBNAME CReamos el scrip de configuracion de slony desde el master
slonik <<_EOF_ #-# define the namespace the replication system uses in our example it is # slony_example #-cluster name = $CLUSTERNAME; #-# admin conninfo's are used by slonik to connect to the nodes one for each # node on each side of the cluster, the syntax is that of PQconnectdb in # the C-API # -node 1 admin conninfo = 'dbname=$MASTERDBNAME host=$MASTERHOST user=$REPLICA TIONUSER password=AMROEI2011' ; node 2 admin conninfo = 'dbname=$SLAVEDBNAME host=$SLAVEHOST user=$REPL ICATIONUSER password=AMROEI2011' ; #-# init the first node. Its id MUST be 1. This creates the schema # _$CLUSTERNAME containing all replication system specific database # objects. #-init cluster ( id=1, comment = 'Master Node'); #-# Slony-I organizes tables into sets. The smallest unit a node can # subscribe is a set. The following commands create one set containing # all 4 pgbench tables. The master or origin of the set is node 1. #-create set (id=1, origin=1, comment='All pgbench tables'); set add table (set id=1, origin=1, id=1, fully qualified name = 'public.expe diente', comment='expediente table');
#-# Create the second node (the slave) tell the 2 nodes how to connect to # each other and how they should listen for events. #-store node (id=2, comment = 'Slave node', event node=1); store path (server = 1, client = 2, conninfo='dbname=$MASTERDBNAME host=$MAS TERHOST user=$REPLICATIONUSER password=AMROEI2011'); store path (server = 2, client = 1, conninfo='dbname=$SLAVEDBNAME host=$SLAV EHOST user=$REPLICATIONUSER password=AMROEI2011'); _EOF_ ON MASTER slon $CLUSTERNAME "dbname=$MASTERDBNAME user=$REPLICATIONUSER host=$MASTERHOST p assword=AMROEI2011" ON master slon $CLUSTERNAME "dbname=$SLAVEDBNAME user=$REPLICATIONUSER host=$SLAVEHOST pas sword=AMROEI2011" ON SLAVE ABRIMOS CONSOLA en el master slonik <<_EOF_ # ---# This defines which namespace the replication system uses # ---cluster name = $CLUSTERNAME; # ---# Admin conninfo's are used by the slonik program to connect # to the node databases. So these are the PQconnectdb arguments # that connect from the administrators workstation (where # slonik is executed). # ---node 1 admin conninfo = 'dbname=$MASTERDBNAME host=$MASTERHOST user=$REPLIC ATIONUSER password=AMROEI2011'; node 2 admin conninfo = 'dbname=$SLAVEDBNAME host=$SLAVEHOST user=$REPLICAT IONUSER password=AMROEI2011'; # ---# Node 2 subscribes set 1 # ---subscribe set ( id = 1, provider = 1, receiver = 2, forward = no); _EOF_ APARECE UN MENSAGE , ES NORMAL,QUE MUESTRE QUE EJECUTARA UN PERFORM EN LINEA X. EN ESTE MOMENTO COMIENZA LA REPLICACION. /////abrrie el puerto 2221 para el ssh
El archivo que define las reglas que usa el firewall de linux Centos es iptables , este se encuentra en /etc/sysconfig/iptables
Podemos editar este archivo para definir nuestras reglas. Por ejemplo si deseamos abrir el puerto del SSH (22): 1. Abrimos el archivo de iptables nano /etc/sysconfig/iptables 2. Buscamos la linea que contiene [0:0] -A RH-Firewall-1-INPUT -i lo -j ACCEPT y le damos un ENTER 3. Escribimos [0:0] -A RH-Firewall-1-INPUT -p tcp --dport 21 -j ACCEPT 4. Guardamos el archivo con CRTL + O y lo cerramos con CTRL + X 5. Reiniciamos el servicio con service iptables restart
//cambiar el puerto del ssh Por defecto, ssh escucha las conexiones entrantes en el puerto 22. Para que un h acker determine si ssh se est ejecutando en su mquina, lo ms probable es que escane e el puerto 22. Un mtodo efectivo es ejecutar ssh en un puerto no-estndar. Cualqui er puerto sin usar funcionar, pero es preferible usar uno por encima del 1024. Muchas personas escogen el 2222 como un puerto alternativo (porque es fcil de rec ordar), de la misma forma que el 8080 es conocido, a menudo, como un puerto HTTP alternativo. Por esta razn, probablemente esta no es la mejor opcin. De la misma forma que cualquier hacker escanear el puerto 22, seguramente tambin escanear el pu erto 2222 solo como buena medida. Es mejor escoger cualquier puerto alto al azar que no sea usado por ningn servicio conocido. Para hacer los cambios aada una lnea como esta a su fichero /etc/ssh/sshd_config: # Ejecutar ssh en un puerto No-Estndar: Port 2345 #Cmbiame
/*****/ https://sites.google.com/site/pgsqldoc/Home/slony