Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # CKAN 6 - Virtualbox - VISTA
- These instructions are a CentOS 6 adapted version of CKAN’s Ubuntu install.
- http://docs.ckan.org/en/latest/maintaining/installing/install-from-source.html
- These instructions are targeted for a Virtualbox install on StatCan’s VISTA SDCs and the version of the software packages installed.
- ## Setup the environment
- ### Downloading the OS
- Download the first DVD of latest 32 bit (i386) CentOS 6 ISO.
- At the time of writing this the file required was [CentOS-6.6-i386-bin-DVD1.iso](http://isoredirect.centos.org/centos/6/isos/i386/)
- ### Installing in virtuabox
- Create a new server and accept all defaults with the exception of memory ( use 2 GB ) and storage ( at least 10 GB ). Follow through with the install without network connectivity.
- 1. Start the blank box
- 2. Select the image you downloaded
- 3. Accept defaults except:
- * Storage Device Warning : **[Yes, discard any data]**
- * Which type of installation would you like? **Use all the space**
- 4. Once CentOS has formatted the disk it runs to the end, ~45
- ### Setup the proxy (if required)
- #### /etc/environment
- As root add the following to the bottom of the file replacing **\<user>** and **\<pass>** with the proxy credentials.
- ```
- http_proxy="http://<user>:<pass>@stcweb.statcan.ca:80/"
- HTTP_PROXY="http://<user>:<pass>@stcweb.statcan.ca:80/"
- https_proxy="https://<user>:<pass>@stcweb.statcan.ca:80/"
- HTTPS_PROXY="https://<user>:<pass>@stcweb.statcan.ca:80/"
- no_proxy="localhost,127.0.0.1,127.0.0.1/8,/var/run/docker.sock"
- ```
- #### /etc/apt/apt.conf.d/77proxy
- As root add the following to the bottom of the file replacing **\<user>** and **\<pass>** with the proxy credentials.
- ```
- Acquire::http::proxy "http://<user>:<pass>@stcweb.statcan.ca:80/";
- Acquire::https::proxy "https://<user>:<pass>@stcweb.statcan.ca:80/";
- ```
- #### Native OS proxy config [GUI]
- ```
- SYSTEM_TOOLBAR > System > Preferences > Network Proxy
- Proxy Configuration > Manual proxy configuration
- HTTP Proxy: stcweb.statcan.ca
- Port: 80
- [Details] > Use Authentication
- Username: <user>
- Password: <pass>
- [Close]
- Secure HTTP proxy: stcweb.statcan.ca
- Port: 80
- [Close]
- ```
- #### Apply proxy settings to core applications
- ##### /etc/yum.conf
- As root add the following directly after [main] replacing **\<user>** and **\<pass>** with the proxy credentials.
- ```
- proxy=http://stcweb.statcan.ca:80/
- proxy_username=<user>
- proxy_password=<pass>
- ```
- ##### Firefox [GUI]
- ```
- APPLICATION_TOOLBAR > Edit > Preferences
- Advanced > Network > [Settings...]
- Use system proxy settings
- [Ok]
- [Close]
- ```
- #### Restart the machine
- To account for some odd behaviour:
- 1. Close all applications ( terminals and firefox )
- 2. Restart the machine
- 3. Open firefox first, connect to an external site (inputting user:pass credentials)
- 4. Open terminal and continue
- ### Update the current system software
- ```
- sudo yum update -y
- ```
- ## Install CKAN
- Following:
- http://docs.ckan.org/en/latest/maintaining/installing/install-from-source.html
- ### 1. Install the required packages
- Replace the provided by with the following:
- ```
- rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
- yum install -y python-devel python-pip python-virtualenv
- yum install -y postgresql postgresql-devel postgresql-server
- yum install -y git-core
- yum install -y java-1.6.0-openjdk
- yum install -y openssl-devel
- yum install -y gcc
- chkconfig postgresql on
- service postgresql initdb
- service postgresql start
- ```
- #### Notes
- * if there are pg_config issues you may need to:
- ```
- export PATH=$PATH:/usr/pgsql-x.x/bin
- ```
- ### 2. Install CKAN into a Python Virtual Environment (VE)
- As a local user, not root, execute:
- #### Section a — Create a Python VE
- Run as is without the developer’s symlinks
- ```
- sudo mkdir -p /usr/lib/ckan/default
- sudo chown `whoami` /usr/lib/ckan/default
- virtualenv --no-site-packages /usr/lib/ckan/default
- . /usr/lib/ckan/default/bin/activate
- ```
- If using a proxy and prior to installing into the python virtualenv it starts WITHOUT the proxy environment you previously setup. pip respects the lowercase variables, as such export the following:
- ```
- export http_proxy="http://<user>:<pass>@stcweb.statcan.ca:80/"
- export https_proxy="https://<user>:<pass>@stcweb.statcan.ca:80/"
- ```
- #### Section b — Install CKAN in your VE
- Install stable CKAN 2.3
- ```
- pip install -e 'git+https://github.com/open-data/ckan.git@canada-v2.3#egg=ckan'
- ```
- #### Section c — Install required Python modules into the VE
- If behind a proxy there are SSL issues with this concoction of OS/Python versions behind the StatCan ( general? ) proxy. Ian located libraries to bridge that gap:
- ```
- pip install pyasn1
- pip install ndg-httpsclient
- pip install pyOpenSSL
- ```
- Continue with the normal instructions:
- ```
- pip install -r /usr/lib/ckan/default/src/ckan/requirements.txt
- ```
- ##### Notes
- * Run behind a proxy creates a series of issues
- * Run without a proxy it failed on Pygments==1.6, re-runing the command cleared the Pygments issue
- * Run with our without proxy
- #### Section d — Deactivate and reactivate your VE
- ```
- deactivate
- . /usr/lib/ckan/default/bin/activate
- ```
- ### 3. Setup a PostgreSQL database
- Same as source.
- #### Check for utf-8
- ```
- sudo -u postgres psql -l
- ```
- #### Create PG user
- ```
- sudo -u postgres createuser -S -D -R -P ckan_default
- ```
- #### Create the DB
- Be sure to save the password you use for the following command.
- ```
- sudo -u postgres createdb -O ckan_default ckan_default -E utf-8
- ```
- #### /var/lib/pgsql/data/pg_hba.conf
- ##### If a local dB
- sqlalchemy wants IPv6, we should want to be restrictive on permissions.
- 1. Disable all forms of access to the dB
- 2. Add ckan_default IPv6
- 3. Add ckan_default IPv4 (if required for alternate scripting)
- 4. Restart PostgreSQL
- ```
- # TYPE DATABASE USER CIDR-ADDRESS METHOD
- # "local" is for Unix domain socket connections only
- #local all all ident
- # IPv4 local connections:
- #host all all 127.0.0.1/32 ident
- # IPv6 local connections:
- #host all all ::1/128 ident
- # CKAN Specific Permissions
- ##### required for sqlalchemy
- host ckan_default all ::1/128 md5
- ##### required for script XYZ.py
- #host ckan_default all 127.0.0.1/32 md5
- ```
- ```
- sudo service postgresql restart
- ```
- #### If a remote dB
- THIS MAY BE FALSE, SQLALCHEMY SEEMS TO DEMAND IPV6
- ##### postgresql.conf
- ```
- listen_addresses = 'localhost,192.168.#.#’
- ```
- ##### pg_hba.conf
- Consider that the following config is invalid, you may need the IPv6 equivalent.
- ```
- host all all 192.168.#.#/32 md5
- ```
- ### 4. Create a CKAN config file
- Same as source.
- #### Create a directory to contain the site’s config files:
- ```
- sudo mkdir -p /etc/ckan/default
- sudo chown -R `whoami` /etc/ckan/
- ```
- #### Change to the ckan directory and create a CKAN config file:
- ```
- cd /usr/lib/ckan/default/src/ckan
- paster make-config ckan /etc/ckan/default/development.ini
- ```
- #### /etc/ckan/default/development.ini file
- ##### sqlalchemy.url = postgresql://ckan_default:pass@localhost/ckan_default
- Replace **pass** with the password the database used in **step 3 - Create the DB**
- If a remote host replace **localhost** with the remote and append **?sslmode=disable**
- ###### ckan.site_id = default
- Replace **default** with a value unique to this install
- ### 5. Setup Solr
- We are using an archived version of solr, 3.5, and as such we have to get it from the archives.
- #### Fetch
- ```
- mkdir ~/src;cd ~/src
- wget https://archive.apache.org/dist/lucene/solr/3.5.0/apache-solr-3.5.0.tgz
- ```
- #### Open and move
- ```
- tar -xvzf apache-solr-3.5.0.tgz
- sudo mkdir /etc/apache-solr/
- sudo cp -R apache-solr-3.5.0/* /etc/apache-solr/
- ```
- #### Create and set permissions on the data directory
- ```
- sudo mkdir -p /etc/apache-solr/example/solr/data/
- sudo chown -R `whoami` /etc/apache-solr/example/solr/data/
- ```
- #### Cleanup
- ```
- rm -rf apache-solr-3.5.0*
- ```
- #### Test
- ```
- cd /etc/apache-solr/example
- java -jar start.jar
- ```
- In a Browser try:
- [http://127.0.0.1:8983/solr/](http://127.0.0.1:8983/solr/)
- #### Set startup Script
- ```
- sudo cat > /etc/init.d/solr
- #!/bin/sh
- # Starts, stops, and restarts Apache Solr.
- #
- # chkconfig: 35 92 08
- # description: Starts and stops Apache Solr
- SOLR_DIR="/etc/apache-solr/example"
- JAVA_OPTIONS="-Xmx1048m -DSTOP.PORT=8984 -DSTOP.KEY=SHAZBOT -jar start.jar"
- LOG_FILE="/var/log/solr.log"
- JAVA="/usr/bin/java"
- case $1 in
- start)
- echo "Starting Solr"
- cd $SOLR_DIR
- $JAVA $JAVA_OPTIONS 2> $LOG_FILE &
- ;;
- stop)
- echo "Stopping Solr"
- cd $SOLR_DIR
- $JAVA $JAVA_OPTIONS --stop
- ;;
- restart)
- echo “Restarting in 5s“
- $0 stop
- sleep 5
- $0 start
- ;;
- *)
- echo "Usage: $0 {start|stop|restart}" >&2
- exit 1
- ;;
- esac
- ^d
- sudo chmod 755 /etc/init.d/solr
- sudo chkconfig --add solr
- sudo service solr stop
- sudo service solr start
- ```
- #### Apply Schema
- Consider which schema you need to use, assuming it’s in the Github account
- ```
- sudo service solr stop
- cd /etc/apache-solr/example/solr/conf
- sudo mv schema.xml schema.xml.yyyymmdd
- sudo ln -s /usr/lib/ckan/default/src/ckan/ckan/config/solr/schema.xml schema.xml
- sudo service solr start
- ```
- ### 6. Create database tables
- ```
- cd /usr/lib/ckan/default/src/ckan
- paster db init -c /etc/ckan/default/development.ini
- ```
- ### 7. Set up the DataStore
- skipped
- ### 8. Link to who.ini
- ```
- ln -s /usr/lib/ckan/default/src/ckan/who.ini /etc/ckan/default/who.ini
- ```
- ### 9. You’re done!
- ```
- cd /usr/lib/ckan/default/src/ckan
- paster serve /etc/ckan/default/development.ini
- ```
- In a Browser try:
- [http://127.0.0.1:5000/](http://127.0.0.1:5000/)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement