postgres源码安装并设置开机自启动

来源:互联网 发布:前程无忧和前锦网络 编辑:程序博客网 时间:2024/06/01 08:27
操作系统:红帽6.5   64位数据库:postgresql 9.4chkconfig iptables offservice iptables stopvi /etc/selinux/configSELINUX=disabledchkconfig NetworkManager off修改系统时间1、下载源码解压介质直接上传到/tmp下。cd /tmptar jxvf postgresql-9.4.4.tar.bz2  或者tar zxvf postgresql-9.4.4.tar.gz或:tar -xf  postgresql-9.6.1.tar.bz22、创建安装的目录mkdir /opt/pgsql-9.4.43、进入解压后的目录cd /tmp/postgresql-9.4.4  4、进行安装  编译源码./configure --prefix=/opt/pgsql-9.4.4……checking for gcc... nochecking for cc... noconfigure: error: in `/tmp/postgresql-9.4.4':configure: error: no acceptable C compiler found in $PATHSee `config.log' for more details要挂载好映像。配置好yum。将操作系统盘放入光驱并挂载mount /dev/sr0 /mnt或者可上传系统ISO,并挂载镜像mount -o loop xxx.iso /mnt 配置yum安装程序 vi /etc/yum.repos.d/rhel.repo输入如下内容:[rhel]name=rhelbaseurl=file:///mnt/Server/enabled=1gpgcheck=0yum install gcc  readline-devel zlib-devel -y./configure --prefix=/opt/pgsql-9.4.45、make6、make install安装完成7、useradd postgres8、passwd postgreschown postgres:postgres -R /opt9、环境变量的设置可以把下面的内容添加到linux用户的~/.bash_profile或~/.profile文件中, [root@highgo postgresql-9.4.0]# su - postgres[postgres@highgo ~]$ vi .bash_profile直接将下面粘贴到最后,然后保存#postgresPGDATA=/opt/pgsql-9.4.4/dataPATH=/opt/pgsql-9.4.4/bin:$PATHexport LD_LIBRARY_PATH=/opt/pgsql-9.4.4/lib:$LD_LIBRARY_PATHexport PGDATA PATH[postgres@highgo ~]$ source .bash_profile  运行一下.bash_profile,使其生效。环境变量设置方法二:(最好别用,后续问题很多)vi /etc/profileexport PATH=/opt/pgsql-9.4.4/bin:$PATHexport LD_LIBRARY_PATH=/opt/pgsql-9.4.4/lib:$LD_LIBRARY_PATHsource /etc/profilechown postgres:postgres /opt -Rsu - postgresvi .bash_profileexport PGDATA=/opt/pgsql-9.4.4/data10、initdb11、pg_ctl start12、psql成功。源码安装开机服务:设置PostgreSQL开机自启动PostgreSQL的开机自启动脚本位于PostgreSQL源码目录的contrib/start-scripts路径下这个路径是安装包解压完的路径。linux文件即为linux系统上的启动脚本1)修改linux文件属性,添加X属性exit切换到root用户#cd /tmp/postgresql-9.4.4/contrib/start-scripts/   切换到解压目录下#chmod a+x linux2) 复制linux文件到/etc/init.d目录下,更名为postgresql#cp linux /etc/init.d/postgresql3)修改/etc/init.d/postgresql文件的两个变量#vi /etc/init.d/postgresqlprefix设置为postgresql的安装路径:prefix=/opt/pgsql-9.4.4PGDATA设置为postgresql的数据目录路径:PGDATA="/opt/pgsql-9.4.4/data"4) 执行service postgresql start,就可以启动PostgreSQL服务#service postgresql start 5)设置postgresql服务开机自启动#chkconfig --add postgresql执行上面的命令,就可以实现postgresql服务的开机自启动。reboot

0 0
原创粉丝点击